1 ; RUN: opt < %s -aa-pipeline=tbaa,basic-aa -passes=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: ptr* %5, i64* %9
21 ; CHECK: NoAlias: store i64 %conv, ptr %9, align 8, !tbaa !6 <-> store ptr null, ptr %5, align 8, !tbaa !9
23 %struct.Foo = type { i64 }
24 %struct.Bar = type { ptr }
26 define i64 @_Z3fooi(i32 %n) #0 {
28 %n.addr = alloca i32, align 4
29 %f = alloca ptr, align 8
30 %i1 = alloca i32, align 4
31 %b = alloca ptr, align 8
32 store i32 %n, ptr %n.addr, align 4, !tbaa !0
33 %call = call noalias ptr @_Znwm(i64 8)
34 store ptr %call, ptr %f, align 8, !tbaa !4
35 %0 = load ptr, ptr %f, align 8, !tbaa !4
36 store i64 1, ptr %0, align 8, !tbaa !6
37 store i32 0, ptr %i1, align 4, !tbaa !0
41 %1 = load i32, ptr %i1, align 4, !tbaa !0
42 %2 = load i32, ptr %n.addr, align 4, !tbaa !0
43 %cmp = icmp slt i32 %1, %2
44 br i1 %cmp, label %for.body, label %for.end
47 %3 = load ptr, ptr %f, align 8, !tbaa !4
48 %new.isnull = icmp eq ptr %3, null
49 br i1 %new.isnull, label %new.cont, label %new.notnull
55 %4 = phi ptr [ %3, %new.notnull ], [ null, %for.body ]
56 store ptr %4, ptr %b, align 8, !tbaa !4
57 %5 = load ptr, ptr %b, align 8, !tbaa !4
58 store ptr null, ptr %5, align 8, !tbaa !9
59 %6 = load ptr, ptr %f, align 8, !tbaa !4
60 %new.isnull2 = icmp eq ptr %6, null
61 br i1 %new.isnull2, label %new.cont4, label %new.notnull3
67 %7 = phi ptr [ %6, %new.notnull3 ], [ null, %new.cont ]
68 store ptr %7, ptr %f, align 8, !tbaa !4
69 %8 = load i32, ptr %i1, align 4, !tbaa !0
70 %conv = sext i32 %8 to i64
71 %9 = load ptr, ptr %f, align 8, !tbaa !4
72 store i64 %conv, ptr %9, align 8, !tbaa !6
76 %10 = load i32, ptr %i1, align 4, !tbaa !0
77 %inc = add nsw i32 %10, 1
78 store i32 %inc, ptr %i1, align 4, !tbaa !0
82 %11 = load ptr, ptr %f, align 8, !tbaa !4
83 %12 = load i64, ptr %11, align 8, !tbaa !6
87 declare noalias ptr @_Znwm(i64)
89 attributes #0 = { nounwind }
92 !1 = !{!"int", !2, i64 0}
93 !2 = !{!"omnipotent char", !3, i64 0}
94 !3 = !{!"Simple C/C++ TBAA"}
96 !5 = !{!"any pointer", !2, i64 0}
98 !7 = !{!"_ZTS3Foo", !8, i64 0}
99 !8 = !{!"long", !2, i64 0}
100 !9 = !{!10, !5, i64 0}
101 !10 = !{!"_ZTS3Bar", !5, i64 0}