summaryrefslogtreecommitdiff
path: root/test/Transforms/DeadArgElim
diff options
context:
space:
mode:
authorMatthijs Kooijman <matthijs@stdin.nl>2008-07-10 10:24:08 +0000
committerMatthijs Kooijman <matthijs@stdin.nl>2008-07-10 10:24:08 +0000
commitd16918f843933dbdfb23345b24de82c1da0637fe (patch)
tree0d443f022a882e7c129e0662975b1d2c18e89b2f /test/Transforms/DeadArgElim
parentef0732d25a9882c947984ae3f2afbef5463ba00f (diff)
downloadllvm-d16918f843933dbdfb23345b24de82c1da0637fe.tar.gz
llvm-d16918f843933dbdfb23345b24de82c1da0637fe.tar.bz2
llvm-d16918f843933dbdfb23345b24de82c1da0637fe.tar.xz
Restructure dead argument elimination, try #3 :-)
Rewrite the DeadArgumentElimination pass, to use a more explicit tracking of dependencies between return values and/or arguments. Also make the handling of arguments and return values the same. The pass now looks properly inside returned structs, but only at the first level (ie, not inside nested structs). This version fixed a few more bugs and was cleaned up a bit. It now passes all of LLVM's testing, and should still pass SPEC2006. There is still a minor bug with regard to returning nested structs. Since there is currently nothing that emits such IR, I will fix that in a seperate commit (partly because it requires a non-trivial fix). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53400 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/DeadArgElim')
-rw-r--r--test/Transforms/DeadArgElim/multdeadretval.ll19
1 files changed, 17 insertions, 2 deletions
diff --git a/test/Transforms/DeadArgElim/multdeadretval.ll b/test/Transforms/DeadArgElim/multdeadretval.ll
index 2eca74dd7e..f60fd0fc39 100644
--- a/test/Transforms/DeadArgElim/multdeadretval.ll
+++ b/test/Transforms/DeadArgElim/multdeadretval.ll
@@ -3,7 +3,6 @@
; run instcombine to fold insert/extractvalue chains and we run dce to clean up
; any remaining dead stuff.
; RUN: llvm-as < %s | opt -deadargelim -instcombine -dce | llvm-dis | not grep i16
-; XFAIL: *
define internal {i16, i32} @test(i16 %DEADARG) {
%A = insertvalue {i16,i32} undef, i16 1, 0
@@ -18,6 +17,8 @@ define internal {i32, i16} @test2() {
ret {i32,i16} %B
}
+; Dead argument, used to check if the second result of test2 is dead even when
+; it's used as a dead argument
define internal i32 @test3(i16 %A) {
%ret = call {i16, i32} @test( i16 %A ) ; <i32> [#uses=0]
%DEAD = extractvalue {i16, i32} %ret, 0
@@ -29,6 +30,14 @@ define internal i16 @test4() {
ret i16 0
}
+; Multiple return values, multiple live return values
+define internal {i32, i32, i16} @test5() {
+ %A = insertvalue {i32,i32,i16} undef, i32 1, 0
+ %B = insertvalue {i32,i32,i16} %A, i32 2, 1
+ %C = insertvalue {i32,i32,i16} %B, i16 3, 2
+ ret {i32, i32, i16} %C
+}
+
define i32 @main() {
%ret = call {i32, i16} @test2() ; <i32> [#uses=1]
%LIVE = extractvalue {i32, i16} %ret, 0
@@ -36,5 +45,11 @@ define i32 @main() {
%Y = add i32 %LIVE, -123 ; <i32> [#uses=1]
%LIVE2 = call i32 @test3(i16 %DEAD) ; <i32> [#uses=1]
%Z = add i32 %LIVE2, %Y ; <i32> [#uses=1]
- ret i32 %Z
+ %ret1 = call { i32, i32, i16 } @test5 ()
+ %LIVE3 = extractvalue { i32, i32, i16} %ret1, 0
+ %LIVE4 = extractvalue { i32, i32, i16} %ret1, 1
+ %DEAD2 = extractvalue { i32, i32, i16} %ret1, 2
+ %V = add i32 %LIVE3, %LIVE4
+ %W = add i32 %Z, %V
+ ret i32 %W
}