aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-10-18 18:49:29 +0000
committerChris Lattner <sabre@nondot.org>2007-10-18 18:49:29 +0000
commita0bc7fc7bd048a69533ea14e73a57504eea56ca1 (patch)
tree615674437e195d50c48e60daba3960891954aa86
parent50c26b642c339c430eaef7ebf516063daa93186d (diff)
downloadexternal_llvm-a0bc7fc7bd048a69533ea14e73a57504eea56ca1.zip
external_llvm-a0bc7fc7bd048a69533ea14e73a57504eea56ca1.tar.gz
external_llvm-a0bc7fc7bd048a69533ea14e73a57504eea56ca1.tar.bz2
Fix PR1735 and Transforms/DeadArgElim/2007-10-18-VarargsReturn.ll by
fixing some obviously broken code :( git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43141 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/IPO/DeadArgumentElimination.cpp6
-rw-r--r--test/Transforms/DeadArgElim/2007-10-18-VarargsReturn.ll12
2 files changed, 15 insertions, 3 deletions
diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp
index dd5d668..8dd0925 100644
--- a/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -168,7 +168,7 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
CallSite CS = CallSite::get(Fn.use_back());
Instruction *Call = CS.getInstruction();
- // Loop over the operands, dropping extraneous ones at the end of the list.
+ // Pass all the same arguments.
Args.assign(CS.arg_begin(), CS.arg_begin()+NumArgs);
Instruction *New;
@@ -185,13 +185,13 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
Args.clear();
if (!Call->use_empty())
- Call->replaceAllUsesWith(Constant::getNullValue(Call->getType()));
+ Call->replaceAllUsesWith(New);
New->takeName(Call);
// Finally, remove the old call from the program, reducing the use-count of
// F.
- Call->getParent()->getInstList().erase(Call);
+ Call->eraseFromParent();
}
// Since we have now created the new function, splice the body of the old
diff --git a/test/Transforms/DeadArgElim/2007-10-18-VarargsReturn.ll b/test/Transforms/DeadArgElim/2007-10-18-VarargsReturn.ll
new file mode 100644
index 0000000..2a09b76
--- /dev/null
+++ b/test/Transforms/DeadArgElim/2007-10-18-VarargsReturn.ll
@@ -0,0 +1,12 @@
+; RUN: llvm-as < %s | opt -deadargelim | llvm-dis | not grep {ret i32 0}
+; PR1735
+
+define internal i32 @test(i32 %A, ...) {
+ ret i32 %A
+}
+
+define i32 @foo() {
+ %A = call i32(i32, ...)* @test(i32 1)
+ ret i32 %A
+}
+