• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 -no-struct-path-tbaa -disable-llvm-optzns -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -O1 -disable-llvm-optzns -o - %s | FileCheck %s -check-prefix=PATH
3 
4 // Types with the may_alias attribute should be considered equivalent
5 // to char for aliasing.
6 
7 typedef int __attribute__((may_alias)) aliasing_int;
8 
test0(aliasing_int * ai,int * i)9 void test0(aliasing_int *ai, int *i)
10 {
11 // CHECK: store i32 0, i32* %{{.*}}, !tbaa [[TAG_CHAR:!.*]]
12 // PATH: store i32 0, i32* %{{.*}}, !tbaa [[TAG_CHAR:!.*]]
13   *ai = 0;
14 // CHECK: store i32 1, i32* %{{.*}}, !tbaa [[TAG_INT:!.*]]
15 // PATH: store i32 1, i32* %{{.*}}, !tbaa [[TAG_INT:!.*]]
16   *i = 1;
17 }
18 
19 // PR9307
20 struct Test1 { int x; };
21 struct Test1MA { int x; } __attribute__((may_alias));
test1(struct Test1MA * p1,struct Test1 * p2)22 void test1(struct Test1MA *p1, struct Test1 *p2) {
23   // CHECK: store i32 2, i32* {{%.*}}, !tbaa [[TAG_CHAR]]
24   // PATH: store i32 2, i32* {{%.*}}, !tbaa [[TAG_CHAR]]
25   p1->x = 2;
26   // CHECK: store i32 3, i32* {{%.*}}, !tbaa [[TAG_INT]]
27   // PATH: store i32 3, i32* {{%.*}}, !tbaa [[TAG_test1_x:!.*]]
28   p2->x = 3;
29 }
30 // CHECK:  !"any pointer", [[TYPE_CHAR:!.*]],
31 // CHECK: [[TYPE_CHAR]] = !{!"omnipotent char", [[TAG_CXX_TBAA:!.*]],
32 // CHECK: [[TAG_CXX_TBAA]] = !{!"Simple C/C++ TBAA"}
33 // CHECK: [[TAG_CHAR]] = !{[[TYPE_CHAR]], [[TYPE_CHAR]], i64 0}
34 // CHECK: [[TAG_INT]] = !{[[TYPE_INT:!.*]], [[TYPE_INT]], i64 0}
35 // CHECK: [[TYPE_INT]] = !{!"int", [[TYPE_CHAR]]
36 
37 // PATH: [[TYPE_CHAR:!.*]] = !{!"omnipotent char", !{{.*}}
38 // PATH: [[TAG_CHAR]] = !{[[TYPE_CHAR]], [[TYPE_CHAR]], i64 0}
39 // PATH: [[TAG_INT]] = !{[[TYPE_INT:!.*]], [[TYPE_INT]], i64 0}
40 // PATH: [[TYPE_INT]] = !{!"int", [[TYPE_CHAR]]
41 // PATH: [[TAG_test1_x]] = !{[[TYPE_test1:!.*]], [[TYPE_INT]], i64 0}
42 // PATH: [[TYPE_test1]] = !{!"Test1", [[TYPE_INT]], i64 0}
43