1; RUN: opt < %s -analyze -basicaa -tbaa -da | FileCheck %s 2 3; CHECK-LABEL: 'Dependence Analysis' for function 'test_no_noalias' 4; CHECK: da analyze - none! 5; CHECK: da analyze - confused! 6; CHECK: da analyze - none! 7define void @test_no_noalias(i32* %A, i32* %B) { 8 store i32 1, i32* %A 9 store i32 2, i32* %B 10 ret void 11} 12 13; CHECK-LABEL: test_one_noalias 14; CHECK: da analyze - none! 15; CHECK: da analyze - none! 16; CHECK: da analyze - none! 17define void @test_one_noalias(i32* noalias %A, i32* %B) { 18 store i32 1, i32* %A 19 store i32 2, i32* %B 20 ret void 21} 22 23; CHECK-LABEL: test_two_noalias 24; CHECK: da analyze - none! 25; CHECK: da analyze - none! 26; CHECK: da analyze - none! 27define void @test_two_noalias(i32* noalias %A, i32* noalias %B) { 28 store i32 1, i32* %A 29 store i32 2, i32* %B 30 ret void 31} 32 33; CHECK-LABEL: test_global_alias 34; CHECK: da analyze - none! 35; CHECK: da analyze - confused! 36; CHECK: da analyze - none! 37@g = global i32 5 38define void @test_global_alias(i32* %A) { 39 store i32 1, i32* %A 40 store i32 2, i32* @g 41 ret void 42} 43 44; CHECK-LABEL: test_global_noalias 45; CHECK: da analyze - none! 46; CHECK: da analyze - none! 47; CHECK: da analyze - none! 48define void @test_global_noalias(i32* noalias %A) { 49 store i32 1, i32* %A 50 store i32 2, i32* @g 51 ret void 52} 53 54; CHECK-LABEL: test_global_size 55; CHECK: da analyze - none! 56; CHECK: da analyze - confused! 57; CHECK: da analyze - none! 58; CHECK: da analyze - none! 59; CHECK: da analyze - confused! 60; CHECK: da analyze - none! 61 62@a = global i16 5, align 2 63@b = global i16* @a, align 4 64define void @test_global_size() { 65 %l0 = load i16*, i16** @b, align 4 66 %l1 = load i16, i16* %l0, align 2 67 store i16 1, i16* @a, align 2 68 ret void 69} 70 71; CHECK-LABEL: test_tbaa_same 72; CHECK: da analyze - none! 73; CHECK: da analyze - confused! 74; CHECK: da analyze - none! 75define void @test_tbaa_same(i32* %A, i32* %B) { 76 store i32 1, i32* %A, !tbaa !5 77 store i32 2, i32* %B, !tbaa !5 78 ret void 79} 80 81; CHECK-LABEL: test_tbaa_diff 82; CHECK: da analyze - none! 83; CHECK: da analyze - none! 84; CHECK: da analyze - none! 85define void @test_tbaa_diff(i32* %A, i16* %B) { 86 store i32 1, i32* %A, !tbaa !5 87 store i16 2, i16* %B, !tbaa !9 88 ret void 89} 90 91; CHECK-LABEL: tbaa_loop 92; CHECK: da analyze - input 93; CHECK: da analyze - none 94; CHECK: da analyze - output 95define void @tbaa_loop(i32 %I, i32 %J, i32* nocapture %A, i16* nocapture readonly %B) { 96entry: 97 %cmp = icmp ne i32 %J, 0 98 %cmp122 = icmp ne i32 %I, 0 99 %or.cond = and i1 %cmp, %cmp122 100 br i1 %or.cond, label %for.outer.preheader, label %for.end 101 102for.outer.preheader: 103 br label %for.outer 104 105for.outer: 106 %i.us = phi i32 [ %add8.us, %for.latch ], [ 0, %for.outer.preheader ] 107 br label %for.inner 108 109for.inner: 110 %j.us = phi i32 [ 0, %for.outer ], [ %inc.us, %for.inner ] 111 %sum1.us = phi i32 [ 0, %for.outer ], [ %add.us, %for.inner ] 112 %arrayidx.us = getelementptr inbounds i16, i16* %B, i32 %j.us 113 %0 = load i16, i16* %arrayidx.us, align 4, !tbaa !9 114 %sext = sext i16 %0 to i32 115 %add.us = add i32 %sext, %sum1.us 116 %inc.us = add nuw i32 %j.us, 1 117 %exitcond = icmp eq i32 %inc.us, %J 118 br i1 %exitcond, label %for.latch, label %for.inner 119 120for.latch: 121 %add.us.lcssa = phi i32 [ %add.us, %for.inner ] 122 %arrayidx6.us = getelementptr inbounds i32, i32* %A, i32 %i.us 123 store i32 %add.us.lcssa, i32* %arrayidx6.us, align 4, !tbaa !5 124 %add8.us = add nuw i32 %i.us, 1 125 %exitcond25 = icmp eq i32 %add8.us, %I 126 br i1 %exitcond25, label %for.end.loopexit, label %for.outer 127 128for.end.loopexit: 129 br label %for.end 130 131for.end: 132 ret void 133} 134 135!5 = !{!6, !6, i64 0} 136!6 = !{!"int", !7, i64 0} 137!7 = !{!"omnipotent char", !8, i64 0} 138!8 = !{!"Simple C/C++ TBAA"} 139!9 = !{!10, !10, i64 0} 140!10 = !{!"short", !7, i64 0} 141