blob: 4d6f721f6abb4bea1ac5e9430ee8171151f4944d [file] [log] [blame]
Manman Renf5d9d342013-10-11 20:48:38 +00001// 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
Dan Gohmanc2897692010-12-13 23:51:08 +00003
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{
Richard Smith8d304d52013-07-14 06:18:38 +000011// CHECK: store i32 0, i32* %{{.*}}, !tbaa [[TAG_CHAR:!.*]]
Manman Ren0e521662013-04-27 00:39:37 +000012// PATH: store i32 0, i32* %{{.*}}, !tbaa [[TAG_CHAR:!.*]]
Dan Gohmanc2897692010-12-13 23:51:08 +000013 *ai = 0;
Richard Smith8d304d52013-07-14 06:18:38 +000014// CHECK: store i32 1, i32* %{{.*}}, !tbaa [[TAG_INT:!.*]]
Manman Ren0e521662013-04-27 00:39:37 +000015// PATH: store i32 1, i32* %{{.*}}, !tbaa [[TAG_INT:!.*]]
Dan Gohmanc2897692010-12-13 23:51:08 +000016 *i = 1;
17}
18
John McCall53fcbd22011-02-26 08:07:02 +000019// PR9307
20struct Test1 { int x; };
21struct Test1MA { int x; } __attribute__((may_alias));
22void test1(struct Test1MA *p1, struct Test1 *p2) {
Richard Smith8d304d52013-07-14 06:18:38 +000023 // CHECK: store i32 2, i32* {{%.*}}, !tbaa [[TAG_CHAR]]
Manman Ren0e521662013-04-27 00:39:37 +000024 // PATH: store i32 2, i32* {{%.*}}, !tbaa [[TAG_CHAR]]
John McCall53fcbd22011-02-26 08:07:02 +000025 p1->x = 2;
Richard Smith8d304d52013-07-14 06:18:38 +000026 // CHECK: store i32 3, i32* {{%.*}}, !tbaa [[TAG_INT]]
Manman Ren0e521662013-04-27 00:39:37 +000027 // PATH: store i32 3, i32* {{%.*}}, !tbaa [[TAG_test1_x:!.*]]
John McCall53fcbd22011-02-26 08:07:02 +000028 p2->x = 3;
29}
Manman Ren4f755de2013-10-08 00:08:49 +000030// CHECK: metadata !{metadata !"any pointer", metadata [[TYPE_CHAR:!.*]],
31// CHECK: [[TYPE_CHAR]] = metadata !{metadata !"omnipotent char", metadata [[TAG_CXX_TBAA:!.*]],
Richard Smith8d304d52013-07-14 06:18:38 +000032// CHECK: [[TAG_CXX_TBAA]] = metadata !{metadata !"Simple C/C++ TBAA"}
Manman Ren4f755de2013-10-08 00:08:49 +000033// 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]]
Manman Ren0e521662013-04-27 00:39:37 +000036
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}
Manman Ren879ce882013-08-21 20:58:45 +000042// PATH: [[TYPE_test1]] = metadata !{metadata !"Test1", metadata [[TYPE_INT]], i64 0}