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;
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
--- /dev/null
+; 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
+}
+