llvm.org GIT mirror llvm / dcd188d
Remove llvm-upgrade. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47110 91177308-0d34-0410-b5e6-96231b3b80d8 Tanya Lattner 12 years ago
43 changed file(s) with 557 addition(s) and 593 deletion(s). Raw diff Collapse all Expand all
None ; RUN: llvm-upgrade < %s | llvm-as | opt -anders-aa -load-vn -gcse -deadargelim | llvm-dis | not grep ARG
0 ; RUN: llvm-as < %s | opt -anders-aa -load-vn -gcse -deadargelim | llvm-dis | not grep ARG
11
2 %G = internal constant int* null
2 @G = internal constant i32* null
33
4 implementation
5
6 internal int %internal(int* %ARG) {
4 define internal i32 @internal(i32* %ARG) {
75 ;; The 'Arg' argument must-aliases the null pointer, so it can be subsituted
86 ;; directly here, making it dead.
9 store int* %ARG, int** %G
10 ret int 0
7 store i32* %ARG, i32** @G
8 ret i32 0
119 }
1210
13 int %foo() {
14 %V = call int %internal(int* null)
15 ret int %V
11 define i32 @foo() {
12 %V = call i32 @internal(i32* null)
13 ret i32 %V
1614 }
None ; RUN: llvm-upgrade < %s | llvm-as | opt -anders-aa -aa-eval
0 ; RUN: llvm-as < %s | opt -anders-aa -aa-eval
11
2 implementation
3
4 void %test1() {
5 %X = malloc int*
6 %Y = malloc int
7 %Z = cast int* %Y to int
8 %W = cast int %Z to int*
9 store int* %W, int** %X
2 define void @test1() {
3 %X = malloc i32*
4 %Y = malloc i32
5 %Z = ptrtoint i32* %Y to i32
6 %W = inttoptr i32 %Z to i32*
7 store i32* %W, i32** %X
108 ret void
119 }
1210
13 void %test2(int* %P) {
14 %X = malloc int*
15 %Y = malloc int
16 store int* %P, int** %X
11 define void @test2(i32* %P) {
12 %X = malloc i32*
13 %Y = malloc i32
14 store i32* %P, i32** %X
1715 ret void
1816 }
1917
20 internal int *%test3(int* %P) {
21 ret int* %P
18 define internal i32 *@test3(i32* %P) {
19 ret i32* %P
2220 }
2321
24 void %test4() {
25 %X = malloc int
26 %Y = call int* %test3(int* %X)
27 %ZZ = getelementptr int* null, int 17
22 define void @test4() {
23 %X = malloc i32
24 %Y = call i32* @test3(i32* %X)
25 %ZZ = getelementptr i32* null, i32 17
2826 ret void
2927 }
None ; RUN: llvm-upgrade < %s | llvm-as | opt -anders-aa -load-vn -gcse -deadargelim | llvm-dis | grep store | not grep null
0 ; RUN: llvm-as < %s | opt -anders-aa -load-vn -gcse -deadargelim | llvm-dis | grep store | not grep null
11
22 ; Because the 'internal' function is passed to an external function, we don't
33 ; know what the incoming values will alias. As such, we cannot do the
44 ; optimization checked by the 'arg-must-alias.llx' test.
55
6 declare void %external(int(int*)*)
7 %G = internal constant int* null
6 declare void @external(i32(i32*)*)
7 @G = internal constant i32* null
88
9 implementation
10
11 internal int %internal(int* %ARG) {
9 define internal i32 @internal(i32* %ARG) {
1210 ;;; We *DON'T* know that ARG always points to null!
13 store int* %ARG, int** %G
14 ret int 0
11 store i32* %ARG, i32** @G
12 ret i32 0
1513 }
1614
17 int %foo() {
18 call void %external(int(int*)* %internal)
19 %V = call int %internal(int* null)
20 ret int %V
15 define i32 @foo() {
16 call void @external(i32(i32*)* @internal)
17 %V = call i32 @internal(i32* null)
18 ret i32 %V
2119 }
None ; RUN: llvm-upgrade < %s | llvm-as | \
1 ; RUN: opt -anders-aa -load-vn -gcse -instcombine | llvm-dis | \
2 ; RUN: grep {ret i1 true}
0 ; RUN: llvm-as < %s | opt -anders-aa -load-vn -gcse -instcombine | llvm-dis \
1 ; RUN: | grep {ret i1 true}
32
4 %G = internal global int* null
5 declare int *%ext()
6 bool %bar() {
7 %V1 = load int** %G
8 %X2 = call int *%ext()
9 %V2 = load int** %G
10 store int* %X2, int** %G
3 @G = internal global i32* null
4 declare i32 *@ext()
115
12 %C = seteq int* %V1, %V2
13 ret bool %C
6 define i1 @bar() {
7 %V1 = load i32** @G
8 %X2 = call i32 *@ext()
9 %V2 = load i32** @G
10 store i32* %X2, i32** @G
11
12 %C = icmp eq i32* %V1, %V2
13 ret i1 %C
1414 }
None ; RUN: llvm-upgrade < %s | llvm-as | opt -anders-aa -disable-output
0 ; RUN: llvm-as < %s | opt -anders-aa -disable-output
11
2 void %foo() { ret void }
2 define void @foo() { ret void }
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: llvm-upgrade < %s | llvm-as | opt -load-vn -gcse -instcombine | llvm-dis | grep DONOTREMOVE
4 ; RUN: llvm-as < %s | opt -load-vn -gcse -instcombine | llvm-dis | grep DONOTREMOVE
55
6 int %test() {
7 %A = alloca int
8 store int 0, int* %A
9 %X = load int* %A
10 %B = cast int* %A to sbyte*
11 %C = getelementptr sbyte* %B, long 1
12 store sbyte 1, sbyte* %C ; Aliases %A
13 %Y.DONOTREMOVE = load int* %A
14 %Z = sub int %X, %Y.DONOTREMOVE
15 ret int %Z
6 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
1616 }
1717
None ; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -aa-eval -disable-output
0 ; RUN: llvm-as < %s | opt -basicaa -aa-eval -disable-output
11 ; Test for a bug in BasicAA which caused a crash when querying equality of P1&P2
2 void %test({[2 x int],[2 x int]}* %A, long %X, long %Y) {
3 %P1 = getelementptr {[2 x int],[2 x int]}* %A, long 0, uint 0, long %X
4 %P2 = getelementptr {[2 x int],[2 x int]}* %A, long 0, uint 1, long %Y
2 define void @test({[2 x i32],[2 x i32]}* %A, i64 %X, i64 %Y) {
3 %P1 = getelementptr {[2 x i32],[2 x i32]}* %A, i64 0, i32 0, i64 %X
4 %P2 = getelementptr {[2 x i32],[2 x i32]}* %A, i64 0, i32 1, i64 %Y
55 ret void
66 }
None ; RUN: llvm-upgrade < %s | llvm-as | opt -load-vn -gcse -instcombine | llvm-dis | grep sub
0 ; RUN: llvm-as < %s | opt -load-vn -gcse -instcombine | llvm-dis | grep sub
11
22 ; BasicAA was incorrectly concluding that P1 and P2 didn't conflict!
33
4 int %test(int *%Ptr, long %V) {
5 %P2 = getelementptr int* %Ptr, long 1
6 %P1 = getelementptr int* %Ptr, long %V
7 %X = load int* %P1
8 store int 5, int* %P2
4 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
99
10 %Y = load int* %P1
10 %Y = load i32* %P1
1111
12 %Z = sub int %X, %Y
13 ret int %Z
12 %Z = sub i32 %X, %Y
13 ret i32 %Z
1414 }
None ; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -aa-eval -disable-output
0 ; RUN: llvm-as < %s | opt -basicaa -aa-eval -disable-output
11 ; Test for a bug in BasicAA which caused a crash when querying equality of P1&P2
2 void %test([17 x ushort]* %mask_bits) {
3 %P1 = getelementptr [17 x ushort]* %mask_bits, long 0, long 0
4 %P2 = getelementptr [17 x ushort]* %mask_bits, long 252645134, long 0
2 define void @test([17 x i16]* %mask_bits) {
3 %P1 = getelementptr [17 x i16]* %mask_bits, i64 0, i64 0
4 %P2 = getelementptr [17 x i16]* %mask_bits, i64 252645134, i64 0
55 ret void
66 }
None ; RUN: llvm-upgrade < %s | llvm-as | opt -licm -disable-output
1 %struct..apr_array_header_t = type { int*, int, int, int, sbyte* }
2 %struct..apr_table_t = type { %struct..apr_array_header_t, uint, [32 x int], [32 x int] }
0 ; RUN: llvm-as < %s | opt -licm -disable-output
1 %struct..apr_array_header_t = type { i32*, i32, i32, i32, i8* }
2 %struct..apr_table_t = type { %struct..apr_array_header_t, i32, [32 x i32], [32 x i32] }
33
4 void %table_reindex(%struct..apr_table_t* %t.1) { ; No predecessors!
4 define void @table_reindex(%struct..apr_table_t* %t.1) { ; No predecessors!
55 br label %loopentry
66
77 loopentry: ; preds = %0, %no_exit
8 %tmp.101 = getelementptr %struct..apr_table_t* %t.1, long 0, uint 0, uint 2
9 %tmp.11 = load int* %tmp.101 ; [#uses=0]
10 br bool false, label %no_exit, label %UnifiedExitNode
8 %tmp.101 = getelementptr %struct..apr_table_t* %t.1, i64 0, i32 0, i32 2
9 %tmp.11 = load i32* %tmp.101 ; [#uses=0]
10 br i1 false, label %no_exit, label %UnifiedExitNode
1111
1212 no_exit: ; preds = %loopentry
13 %tmp.25 = cast int 0 to long ; [#uses=1]
14 %tmp.261 = getelementptr %struct..apr_table_t* %t.1, long 0, uint 3, long %tmp.25 ; [#uses=1]
15 store int 0, int* %tmp.261
13 %tmp.25 = sext i32 0 to i64 ; [#uses=1]
14 %tmp.261 = getelementptr %struct..apr_table_t* %t.1, i64 0, i32 3, i64 %tmp.25 ; [#uses=1]
15 store i32 0, i32* %tmp.261
1616 br label %loopentry
1717
1818 UnifiedExitNode: ; preds = %loopentry
None ; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -aa-eval -disable-output
0 ; RUN: llvm-as < %s | opt -basicaa -aa-eval -disable-output
11
2 int %MTConcat([3 x int]* %a.1) {
3 %tmp.961 = getelementptr [3 x int]* %a.1, long 0, long 4
4 %tmp.97 = load int* %tmp.961
5 %tmp.119 = getelementptr [3 x int]* %a.1, long 1, long 0
6 %tmp.120 = load int* %tmp.119
7 %tmp.1541 = getelementptr [3 x int]* %a.1, long 0, long 4
8 %tmp.155 = load int* %tmp.1541
9 ret int 0
2 define i32 @MTConcat([3 x i32]* %a.1) {
3 %tmp.961 = getelementptr [3 x i32]* %a.1, i64 0, i64 4
4 %tmp.97 = load i32* %tmp.961
5 %tmp.119 = getelementptr [3 x i32]* %a.1, i64 1, i64 0
6 %tmp.120 = load i32* %tmp.119
7 %tmp.1541 = getelementptr [3 x i32]* %a.1, i64 0, i64 4
8 %tmp.155 = load i32* %tmp.1541
9 ret i32 0
1010 }
None ; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -aa-eval -disable-output
0 ; RUN: llvm-as < %s | opt -basicaa -aa-eval -disable-output
11
2 %struct..RefPoint = type { int, { uint, ushort, ushort } }
3 %struct..RefRect = type { %struct..RefPoint, %struct..RefPoint }
2 %struct..RefPoint = type { i32, { i32, i8, i8 } }
3 %struct..RefRect = type { %struct..RefPoint, %struct..RefPoint }
44
5 implementation ; Functions:
6
7 uint %BMT_CommitPartDrawObj() {
8 %tmp.19111 = getelementptr %struct..RefRect* null, long 0, uint 0, uint 1, uint 2
9 %tmp.20311 = getelementptr %struct..RefRect* null, long 0, uint 1, uint 1, uint 2
10 ret uint 0
5 define i32 @BMT_CommitPartDrawObj() {
6 %tmp.19111 = getelementptr %struct..RefRect* null, i64 0, i32 0, i32 1, i32 2
7 %tmp.20311 = getelementptr %struct..RefRect* null, i64 0, i32 1, i32 1, i32 2
8 ret i32 0
119 }
0 ; In this test, a local alloca cannot alias an incoming argument.
11
2 ; RUN: llvm-upgrade < %s | llvm-as | opt -load-vn -gcse -instcombine | llvm-dis | not grep sub
2 ; RUN: llvm-as < %s | opt -load-vn -gcse -instcombine | llvm-dis | not grep sub
33
4 int %test(int* %P) {
5 %X = alloca int
6 %V1 = load int* %P
7 store int 0, int* %X
8 %V2 = load int* %P
9 %Diff = sub int %V1, %V2
10 ret int %Diff
4 define i32 @test(i32* %P) {
5 %X = alloca i32
6 %V1 = load i32* %P
7 store i32 0, i32* %X
8 %V2 = load i32* %P
9 %Diff = sub i32 %V1, %V2
10 ret i32 %Diff
1111 }
0 ; This testcase consists of alias relations which should be completely
11 ; resolvable by basicaa.
22
3 ; RUN: llvm-upgrade < %s | llvm-as | \
4 ; RUN: opt -aa-eval -print-may-aliases -disable-output |& not grep May:
3 ; RUN: llvm-as < %s | opt -aa-eval -print-may-aliases -disable-output \
4 ; RUN: |& not grep May:
55
6 %T = type { uint, [10 x ubyte] }
6 %T = type { i32, [10 x i8] }
77
8 void %test(%T* %P) {
9 %A = getelementptr %T* %P, long 0
10 %B = getelementptr %T* %P, long 0, uint 0
11 %C = getelementptr %T* %P, long 0, uint 1
12 %D = getelementptr %T* %P, long 0, uint 1, long 0
13 %E = getelementptr %T* %P, long 0, uint 1, long 5
8 define void @test(%T* %P) {
9 %A = getelementptr %T* %P, i64 0
10 %B = getelementptr %T* %P, i64 0, i32 0
11 %C = getelementptr %T* %P, i64 0, i32 1
12 %D = getelementptr %T* %P, i64 0, i32 1, i64 0
13 %E = getelementptr %T* %P, i64 0, i32 1, i64 5
1414 ret void
1515 }
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: llvm-upgrade < %s | llvm-as | \
4 ; RUN: opt -aa-eval -print-may-aliases -disable-output |& not grep May:
3 ; RUN: llvm-as < %s | opt -aa-eval -print-may-aliases -disable-output \
4 ; RUN: |& not grep May:
55
6 %T = type { uint, [10 x ubyte] }
6 %T = type { i32, [10 x i8] }
77
8 %G = external global %T
8 @G = external global %T
99
10 void %test() {
11 %D = getelementptr %T* %G, long 0, uint 0
12 %E = getelementptr %T* %G, long 0, uint 1, long 5
13 %F = getelementptr uint* getelementptr (%T* %G, long 0, uint 0), long 0
14 %X = getelementptr [10 x ubyte]* getelementptr (%T* %G, long 0, uint 1), long 0, long 5
10 define void @test() {
11 %D = getelementptr %T* @G, i64 0, i32 0
12 %E = getelementptr %T* @G, i64 0, i32 1, i64 5
13 %F = getelementptr i32* getelementptr (%T* @G, i64 0, i32 0), i64 0
14 %X = getelementptr [10 x i8]* getelementptr (%T* @G, i64 0, i32 1), i64 0, i64 5
1515
1616 ret void
1717 }
None ; RUN: llvm-upgrade < %s | llvm-as | opt -load-vn -gcse -instcombine | \
0 ; RUN: llvm-as < %s | opt -load-vn -gcse -instcombine | \
11 ; RUN: llvm-dis | not grep load
22
3 %X = constant [2 x int] [int 4, int 5]
3 @X = constant [2 x i32] [i32 4, i32 5]
44
5 int %test(int* %Y, long %idx) {
6 %P = getelementptr [2 x int]* %X, long 0, long %idx
7 %A = load int* %P ; Load from invariant memory
8 store int 4, int* %Y ; Store could not be to %X
9 %B = load int* %P
10 %C = sub int %A, %B
11 ret int %C
5 define i32 @test(i32* %Y, i64 %idx) {
6 %P = getelementptr [2 x i32]* @X, i64 0, i64 %idx
7 %A = load i32* %P ; Load from invariant memory
8 store i32 4, i32* %Y ; Store could not be to @X
9 %B = load i32* %P
10 %C = sub i32 %A, %B
11 ret i32 %C
1212 }
None ; RUN: llvm-upgrade < %s | llvm-as | opt -dse | llvm-dis | grep {store i32 0}
0 ; RUN: llvm-as < %s | opt -dse | llvm-dis | grep {store i32 0}
11
2 void %test({int,int }* %P) {
3 %Q = getelementptr {int,int}* %P, int 1
4 %X = getelementptr {int,int}* %Q, int 0, uint 1
5 %Y = getelementptr {int,int}* %Q, int 1, uint 1
6 store int 0, int* %X
7 store int 1, int* %Y
2 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
88 ret void
99 }
None ; RUN: llvm-upgrade < %s | llvm-as | opt -licm
0 ; RUN: llvm-as < %s | opt -licm
11
2 "java/lang/Object" = type { %struct.llvm_java_object_base }
3 "java/lang/StringBuffer" = type { "java/lang/Object", int, { "java/lang/Object", uint, [0 x ushort] }*, bool }
4 %struct.llvm_java_object_base = type opaque
2 %"java/lang/Object" = type { %struct.llvm_java_object_base }
3 %"java/lang/StringBuffer" = type { "java/lang/Object", i32, { "java/lang/Object", i32, [0 x i8] }*, i1 }
4 %struct.llvm_java_object_base = type opaque
55
6 implementation ; Functions:
7
8 void "java/lang/StringBuffer/setLength(I)V"(%struct.llvm_java_object_base*) {
6 define void @"java/lang/StringBuffer/setLength(I)V"(%struct.llvm_java_object_base*) {
97 bc0:
10 br bool false, label %bc40, label %bc65
8 br i1 false, label %bc40, label %bc65
119
1210 bc65: ; preds = %bc0, %bc40
1311 ret void
1412
1513 bc40: ; preds = %bc0, %bc40
16 %tmp75 = cast %struct.llvm_java_object_base* %0 to "java/lang/StringBuffer"* ; <"java/lang/StringBuffer"*> [#uses=1]
17 %tmp76 = getelementptr "java/lang/StringBuffer"* %tmp75, int 0, uint 1 ; [#uses=1]
18 store int 0, int* %tmp76
19 %tmp381 = cast %struct.llvm_java_object_base* %0 to "java/lang/StringBuffer"* ; <"java/lang/StringBuffer"*> [#uses=1]
20 %tmp392 = getelementptr "java/lang/StringBuffer"* %tmp381, int 0, uint 1 ; [#uses=1]
21 %tmp403 = load int* %tmp392 ; [#uses=0]
22 br bool false, label %bc40, label %bc65
14 %tmp75 = bitcast %struct.llvm_java_object_base* %0 to %"java/lang/StringBuffer"* ; <"java/lang/StringBuffer"*> [#uses=1]
15 %tmp76 = getelementptr %"java/lang/StringBuffer"* %tmp75, i32 0, i32 1 ; [#uses=1]
16 store i32 0, i32* %tmp76
17 %tmp381 = bitcast %struct.llvm_java_object_base* %0 to %"java/lang/StringBuffer"* ; <"java/lang/StringBuffer"*> [#uses=1]
18 %tmp392 = getelementptr %"java/lang/StringBuffer"* %tmp381, i32 0, i32 1 ; [#uses=1]
19 %tmp403 = load i32* %tmp392 ; [#uses=0]
20 br i1 false, label %bc40, label %bc65
2321 }
None ; RUN: llvm-upgrade < %s | llvm-as | opt -dse
0 ; RUN: llvm-as < %s | opt -dse
11
2 "java/lang/Object" = type { %struct.llvm_java_object_base }
3 "java/lang/StringBuffer" = type { "java/lang/Object", int, { "java/lang/Object", uint, [0 x ushort] }*, bool }
4 %struct.llvm_java_object_base = type opaque
2 %"java/lang/Object" = type { %struct.llvm_java_object_base }
3 %"java/lang/StringBuffer" = type { "java/lang/Object", i32, { "java/lang/Object", i32, [0 x i8] }*, i1 }
4 %struct.llvm_java_object_base = type opaque
55
6 implementation ; Functions:
7
8 void "java/lang/StringBuffer/ensureCapacity_unsynchronized(I)V"() {
6 define void @"java/lang/StringBuffer/ensureCapacity_unsynchronized(I)V"() {
97 bc0:
10 %tmp = getelementptr "java/lang/StringBuffer"* null, int 0, uint 3 ; [#uses=1]
11 br bool false, label %bc16, label %bc7
8 %tmp = getelementptr %"java/lang/StringBuffer"* null, i32 0, i32 3 ; [#uses=1]
9 br i1 false, label %bc16, label %bc7
1210
1311 bc16: ; preds = %bc0
14 %tmp91 = getelementptr "java/lang/StringBuffer"* null, int 0, uint 2 ; <{ "java/lang/Object", uint, [0 x ushort] }**> [#uses=1]
15 store { "java/lang/Object", uint, [0 x ushort] }* null, { "java/lang/Object", uint, [0 x ushort] }** %tmp91
16 store bool false, bool* %tmp
12 %tmp91 = getelementptr %"java/lang/StringBuffer"* null, i32 0, i32 2 ; <{ "java/lang/Object", i32, [0 x i8] }**> [#uses=1]
13 store { %"java/lang/Object", i32, [0 x i8] }* null, { %"java/lang/Object", i32, [0 x i8] }** %tmp91
14 store i1 false, i1* %tmp
1715 ret void
1816
1917 bc7: ; preds = %bc0
None ; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -load-vn -gcse -instcombine |\
1 ; RUN: llvm-dis | grep {load i32\\* %A}
0 ; RUN: llvm-as < %s | opt -basicaa -load-vn -gcse -instcombine |\
1 ; RUN: llvm-dis | grep {load i32\\* %A}
22
3 declare double* %useit(int*)
3 declare double* @useit(i32*)
44
5 int %foo(uint %Amt) {
6 %A = malloc int, uint %Amt
7 %P = call double* %useit(int* %A)
5 define i32 @foo(i32 %Amt) {
6 %A = malloc i32, i32 %Amt
7 %P = call double* @useit(i32* %A)
88
9 %X = load int* %A
9 %X = load i32* %A
1010 store double 0.0, double* %P
11 %Y = load int* %A
12 %Z = sub int %X, %Y
13 ret int %Z
11 %Y = load i32* %A
12 %Z = sub i32 %X, %Y
13 ret i32 %Z
1414 }
None ; RUN: llvm-upgrade < %s | llvm-as | \
1 ; RUN: opt -aa-eval -disable-output |& grep {2 no alias respon}
0 ; RUN: llvm-as < %s | opt -aa-eval -disable-output |& grep {2 no alias respon}
1 ; TEST that A[1][0] may alias A[0][i].
22
3 ;; TEST that A[1][0] may alias A[0][i].
4
5 void %test(int %N) {
3 define void @test(i32 %N) {
64 entry:
7 %X = alloca [3 x [3 x int]] ; <[3 x [3 x int]]*> [#uses=4]
8 %tmp.24 = setgt int %N, 0 ; [#uses=1]
9 br bool %tmp.24, label %no_exit, label %loopexit
5 %X = alloca [3 x [3 x i32]] ; <[3 x [3 x i32]]*> [#uses=4]
6 %tmp.24 = icmp sgt i32 %N, 0 ; [#uses=1]
7 br i1 %tmp.24, label %no_exit, label %loopexit
108
119 no_exit: ; preds = %no_exit, %entry
12 %i.0.0 = phi int [ 0, %entry ], [ %inc, %no_exit ] ; [#uses=2]
13 %tmp.6 = getelementptr [3 x [3 x int]]* %X, int 0, int 0, int %i.0.0 ; [#uses=1]
14 store int 1, int* %tmp.6
15 %tmp.8 = getelementptr [3 x [3 x int]]* %X, int 0, int 0, int 0 ; [#uses=1]
16 %tmp.9 = load int* %tmp.8 ; [#uses=1]
17 %tmp.11 = getelementptr [3 x [3 x int]]* %X, int 0, int 1, int 0 ; [#uses=1]
18 %tmp.12 = load int* %tmp.11 ; [#uses=1]
19 %tmp.13 = add int %tmp.12, %tmp.9 ; [#uses=1]
20 %inc = add int %i.0.0, 1 ; [#uses=2]
21 %tmp.2 = setlt int %inc, %N ; [#uses=1]
22 br bool %tmp.2, label %no_exit, label %loopexit
10 %i.0.0 = phi i32 [ 0, %entry ], [ %inc, %no_exit ] ; [#uses=2]
11 %tmp.6 = getelementptr [3 x [3 x i32]]* %X, i32 0, i32 0, i32 %i.0.0 ; [#uses=1]
12 store i32 1, i32* %tmp.6
13 %tmp.8 = getelementptr [3 x [3 x i32]]* %X, i32 0, i32 0, i32 0 ; [#uses=1]
14 %tmp.9 = load i32* %tmp.8 ; [#uses=1]
15 %tmp.11 = getelementptr [3 x [3 x i32]]* %X, i32 0, i32 1, i32 0 ; [#uses=1]
16 %tmp.12 = load i32* %tmp.11 ; [#uses=1]
17 %tmp.13 = add i32 %tmp.12, %tmp.9 ; [#uses=1]
18 %inc = add i32 %i.0.0, 1 ; [#uses=2]
19 %tmp.2 = icmp slt i32 %inc, %N ; [#uses=1]
20 br i1 %tmp.2, label %no_exit, label %loopexit
2321
2422 loopexit: ; preds = %no_exit, %entry
25 %Y.0.1 = phi int [ 0, %entry ], [ %tmp.13, %no_exit ] ; [#uses=1]
26 %tmp.4 = getelementptr [3 x [3 x int]]* %X, int 0, int 0 ; <[3 x int]*> [#uses=1]
27 %tmp.15 = call int (...)* %foo( [3 x int]* %tmp.4, int %Y.0.1 ) ; [#uses=0]
23 %Y.0.1 = phi i32 [ 0, %entry ], [ %tmp.13, %no_exit ] ; [#uses=1]
24 %tmp.4 = getelementptr [3 x [3 x i32]]* %X, i32 0, i32 0 ; <[3 x i32]*> [#uses=1]
25 %tmp.15 = call i32 (...)* @foo( [3 x i32]* %tmp.4, i32 %Y.0.1 ) ; [#uses=0]
2826 ret void
2927 }
3028
31 declare int %foo(...)
29 declare i32 @foo(...)
None ; RUN: llvm-upgrade < %s | llvm-as | opt -licm -disable-output
1 target endian = big
2 target pointersize = 32
0 ; RUN: llvm-as < %s | opt -licm -disable-output
1 target datalayout = "E-p:32:32"
32 target triple = "powerpc-apple-darwin8.7.0"
43
5 implementation ; Functions:
6
7 void %glgRunProcessor() {
4 define void @glgRunProcessor() {
85 entry:
9 br bool false, label %bb2037.i, label %cond_true.i18
6 br i1 false, label %bb2037.i, label %cond_true.i18
107
118 cond_true.i18: ; preds = %entry
129 ret void
1310
1411 bb205.i: ; preds = %bb2037.i
15 switch uint 0, label %bb1013.i [
16 uint 14, label %bb239.i
17 uint 15, label %bb917.i
12 switch i32 0, label %bb1013.i [
13 i32 14, label %bb239.i
14 i32 15, label %bb917.i
1815 ]
1916
2017 bb239.i: ; preds = %bb205.i
21 br bool false, label %cond_false277.i, label %cond_true264.i
18 br i1 false, label %cond_false277.i, label %cond_true264.i
2219
2320 cond_true264.i: ; preds = %bb239.i
2421 ret void
2522
2623 cond_false277.i: ; preds = %bb239.i
27 %tmp1062.i = getelementptr [2 x <4 x int>]* null, int 0, int 1 ; <<4 x int>*> [#uses=1]
28 store <4 x int> zeroinitializer, <4 x int>* %tmp1062.i
29 br bool false, label %cond_true1032.i, label %cond_false1063.i85
24 %tmp1062.i = getelementptr [2 x <4 x i32>]* null, i32 0, i32 1 ; <<4 x i32>*> [#uses=1]
25 store <4 x i32> zeroinitializer, <4 x i32>* %tmp1062.i
26 br i1 false, label %cond_true1032.i, label %cond_false1063.i85
3027
3128 bb917.i: ; preds = %bb205.i
3229 ret void
3532 ret void
3633
3734 cond_true1032.i: ; preds = %cond_false277.i
38 %tmp1187.i = getelementptr [2 x <4 x int>]* null, int 0, int 0, int 7 ; [#uses=1]
39 store int 0, int* %tmp1187.i
35 %tmp1187.i = getelementptr [2 x <4 x i32>]* null, i32 0, i32 0, i32 7 ; [#uses=1]
36 store i32 0, i32* %tmp1187.i
4037 br label %bb2037.i
4138
4239 cond_false1063.i85: ; preds = %cond_false277.i
4340 ret void
4441
4542 bb2037.i: ; preds = %cond_true1032.i, %entry
46 br bool false, label %bb205.i, label %cond_next2042.i
43 br i1 false, label %bb205.i, label %cond_next2042.i
4744
4845 cond_next2042.i: ; preds = %bb2037.i
4946 ret void
0 ; This testcase tests for various features the basicaa test should be able to
11 ; determine, as noted in the comments.
22
3 ; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -load-vn -gcse -instcombine -dce | llvm-dis | not grep REMOVE
3 ; RUN: llvm-as < %s | opt -basicaa -load-vn -gcse -instcombine -dce | llvm-dis | not grep REMOVE
44
5 %Global = external global { int }
6
7 implementation
8
5 @Global = external global { i32 }
96
107 ; Array test: Test that operations on one local array do not invalidate
118 ; operations on another array. Important for scientific codes.
129 ;
13 int %different_array_test(long %A, long %B) {
14 %Array1 = alloca int, uint 100
15 %Array2 = alloca int, uint 200
10 define i32 @different_array_test(i64 %A, i64 %B) {
11 %Array1 = alloca i32, i32 100
12 %Array2 = alloca i32, i32 200
1613
17 %pointer = getelementptr int* %Array1, long %A
18 %val = load int* %pointer
14 %pointer = getelementptr i32* %Array1, i64 %A
15 %val = load i32* %pointer
1916
20 %pointer2 = getelementptr int* %Array2, long %B
21 store int 7, int* %pointer2
17 %pointer2 = getelementptr i32* %Array2, i64 %B
18 store i32 7, i32* %pointer2
2219
23 %REMOVE = load int* %pointer ; redundant with above load
24 %retval = sub int %REMOVE, %val
25 ret int %retval
20 %REMOVE = load i32* %pointer ; redundant with above load
21 %retval = sub i32 %REMOVE, %val
22 ret i32 %retval
2623 }
2724
2825 ; Constant index test: Constant indexes into the same array should not
2926 ; interfere with each other. Again, important for scientific codes.
3027 ;
31 int %constant_array_index_test() {
32 %Array = alloca int, uint 100
33 %P1 = getelementptr int* %Array, long 7
34 %P2 = getelementptr int* %Array, long 6
28 define i32 @constant_array_index_test() {
29 %Array = alloca i32, i32 100
30 %P1 = getelementptr i32* %Array, i64 7
31 %P2 = getelementptr i32* %Array, i64 6
3532
36 %A = load int* %P1
37 store int 1, int* %P2 ; Should not invalidate load
38 %BREMOVE = load int* %P1
39 %Val = sub int %A, %BREMOVE
40 ret int %Val
33 %A = load i32* %P1
34 store i32 1, i32* %P2 ; Should not invalidate load
35 %BREMOVE = load i32* %P1
36 %Val = sub i32 %A, %BREMOVE
37 ret i32 %Val
4138 }
4239
4340 ; Test that if two pointers are spaced out by a constant getelementptr, that
4441 ; they cannot alias.
45 int %gep_distance_test(int* %A) {
46 %REMOVEu = load int* %A
47 %B = getelementptr int* %A, long 2 ; Cannot alias A
48 store int 7, int* %B
49 %REMOVEv = load int* %A
50 %r = sub int %REMOVEu, %REMOVEv
51 ret int %r
42 define i32 @gep_distance_test(i32* %A) {
43 %REMOVEu = load i32* %A
44 %B = getelementptr i32* %A, i64 2 ; Cannot alias A
45 store i32 7, i32* %B
46 %REMOVEv = load i32* %A
47 %r = sub i32 %REMOVEu, %REMOVEv
48 ret i32 %r
5249 }
5350
5451 ; Test that if two pointers are spaced out by a constant offset, that they
5552 ; cannot alias, even if there is a variable offset between them...
56 int %gep_distance_test2({int,int}* %A, long %distance) {
57 %A = getelementptr {int,int}* %A, long 0, uint 0
58 %REMOVEu = load int* %A
59 %B = getelementptr {int,int}* %A, long %distance, uint 1
60 store int 7, int* %B ; B cannot alias A, it's at least 4 bytes away
61 %REMOVEv = load int* %A
62 %r = sub int %REMOVEu, %REMOVEv
63 ret int %r
53 define i32 @gep_distance_test2({i32,i32}* %A, i64 %distance) {
54 %A1 = getelementptr {i32,i32}* %A, i64 0, i32 0
55 %REMOVEu = load i32* %A1
56 %B = getelementptr {i32,i32}* %A, i64 %distance, i32 1
57 store i32 7, i32* %B ; B cannot alias A, it's at least 4 bytes away
58 %REMOVEv = load i32* %A1
59 %r = sub i32 %REMOVEu, %REMOVEv
60 ret i32 %r
6461 }
6562
6663 ; Test that we can do funny pointer things and that distance calc will still
6764 ; work.
68 int %gep_distance_test3(int * %A) {
69 %X = load int* %A
70 %B = cast int* %A to sbyte*
71 %C = getelementptr sbyte* %B, long 4
72 %Y = load sbyte* %C
73 ret int 8
65 define i32 @gep_distance_test3(i32 * %A) {
66 %X = load i32* %A
67 %B = bitcast i32* %A to i8*
68 %C = getelementptr i8* %B, i64 4
69 %Y = load i8* %C
70 ret i32 8
7471 }
7572
7673 ; Test that we can disambiguate globals reached through constantexpr geps
77 int %constexpr_test() {
78 %X = alloca int
79 %Y = load int* %X
80 store int 5, int* getelementptr ({ int }* %Global, long 0, uint 0)
81 %REMOVE = load int* %X
82 %retval = sub int %Y, %REMOVE
83 ret int %retval
74 define i32 @constexpr_test() {
75 %X = alloca i32
76 %Y = load i32* %X
77 store i32 5, i32* getelementptr ({ i32 }* @Global, i64 0, i32 0)
78 %REMOVE = load i32* %X
79 %retval = sub i32 %Y, %REMOVE
80 ret i32 %retval
8481 }
11 ; disambiguating some obvious cases. All loads should be removable in
22 ; this testcase.
33
4 ; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -load-vn -gcse -instcombine -dce | llvm-dis | not grep load
4 ; RUN: llvm-as < %s | opt -basicaa -load-vn -gcse -instcombine -dce \
5 ; RUN: | llvm-dis | not grep load
56
6 %A = global int 7
7 %B = global int 8
8 implementation
7 @A = global i32 7
8 @B = global i32 8
99
10 int %test() {
11 %A1 = load int* %A
10 define i32 @test() {
11 %A1 = load i32* @A
1212
13 store int 123, int* %B ; Store cannot alias %A
13 store i32 123, i32* @B ; Store cannot alias @A
1414
15 %A2 = load int* %A
16 %X = sub int %A1, %A2
17 ret int %X
15 %A2 = load i32* @A
16 %X = sub i32 %A1, %A2
17 ret i32 %X
1818 }
1919
20 int %test2() {
21 %A1 = load int* %A
20 define i32 @test2() {
21 %A1 = load i32* @A
2222 br label %Loop
2323 Loop:
24 %AP = phi int [0, %0], [%X, %Loop]
25 store int %AP, int* %B ; Store cannot alias %A
24 %AP = phi i32 [0, %0], [%X, %Loop]
25 store i32 %AP, i32* @B ; Store cannot alias @A
2626
27 %A2 = load int* %A
28 %X = sub int %A1, %A2
29 %c = seteq int %X, 0
30 br bool %c, label %out, label %Loop
27 %A2 = load i32* @A
28 %X = sub i32 %A1, %A2
29 %c = icmp eq i32 %X, 0
30 br i1 %c, label %out, label %Loop
3131
3232 out:
33 ret int %X
33 ret i32 %X
3434 }
3535
36 declare void %external()
36 declare void @external()
3737
38 int %test3() {
39 %X = alloca int
40 store int 7, int* %X
41 call void %external()
42 %V = load int* %X
43 ret int %V
38 define i32 @test3() {
39 %X = alloca i32
40 store i32 7, i32* %X
41 call void @external()
42 %V = load i32* %X
43 ret i32 %V
4444 }
4545
0 ; A store or load cannot alias a global if the accessed amount is larger then
11 ; the global.
22
3 ; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -load-vn -gcse -instcombine | llvm-dis | not grep load
3 ; RUN: llvm-as < %s | opt -basicaa -load-vn -gcse -instcombine | llvm-dis | not grep load
44
5 %B = global short 8
5 @B = global i16 8 ; [#uses=2]
66
7 implementation
8
9 short %test(int *%P) {
10 %X = load short* %B
11 store int 7, int* %P
12 %Y = load short* %B
13 %Z = sub short %Y, %X
14 ret short %Z
7 define i16 @test(i32* %P) {
8 %X = load i16* @B ; [#uses=1]
9 store i32 7, i32* %P
10 %Y = load i16* @B ; [#uses=1]
11 %Z = sub i16 %Y, %X ; [#uses=1]
12 ret i16 %Z
1513 }
1614
22 ; two pointers, then the load should be hoisted, and the store sunk. Thus
33 ; the loop becomes empty and can be deleted by ADCE.
44
5 ; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -licm --adce | llvm-dis | not grep Loop
5 ; RUN: llvm-as < %s | opt -basicaa -licm --adce | llvm-dis | not grep Loop
66
7 %A = global int 7
8 %B = global int 8
9 %C = global [2 x int ] [ int 4, int 8 ]
10 implementation
7 @A = global i32 7 ; [#uses=3]
8 @B = global i32 8 ; [#uses=2]
9 @C = global [2 x i32] [ i32 4, i32 8 ] ; <[2 x i32]*> [#uses=2]
1110
12 int %test(bool %c) {
13 %Atmp = load int* %A
14 br label %Loop
15 Loop:
16 %ToRemove = load int* %A
17 store int %Atmp, int* %B ; Store cannot alias %A
11 define i32 @test(i1 %c) {
12 %Atmp = load i32* @A ; [#uses=2]
13 br label %Loop
1814
19 br bool %c, label %Out, label %Loop
20 Out:
21 %X = sub int %ToRemove, %Atmp
22 ret int %X
15 Loop: ; preds = %Loop, %0
16 %ToRemove = load i32* @A ; [#uses=1]
17 store i32 %Atmp, i32* @B
18 br i1 %c, label %Out, label %Loop
19
20 Out: ; preds = %Loop
21 %X = sub i32 %ToRemove, %Atmp ; [#uses=1]
22 ret i32 %X
2323 }
2424
25 int %test2(bool %c) {
26 br label %Loop
27 Loop:
28 %AVal = load int* %A
29 %C0 = getelementptr [2 x int ]* %C, long 0, long 0
30 store int %AVal, int* %C0 ; Store cannot alias %A
25 define i32 @test2(i1 %c) {
26 br label %Loop
3127
32 %BVal = load int* %B
33 %C1 = getelementptr [2 x int ]* %C, long 0, long 1
34 store int %BVal, int* %C1 ; Store cannot alias %A, %B, or %C0
28 Loop: ; preds = %Loop, %0
29 %AVal = load i32* @A ; [#uses=2]
30 %C0 = getelementptr [2 x i32]* @C, i64 0, i64 0 ; [#uses=1]
31 store i32 %AVal, i32* %C0
32 %BVal = load i32* @B ; [#uses=2]
33 %C1 = getelementptr [2 x i32]* @C, i64 0, i64 1 ; [#uses=1]
34 store i32 %BVal, i32* %C1
35 br i1 %c, label %Out, label %Loop
3536
36 br bool %c, label %Out, label %Loop
37 Out:
38 %X = sub int %AVal, %BVal
39 ret int %X
37 Out: ; preds = %Loop
38 %X = sub i32 %AVal, %BVal ; [#uses=1]
39 ret i32 %X
4040 }
4141
0 ; A very rudimentary test on AliasAnalysis::getModRefInfo.
1 ; RUN: llvm-upgrade < %s | llvm-as | \
2 ; RUN: opt -print-all-alias-modref-info -aa-eval -disable-output |& \
3 ; RUN: not grep NoModRef
1 ; RUN: llvm-as < %s | opt -print-all-alias-modref-info -aa-eval -disable-output |& \
2 ; RUN: not grep NoModRef
43
5 int %callee() {
6 %X = alloca { int, int }
7 %Y = getelementptr { int, int }* %X, uint 0, uint 0
8 %Z = load int* %Y
9 ret int %Z
4 define i32 @callee() {
5 %X = alloca { i32, i32 } ; <{ i32, i32 }*> [#uses=1]
6 %Y = getelementptr { i32, i32 }* %X, i64 0, i32 0 ; [#uses=1]
7 %Z = load i32* %Y ; [#uses=1]
8 ret i32 %Z
109 }
1110
12 int %caller() {
13 %X = call int %callee()
14 ret int %X
11 define i32 @caller() {
12 %X = call i32 @callee( ) ; [#uses=1]
13 ret i32 %X
1514 }
None ; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -load-vn -gcse -instcombine |\
0 ; RUN: llvm-as < %s | opt -basicaa -load-vn -gcse -instcombine |\
11 ; RUN: llvm-dis | grep {ret i32 0}
2 declare void %foo(int*)
3 declare void %bar()
42
5 int %test() {
6 %A = alloca int
7 call void %foo(int* %A)
3 declare void @foo(i32*)
84
9 %X = load int* %A
10 tail call void %bar() ;; Cannot modify *%A because it's on the stack.
11 %Y = load int* %A
12 %Z = sub int %X, %Y
13 ret int %Z
5 declare void @bar()
6
7 define i32 @test() {
8 %A = alloca i32 ; [#uses=3]
9 call void @foo( i32* %A )
10 %X = load i32* %A ; [#uses=1]
11 tail call void @bar( )
12 %Y = load i32* %A ; [#uses=1]
13 %Z = sub i32 %X, %Y ; [#uses=1]
14 ret i32 %Z
1415 }
15
16
None ; RUN: llvm-upgrade < %s | llvm-as | opt -analyze -postdomfrontier \
0 ; RUN: llvm-as < %s | opt -analyze -postdomfrontier \
11 ; RUN: -disable-verify
2 ; END.
3 ;
42 ; ModuleID = '2006-09-26-PostDominanceFrontier.bc'
5 target endian = little
6 target pointersize = 64
3 target datalayout = "e-p:64:64"
74 target triple = "alphaev67-unknown-linux-gnu"
8 %struct.FILE = type { int, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, sbyte*, %struct._IO_marker*, %struct.FILE*, int, int, long, ushort, sbyte, [1 x sbyte], sbyte*, long, sbyte*, sbyte*, int, [44 x sbyte] }
9 %struct._IO_marker = type { %struct._IO_marker*, %struct.FILE*, int }
10 %TOP = external global ulong* ; [#uses=1]
11 %BOT = external global ulong* ; [#uses=1]
12 %str = external global [2 x sbyte] ; <[2 x sbyte]*> [#uses=0]
5 %struct.FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %struct._IO_marker*, %struct.FILE*, i32, i32, i64, i16, i8, [1 x i8], i8*, i64, i8*, i8*, i32, [44 x i8] }
6 %struct._IO_marker = type { %struct._IO_marker*, %struct.FILE*, i32 }
7 @TOP = external global i64* ; [#uses=1]
8 @BOT = external global i64* ; [#uses=1]
9 @str = external global [2 x i8] ; <[2 x i8]*> [#uses=0]
1310
14 implementation ; Functions:
11 declare void @fopen()
1512
16 declare void %fopen()
17
18 void %main(sbyte** %argv) {
13 define void @main(i8** %argv) {
1914 entry:
20 %netSelect.i507 = alloca ulong, align 8 ; [#uses=0]
21 %topStart.i = alloca ulong, align 8 ; [#uses=0]
22 %topEnd.i = alloca ulong, align 8 ; [#uses=0]
23 %botStart.i = alloca ulong, align 8 ; [#uses=0]
24 %botEnd.i = alloca ulong, align 8 ; [#uses=0]
25 %c1.i154 = alloca uint, align 4 ; [#uses=0]
26 %b1.i155 = alloca uint, align 4 ; [#uses=0]
27 %t1.i156 = alloca uint, align 4 ; [#uses=0]
28 %c1.i = alloca uint, align 4 ; [#uses=0]
29 %b1.i = alloca uint, align 4 ; [#uses=0]
30 %t1.i = alloca uint, align 4 ; [#uses=0]
31 %netSelect.i5 = alloca ulong, align 8 ; [#uses=0]
32 %netSelect.i = alloca ulong, align 8 ; [#uses=0]
33 %tmp2.i = getelementptr sbyte** %argv, int 1 ; [#uses=1]
34 %tmp3.i4 = load sbyte** %tmp2.i ; [#uses=0]
35 call void %fopen( )
36 br bool false, label %DimensionChannel.exit, label %bb.backedge.i
15 %netSelect.i507 = alloca i64, align 8 ; [#uses=0]
16 %topStart.i = alloca i64, align 8 ; [#uses=0]
17 %topEnd.i = alloca i64, align 8 ; [#uses=0]
18 %botStart.i = alloca i64, align 8 ; [#uses=0]
19 %botEnd.i = alloca i64, align 8 ; [#uses=0]
20 %c1.i154 = alloca i32, align 4 ; [#uses=0]
21 %b1.i155 = alloca i32, align 4 ; [#uses=0]
22 %t1.i156 = alloca i32, align 4 ; [#uses=0]
23 %c1.i = alloca i32, align 4 ; [#uses=0]
24 %b1.i = alloca i32, align 4 ; [#uses=0]
25 %t1.i = alloca i32, align 4 ; [#uses=0]
26 %netSelect.i5 = alloca i64, align 8 ; [#uses=0]
27 %netSelect.i = alloca i64, align 8 ; [#uses=0]
28 %tmp2.i = getelementptr i8** %argv, i32 1 ; [#uses=1]
29 %tmp3.i4 = load i8** %tmp2.i ; [#uses=0]
30 call void @fopen( )
31 br i1 false, label %DimensionChannel.exit, label %bb.backedge.i
3732
3833 bb.backedge.i: ; preds = %entry
3934 ret void
4035
4136 DimensionChannel.exit: ; preds = %entry
42 %tmp13.i137 = malloc ulong, uint 0 ; [#uses=1]
43 %tmp610.i = malloc ulong, uint 0 ; *> [#uses=1]
37 %tmp13.i137 = malloc i64, i32 0 ; *> [#uses=1]
38 %tmp610.i = malloc i64, i32 0 ; [#uses=1]
4439 br label %cond_true.i143
4540
4641 cond_true.i143: ; preds = %cond_true.i143, %DimensionChannel.exit
47 %tmp9.i140 = getelementptr ulong* %tmp13.i137, ulong 0 ; [#uses=0]
48 %tmp12.i = getelementptr ulong* %tmp610.i, ulong 0 ; [#uses=0]
49 br bool false, label %bb18.i144, label %cond_true.i143
42 %tmp9.i140 = getelementptr i64* %tmp13.i137, i64 0 ; [#uses=0]
43 %tmp12.i = getelementptr i64* %tmp610.i, i64 0 ; [#uses=0]
44 br i1 false, label %bb18.i144, label %cond_true.i143
5045
5146 bb18.i144: ; preds = %cond_true.i143
52 call void %fopen( )
53 %tmp76.i105 = malloc ulong, uint 0 ; [#uses=3]
54 %tmp674.i = malloc ulong, uint 0 ; [#uses=2]
55 %tmp1072.i = malloc ulong, uint 0 ; [#uses=2]
56 %tmp1470.i = malloc ulong, uint 0 ; [#uses=1]
47 call void @fopen( )
48 %tmp76.i105 = malloc i64, i32 0 ; [#uses=3]
49 %tmp674.i = malloc i64, i32 0 ; [#uses=2]
50 %tmp1072.i = malloc i64, i32 0 ; [#uses=2]
51 %tmp1470.i = malloc i64, i32 0 ; [#uses=1]
5752 br label %cond_true.i114
5853
5954 cond_true.i114: ; preds = %cond_true.i114, %bb18.i144
60 %tmp17.i108 = getelementptr ulong* %tmp76.i105, ulong 0 ; [#uses=0]
61 %tmp20.i = getelementptr ulong* %tmp674.i, ulong 0 ; [#uses=0]
62 %tmp23.i111 = getelementptr ulong* %tmp1470.i, ulong 0 ; [#uses=0]
63 br bool false, label %cond_true40.i, label %cond_true.i114
55 %tmp17.i108 = getelementptr i64* %tmp76.i105, i64 0 ; [#uses=0]
56 %tmp20.i = getelementptr i64* %tmp674.i, i64 0 ; [#uses=0]
57 %tmp23.i111 = getelementptr i64* %tmp1470.i, i64 0 ; [#uses=0]
58 br i1 false, label %cond_true40.i, label %cond_true.i114
6459
6560 cond_true40.i: ; preds = %cond_true40.i, %cond_true.i114
66 %tmp33.i115 = getelementptr ulong* %tmp1072.i, ulong 0 ; [#uses=0]
67 br bool false, label %bb142.i, label %cond_true40.i
61 %tmp33.i115 = getelementptr i64* %tmp1072.i, i64 0 ; [#uses=0]
62 br i1 false, label %bb142.i, label %cond_true40.i
6863
6964 cond_next54.i: ; preds = %cond_true76.i
70 %tmp57.i = getelementptr ulong* %tmp55.i, ulong 0 ; [#uses=0]
71 br bool false, label %bb64.i, label %bb69.i
65 %tmp57.i = getelementptr i64* %tmp55.i, i64 0 ; [#uses=0]
66 br i1 false, label %bb64.i, label %bb69.i
7267
7368 bb64.i: ; preds = %cond_true76.i, %cond_next54.i
74 %tmp67.i117 = getelementptr ulong* %tmp76.i105, ulong 0 ; [#uses=0]
75 br bool false, label %bb114.i, label %cond_true111.i
69 %tmp67.i117 = getelementptr i64* %tmp76.i105, i64 0 ; [#uses=0]
70 br i1 false, label %bb114.i, label %cond_true111.i
7671
7772 bb69.i: ; preds = %cond_next54.i
78 br bool false, label %bb79.i, label %cond_true76.i
73 br i1 false, label %bb79.i, label %cond_true76.i
7974
8075 cond_true76.i: ; preds = %bb142.i, %bb69.i
81 %tmp48.i = getelementptr ulong* %tmp46.i, ulong 0 ; [#uses=0]
82 br bool false, label %bb64.i, label %cond_next54.i
76 %tmp48.i = getelementptr i64* %tmp46.i, i64 0 ; [#uses=0]
77 br i1 false, label %bb64.i, label %cond_next54.i
8378
8479 bb79.i: ; preds = %bb69.i
85 br bool false, label %bb114.i, label %cond_true111.i
80 br i1 false, label %bb114.i, label %cond_true111.i
8681
8782 cond_true111.i: ; preds = %bb79.i, %bb64.i
88 %tmp84.i127 = getelementptr ulong* %tmp46.i, ulong 0 ; *> [#uses=0]
83 %tmp84.i127 = getelementptr i64* %tmp46.i, i64 0 ; *> [#uses=0]
8984 ret void
9085
9186 bb114.i: ; preds = %bb142.i, %bb79.i, %bb64.i
92 %tmp117.i = getelementptr ulong* %tmp76.i105, ulong 0 ; [#uses=0]
93 %tmp132.i131 = getelementptr ulong* %tmp674.i, ulong 0 ; [#uses=0]
94 %tmp122.i = getelementptr ulong* %tmp1072.i, ulong 0 ; *> [#uses=0]
87 %tmp117.i = getelementptr i64* %tmp76.i105, i64 0 ; *> [#uses=0]
88 %tmp132.i131 = getelementptr i64* %tmp674.i, i64 0 ; [#uses=0]
89 %tmp122.i = getelementptr i64* %tmp1072.i, i64 0 ; [#uses=0]
9590 ret void
9691
9792 bb142.i: ; preds = %cond_true40.i
98 %tmp46.i = load ulong** %BOT ; [#uses=2]
99 %tmp55.i = load ulong** %TOP ; [#uses=1]
100 br bool false, label %bb114.i, label %cond_true76.i
93 %tmp46.i = load i64** @BOT ; [#uses=2]
94 %tmp55.i = load i64** @TOP ; [#uses=1]
95 br i1 false, label %bb114.i, label %cond_true76.i
10196 }
None ; RUN: llvm-upgrade < %s | llvm-as | opt -domtree -break-crit-edges -analyze \
0 ; RUN: llvm-as < %s | opt -domtree -break-crit-edges -analyze \
11 ; RUN: -domtree | grep {3.*%brtrue }
22 ; PR932
3 implementation ; Functions:
43
5 declare void %use1(int)
4 declare void @use1(i32)
65
7 void %f(int %i, bool %c) {
6 define void @f(i32 %i, i1 %c) {
87 entry:
9 %A = seteq int %i, 0 ; [#uses=1]
10 br bool %A, label %brtrue, label %brfalse
8 %A = icmp eq i32 %i, 0 ; [#uses=1]
9 br i1 %A, label %brtrue, label %brfalse
1110
1211 brtrue: ; preds = %brtrue, %entry
13 %B = phi bool [ true, %brtrue ], [ false, %entry ] ; [#uses=1]
14 call void %use1( int %i )
15 br bool %B, label %brtrue, label %brfalse
12 %B = phi i1 [ true, %brtrue ], [ false, %entry ] ; [#uses=1]
13 call void @use1( i32 %i )
14 br i1 %B, label %brtrue, label %brfalse
1615
1716 brfalse: ; preds = %brtrue, %entry
18 call void %use1( int %i )
17 call void @use1( i32 %i )
1918 ret void
2019 }
None ; RUN: llvm-upgrade < %s | llvm-as | opt -postdomfrontier -disable-output
1
2 void @SManager() {
0 ; RUN: llvm-as < %s | opt -postdomfrontier -disable-output
1
2 define void @SManager() {
33 entry:
44 br label %bb.outer
55
589589 br i1 false, label %bb420, label %bb.loopexit
590590 }
591591
592 void @Invalidate() {
592 define void @Invalidate() {
593593 entry:
594594 br i1 false, label %cond_false, label %cond_true
595595
None ; RUN: llvm-upgrade < %s | llvm-as | opt -postdomfrontier -disable-output
0 ; RUN: llvm-as < %s | opt -postdomfrontier -disable-output
11
2 void @args_out_of_range() {
2 define void @args_out_of_range() {
33 entry:
44 br label %bb
55
77 br label %bb
88 }
99
10 void @args_out_of_range_3() {
10 define void @args_out_of_range_3() {
1111 entry:
1212 br label %bb
1313
1515 br label %bb
1616 }
1717
18 void @Feq() {
18 define void @Feq() {
1919 entry:
2020 br i1 false, label %cond_true, label %cond_next
2121
None ; RUN: llvm-upgrade < %s | llvm-as | opt -globalsmodref-aa -load-vn -gcse | llvm-dis | not grep load
1 %X = internal global int 4
0 ; RUN: llvm-as < %s | opt -globalsmodref-aa -load-vn -gcse | llvm-dis | not grep load
1 @X = internal global i32 4 ; [#uses=1]
22
3 int %test(int *%P) {
4 store int 7, int* %P
5 store int 12, int* %X ;; cannot alias P, X's addr isn't taken
6 %V = load int* %P
7 ret int %V
3 define i32 @test(i32* %P) {
4 store i32 7, i32* %P
5 store i32 12, i32* @X
6 %V = load i32* %P ; [#uses=1]
7 ret i32 %V
88 }
None ; RUN: llvm-upgrade < %s | llvm-as | \
1 ; RUN: opt -globalsmodref-aa -load-vn -gcse -instcombine | llvm-dis | \
0 ; RUN: llvm-as < %s | opt -globalsmodref-aa -load-vn -gcse -instcombine | llvm-dis | \
21 ; RUN: grep {ret i32 0}
3 ; END.
4 %G = internal global int* null
52
6 implementation
3 @G = internal global i32* null ; [#uses=3]
74
8 void %test() {
9 %A = malloc int
10 store int* %A, int** %G
5 define void @test() {
6 %A = malloc i32 ; [#uses=1]
7 store i32* %A, i32** @G
118 ret void
129 }
1310
14 int %test1(int *%P) {
15 %g1 = load int** %G
16 %h1 = load int* %g1
17
18 ; This store cannot alias either G or g1.
19 store int 123, int* %P
20
21 %g2 = load int** %G
22 %h2 = load int* %g1
23 %X = sub int %h1, %h2 ;; -> 0
24 ret int %X
11 define i32 @test1(i32* %P) {
12 %g1 = load i32** @G ; [#uses=2]
13 %h1 = load i32* %g1 ; [#uses=1]
14 store i32 123, i32* %P
15 %g2 = load i32** @G ; [#uses=0]
16 %h2 = load i32* %g1 ; [#uses=1]
17 %X = sub i32 %h1, %h2 ; [#uses=1]
18 ret i32 %X
2519 }
None ; RUN: llvm-upgrade < %s | llvm-as | opt -globalsmodref-aa -load-vn -gcse | llvm-dis | not grep load
1 %X = internal global int 4
0 ; RUN: llvm-as < %s | opt -globalsmodref-aa -load-vn -gcse | llvm-dis | not grep load
1 @X = internal global i32 4 ; [#uses=2]
22
3 int %test(int *%P) {
4 store int 12, int* %X
5 call void %doesnotmodX()
6 %V = load int* %X
7 ret int %V
3 define i32 @test(i32* %P) {
4 store i32 12, i32* @X
5 call void @doesnotmodX( )
6 %V = load i32* @X ; [#uses=1]
7 ret i32 %V
88 }
99
10 void %doesnotmodX() {
11 ret void
10 define void @doesnotmodX() {
11 ret void
1212 }
0 ; Test that pure functions are cse'd away
1 ; RUN: llvm-as < %s | opt -globalsmodref-aa -load-vn -gcse -instcombine | \
2 ; RUN: llvm-dis | not grep sub
13
2 ; RUN: llvm-upgrade < %s | llvm-as | opt -globalsmodref-aa -load-vn -gcse -instcombine | llvm-dis | not grep sub
3
4 int %pure(int %X) {
5 %Y = add int %X, 1
6 ret int %Y
4 define i32 @pure(i32 %X) {
5 %Y = add i32 %X, 1 ; [#uses=1]
6 ret i32 %Y
77 }
88
9 int %test1(int %X) {
10 %A = call int %pure(int %X)
11 %B = call int %pure(int %X)
12 %C = sub int %A, %B
13 ret int %C
9 define i32 @test1(i32 %X) {
10 %A = call i32 @pure( i32 %X ) ; [#uses=1]
11 %B = call i32 @pure( i32 %X ) ; [#uses=1]
12 %C = sub i32 %A, %B ; [#uses=1]
13 ret i32 %C
1414 }
1515
16 int %test2(int %X, int* %P) {
17 %A = call int %pure(int %X)
18 store int %X, int* %P ;; Does not invalidate 'pure' call.
19 %B = call int %pure(int %X)
20 %C = sub int %A, %B
21 ret int %C
16 define i32 @test2(i32 %X, i32* %P) {
17 %A = call i32 @pure( i32 %X ) ; [#uses=1]
18 store i32 %X, i32* %P ;; Does not invalidate 'pure' call.
19 %B = call i32 @pure( i32 %X ) ; [#uses=1]
20 %C = sub i32 %A, %B ; [#uses=1]
21 ret i32 %C
2222 }
None ; This testcase ensures that redundant loads are eliminated when they should
0 ; This testcase ensures that redundant loads are eliminated when they should
11 ; be. All RL variables (redundant loads) should be eliminated.
22 ;
3 ; RUN: llvm-upgrade < %s | llvm-as | opt -load-vn -gcse | llvm-dis | not grep %RL
3 ; RUN: llvm-as < %s | opt -load-vn -gcse | llvm-dis | not grep %RL
44 ;
5 int "test1"(int* %P) {
6 %A = load int* %P
7 %RL = load int* %P
8 %C = add int %A, %RL
9 ret int %C
5
6 define i32 @test1(i32* %P) {
7 %A = load i32* %P ; [#uses=1]
8 %RL = load i32* %P ; [#uses=1]
9 %C = add i32 %A, %RL ; [#uses=1]
10 ret i32 %C
1011 }
1112
12 int "test2"(int* %P) {
13 %A = load int* %P
13 define i32 @test2(i32* %P) {
14 %A = load i32* %P ; [#uses=1]
1415 br label %BB2
15 BB2:
16
17 BB2: ; preds = %0
1618 br label %BB3
17 BB3:
18 %RL = load int* %P
19 %B = add int %A, %RL
20 ret int %B
19
20 BB3: ; preds = %BB2
21 %RL = load i32* %P ; [#uses=1]
22 %B = add i32 %A, %RL ; [#uses=1]
23 ret i32 %B
2124 }
22
0 ; RUN: llvm-as < %s | opt -load-vn -gcse -instcombine | llvm-dis | grep sub
1
1 ; RUN: llvm-upgrade < %s | llvm-as | opt -load-vn -gcse -instcombine | llvm-dis | grep sub
2
3 int %test(int* %P) {
4 %X = volatile load int* %P
5 %Y = volatile load int* %P
6 %Z = sub int %X, %Y
7 ret int %Z
2 define i32 @test(i32* %P) {
3 %X = volatile load i32* %P ; [#uses=1]
4 %Y = volatile load i32* %P ; [#uses=1]
5 %Z = sub i32 %X, %Y ; [#uses=1]
6 ret i32 %Z
87 }
None ; This testcase ensures that redundant loads are preserved when they are not
0 ; This testcase ensures that redundant loads are preserved when they are not
11 ; allowed to be eliminated.
2 ; RUN: llvm-upgrade < %s | llvm-as | opt -load-vn -gcse | llvm-dis | grep sub
2 ; RUN: llvm-as < %s | opt -load-vn -gcse | llvm-dis | grep sub
33 ;
4 int %test1(int* %P) {
5 %A = load int* %P
6 store int 1, int* %P
7 %B = load int* %P
8 %C = sub int %A, %B
9 ret int %C
4
5 define i32 @test1(i32* %P) {
6 %A = load i32* %P ; [#uses=1]
7 store i32 1, i32* %P
8 %B = load i32* %P ; [#uses=1]
9 %C = sub i32 %A, %B ; [#uses=1]
10 ret i32 %C
1011 }
1112
12 int %test2(int* %P) {
13 %A = load int* %P
13 define i32 @test2(i32* %P) {
14 %A = load i32* %P ; [#uses=1]
1415 br label %BB2
15 BB2:
16 store int 5, int* %P
16
17 BB2: ; preds = %0
18 store i32 5, i32* %P
1719 br label %BB3
18 BB3:
19 %B = load int* %P
20 %C = sub int %A, %B
21 ret int %C
20
21 BB3: ; preds = %BB2
22 %B = load i32* %P ; [#uses=1]
23 %C = sub i32 %A, %B ; [#uses=1]
24 ret i32 %C
2225 }
23
24
0 ; Check to make sure that Value Numbering doesn't merge casts of different
11 ; flavors.
2 ; RUN: llvm-upgrade < %s | llvm-as | opt -load-vn -gcse | llvm-dis | \
2 ; RUN: llvm-as < %s | opt -load-vn -gcse | llvm-dis | \
33 ; RUN: grep {\[sz\]ext} | count 2
44
5 declare void %external(int)
5 declare void @external(i32)
66
7 int %test_casts(short %x) {
8 %a = sext short %x to int
9 %b = zext short %x to int
10 call void %external(int %a)
11 ret int %b
7 define i32 @test_casts(i16 %x) {
8 %a = sext i16 %x to i32 ; [#uses=1]
9 %b = zext i16 %x to i32 ; [#uses=1]
10 call void @external( i32 %a )
11 ret i32 %b
1212 }
None ; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -load-vn -gcse -instcombine | llvm-dis | not grep sub
0 ; RUN: llvm-as < %s | opt -basicaa -load-vn -gcse -instcombine | \
1 ; RUN: llvm-dis | not grep sub
12
2 %S = type { int, sbyte }
3 %S = type { i32, i8 }
34
4 sbyte %test(sbyte** %P) {
5 %A = load sbyte** %P
6 %B = load sbyte* %A
7
8 %X = load sbyte** %P
9 %Y = load sbyte* %X
10
11 %R = sub sbyte %B, %Y
12 ret sbyte %R
5 define i8 @test(i8** %P) {
6 %A = load i8** %P ; [#uses=1]
7 %B = load i8* %A ; [#uses=1]
8 %X = load i8** %P ; [#uses=1]
9 %Y = load i8* %X ; [#uses=1]
10 %R = sub i8 %B, %Y ; [#uses=1]
11 ret i8 %R
1312 }
1413
15 sbyte %test(%S ** %P) {
16 %A = load %S** %P
17 %B = getelementptr %S* %A, int 0, uint 1
18 %C = load sbyte* %B
14 define i8 @test1(%S** %P) {
15 %A = load %S** %P ; <%S*> [#uses=1]
16 %B = getelementptr %S* %A, i32 0, i32 1 ; [#uses=1]
17 %C = load i8* %B ; [#uses=1]
18 %X = load %S** %P ; <%S*> [#uses=1]
19 %Y = getelementptr %S* %X, i32 0, i32 1 ; [#uses=1]
20 %Z = load i8* %Y ; [#uses=1]
21 %R = sub i8 %C, %Z ; [#uses=1]
22 ret i8 %R
23 }
1924
20 %X = load %S** %P
21 %Y = getelementptr %S* %X, int 0, uint 1
22 %Z = load sbyte* %Y
23
24 %R = sub sbyte %C, %Z
25 ret sbyte %R
26 }
None ; RUN: llvm-upgrade < %s | llvm-as | opt -load-vn -gcse | llvm-dis | not grep load
0 ; RUN: llvm-as < %s | opt -load-vn -gcse | llvm-dis | not grep load
11 ; Test that loads of undefined memory are eliminated.
22
3 int %test1() {
4 %X = malloc int
5 %Y = load int* %X
6 ret int %Y
7 }
8 int %test2() {
9 %X = alloca int
10 %Y = load int* %X
11 ret int %Y
3 define i32 @test1() {
4 %X = malloc i32 ; [#uses=1]
5 %Y = load i32* %X ; [#uses=1]
6 ret i32 %Y
127 }
138
9 define i32 @test2() {
10 %X = alloca i32 ; [#uses=1]
11 %Y = load i32* %X ; [#uses=1]
12 ret i32 %Y
13 }
0 ; This testcase was incorrectly computing that the loopentry.7 loop was
11 ; not a child of the loopentry.6 loop.
22 ;
3 ; RUN: llvm-upgrade < %s | llvm-as | opt -analyze -loops | \
3 ; RUN: llvm-as < %s | opt -analyze -loops | \
44 ; RUN: grep {^ Loop Containing: %loopentry.7}
55
6 void %getAndMoveToFrontDecode() { ; No predecessors!
6 define void @getAndMoveToFrontDecode() {
77 br label %endif.2
88
9 endif.2: ; preds = %0, %loopexit.5
10 br bool false, label %loopentry.5, label %UnifiedExitNode
9 endif.2: ; preds = %loopexit.5, %0
10 br i1 false, label %loopentry.5, label %UnifiedExitNode
1111
12 loopentry.5: ; preds = %endif.2, %loopexit.6
13 br bool false, label %loopentry.6, label %UnifiedExitNode
12 loopentry.5: ; preds = %loopexit.6, %endif.2
13 br i1 false, label %loopentry.6, label %UnifiedExitNode
1414
15 loopentry.6: ; preds = %loopentry.5, %loopentry.7
16 br bool false, label %loopentry.7, label %loopexit.6
15 loopentry.6: ; preds = %loopentry.7, %loopentry.5
16 br i1 false, label %loopentry.7, label %loopexit.6
1717
18 loopentry.7: ; preds = %loopentry.6, %loopentry.7
19 br bool false, label %loopentry.7, label %loopentry.6
18 loopentry.7: ; preds = %loopentry.7, %loopentry.6
19 br i1 false, label %loopentry.7, label %loopentry.6
2020
2121 loopexit.6: ; preds = %loopentry.6
22 br bool false, label %loopentry.5, label %loopexit.5
22 br i1 false, label %loopentry.5, label %loopexit.5
2323
2424 loopexit.5: ; preds = %loopexit.6
25 br bool false, label %endif.2, label %UnifiedExitNode
25 br i1 false, label %endif.2, label %UnifiedExitNode
2626
27 UnifiedExitNode: ; preds = %endif.2, %loopexit.5, %loopentry.5
27 UnifiedExitNode: ; preds = %loopexit.5, %loopentry.5, %endif.2
2828 ret void
2929 }