Skip to content
Snippets Groups Projects
Commit 05c71fb3 authored by Chris Lattner's avatar Chris Lattner
Browse files

* We were forgetting to pass varargs arguments through a call

* Add a work around for bug PR56, gross but necessary for now.

llvm-svn: 9428
parent 7d56d2c6
No related branches found
No related tags found
No related merge requests found
...@@ -380,6 +380,17 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) { ...@@ -380,6 +380,17 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) {
DeadRetVal.erase(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()); FunctionType *NFTy = FunctionType::get(RetTy, Params, FTy->isVarArg());
// Create the new function body and insert it into the module... // Create the new function body and insert it into the module...
...@@ -400,6 +411,13 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) { ...@@ -400,6 +411,13 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) {
if (!DeadArguments.count(I)) // Remove operands for dead arguments if (!DeadArguments.count(I)) // Remove operands for dead arguments
Args.push_back(*AI); 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; Instruction *New;
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) { if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
New = new InvokeInst(NF, II->getNormalDest(), II->getExceptionalDest(), New = new InvokeInst(NF, II->getNormalDest(), II->getExceptionalDest(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment