[llvm-commits] CVS: llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
Chris Lattner
lattner at cs.uiuc.edu
Thu Oct 23 12:46:01 PDT 2003
Changes in directory llvm/lib/Transforms/IPO:
DeadArgumentElimination.cpp updated: 1.8 -> 1.9
---
Log message:
* We were forgetting to pass varargs arguments through a call
* Add a work around for bug PR56, gross but necessary for now.
---
Diffs of the changes: (+18 -0)
Index: llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
diff -u llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp:1.8 llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp:1.9
--- llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp:1.8 Wed Oct 22 22:48:17 2003
+++ llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp Thu Oct 23 12:44:53 2003
@@ -380,6 +380,17 @@
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...
@@ -399,6 +410,13 @@
for (Function::aiterator I = F->abegin(), E = F->aend(); I != E; ++I, ++AI)
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)) {
More information about the llvm-commits
mailing list