summaryrefslogtreecommitdiff
path: root/test/Transforms/DeadArgElim
diff options
context:
space:
mode:
authorMatthijs Kooijman <matthijs@stdin.nl>2008-06-18 11:12:53 +0000
committerMatthijs Kooijman <matthijs@stdin.nl>2008-06-18 11:12:53 +0000
commitca85d65277e7d07985712e49b267b34a65fe6aab (patch)
tree866c9602893d01dfd213a040202defe743d41296 /test/Transforms/DeadArgElim
parentc2afe89019790adb2c590397960d69b8f1d9a537 (diff)
downloadllvm-ca85d65277e7d07985712e49b267b34a65fe6aab.tar.gz
llvm-ca85d65277e7d07985712e49b267b34a65fe6aab.tar.bz2
llvm-ca85d65277e7d07985712e49b267b34a65fe6aab.tar.xz
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). Also add a testcase for testing various variations of (multiple) dead rerturn values. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52459 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/DeadArgElim')
-rw-r--r--test/Transforms/DeadArgElim/multdeadretval.ll39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/Transforms/DeadArgElim/multdeadretval.ll b/test/Transforms/DeadArgElim/multdeadretval.ll
new file mode 100644
index 0000000000..bccd0dfdb3
--- /dev/null
+++ b/test/Transforms/DeadArgElim/multdeadretval.ll
@@ -0,0 +1,39 @@
+; This test sees if return values (and arguments) are properly removed when they
+; are unused. All unused values are typed i16, so we can easily check. We also
+; 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
+
+define internal {i16, i32} @test(i16 %DEADARG) {
+ %A = insertvalue {i16,i32} undef, i16 1, 0
+ %B = insertvalue {i16,i32} %A, i32 1001, 1
+ ret {i16,i32} %B
+}
+
+define internal {i32, i16} @test2() {
+ %DEAD = call i16 @test4()
+ %A = insertvalue {i32,i16} undef, i32 1, 0
+ %B = insertvalue {i32,i16} %A, i16 %DEAD, 1
+ ret {i32,i16} %B
+}
+
+define internal i32 @test3(i16 %A) {
+ %ret = call {i16, i32} @test( i16 %A ) ; <i32> [#uses=0]
+ %DEAD = extractvalue {i16, i32} %ret, 0
+ %LIVE = extractvalue {i16, i32} %ret, 1
+ ret i32 %LIVE
+}
+
+define internal i16 @test4() {
+ ret i16 0
+}
+
+define i32 @main() {
+ %ret = call {i32, i16} @test2() ; <i32> [#uses=1]
+ %LIVE = extractvalue {i32, i16} %ret, 0
+ %DEAD = extractvalue {i32, i16} %ret, 1
+ %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
+}