aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-10-23 17:44:53 +0000
committerChris Lattner <sabre@nondot.org>2003-10-23 17:44:53 +0000
commitff5bf9c62bb1d604ea9ad95f0687ac1592fa774a (patch)
treee34c0592556493eb9703cc9cf9e89b2dff6f685a
parent0849f5ace979a4827befcaff54535381fca12d89 (diff)
* We were forgetting to pass varargs arguments through a call
* Add a work around for bug PR56, gross but necessary for now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9428 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/IPO/DeadArgumentElimination.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp
index e70dd20a83..04567e1316 100644
--- a/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -380,6 +380,17 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) {
DeadRetVal.erase(F);
}
+ // Work around LLVM bug PR56: the CWriter cannot emit varargs functions which
+ // have zero fixed arguments.
+ //
+ // FIXME: once this bug is fixed in the CWriter, this hack should be removed.
+ //
+ bool ExtraArgHack = false;
+ if (Params.empty() && FTy->isVarArg()) {
+ ExtraArgHack = true;
+ Params.push_back(Type::IntTy);
+ }
+
FunctionType *NFTy = FunctionType::get(RetTy, Params, FTy->isVarArg());
// Create the new function body and insert it into the module...
@@ -400,6 +411,13 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) {
if (!DeadArguments.count(I)) // Remove operands for dead arguments
Args.push_back(*AI);
+ if (ExtraArgHack)
+ Args.push_back(Constant::getNullValue(Type::IntTy));
+
+ // Push any varargs arguments on the list
+ for (; AI != CS.arg_end(); ++AI)
+ Args.push_back(*AI);
+
Instruction *New;
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
New = new InvokeInst(NF, II->getNormalDest(), II->getExceptionalDest(),