diff options
Diffstat (limited to 'test/Analysis/CFLAliasAnalysis')
11 files changed, 143 insertions, 34 deletions
diff --git a/test/Analysis/CFLAliasAnalysis/asm-global-bugfix.ll b/test/Analysis/CFLAliasAnalysis/asm-global-bugfix.ll index d8ee94b..ec2de54 100644 --- a/test/Analysis/CFLAliasAnalysis/asm-global-bugfix.ll +++ b/test/Analysis/CFLAliasAnalysis/asm-global-bugfix.ll @@ -7,10 +7,10 @@ @G = private unnamed_addr constant [1 x i8] c"\00", align 1 ; CHECK: Function: test_no_crash -; CHECK: 1 no alias responses +; CHECK: 0 no alias responses define void @test_no_crash() #0 { entry: call i8* asm "nop", "=r,r"( - i8* getelementptr inbounds ([1 x i8]* @G, i64 0, i64 0)) + i8* getelementptr inbounds ([1 x i8], [1 x i8]* @G, i64 0, i64 0)) ret void } diff --git a/test/Analysis/CFLAliasAnalysis/branch-alias.ll b/test/Analysis/CFLAliasAnalysis/branch-alias.ll new file mode 100644 index 0000000..8307462 --- /dev/null +++ b/test/Analysis/CFLAliasAnalysis/branch-alias.ll @@ -0,0 +1,73 @@ +; Makes sure that we give up on some pathological cases with inttoptr/ptrtoint +; +; @ptr_test was generated from the following C code: +; void ptr_test() { +; int* A; +; unsigned long RefCopy = 0; +; for (int i = 0; i < 8*sizeof(&A); ++i) { +; if ((unsigned long)&A & (1UL << i)) +; RefCopy |= 1UL << i; +; } +; +; int** AliasA1 = (int**)RefCopy; +; int* ShouldAliasA = *AliasA1; +; } + +; RUN: opt < %s -cfl-aa -aa-eval -print-may-aliases -disable-output 2>&1 | FileCheck %s + +; CHECK: Function: ptr_test +define void @ptr_test() #0 { + ; CHECK: MayAlias: i32** %A, i32** %ShouldAliasA + ; CHECK-NOT: %AliasA1 +entry: + %A = alloca i32*, align 8 + %RefCopy = alloca i64, align 8 + %i = alloca i32, align 4 + %AliasA1 = alloca i32**, align 8 + %ShouldAliasA = alloca i32*, align 8 + store i64 0, i64* %RefCopy, align 8 + store i32 0, i32* %i, align 4 + br label %for.cond + +for.cond: ; preds = %for.inc, %entry + %0 = load i32, i32* %i, align 4 + %conv = sext i32 %0 to i64 + %cmp = icmp ult i64 %conv, 64 + br i1 %cmp, label %for.body, label %for.end + +for.body: ; preds = %for.cond + %1 = ptrtoint i32** %A to i64 + %2 = load i32, i32* %i, align 4 + %sh_prom = zext i32 %2 to i64 + %shl = shl i64 1, %sh_prom + %and = and i64 %1, %shl + %tobool = icmp ne i64 %and, 0 + br i1 %tobool, label %if.then, label %if.end + +if.then: ; preds = %for.body + %3 = load i32, i32* %i, align 4 + %sh_prom2 = zext i32 %3 to i64 + %shl3 = shl i64 1, %sh_prom2 + %4 = load i64, i64* %RefCopy, align 8 + %or = or i64 %4, %shl3 + store i64 %or, i64* %RefCopy, align 8 + br label %if.end + +if.end: ; preds = %if.then, %for.body + br label %for.inc + +for.inc: ; preds = %if.end + %5 = load i32, i32* %i, align 4 + %inc = add nsw i32 %5, 1 + store i32 %inc, i32* %i, align 4 + br label %for.cond + +for.end: ; preds = %for.cond + %6 = load i64, i64* %RefCopy, align 8 + %7 = inttoptr i64 %6 to i32** + store i32** %7, i32*** %AliasA1, align 8 + %8 = load i32**, i32*** %AliasA1, align 8 + %9 = load i32*, i32** %8, align 8 + store i32* %9, i32** %ShouldAliasA, align 8 + ret void +} diff --git a/test/Analysis/CFLAliasAnalysis/const-expr-gep.ll b/test/Analysis/CFLAliasAnalysis/const-expr-gep.ll index 9ae200b..c7ff407 100644 --- a/test/Analysis/CFLAliasAnalysis/const-expr-gep.ll +++ b/test/Analysis/CFLAliasAnalysis/const-expr-gep.ll @@ -7,15 +7,51 @@ %T = type { i32, [10 x i8] } @G = external global %T +@G2 = external global %T -; CHECK: Function: test -; CHECK-NOT: May: +; TODO: Quite a few of these are MayAlias because we don't yet consider +; constant offsets in CFLAA. If we start doing so, then we'll need to +; change these test cases +; CHECK: Function: test +; CHECK: MayAlias: i32* %D, i32* %F +; CHECK: MayAlias: i32* %D, i8* %X +; CHECK: MayAlias: i32* %F, i8* %X define void @test() { - %D = getelementptr %T* @G, i64 0, i32 0 - %E = getelementptr %T* @G, i64 0, i32 1, i64 5 - %F = getelementptr i32* getelementptr (%T* @G, i64 0, i32 0), i64 0 - %X = getelementptr [10 x i8]* getelementptr (%T* @G, i64 0, i32 1), i64 0, i64 5 + %D = getelementptr %T, %T* @G, i64 0, i32 0 + %F = getelementptr i32, i32* getelementptr (%T, %T* @G, i64 0, i32 0), i64 0 + %X = getelementptr [10 x i8], [10 x i8]* getelementptr (%T, %T* @G, i64 0, i32 1), i64 0, i64 5 + + ret void +} + +; CHECK: Function: simplecheck +; CHECK: MayAlias: i32* %F, i32* %arg0 +; CHECK: MayAlias: i32* %H, i32* %arg0 +; CHECK: MayAlias: i32* %F, i32* %H +define void @simplecheck(i32* %arg0) { + %F = getelementptr i32, i32* getelementptr (%T, %T* @G, i64 0, i32 0), i64 0 + %H = getelementptr %T, %T* @G2, i64 0, i32 0 + + ret void +} + +; Ensure that CFLAA properly identifies and handles escaping variables (i.e. +; globals) in nested ConstantExprs + +; CHECK: Function: checkNesting +; CHECK: MayAlias: i32* %A, i32* %arg0 + +%NestedT = type { [1 x [1 x i32]] } +@NT = external global %NestedT +define void @checkNesting(i32* %arg0) { + %A = getelementptr [1 x i32], + [1 x i32]* getelementptr + ([1 x [1 x i32]], [1 x [1 x i32]]* getelementptr (%NestedT, %NestedT* @NT, i64 0, i32 0), + i64 0, + i32 0), + i64 0, + i32 0 ret void } diff --git a/test/Analysis/CFLAliasAnalysis/constant-over-index.ll b/test/Analysis/CFLAliasAnalysis/constant-over-index.ll index fb44b95..a8e00aa 100644 --- a/test/Analysis/CFLAliasAnalysis/constant-over-index.ll +++ b/test/Analysis/CFLAliasAnalysis/constant-over-index.ll @@ -10,13 +10,13 @@ define void @foo([3 x [3 x double]]* noalias %p) { entry: - %p3 = getelementptr [3 x [3 x double]]* %p, i64 0, i64 0, i64 3 + %p3 = getelementptr [3 x [3 x double]], [3 x [3 x double]]* %p, i64 0, i64 0, i64 3 br label %loop loop: %i = phi i64 [ 0, %entry ], [ %i.next, %loop ] - %p.0.i.0 = getelementptr [3 x [3 x double]]* %p, i64 0, i64 %i, i64 0 + %p.0.i.0 = getelementptr [3 x [3 x double]], [3 x [3 x double]]* %p, i64 0, i64 %i, i64 0 store volatile double 0.0, double* %p3 store volatile double 0.1, double* %p.0.i.0 diff --git a/test/Analysis/CFLAliasAnalysis/full-store-partial-alias.ll b/test/Analysis/CFLAliasAnalysis/full-store-partial-alias.ll index 21edfc2..adacf04 100644 --- a/test/Analysis/CFLAliasAnalysis/full-store-partial-alias.ll +++ b/test/Analysis/CFLAliasAnalysis/full-store-partial-alias.ll @@ -20,13 +20,13 @@ define i32 @signbit(double %x) nounwind { ; CHECK: ret i32 0 entry: %u = alloca %union.anon, align 8 - %tmp9 = getelementptr inbounds %union.anon* %u, i64 0, i32 0 + %tmp9 = getelementptr inbounds %union.anon, %union.anon* %u, i64 0, i32 0 store double %x, double* %tmp9, align 8, !tbaa !0 - %tmp2 = load i32* bitcast (i64* @endianness_test to i32*), align 8, !tbaa !3 + %tmp2 = load i32, i32* bitcast (i64* @endianness_test to i32*), align 8, !tbaa !3 %idxprom = sext i32 %tmp2 to i64 %tmp4 = bitcast %union.anon* %u to [2 x i32]* - %arrayidx = getelementptr inbounds [2 x i32]* %tmp4, i64 0, i64 %idxprom - %tmp5 = load i32* %arrayidx, align 4, !tbaa !3 + %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %tmp4, i64 0, i64 %idxprom + %tmp5 = load i32, i32* %arrayidx, align 4, !tbaa !3 %tmp5.lobit = lshr i32 %tmp5, 31 ret i32 %tmp5.lobit } diff --git a/test/Analysis/CFLAliasAnalysis/gep-signed-arithmetic.ll b/test/Analysis/CFLAliasAnalysis/gep-signed-arithmetic.ll index 19d251c..c2fcf32 100644 --- a/test/Analysis/CFLAliasAnalysis/gep-signed-arithmetic.ll +++ b/test/Analysis/CFLAliasAnalysis/gep-signed-arithmetic.ll @@ -10,10 +10,10 @@ define i32 @test(i32 %indvar) nounwind { %tab = alloca i32, align 4 %tmp31 = mul i32 %indvar, -2 %tmp32 = add i32 %tmp31, 30 - %t.5 = getelementptr i32* %tab, i32 %tmp32 - %loada = load i32* %tab + %t.5 = getelementptr i32, i32* %tab, i32 %tmp32 + %loada = load i32, i32* %tab store i32 0, i32* %t.5 - %loadb = load i32* %tab + %loadb = load i32, i32* %tab %rval = add i32 %loada, %loadb ret i32 %rval } diff --git a/test/Analysis/CFLAliasAnalysis/multilevel-combine.ll b/test/Analysis/CFLAliasAnalysis/multilevel-combine.ll index 9bbc721..e997374 100644 --- a/test/Analysis/CFLAliasAnalysis/multilevel-combine.ll +++ b/test/Analysis/CFLAliasAnalysis/multilevel-combine.ll @@ -25,7 +25,7 @@ define void @test(i1 %C) { store %T* %MS, %T** %M - %AP = load %T** %M ; PartialAlias with %A, %B + %AP = load %T*, %T** %M ; PartialAlias with %A, %B ret void } diff --git a/test/Analysis/CFLAliasAnalysis/multilevel.ll b/test/Analysis/CFLAliasAnalysis/multilevel.ll index 9c9eb9a..d42dca4 100644 --- a/test/Analysis/CFLAliasAnalysis/multilevel.ll +++ b/test/Analysis/CFLAliasAnalysis/multilevel.ll @@ -23,8 +23,8 @@ define void @test() { store %T* %A, %T** %M store %T* %B, %T** %N - %AP = load %T** %M ; PartialAlias with %A - %BP = load %T** %N ; PartialAlias with %B + %AP = load %T*, %T** %M ; PartialAlias with %A + %BP = load %T*, %T** %N ; PartialAlias with %B ret void } diff --git a/test/Analysis/CFLAliasAnalysis/must-and-partial.ll b/test/Analysis/CFLAliasAnalysis/must-and-partial.ll index 163a6c3..9deacf8 100644 --- a/test/Analysis/CFLAliasAnalysis/must-and-partial.ll +++ b/test/Analysis/CFLAliasAnalysis/must-and-partial.ll @@ -10,7 +10,7 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3 define i8 @test0(i1 %x) { entry: %base = alloca i8, align 4 - %baseplusone = getelementptr i8* %base, i64 1 + %baseplusone = getelementptr i8, i8* %base, i64 1 br i1 %x, label %red, label %green red: br label %green @@ -21,7 +21,7 @@ green: %bigbase0 = bitcast i8* %base to i16* store i16 -1, i16* %bigbase0 - %loaded = load i8* %phi + %loaded = load i8, i8* %phi ret i8 %loaded } @@ -30,14 +30,14 @@ green: define i8 @test1(i1 %x) { entry: %base = alloca i8, align 4 - %baseplusone = getelementptr i8* %base, i64 1 + %baseplusone = getelementptr i8, i8* %base, i64 1 %sel = select i1 %x, i8* %baseplusone, i8* %base store i8 0, i8* %sel %bigbase1 = bitcast i8* %base to i16* store i16 -1, i16* %bigbase1 - %loaded = load i8* %sel + %loaded = load i8, i8* %sel ret i8 %loaded } @@ -45,10 +45,10 @@ entry: ; even if they are nocapture ; CHECK: MayAlias: double* %A, double* %Index define void @testr2(double* nocapture readonly %A, double* nocapture readonly %Index) { - %arrayidx22 = getelementptr inbounds double* %Index, i64 2 - %1 = load double* %arrayidx22 - %arrayidx25 = getelementptr inbounds double* %A, i64 2 - %2 = load double* %arrayidx25 + %arrayidx22 = getelementptr inbounds double, double* %Index, i64 2 + %1 = load double, double* %arrayidx22 + %arrayidx25 = getelementptr inbounds double, double* %A, i64 2 + %2 = load double, double* %arrayidx25 %mul26 = fmul double %1, %2 ret void } diff --git a/test/Analysis/CFLAliasAnalysis/simple.ll b/test/Analysis/CFLAliasAnalysis/simple.ll index 7bc455a..adc7186 100644 --- a/test/Analysis/CFLAliasAnalysis/simple.ll +++ b/test/Analysis/CFLAliasAnalysis/simple.ll @@ -9,10 +9,10 @@ ; CHECK-NOT: May: define void @test(%T* %P) { - %A = getelementptr %T* %P, i64 0 - %B = getelementptr %T* %P, i64 0, i32 0 - %C = getelementptr %T* %P, i64 0, i32 1 - %D = getelementptr %T* %P, i64 0, i32 1, i64 0 - %E = getelementptr %T* %P, i64 0, i32 1, i64 5 + %A = getelementptr %T, %T* %P, i64 0 + %B = getelementptr %T, %T* %P, i64 0, i32 0 + %C = getelementptr %T, %T* %P, i64 0, i32 1 + %D = getelementptr %T, %T* %P, i64 0, i32 1, i64 0 + %E = getelementptr %T, %T* %P, i64 0, i32 1, i64 5 ret void } diff --git a/test/Analysis/CFLAliasAnalysis/stratified-attrs-indexing.ll b/test/Analysis/CFLAliasAnalysis/stratified-attrs-indexing.ll index 8afedf2..3475285 100644 --- a/test/Analysis/CFLAliasAnalysis/stratified-attrs-indexing.ll +++ b/test/Analysis/CFLAliasAnalysis/stratified-attrs-indexing.ll @@ -18,7 +18,7 @@ define void @test(i1 %cond, i32* %arg31, i32* %arg32, i32* %arg33, i32* %arg34, i32* %arg35) { ; CHECK: 946 Total Alias Queries Performed - ; CHECK: 810 no alias responses (85.6%) + ; CHECK: 43 no alias responses (4.5%) %a = alloca i32, align 4 %b = select i1 %cond, i32* %arg35, i32* %arg34 %c = select i1 %cond, i32* %arg34, i32* %arg33 |