1 ; RUN: opt < %s -tbaa -basicaa -aa-eval -evaluate-aa-metadata -print-no-aliases -print-may-aliases -disable-output 2>&1 | FileCheck %s
2 ; RUN: opt < %s -aa-pipeline=type-based-aa,basic-aa -passes=aa-eval -evaluate-aa-metadata -print-no-aliases -print-may-aliases -disable-output 2>&1 | FileCheck %s
4 ; Generated with "clang -cc1 -disable-llvm-optzns -O1 -emit-llvm"
6 ; struct Foo { long i; };
7 ; struct Bar { void *p; };
11 ; for (int i=0; i<n; ++i) {
12 ; Bar *b = new (f) Bar;
20 ; Basic AA says MayAlias, TBAA says NoAlias
21 ; CHECK: MayAlias: i64* %i5, i8** %p
22 ; CHECK: NoAlias: store i64 %conv, i64* %i5, align 8, !tbaa !6 <-> store i8* null, i8** %p, align 8, !tbaa !9
24 %struct.Foo = type { i64 }
25 %struct.Bar = type { i8* }
27 define i64 @_Z3fooi(i32 %n) #0 {
29 %n.addr = alloca i32, align 4
30 %f = alloca %struct.Foo*, align 8
31 %i1 = alloca i32, align 4
32 %b = alloca %struct.Bar*, align 8
33 store i32 %n, i32* %n.addr, align 4, !tbaa !0
34 %call = call noalias i8* @_Znwm(i64 8)
35 %0 = bitcast i8* %call to %struct.Foo*
36 store %struct.Foo* %0, %struct.Foo** %f, align 8, !tbaa !4
37 %1 = load %struct.Foo*, %struct.Foo** %f, align 8, !tbaa !4
38 %i = getelementptr inbounds %struct.Foo, %struct.Foo* %1, i32 0, i32 0
39 store i64 1, i64* %i, align 8, !tbaa !6
40 store i32 0, i32* %i1, align 4, !tbaa !0
44 %2 = load i32, i32* %i1, align 4, !tbaa !0
45 %3 = load i32, i32* %n.addr, align 4, !tbaa !0
46 %cmp = icmp slt i32 %2, %3
47 br i1 %cmp, label %for.body, label %for.end
50 %4 = load %struct.Foo*, %struct.Foo** %f, align 8, !tbaa !4
51 %5 = bitcast %struct.Foo* %4 to i8*
52 %new.isnull = icmp eq i8* %5, null
53 br i1 %new.isnull, label %new.cont, label %new.notnull
56 %6 = bitcast i8* %5 to %struct.Bar*
60 %7 = phi %struct.Bar* [ %6, %new.notnull ], [ null, %for.body ]
61 store %struct.Bar* %7, %struct.Bar** %b, align 8, !tbaa !4
62 %8 = load %struct.Bar*, %struct.Bar** %b, align 8, !tbaa !4
63 %p = getelementptr inbounds %struct.Bar, %struct.Bar* %8, i32 0, i32 0
64 store i8* null, i8** %p, align 8, !tbaa !9
65 %9 = load %struct.Foo*, %struct.Foo** %f, align 8, !tbaa !4
66 %10 = bitcast %struct.Foo* %9 to i8*
67 %new.isnull2 = icmp eq i8* %10, null
68 br i1 %new.isnull2, label %new.cont4, label %new.notnull3
71 %11 = bitcast i8* %10 to %struct.Foo*
75 %12 = phi %struct.Foo* [ %11, %new.notnull3 ], [ null, %new.cont ]
76 store %struct.Foo* %12, %struct.Foo** %f, align 8, !tbaa !4
77 %13 = load i32, i32* %i1, align 4, !tbaa !0
78 %conv = sext i32 %13 to i64
79 %14 = load %struct.Foo*, %struct.Foo** %f, align 8, !tbaa !4
80 %i5 = getelementptr inbounds %struct.Foo, %struct.Foo* %14, i32 0, i32 0
81 store i64 %conv, i64* %i5, align 8, !tbaa !6
85 %15 = load i32, i32* %i1, align 4, !tbaa !0
86 %inc = add nsw i32 %15, 1
87 store i32 %inc, i32* %i1, align 4, !tbaa !0
91 %16 = load %struct.Foo*, %struct.Foo** %f, align 8, !tbaa !4
92 %i6 = getelementptr inbounds %struct.Foo, %struct.Foo* %16, i32 0, i32 0
93 %17 = load i64, i64* %i6, align 8, !tbaa !6
97 declare noalias i8* @_Znwm(i64)
99 attributes #0 = { nounwind }
101 !0 = !{!1, !1, i64 0}
102 !1 = !{!"int", !2, i64 0}
103 !2 = !{!"omnipotent char", !3, i64 0}
104 !3 = !{!"Simple C/C++ TBAA"}
105 !4 = !{!5, !5, i64 0}
106 !5 = !{!"any pointer", !2, i64 0}
107 !6 = !{!7, !8, i64 0}
108 !7 = !{!"_ZTS3Foo", !8, i64 0}
109 !8 = !{!"long", !2, i64 0}
110 !9 = !{!10, !5, i64 0}
111 !10 = !{!"_ZTS3Bar", !5, i64 0}