FileCheck-ize these tests. Harden some of them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155432 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling 2012-04-24 09:15:38 +00:00
parent 3ef43cf3a2
commit d5cc8b81ca
28 changed files with 159 additions and 82 deletions

View File

@ -2,17 +2,19 @@
; is performed. It is not legal to delete the second load instruction because
; the value computed by the first load instruction is changed by the store.
; RUN: opt < %s -basicaa -gvn -instcombine -S | grep DONOTREMOVE
; RUN: opt < %s -basicaa -gvn -instcombine -S | FileCheck %s
define i32 @test() {
%A = alloca i32
store i32 0, i32* %A
%X = load i32* %A
%B = bitcast i32* %A to i8*
%C = getelementptr i8* %B, i64 1
store i8 1, i8* %C ; Aliases %A
%Y.DONOTREMOVE = load i32* %A
%Z = sub i32 %X, %Y.DONOTREMOVE
ret i32 %Z
; CHECK: %Y.DONOTREMOVE = load i32* %A
; CHECK: %Z = sub i32 0, %Y.DONOTREMOVE
%A = alloca i32
store i32 0, i32* %A
%X = load i32* %A
%B = bitcast i32* %A to i8*
%C = getelementptr i8* %B, i64 1
store i8 1, i8* %C ; Aliases %A
%Y.DONOTREMOVE = load i32* %A
%Z = sub i32 %X, %Y.DONOTREMOVE
ret i32 %Z
}

View File

@ -1,15 +1,14 @@
; RUN: opt < %s -basicaa -gvn -instcombine -S | grep sub
; RUN: opt < %s -basicaa -gvn -instcombine -S | FileCheck %s
; BasicAA was incorrectly concluding that P1 and P2 didn't conflict!
define i32 @test(i32 *%Ptr, i64 %V) {
%P2 = getelementptr i32* %Ptr, i64 1
%P1 = getelementptr i32* %Ptr, i64 %V
%X = load i32* %P1
store i32 5, i32* %P2
%Y = load i32* %P1
%Z = sub i32 %X, %Y
ret i32 %Z
; CHECK: sub i32 %X, %Y
%P2 = getelementptr i32* %Ptr, i64 1
%P1 = getelementptr i32* %Ptr, i64 %V
%X = load i32* %P1
store i32 5, i32* %P2
%Y = load i32* %P1
%Z = sub i32 %X, %Y
ret i32 %Z
}

View File

@ -1,6 +1,9 @@
; In this test, a local alloca cannot alias an incoming argument.
; RUN: opt < %s -basicaa -gvn -instcombine -S | not grep sub
; RUN: opt < %s -basicaa -gvn -instcombine -S | FileCheck %s
; CHECK: define i32 @test
; CHECK-NEXT: ret i32 0
define i32 @test(i32* %P) {
%X = alloca i32

View File

@ -1,11 +1,13 @@
; This testcase consists of alias relations which should be completely
; resolvable by basicaa.
; RUN: opt < %s -basicaa -aa-eval -print-may-aliases -disable-output \
; RUN: |& not grep May:
; RUN: opt < %s -basicaa -aa-eval -print-may-aliases -disable-output |& FileCheck %s
%T = type { i32, [10 x i8] }
; CHECK: Function: test
; CHECK-NOT: May:
define void @test(%T* %P) {
%A = getelementptr %T* %P, i64 0
%B = getelementptr %T* %P, i64 0, i32 0

View File

@ -1,13 +1,15 @@
; This testcase consists of alias relations which should be completely
; resolvable by basicaa, but require analysis of getelementptr constant exprs.
; RUN: opt < %s -basicaa -aa-eval -print-may-aliases -disable-output \
; RUN: |& not grep May:
; RUN: opt < %s -basicaa -aa-eval -print-may-aliases -disable-output |& FileCheck %s
%T = type { i32, [10 x i8] }
@G = external global %T
; CHECK: Function: test
; CHECK-NOT: May:
define void @test() {
%D = getelementptr %T* @G, i64 0, i32 0
%E = getelementptr %T* @G, i64 0, i32 1, i64 5

View File

@ -1,10 +1,11 @@
; RUN: opt < %s -basicaa -dse -S | grep {store i32 0}
; RUN: opt < %s -basicaa -dse -S | FileCheck %s
define void @test({i32,i32 }* %P) {
%Q = getelementptr {i32,i32}* %P, i32 1
%X = getelementptr {i32,i32}* %Q, i32 0, i32 1
%Y = getelementptr {i32,i32}* %Q, i32 1, i32 1
store i32 0, i32* %X
store i32 1, i32* %Y
ret void
; CHECK: store i32 0, i32* %X
%Q = getelementptr {i32,i32}* %P, i32 1
%X = getelementptr {i32,i32}* %Q, i32 0, i32 1
%Y = getelementptr {i32,i32}* %Q, i32 1, i32 1
store i32 0, i32* %X
store i32 1, i32* %Y
ret void
}

View File

@ -1,7 +1,9 @@
; RUN: opt < %s -basicaa -aa-eval -disable-output |& grep {2 no alias respon}
; RUN: opt < %s -basicaa -aa-eval -disable-output |& FileCheck %s
; TEST that A[1][0] may alias A[0][i].
target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
; CHECK: 2 no alias responses
define void @test(i32 %N) {
entry:
%X = alloca [3 x [3 x i32]] ; <[3 x [3 x i32]]*> [#uses=4]

View File

@ -1,9 +1,5 @@
; RUN: opt < %s -basicaa -gvn -instcombine -S | FileCheck %s
; PR1109
; RUN: opt < %s -basicaa -gvn -instcombine -S | \
; RUN: grep {sub i32}
; RUN: opt < %s -basicaa -gvn -instcombine -S | \
; RUN: not grep {ret i32 0}
; END.
target datalayout = "e-p:32:32"
target triple = "i686-apple-darwin8"
@ -20,6 +16,9 @@ target triple = "i686-apple-darwin8"
%struct.head_type = type { [2 x %struct.LIST], %struct.FIRST_UNION, %struct.SECOND_UNION, %struct.THIRD_UNION, %struct.FOURTH_UNION, %struct.rec*, { %struct.rec* }, %struct.rec*, %struct.rec*, %struct.rec*, %struct.rec*, %struct.rec*, %struct.rec*, %struct.rec*, %struct.rec*, i32 }
%struct.rec = type { %struct.head_type }
; CHECK: define i32 @test
; CHECK: %Z = sub i32 %A, %Q
; CHECK: ret i32 %Z
define i32 @test(%struct.closure_type* %tmp18169) {
%tmp18174 = getelementptr %struct.closure_type* %tmp18169, i32 0, i32 4, i32 0, i32 0 ; <i32*> [#uses=2]

View File

@ -1,6 +1,7 @@
; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& grep {MayAlias:.*i32\\* %., i32\\* %.} | grep {%x} | grep {%y}
; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& FileCheck %s
declare i32* @unclear(i32* %a)
; CHECK: Function: foo
; CHECK: MayAlias: i32* %x, i32* %y
define void @foo(i32* noalias %x) {
%y = call i32* @unclear(i32* %x)
@ -8,3 +9,5 @@ define void @foo(i32* noalias %x) {
store i32 0, i32* %y
ret void
}
declare i32* @unclear(i32* %a)

View File

@ -1,6 +1,9 @@
; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& grep {9 no alias}
; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& grep {6 may alias}
; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& grep {MayAlias:.*i32\\* %Ipointer, i32\\* %Jpointer}
; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& FileCheck %s
; CHECK: Function: foo
; CHECK: MayAlias: i32* %Ipointer, i32* %Jpointer
; CHECK: 9 no alias responses
; CHECK: 6 may alias responses
define void @foo(i32* noalias %p, i32* noalias %q, i32 %i, i32 %j) {
%Ipointer = getelementptr i32* %p, i32 %i

View File

@ -1,11 +1,10 @@
; RUN: opt < %s -basicaa -gvn -instcombine -S | FileCheck %s
; PR1600
; RUN: opt < %s -basicaa -gvn -instcombine -S | \
; RUN: grep {ret i32 0}
; END.
declare i16 @llvm.cttz.i16(i16, i1)
define i32 @test(i32* %P, i16* %Q) {
; CHECK: ret i32 0
%A = load i16* %Q ; <i16> [#uses=1]
%x = load i32* %P ; <i32> [#uses=1]
%B = call i16 @llvm.cttz.i16( i16 %A, i1 true ) ; <i16> [#uses=1]

View File

@ -1,10 +1,12 @@
; RUN: opt < %s -basicaa -gvn -dce -S | grep tmp7
; RUN: opt < %s -basicaa -gvn -dce -S | FileCheck %s
%struct.A = type { i32 }
%struct.B = type { %struct.A }
@a = global %struct.B zeroinitializer ; <%struct.B*> [#uses=2]
define i32 @_Z3fooP1A(%struct.A* %b) {
; CHECK: %tmp7 = load
; CHECK: ret i32 %tmp7
entry:
store i32 1, i32* getelementptr (%struct.B* @a, i32 0, i32 0, i32 0), align 8
%tmp4 = getelementptr %struct.A* %b, i32 0, i32 0 ;<i32*> [#uses=1]

View File

@ -1,10 +1,11 @@
; RUN: opt < %s -std-compile-opts -S | grep store
; RUN: opt < %s -std-compile-opts -S | FileCheck %s
; ModuleID = 'small2.c'
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
target triple = "i386-apple-darwin8"
%struct.x = type { [4 x i32] }
define void @foo(%struct.x* byval align 4 %X) nounwind {
; CHECK: store i32 2, i32* %tmp1
entry:
%tmp = getelementptr %struct.x* %X, i32 0, i32 0 ; <[4 x i32]*> [#uses=1]
%tmp1 = getelementptr [4 x i32]* %tmp, i32 0, i32 3 ; <i32*> [#uses=1]

View File

@ -1,7 +1,9 @@
; RUN: opt < %s -basicaa -aa-eval |& grep {1 no alias response}
; RUN: opt < %s -basicaa -aa-eval -disable-output |& FileCheck %s
declare noalias i32* @_Znwj(i32 %x) nounwind
; CHECK: 1 no alias response
define i32 @foo() {
%A = call i32* @_Znwj(i32 4)
%B = call i32* @_Znwj(i32 4)

View File

@ -1,8 +1,9 @@
; RUN: opt < %s -basicaa -gvn -S | grep load
; RUN: opt < %s -basicaa -gvn -S | FileCheck %s
declare noalias i32* @noalias()
define i32 @test(i32 %x) {
; CHECK: load i32* %a
%a = call i32* @noalias()
store i32 1, i32* %a
%b = getelementptr i32* %a, i32 %x

View File

@ -1,10 +1,13 @@
; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& grep {NoAlias:.*%P,.*@Z}
; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& FileCheck %s
; If GEP base doesn't alias Z, then GEP doesn't alias Z.
; rdar://7282591
@Y = common global i32 0
@Z = common global i32 0
; CHECK: Function: foo
; CHECK: NoAlias: i32* %P, i32* @Z
define void @foo(i32 %cond) nounwind {
entry:
%a = alloca i32

View File

@ -1,8 +1,10 @@
; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& grep {1 partial alias}
; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& FileCheck %s
; PR7959
target datalayout = "e-p:32:32:32"
; CHECK: 1 partial alias response
define i32 @test(i32* %tab, i32 %indvar) nounwind {
%tmp31 = mul i32 %indvar, -2
%tmp32 = add i32 %tmp31, 30

View File

@ -1,17 +1,17 @@
; RUN: opt < %s -basicaa -gvn -S | grep {ret i32 1}
; RUN: opt < %s -basicaa -gvn -S | FileCheck %s
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
target triple = "i686-apple-darwin8"
%struct.x = type { i32, i32, i32, i32 }
@g = weak global i32 0 ; <i32*> [#uses=1]
define i32 @foo(%struct.x* byval %a) nounwind {
entry:
%tmp1 = tail call i32 (...)* @bar( %struct.x* %a ) nounwind ; <i32> [#uses=0]
%tmp2 = getelementptr %struct.x* %a, i32 0, i32 0 ; <i32*> [#uses=2]
store i32 1, i32* %tmp2, align 4
store i32 2, i32* @g, align 4
%tmp4 = load i32* %tmp2, align 4 ; <i32> [#uses=1]
ret i32 %tmp4
; CHECK: ret i32 1
%tmp1 = tail call i32 (...)* @bar( %struct.x* %a ) nounwind ; <i32> [#uses=0]
%tmp2 = getelementptr %struct.x* %a, i32 0, i32 0 ; <i32*> [#uses=2]
store i32 1, i32* %tmp2, align 4
store i32 2, i32* @g, align 4
%tmp4 = load i32* %tmp2, align 4 ; <i32> [#uses=1]
ret i32 %tmp4
}
declare i32 @bar(...)

View File

@ -1,8 +1,9 @@
; RUN: opt < %s -basicaa -gvn -instcombine -S | grep {ret i32 0}
; RUN: opt < %s -basicaa -gvn -instcombine -S | FileCheck %s
@flag0 = internal global i32 zeroinitializer
@turn = internal global i32 zeroinitializer
; CHECK: ret i32 0
define i32 @main() {
%a = load i32* @flag0

View File

@ -1,8 +1,10 @@
; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output \
; RUN: |& grep {NoAlias: \{\}\\* \[%\]p, \{\}\\* \[%\]q}
; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& FileCheck %s
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
; CHECK: Function: foo:
; CHECK-NEXT: NoAlias: {}* %p, {}* %q
define void @foo({}* %p, {}* %q) {
store {} {}, {}* %p
store {} {}, {}* %q

View File

@ -1,5 +1,5 @@
; RUN: opt -S -tbaa -basicaa -gvn < %s | grep {ret i32 %}
; RUN: opt -S -tbaa -gvn < %s | grep {ret i32 0}
; RUN: opt -S -tbaa -basicaa -gvn < %s | FileCheck -check-prefix=BASICAA %s
; RUN: opt -S -tbaa -gvn < %s | FileCheck %s
; rdar://8875631, rdar://8875069
; BasicAA should notice that the store stores to the entire %u object,
@ -14,6 +14,8 @@ target datalayout = "e-p:64:64:64"
@endianness_test = global i64 1, align 8
define i32 @signbit(double %x) nounwind {
; BASICAA: ret i32 %tmp5.lobit
; CHECK: ret i32 0
entry:
%u = alloca %union.anon, align 8
%tmp9 = getelementptr inbounds %union.anon* %u, i64 0, i32 0

View File

@ -2,12 +2,15 @@
; disambiguating some obvious cases. All loads should be removable in
; this testcase.
; RUN: opt < %s -basicaa -gvn -instcombine -dce -S \
; RUN: | not grep load
; RUN: opt < %s -basicaa -gvn -instcombine -dce -S | FileCheck %s
@A = global i32 7
@B = global i32 8
; CHECK: define i32 @test()
; CHECK-NEXT: store i32 123, i32* @B
; CHECK-NEXT: ret i32 0
define i32 @test() {
%A1 = load i32* @A
@ -18,6 +21,14 @@ define i32 @test() {
ret i32 %X
}
; CHECK: define i32 @test2()
; CHECK-NEXT: br label %Loop
; CHECK: Loop:
; CHECK-NEXT: store i32 0, i32* @B
; CHECK-NEXT: br i1 true, label %out, label %Loop
; CHECK: out:
; CHECK-NEXT: ret i32 0
define i32 @test2() {
%A1 = load i32* @A
br label %Loop
@ -36,6 +47,10 @@ out:
declare void @external()
; CHECK: define i32 @test3()
; CHECK-NEXT: call void @external()
; CHECK-NEXT: ret i32 7
define i32 @test3() {
%X = alloca i32
store i32 7, i32* %X

View File

@ -1,9 +1,10 @@
; RUN: opt < %s -basicaa -gvn -instcombine -S | grep {ret i1 true}
; RUN: opt < %s -basicaa -gvn -instcombine -S | FileCheck %s
; PR2436
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
target triple = "i386-apple-darwin8"
define i1 @foo(i32 %i) nounwind {
; CHECK: ret i1 true
entry:
%arr = alloca [10 x i8*] ; <[10 x i8*]*> [#uses=1]
%tmp2 = call i8* @getPtr( ) nounwind ; <i8*> [#uses=2]

View File

@ -1,8 +1,9 @@
; RUN: opt < %s -basicaa -gvn -instcombine -S | grep {ret i32 0}
; RUN: opt < %s -basicaa -gvn -instcombine -S | FileCheck %s
declare i32* @test(i32* nocapture)
define i32 @test2() {
; CHECK: ret i32 0
%P = alloca i32
%Q = call i32* @test(i32* %P)
%a = load i32* %P

View File

@ -1,10 +1,12 @@
; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& grep {NoAlias:.*%P,.*@Z}
; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& FileCheck %s
; rdar://7282591
@X = common global i32 0
@Y = common global i32 0
@Z = common global i32 0
; CHECK: NoAlias: i32* %P, i32* @Z
define void @foo(i32 %cond) nounwind {
entry:
%"alloca point" = bitcast i32 0 to i32

View File

@ -1,8 +1,17 @@
; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output \
; RUN: |& grep {NoAlias: double\\* \[%\]a, double\\* \[%\]b\$} | count 4
; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& FileCheck %s
; BasicAA should detect NoAliases in PHIs and Selects.
; CHECK: Function: foo
; CHECK: NoAlias: double* %a, double* %b
; CHECK: Function: bar
; CHECK: NoAlias: double* %a, double* %b
; CHECK: Function: qux
; CHECK: NoAlias: double* %a, double* %b
; CHECK: Function: fin
; CHECK: NoAlias: double* %a, double* %b
; CHECK: ===== Alias Analysis Evaluator Report =====
; Two PHIs in the same block.
define void @foo(i1 %m, double* noalias %x, double* noalias %y) {
entry:

View File

@ -1,7 +1,25 @@
; RUN: opt < %s -basicaa -gvn -S | grep TestConst | count 2
; RUN: opt < %s -basicaa -gvn -S | grep TestPure | count 3
; RUN: opt < %s -basicaa -gvn -S | grep TestNone | count 4
@g = global i32 0 ; <i32*> [#uses=1]
; RUN: opt < %s -basicaa -gvn -S | FileCheck %s
@g = global i32 0
; CHECK: @test
; CHECK: entry
; CHECK: %tmp0 = call i32 @TestConst(i32 5) readnone
; CHECK-NEXT: %tmp1 = call i32 @TestPure(i32 6) readonly
; CHECK-NEXT: %tmp2 = call i32 @TestNone(i32 7)
; CHECK-NEXT: store i32 1, i32* @g
; CHECK-NEXT: %tmp5 = call i32 @TestPure(i32 6) readonly
; CHECK-NEXT: %tmp7 = call i32 @TestNone(i32 7)
; CHECK-NEXT: %tmp8 = call i32 @TestNone(i32 7)
; CHECK-NEXT: %sum0 = add i32 %tmp0, %tmp1
; CHECK-NEXT: %sum1 = add i32 %sum0, %tmp2
; CHECK-NEXT: %sum2 = add i32 %sum1, %tmp0
; CHECK-NEXT: %sum3 = add i32 %sum2, %tmp0
; CHECK-NEXT: %sum4 = add i32 %sum3, %tmp5
; CHECK-NEXT: %sum5 = add i32 %sum4, %tmp5
; CHECK-NEXT: %sum6 = add i32 %sum5, %tmp7
; CHECK-NEXT: %sum7 = add i32 %sum6, %tmp8
; CHECK-NEXT: ret i32 %sum7
define i32 @test() {
entry:

View File

@ -1,11 +1,7 @@
; RUN: opt < %s -basicaa -gvn -instcombine |\
; RUN: llvm-dis | grep {ret i32 0}
declare void @foo(i32*)
declare void @bar()
; RUN: opt < %s -basicaa -gvn -instcombine -S | FileCheck %s
define i32 @test() {
; CHECK: ret i32 0
%A = alloca i32 ; <i32*> [#uses=3]
call void @foo( i32* %A )
%X = load i32* %A ; <i32> [#uses=1]
@ -14,3 +10,7 @@ define i32 @test() {
%Z = sub i32 %X, %Y ; <i32> [#uses=1]
ret i32 %Z
}
declare void @foo(i32*)
declare void @bar()