llvm.org GIT mirror llvm / d5cc8b8
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 Bill Wendling 8 years ago
28 changed file(s) with 159 addition(s) and 82 deletion(s). Raw diff Collapse all Expand all
11 ; is performed. It is not legal to delete the second load instruction because
22 ; the value computed by the first load instruction is changed by the store.
33
4 ; RUN: opt < %s -basicaa -gvn -instcombine -S | grep DONOTREMOVE
4 ; RUN: opt < %s -basicaa -gvn -instcombine -S | FileCheck %s
55
66 define i32 @test() {
7 %A = alloca i32
8 store i32 0, i32* %A
9 %X = load i32* %A
10 %B = bitcast i32* %A to i8*
11 %C = getelementptr i8* %B, i64 1
12 store i8 1, i8* %C ; Aliases %A
13 %Y.DONOTREMOVE = load i32* %A
14 %Z = sub i32 %X, %Y.DONOTREMOVE
15 ret i32 %Z
7 ; CHECK: %Y.DONOTREMOVE = load i32* %A
8 ; CHECK: %Z = sub i32 0, %Y.DONOTREMOVE
9 %A = alloca i32
10 store i32 0, i32* %A
11 %X = load i32* %A
12 %B = bitcast i32* %A to i8*
13 %C = getelementptr i8* %B, i64 1
14 store i8 1, i8* %C ; Aliases %A
15 %Y.DONOTREMOVE = load i32* %A
16 %Z = sub i32 %X, %Y.DONOTREMOVE
17 ret i32 %Z
1618 }
1719
None ; RUN: opt < %s -basicaa -gvn -instcombine -S | grep sub
0 ; RUN: opt < %s -basicaa -gvn -instcombine -S | FileCheck %s
11
22 ; BasicAA was incorrectly concluding that P1 and P2 didn't conflict!
33
44 define i32 @test(i32 *%Ptr, i64 %V) {
5 %P2 = getelementptr i32* %Ptr, i64 1
6 %P1 = getelementptr i32* %Ptr, i64 %V
7 %X = load i32* %P1
8 store i32 5, i32* %P2
9
10 %Y = load i32* %P1
11
12 %Z = sub i32 %X, %Y
13 ret i32 %Z
5 ; CHECK: sub i32 %X, %Y
6 %P2 = getelementptr i32* %Ptr, i64 1
7 %P1 = getelementptr i32* %Ptr, i64 %V
8 %X = load i32* %P1
9 store i32 5, i32* %P2
10 %Y = load i32* %P1
11 %Z = sub i32 %X, %Y
12 ret i32 %Z
1413 }
0 ; In this test, a local alloca cannot alias an incoming argument.
11
2 ; RUN: opt < %s -basicaa -gvn -instcombine -S | not grep sub
2 ; RUN: opt < %s -basicaa -gvn -instcombine -S | FileCheck %s
3
4 ; CHECK: define i32 @test
5 ; CHECK-NEXT: ret i32 0
36
47 define i32 @test(i32* %P) {
58 %X = alloca i32
0 ; This testcase consists of alias relations which should be completely
11 ; resolvable by basicaa.
22
3 ; RUN: opt < %s -basicaa -aa-eval -print-may-aliases -disable-output \
4 ; RUN: |& not grep May:
3 ; RUN: opt < %s -basicaa -aa-eval -print-may-aliases -disable-output |& FileCheck %s
54
65 %T = type { i32, [10 x i8] }
6
7 ; CHECK: Function: test
8 ; CHECK-NOT: May:
79
810 define void @test(%T* %P) {
911 %A = getelementptr %T* %P, i64 0
0 ; This testcase consists of alias relations which should be completely
11 ; resolvable by basicaa, but require analysis of getelementptr constant exprs.
22
3 ; RUN: opt < %s -basicaa -aa-eval -print-may-aliases -disable-output \
4 ; RUN: |& not grep May:
3 ; RUN: opt < %s -basicaa -aa-eval -print-may-aliases -disable-output |& FileCheck %s
54
65 %T = type { i32, [10 x i8] }
76
87 @G = external global %T
8
9 ; CHECK: Function: test
10 ; CHECK-NOT: May:
911
1012 define void @test() {
1113 %D = getelementptr %T* @G, i64 0, i32 0
None ; RUN: opt < %s -basicaa -dse -S | grep {store i32 0}
0 ; RUN: opt < %s -basicaa -dse -S | FileCheck %s
11
22 define void @test({i32,i32 }* %P) {
3 %Q = getelementptr {i32,i32}* %P, i32 1
4 %X = getelementptr {i32,i32}* %Q, i32 0, i32 1
5 %Y = getelementptr {i32,i32}* %Q, i32 1, i32 1
6 store i32 0, i32* %X
7 store i32 1, i32* %Y
8 ret void
3 ; CHECK: store i32 0, i32* %X
4 %Q = getelementptr {i32,i32}* %P, i32 1
5 %X = getelementptr {i32,i32}* %Q, i32 0, i32 1
6 %Y = getelementptr {i32,i32}* %Q, i32 1, i32 1
7 store i32 0, i32* %X
8 store i32 1, i32* %Y
9 ret void
910 }
None ; RUN: opt < %s -basicaa -aa-eval -disable-output |& grep {2 no alias respon}
0 ; RUN: opt < %s -basicaa -aa-eval -disable-output |& FileCheck %s
11 ; TEST that A[1][0] may alias A[0][i].
22 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"
3
4 ; CHECK: 2 no alias responses
35
46 define void @test(i32 %N) {
57 entry:
0 ; RUN: opt < %s -basicaa -gvn -instcombine -S | FileCheck %s
1 ; PR1109
1 ; RUN: opt < %s -basicaa -gvn -instcombine -S | \
2 ; RUN: grep {sub i32}
3 ; RUN: opt < %s -basicaa -gvn -instcombine -S | \
4 ; RUN: not grep {ret i32 0}
5 ; END.
62
73 target datalayout = "e-p:32:32"
84 target triple = "i686-apple-darwin8"
1915 %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 }
2016 %struct.rec = type { %struct.head_type }
2117
18 ; CHECK: define i32 @test
19 ; CHECK: %Z = sub i32 %A, %Q
20 ; CHECK: ret i32 %Z
2221
2322 define i32 @test(%struct.closure_type* %tmp18169) {
2423 %tmp18174 = getelementptr %struct.closure_type* %tmp18169, i32 0, i32 4, i32 0, i32 0 ; [#uses=2]
None ; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& grep {MayAlias:.*i32\\* %., i32\\* %.} | grep {%x} | grep {%y}
0 ; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& FileCheck %s
11
2 declare i32* @unclear(i32* %a)
2 ; CHECK: Function: foo
3 ; CHECK: MayAlias: i32* %x, i32* %y
34
45 define void @foo(i32* noalias %x) {
56 %y = call i32* @unclear(i32* %x)
78 store i32 0, i32* %y
89 ret void
910 }
11
12 declare i32* @unclear(i32* %a)
None ; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& grep {9 no alias}
1 ; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& grep {6 may alias}
2 ; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& grep {MayAlias:.*i32\\* %Ipointer, i32\\* %Jpointer}
0 ; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& FileCheck %s
1
2 ; CHECK: Function: foo
3 ; CHECK: MayAlias: i32* %Ipointer, i32* %Jpointer
4 ; CHECK: 9 no alias responses
5 ; CHECK: 6 may alias responses
36
47 define void @foo(i32* noalias %p, i32* noalias %q, i32 %i, i32 %j) {
58 %Ipointer = getelementptr i32* %p, i32 %i
0 ; RUN: opt < %s -basicaa -gvn -instcombine -S | FileCheck %s
1 ; PR1600
1 ; RUN: opt < %s -basicaa -gvn -instcombine -S | \
2 ; RUN: grep {ret i32 0}
3 ; END.
42
53 declare i16 @llvm.cttz.i16(i16, i1)
64
75 define i32 @test(i32* %P, i16* %Q) {
6 ; CHECK: ret i32 0
87 %A = load i16* %Q ; [#uses=1]
98 %x = load i32* %P ; [#uses=1]
109 %B = call i16 @llvm.cttz.i16( i16 %A, i1 true ) ; [#uses=1]
None ; RUN: opt < %s -basicaa -gvn -dce -S | grep tmp7
0 ; RUN: opt < %s -basicaa -gvn -dce -S | FileCheck %s
11
22 %struct.A = type { i32 }
33 %struct.B = type { %struct.A }
44 @a = global %struct.B zeroinitializer ; <%struct.B*> [#uses=2]
55
66 define i32 @_Z3fooP1A(%struct.A* %b) {
7 ; CHECK: %tmp7 = load
8 ; CHECK: ret i32 %tmp7
79 entry:
810 store i32 1, i32* getelementptr (%struct.B* @a, i32 0, i32 0, i32 0), align 8
911 %tmp4 = getelementptr %struct.A* %b, i32 0, i32 0 ; [#uses=1]
None ; RUN: opt < %s -std-compile-opts -S | grep store
0 ; RUN: opt < %s -std-compile-opts -S | FileCheck %s
11 ; ModuleID = 'small2.c'
22 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"
33 target triple = "i386-apple-darwin8"
44 %struct.x = type { [4 x i32] }
55
66 define void @foo(%struct.x* byval align 4 %X) nounwind {
7 ; CHECK: store i32 2, i32* %tmp1
78 entry:
89 %tmp = getelementptr %struct.x* %X, i32 0, i32 0 ; <[4 x i32]*> [#uses=1]
910 %tmp1 = getelementptr [4 x i32]* %tmp, i32 0, i32 3 ; [#uses=1]
None ; RUN: opt < %s -basicaa -aa-eval |& grep {1 no alias response}
0 ; RUN: opt < %s -basicaa -aa-eval -disable-output |& FileCheck %s
11
22 declare noalias i32* @_Znwj(i32 %x) nounwind
3
4 ; CHECK: 1 no alias response
35
46 define i32 @foo() {
57 %A = call i32* @_Znwj(i32 4)
None ; RUN: opt < %s -basicaa -gvn -S | grep load
0 ; RUN: opt < %s -basicaa -gvn -S | FileCheck %s
11
22 declare noalias i32* @noalias()
33
44 define i32 @test(i32 %x) {
5 ; CHECK: load i32* %a
56 %a = call i32* @noalias()
67 store i32 1, i32* %a
78 %b = getelementptr i32* %a, i32 %x
None ; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& grep {NoAlias:.*%P,.*@Z}
0 ; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& FileCheck %s
11 ; If GEP base doesn't alias Z, then GEP doesn't alias Z.
22 ; rdar://7282591
33
44 @Y = common global i32 0
55 @Z = common global i32 0
6
7 ; CHECK: Function: foo
8 ; CHECK: NoAlias: i32* %P, i32* @Z
69
710 define void @foo(i32 %cond) nounwind {
811 entry:
None ; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& grep {1 partial alias}
0 ; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& FileCheck %s
11 ; PR7959
22
33 target datalayout = "e-p:32:32:32"
4
5 ; CHECK: 1 partial alias response
46
57 define i32 @test(i32* %tab, i32 %indvar) nounwind {
68 %tmp31 = mul i32 %indvar, -2
None ; RUN: opt < %s -basicaa -gvn -S | grep {ret i32 1}
0 ; RUN: opt < %s -basicaa -gvn -S | FileCheck %s
11 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"
22 target triple = "i686-apple-darwin8"
33 %struct.x = type { i32, i32, i32, i32 }
44 @g = weak global i32 0 ; [#uses=1]
55
66 define i32 @foo(%struct.x* byval %a) nounwind {
7 entry:
8 %tmp1 = tail call i32 (...)* @bar( %struct.x* %a ) nounwind ; [#uses=0]
9 %tmp2 = getelementptr %struct.x* %a, i32 0, i32 0 ; [#uses=2]
10 store i32 1, i32* %tmp2, align 4
11 store i32 2, i32* @g, align 4
12 %tmp4 = load i32* %tmp2, align 4 ; [#uses=1]
13 ret i32 %tmp4
7 ; CHECK: ret i32 1
8 %tmp1 = tail call i32 (...)* @bar( %struct.x* %a ) nounwind ; [#uses=0]
9 %tmp2 = getelementptr %struct.x* %a, i32 0, i32 0 ; [#uses=2]
10 store i32 1, i32* %tmp2, align 4
11 store i32 2, i32* @g, align 4
12 %tmp4 = load i32* %tmp2, align 4 ; [#uses=1]
13 ret i32 %tmp4
1414 }
1515
1616 declare i32 @bar(...)
None ; RUN: opt < %s -basicaa -gvn -instcombine -S | grep {ret i32 0}
0 ; RUN: opt < %s -basicaa -gvn -instcombine -S | FileCheck %s
11
22 @flag0 = internal global i32 zeroinitializer
33 @turn = internal global i32 zeroinitializer
44
5 ; CHECK: ret i32 0
56
67 define i32 @main() {
78 %a = load i32* @flag0
None ; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output \
1 ; RUN: |& grep {NoAlias: \{\}\\* \[%\]p, \{\}\\* \[%\]q}
0 ; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& FileCheck %s
21
32 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"
3
4 ; CHECK: Function: foo:
5 ; CHECK-NEXT: NoAlias: {}* %p, {}* %q
46
57 define void @foo({}* %p, {}* %q) {
68 store {} {}, {}* %p
None ; RUN: opt -S -tbaa -basicaa -gvn < %s | grep {ret i32 %}
1 ; RUN: opt -S -tbaa -gvn < %s | grep {ret i32 0}
0 ; RUN: opt -S -tbaa -basicaa -gvn < %s | FileCheck -check-prefix=BASICAA %s
1 ; RUN: opt -S -tbaa -gvn < %s | FileCheck %s
22 ; rdar://8875631, rdar://8875069
33
44 ; BasicAA should notice that the store stores to the entire %u object,
1313 @endianness_test = global i64 1, align 8
1414
1515 define i32 @signbit(double %x) nounwind {
16 ; BASICAA: ret i32 %tmp5.lobit
17 ; CHECK: ret i32 0
1618 entry:
1719 %u = alloca %union.anon, align 8
1820 %tmp9 = getelementptr inbounds %union.anon* %u, i64 0, i32 0
11 ; disambiguating some obvious cases. All loads should be removable in
22 ; this testcase.
33
4 ; RUN: opt < %s -basicaa -gvn -instcombine -dce -S \
5 ; RUN: | not grep load
4 ; RUN: opt < %s -basicaa -gvn -instcombine -dce -S | FileCheck %s
65
76 @A = global i32 7
87 @B = global i32 8
8
9 ; CHECK: define i32 @test()
10 ; CHECK-NEXT: store i32 123, i32* @B
11 ; CHECK-NEXT: ret i32 0
912
1013 define i32 @test() {
1114 %A1 = load i32* @A
1619 %X = sub i32 %A1, %A2
1720 ret i32 %X
1821 }
22
23 ; CHECK: define i32 @test2()
24 ; CHECK-NEXT: br label %Loop
25 ; CHECK: Loop:
26 ; CHECK-NEXT: store i32 0, i32* @B
27 ; CHECK-NEXT: br i1 true, label %out, label %Loop
28 ; CHECK: out:
29 ; CHECK-NEXT: ret i32 0
1930
2031 define i32 @test2() {
2132 %A1 = load i32* @A
3546
3647 declare void @external()
3748
49 ; CHECK: define i32 @test3()
50 ; CHECK-NEXT: call void @external()
51 ; CHECK-NEXT: ret i32 7
52
3853 define i32 @test3() {
3954 %X = alloca i32
4055 store i32 7, i32* %X
None ; RUN: opt < %s -basicaa -gvn -instcombine -S | grep {ret i1 true}
0 ; RUN: opt < %s -basicaa -gvn -instcombine -S | FileCheck %s
11 ; PR2436
22 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"
33 target triple = "i386-apple-darwin8"
44
55 define i1 @foo(i32 %i) nounwind {
6 ; CHECK: ret i1 true
67 entry:
78 %arr = alloca [10 x i8*] ; <[10 x i8*]*> [#uses=1]
89 %tmp2 = call i8* @getPtr( ) nounwind ; [#uses=2]
None ; RUN: opt < %s -basicaa -gvn -instcombine -S | grep {ret i32 0}
0 ; RUN: opt < %s -basicaa -gvn -instcombine -S | FileCheck %s
11
22 declare i32* @test(i32* nocapture)
33
44 define i32 @test2() {
5 ; CHECK: ret i32 0
56 %P = alloca i32
67 %Q = call i32* @test(i32* %P)
78 %a = load i32* %P
None ; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& grep {NoAlias:.*%P,.*@Z}
0 ; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& FileCheck %s
11 ; rdar://7282591
22
33 @X = common global i32 0
44 @Y = common global i32 0
55 @Z = common global i32 0
6
7 ; CHECK: NoAlias: i32* %P, i32* @Z
68
79 define void @foo(i32 %cond) nounwind {
810 entry:
None ; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output \
1 ; RUN: |& grep {NoAlias: double\\* \[%\]a, double\\* \[%\]b\$} | count 4
0 ; RUN: opt < %s -basicaa -aa-eval -print-all-alias-modref-info -disable-output |& FileCheck %s
21
32 ; BasicAA should detect NoAliases in PHIs and Selects.
3
4 ; CHECK: Function: foo
5 ; CHECK: NoAlias: double* %a, double* %b
6 ; CHECK: Function: bar
7 ; CHECK: NoAlias: double* %a, double* %b
8 ; CHECK: Function: qux
9 ; CHECK: NoAlias: double* %a, double* %b
10 ; CHECK: Function: fin
11 ; CHECK: NoAlias: double* %a, double* %b
12 ; CHECK: ===== Alias Analysis Evaluator Report =====
413
514 ; Two PHIs in the same block.
615 define void @foo(i1 %m, double* noalias %x, double* noalias %y) {
None ; RUN: opt < %s -basicaa -gvn -S | grep TestConst | count 2
1 ; RUN: opt < %s -basicaa -gvn -S | grep TestPure | count 3
2 ; RUN: opt < %s -basicaa -gvn -S | grep TestNone | count 4
3 @g = global i32 0 ; [#uses=1]
0 ; RUN: opt < %s -basicaa -gvn -S | FileCheck %s
1
2 @g = global i32 0
3
4 ; CHECK: @test
5 ; CHECK: entry
6 ; CHECK: %tmp0 = call i32 @TestConst(i32 5) readnone
7 ; CHECK-NEXT: %tmp1 = call i32 @TestPure(i32 6) readonly
8 ; CHECK-NEXT: %tmp2 = call i32 @TestNone(i32 7)
9 ; CHECK-NEXT: store i32 1, i32* @g
10 ; CHECK-NEXT: %tmp5 = call i32 @TestPure(i32 6) readonly
11 ; CHECK-NEXT: %tmp7 = call i32 @TestNone(i32 7)
12 ; CHECK-NEXT: %tmp8 = call i32 @TestNone(i32 7)
13 ; CHECK-NEXT: %sum0 = add i32 %tmp0, %tmp1
14 ; CHECK-NEXT: %sum1 = add i32 %sum0, %tmp2
15 ; CHECK-NEXT: %sum2 = add i32 %sum1, %tmp0
16 ; CHECK-NEXT: %sum3 = add i32 %sum2, %tmp0
17 ; CHECK-NEXT: %sum4 = add i32 %sum3, %tmp5
18 ; CHECK-NEXT: %sum5 = add i32 %sum4, %tmp5
19 ; CHECK-NEXT: %sum6 = add i32 %sum5, %tmp7
20 ; CHECK-NEXT: %sum7 = add i32 %sum6, %tmp8
21 ; CHECK-NEXT: ret i32 %sum7
422
523 define i32 @test() {
624 entry:
None ; RUN: opt < %s -basicaa -gvn -instcombine |\
1 ; RUN: llvm-dis | grep {ret i32 0}
2
3 declare void @foo(i32*)
4
5 declare void @bar()
0 ; RUN: opt < %s -basicaa -gvn -instcombine -S | FileCheck %s
61
72 define i32 @test() {
3 ; CHECK: ret i32 0
84 %A = alloca i32 ; [#uses=3]
95 call void @foo( i32* %A )
106 %X = load i32* %A ; [#uses=1]
139 %Z = sub i32 %X, %Y ; [#uses=1]
1410 ret i32 %Z
1511 }
12
13 declare void @foo(i32*)
14
15 declare void @bar()