blob: 6171be763dc7ff32da334db9eb8b5b05b26e8270 [file] [log] [blame]
Dan Gohman2ea7e732010-12-13 23:51:08 +00001// RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 -disable-llvm-optzns -o %t %s
2// RUN: FileCheck < %t %s
3
4// Types with the may_alias attribute should be considered equivalent
5// to char for aliasing.
6
7typedef int __attribute__((may_alias)) aliasing_int;
8
9void test0(aliasing_int *ai, int *i)
10{
John McCallbc7fbf02011-02-26 08:07:02 +000011// CHECK: store i32 0, i32* %{{.*}}, !tbaa !1
Dan Gohman2ea7e732010-12-13 23:51:08 +000012 *ai = 0;
John McCallbc7fbf02011-02-26 08:07:02 +000013// CHECK: store i32 1, i32* %{{.*}}, !tbaa !3
Dan Gohman2ea7e732010-12-13 23:51:08 +000014 *i = 1;
15}
16
John McCallbc7fbf02011-02-26 08:07:02 +000017// PR9307
18struct Test1 { int x; };
19struct Test1MA { int x; } __attribute__((may_alias));
20void test1(struct Test1MA *p1, struct Test1 *p2) {
21 // CHECK: store i32 2, i32* {{%.*}}, !tbaa !1
22 p1->x = 2;
23 // CHECK: store i32 3, i32* {{%.*}}, !tbaa !3
24 p2->x = 3;
25}
Dan Gohman2ea7e732010-12-13 23:51:08 +000026
27// CHECK: !0 = metadata !{metadata !"any pointer", metadata !1}
28// CHECK: !1 = metadata !{metadata !"omnipotent char", metadata !2}
29// CHECK: !2 = metadata !{metadata !"Simple C/C++ TBAA", null}
30// CHECK: !3 = metadata !{metadata !"int", metadata !1}