summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatthijs Kooijman <matthijs@stdin.nl>2008-06-24 16:30:26 +0000
committerMatthijs Kooijman <matthijs@stdin.nl>2008-06-24 16:30:26 +0000
commit1d9a27776101ed4c2b71b6b910803c63100209f4 (patch)
tree2c4bacdf5aa354e749226768f75c51453933edbf /test
parent5b80c663e7662fcf24c764f0cd1b2671958689b8 (diff)
downloadllvm-1d9a27776101ed4c2b71b6b910803c63100209f4.tar.gz
llvm-1d9a27776101ed4c2b71b6b910803c63100209f4.tar.bz2
llvm-1d9a27776101ed4c2b71b6b910803c63100209f4.tar.xz
Commit the new DeadArgElim pass again, this time with the gcc bootstrap failures fixed.
Also add a testcase to reproduce the gcc bootstrap failure in very much reduced form. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52677 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Transforms/DeadArgElim/2008-06-23-DeadAfterLive.ll23
-rw-r--r--test/Transforms/DeadArgElim/deadretval2.ll28
-rw-r--r--test/Transforms/DeadArgElim/multdeadretval.ll39
3 files changed, 89 insertions, 1 deletions
diff --git a/test/Transforms/DeadArgElim/2008-06-23-DeadAfterLive.ll b/test/Transforms/DeadArgElim/2008-06-23-DeadAfterLive.ll
new file mode 100644
index 0000000000..2c9416049a
--- /dev/null
+++ b/test/Transforms/DeadArgElim/2008-06-23-DeadAfterLive.ll
@@ -0,0 +1,23 @@
+; RUN: llvm-as < %s | opt -deadargelim -die | llvm-dis > %t
+; RUN: cat %t | grep 123
+
+; This test tries to catch wrongful removal of return values for a specific case
+; that was break llvm-gcc builds.
+
+; This function has a live return value, it is used by @alive.
+define internal i32 @test5() {
+ ret i32 123
+}
+
+; This function doesn't use the return value @test5 and tries to lure DAE into
+; marking @test5's return value dead because only this call is unused.
+define i32 @dead() {
+ %DEAD = call i32 @test5()
+ ret i32 0
+}
+
+; This function ensures the retval of @test5 is live.
+define i32 @alive() {
+ %LIVE = call i32 @test5()
+ ret i32 %LIVE
+}
diff --git a/test/Transforms/DeadArgElim/deadretval2.ll b/test/Transforms/DeadArgElim/deadretval2.ll
index 76ce84dad8..316d7555e9 100644
--- a/test/Transforms/DeadArgElim/deadretval2.ll
+++ b/test/Transforms/DeadArgElim/deadretval2.ll
@@ -1,4 +1,6 @@
-; RUN: llvm-as < %s | opt -deadargelim -die | llvm-dis | not grep DEAD
+; RUN: llvm-as < %s | opt -deadargelim -die | llvm-dis > %t
+; RUN: cat %t | not grep DEAD
+; RUN: cat %t | grep LIVE | count 4
@P = external global i32 ; <i32*> [#uses=1]
@@ -31,3 +33,27 @@ define void @test4() {
%DEAD2 = call i32 @id( i32 %DEAD ) ; <i32> [#uses=0]
ret void
}
+
+; These test if returning another functions return value properly marks that
+; other function's return value as live. We do this twice, with the functions in
+; different orders (ie, first the caller, than the callee and first the callee
+; and then the caller) since DAE processes functions one by one and handles
+; these cases slightly different.
+
+define internal i32 @test5() {
+ ret i32 123
+}
+
+define i32 @test6() {
+ %LIVE = call i32 @test5()
+ ret i32 %LIVE
+}
+
+define i32 @test7() {
+ %LIVE = call i32 @test8()
+ ret i32 %LIVE
+}
+
+define internal i32 @test8() {
+ ret i32 124
+}
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
+}