8000 * We were forgetting to pass varargs arguments through a call · inside-compiler/llvm-project@05c71fb · GitHub
[go: up one dir, main page]

Skip to content

Commit 05c71fb

Browse files
committed
* 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
1 parent 7d56d2c commit 05c71fb

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,17 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) {
380380
DeadRetVal.erase(F);
381381
}
382382

383+
// Work around LLVM bug PR56: the CWriter cannot emit varargs functions which
384+
// have zero fixed arguments.
385+
//
386+
// FIXME: once this bug is fixed in the CWriter, this hack should be removed.
387+
//
388+
bool ExtraArgHack = false;
389+
if (Params.empty() && FTy->isVarArg()) {
390+
ExtraArgHack = true;
391+
Params.push_back(Type::IntTy);
392+
}
393+
383394
FunctionType *NFTy = FunctionType::get(RetTy, Params, FTy->isVarArg());
384395

385396
// Create the new function body and insert it into the module...
@@ -400,6 +411,13 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) {
400411
if (!DeadArguments.count(I)) // Remove operands for dead arguments
401412
Args.push_back(*AI);
402413

414+
if (ExtraArgHack)
415+
Args.push_back(Constant::getNullValue(Type::IntTy));
416+
417+
// Push any varargs arguments on the list
418+
for (; AI != CS.arg_end(); ++AI)
419+
Args.push_back(*AI);
420+
403421
Instruction *New;
404422
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
405423
New = new InvokeInst(NF, II->getNormalDest(), II->getExceptionalDest(),

0 commit comments

Comments
 (0)
0