12ea7e73361c11f061e00caa8d9e71e84e6dd8554Dan Gohman// RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 -disable-llvm-optzns -o %t %s 22ea7e73361c11f061e00caa8d9e71e84e6dd8554Dan Gohman// RUN: FileCheck < %t %s 32ea7e73361c11f061e00caa8d9e71e84e6dd8554Dan Gohman 42ea7e73361c11f061e00caa8d9e71e84e6dd8554Dan Gohman// Types with the may_alias attribute should be considered equivalent 52ea7e73361c11f061e00caa8d9e71e84e6dd8554Dan Gohman// to char for aliasing. 62ea7e73361c11f061e00caa8d9e71e84e6dd8554Dan Gohman 72ea7e73361c11f061e00caa8d9e71e84e6dd8554Dan Gohmantypedef int __attribute__((may_alias)) aliasing_int; 82ea7e73361c11f061e00caa8d9e71e84e6dd8554Dan Gohman 92ea7e73361c11f061e00caa8d9e71e84e6dd8554Dan Gohmanvoid test0(aliasing_int *ai, int *i) 102ea7e73361c11f061e00caa8d9e71e84e6dd8554Dan Gohman{ 11bc7fbf0d37b286b37d96b033dfaaabf9c729bca8John McCall// CHECK: store i32 0, i32* %{{.*}}, !tbaa !1 122ea7e73361c11f061e00caa8d9e71e84e6dd8554Dan Gohman *ai = 0; 13bc7fbf0d37b286b37d96b033dfaaabf9c729bca8John McCall// CHECK: store i32 1, i32* %{{.*}}, !tbaa !3 142ea7e73361c11f061e00caa8d9e71e84e6dd8554Dan Gohman *i = 1; 152ea7e73361c11f061e00caa8d9e71e84e6dd8554Dan Gohman} 162ea7e73361c11f061e00caa8d9e71e84e6dd8554Dan Gohman 17bc7fbf0d37b286b37d96b033dfaaabf9c729bca8John McCall// PR9307 18bc7fbf0d37b286b37d96b033dfaaabf9c729bca8John McCallstruct Test1 { int x; }; 19bc7fbf0d37b286b37d96b033dfaaabf9c729bca8John McCallstruct Test1MA { int x; } __attribute__((may_alias)); 20bc7fbf0d37b286b37d96b033dfaaabf9c729bca8John McCallvoid test1(struct Test1MA *p1, struct Test1 *p2) { 21bc7fbf0d37b286b37d96b033dfaaabf9c729bca8John McCall // CHECK: store i32 2, i32* {{%.*}}, !tbaa !1 22bc7fbf0d37b286b37d96b033dfaaabf9c729bca8John McCall p1->x = 2; 23bc7fbf0d37b286b37d96b033dfaaabf9c729bca8John McCall // CHECK: store i32 3, i32* {{%.*}}, !tbaa !3 24bc7fbf0d37b286b37d96b033dfaaabf9c729bca8John McCall p2->x = 3; 25bc7fbf0d37b286b37d96b033dfaaabf9c729bca8John McCall} 262ea7e73361c11f061e00caa8d9e71e84e6dd8554Dan Gohman 272ea7e73361c11f061e00caa8d9e71e84e6dd8554Dan Gohman// CHECK: !0 = metadata !{metadata !"any pointer", metadata !1} 282ea7e73361c11f061e00caa8d9e71e84e6dd8554Dan Gohman// CHECK: !1 = metadata !{metadata !"omnipotent char", metadata !2} 292d7cb069fe101da3971a07900ff583380bcac184Duncan Sands// CHECK: !2 = metadata !{metadata !"Simple C/C++ TBAA"} 302ea7e73361c11f061e00caa8d9e71e84e6dd8554Dan Gohman// CHECK: !3 = metadata !{metadata !"int", metadata !1} 31