llvm.org GIT mirror llvm / ff5bf9c
* 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 Chris Lattner 16 years ago
1 changed file(s) with 18 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
379379 DeadRetVal.erase(F);
380380 }
381381
382 // Work around LLVM bug PR56: the CWriter cannot emit varargs functions which
383 // have zero fixed arguments.
384 //
385 // FIXME: once this bug is fixed in the CWriter, this hack should be removed.
386 //
387 bool ExtraArgHack = false;
388 if (Params.empty() && FTy->isVarArg()) {
389 ExtraArgHack = true;
390 Params.push_back(Type::IntTy);
391 }
392
382393 FunctionType *NFTy = FunctionType::get(RetTy, Params, FTy->isVarArg());
383394
384395 // Create the new function body and insert it into the module...
398409 for (Function::aiterator I = F->abegin(), E = F->aend(); I != E; ++I, ++AI)
399410 if (!DeadArguments.count(I)) // Remove operands for dead arguments
400411 Args.push_back(*AI);
412
413 if (ExtraArgHack)
414 Args.push_back(Constant::getNullValue(Type::IntTy));
415
416 // Push any varargs arguments on the list
417 for (; AI != CS.arg_end(); ++AI)
418 Args.push_back(*AI);
401419
402420 Instruction *New;
403421 if (InvokeInst *II = dyn_cast(Call)) {