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 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)); 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: metadata !{metadata !"any pointer", metadata [[TYPE_CHAR:!.*]], 31 // CHECK: [[TYPE_CHAR]] = metadata !{metadata !"omnipotent char", metadata [[TAG_CXX_TBAA:!.*]], 32 // CHECK: [[TAG_CXX_TBAA]] = metadata !{metadata !"Simple C/C++ TBAA"} 33 // CHECK: [[TAG_CHAR]] = metadata !{metadata [[TYPE_CHAR]], metadata [[TYPE_CHAR]], i64 0} 34 // CHECK: [[TAG_INT]] = metadata !{metadata [[TYPE_INT:!.*]], metadata [[TYPE_INT]], i64 0} 35 // CHECK: [[TYPE_INT]] = metadata !{metadata !"int", metadata [[TYPE_CHAR]] 36 37 // PATH: [[TYPE_CHAR:!.*]] = metadata !{metadata !"omnipotent char", metadata !{{.*}} 38 // PATH: [[TAG_CHAR]] = metadata !{metadata [[TYPE_CHAR]], metadata [[TYPE_CHAR]], i64 0} 39 // PATH: [[TAG_INT]] = metadata !{metadata [[TYPE_INT:!.*]], metadata [[TYPE_INT]], i64 0} 40 // PATH: [[TYPE_INT]] = metadata !{metadata !"int", metadata [[TYPE_CHAR]] 41 // PATH: [[TAG_test1_x]] = metadata !{metadata [[TYPE_test1:!.*]], metadata [[TYPE_INT]], i64 0} 42 // PATH: [[TYPE_test1]] = metadata !{metadata !"Test1", metadata [[TYPE_INT]], i64 0} 43