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