1// 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{
11// CHECK: store i32 0, i32* %{{.*}}, !tbaa !1
12  *ai = 0;
13// CHECK: store i32 1, i32* %{{.*}}, !tbaa !3
14  *i = 1;
15}
16
17// 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}
26
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}
31