diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp index 86f3f74db32..7036a01f090 100644 --- a/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -161,7 +161,8 @@ static bool IsAlwaysValidPointer(Value *V) { static bool AllCalleesPassInValidPointerForArgument(Argument *Arg) { Function *Callee = Arg->getParent(); - unsigned ArgNo = std::distance(Callee->arg_begin(), Function::arg_iterator(Arg)); + unsigned ArgNo = std::distance(Callee->arg_begin(), + Function::arg_iterator(Arg)); // Look at all call sites of the function. At this pointer we know we only // have direct callees. @@ -442,10 +443,10 @@ Function *ArgPromotion::DoPromotion(Function *F, Instruction *New; if (InvokeInst *II = dyn_cast(Call)) { New = new InvokeInst(NF, II->getNormalDest(), II->getUnwindDest(), - Args, "", Call); + &Args[0], Args.size(), "", Call); cast(New)->setCallingConv(CS.getCallingConv()); } else { - New = new CallInst(NF, Args, "", Call); + New = new CallInst(NF, &Args[0], Args.size(), "", Call); cast(New)->setCallingConv(CS.getCallingConv()); if (cast(Call)->isTailCall()) cast(New)->setTailCall(); @@ -474,8 +475,8 @@ Function *ArgPromotion::DoPromotion(Function *F, // Loop over the argument list, transfering uses of the old arguments over to // the new arguments, also transfering over the names as well. // - for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(), I2 = NF->arg_begin(); - I != E; ++I) + for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(), + I2 = NF->arg_begin(); I != E; ++I) if (!ArgsToPromote.count(I)) { // If this is an unmodified argument, move the name and users over to the // new version. diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp index 5963c9e800e..d0dbc8b4288 100644 --- a/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -169,10 +169,10 @@ bool DAE::DeleteDeadVarargs(Function &Fn) { Instruction *New; if (InvokeInst *II = dyn_cast(Call)) { New = new InvokeInst(NF, II->getNormalDest(), II->getUnwindDest(), - Args, "", Call); + &Args[0], Args.size(), "", Call); cast(New)->setCallingConv(CS.getCallingConv()); } else { - New = new CallInst(NF, Args, "", Call); + New = new CallInst(NF, &Args[0], Args.size(), "", Call); cast(New)->setCallingConv(CS.getCallingConv()); if (cast(Call)->isTailCall()) cast(New)->setTailCall(); @@ -535,10 +535,10 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) { Instruction *New; if (InvokeInst *II = dyn_cast(Call)) { New = new InvokeInst(NF, II->getNormalDest(), II->getUnwindDest(), - Args, "", Call); + &Args[0], Args.size(), "", Call); cast(New)->setCallingConv(CS.getCallingConv()); } else { - New = new CallInst(NF, Args, "", Call); + New = new CallInst(NF, &Args[0], Args.size(), "", Call); cast(New)->setCallingConv(CS.getCallingConv()); if (cast(Call)->isTailCall()) cast(New)->setTailCall(); diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp index fcaa4e8ac5e..3f32c0c76d5 100644 --- a/lib/Transforms/IPO/LowerSetJmp.cpp +++ b/lib/Transforms/IPO/LowerSetJmp.cpp @@ -259,8 +259,7 @@ void LowerSetJmp::TransformLongJmpCall(CallInst* Inst) // Inst's uses and doesn't get a name. CastInst* CI = new BitCastInst(Inst->getOperand(1), SBPTy, "LJBuf", Inst); - new CallInst(ThrowLongJmp, make_vector(CI, Inst->getOperand(2), 0), - "", Inst); + new CallInst(ThrowLongJmp, CI, Inst->getOperand(2), "", Inst); SwitchValuePair& SVP = SwitchValMap[Inst->getParent()->getParent()]; @@ -303,7 +302,7 @@ AllocaInst* LowerSetJmp::GetSetJmpMap(Function* Func) // Fill in the alloca and call to initialize the SJ map. const Type *SBPTy = PointerType::get(Type::Int8Ty); AllocaInst* Map = new AllocaInst(SBPTy, 0, "SJMap", Inst); - new CallInst(InitSJMap, make_vector(Map, 0), "", Inst); + new CallInst(InitSJMap, Map, "", Inst); return SJMap[Func] = Map; } @@ -340,8 +339,7 @@ LowerSetJmp::SwitchValuePair LowerSetJmp::GetSJSwitch(Function* Func, PrelimBBMap[Func] = LongJmpPre; // Grab the exception. - CallInst* Cond = new - CallInst(IsLJException, std::vector(), "IsLJExcept"); + CallInst* Cond = new CallInst(IsLJException, "IsLJExcept"); LongJmpPreIL.push_back(Cond); // The "decision basic block" gets the number associated with the @@ -353,10 +351,9 @@ LowerSetJmp::SwitchValuePair LowerSetJmp::GetSJSwitch(Function* Func, new BranchInst(DecisionBB, Rethrow, Cond, LongJmpPre); // Fill in the "decision" basic block. - CallInst* LJVal = new CallInst(GetLJValue, std::vector(), "LJVal"); + CallInst* LJVal = new CallInst(GetLJValue, "LJVal"); DecisionBBIL.push_back(LJVal); - CallInst* SJNum = new - CallInst(TryCatchLJ, make_vector(GetSetJmpMap(Func), 0), "SJNum"); + CallInst* SJNum = new CallInst(TryCatchLJ, GetSetJmpMap(Func), "SJNum"); DecisionBBIL.push_back(SJNum); SwitchInst* SI = new SwitchInst(SJNum, Rethrow, 0, DecisionBB); @@ -376,11 +373,11 @@ void LowerSetJmp::TransformSetJmpCall(CallInst* Inst) const Type* SBPTy = PointerType::get(Type::Int8Ty); CastInst* BufPtr = new BitCastInst(Inst->getOperand(1), SBPTy, "SBJmpBuf", Inst); - new CallInst(AddSJToMap, - make_vector(GetSetJmpMap(Func), BufPtr, - ConstantInt::get(Type::Int32Ty, - SetJmpIDMap[Func]++), 0), - "", Inst); + std::vector Args = + make_vector(GetSetJmpMap(Func), BufPtr, + ConstantInt::get(Type::Int32Ty, + SetJmpIDMap[Func]++), 0); + new CallInst(AddSJToMap, &Args[0], Args.size(), "", Inst); // We are guaranteed that there are no values live across basic blocks // (because we are "not in SSA form" yet), but there can still be values live @@ -470,7 +467,7 @@ void LowerSetJmp::visitCallInst(CallInst& CI) std::vector Params(CI.op_begin() + 1, CI.op_end()); InvokeInst* II = new InvokeInst(CI.getCalledValue(), NewBB, PrelimBBMap[Func], - Params, CI.getName(), Term); + &Params[0], Params.size(), CI.getName(), Term); // Replace the old call inst with the invoke inst and remove the call. CI.replaceAllUsesWith(II); @@ -504,8 +501,7 @@ void LowerSetJmp::visitInvokeInst(InvokeInst& II) // If this is a longjmp exception, then branch to the preliminary BB of // the longjmp exception handling. Otherwise, go to the old exception. - CallInst* IsLJExcept = new - CallInst(IsLJException, std::vector(), "IsLJExcept"); + CallInst* IsLJExcept = new CallInst(IsLJException, "IsLJExcept"); InstList.push_back(IsLJExcept); new BranchInst(PrelimBBMap[Func], ExceptBB, IsLJExcept, NewExceptBB); @@ -518,16 +514,14 @@ void LowerSetJmp::visitInvokeInst(InvokeInst& II) // function. void LowerSetJmp::visitReturnInst(ReturnInst &RI) { Function* Func = RI.getParent()->getParent(); - new CallInst(DestroySJMap, make_vector(GetSetJmpMap(Func), 0), - "", &RI); + new CallInst(DestroySJMap, GetSetJmpMap(Func), "", &RI); } // visitUnwindInst - We want to destroy the setjmp map upon exit from the // function. void LowerSetJmp::visitUnwindInst(UnwindInst &UI) { Function* Func = UI.getParent()->getParent(); - new CallInst(DestroySJMap, make_vector(GetSetJmpMap(Func), 0), - "", &UI); + new CallInst(DestroySJMap, GetSetJmpMap(Func), "", &UI); } ModulePass *llvm::createLowerSetJmpPass() { diff --git a/lib/Transforms/IPO/PruneEH.cpp b/lib/Transforms/IPO/PruneEH.cpp index 271a8fa0d06..6040379d58e 100644 --- a/lib/Transforms/IPO/PruneEH.cpp +++ b/lib/Transforms/IPO/PruneEH.cpp @@ -22,6 +22,7 @@ #include "llvm/Intrinsics.h" #include "llvm/Instructions.h" #include "llvm/Analysis/CallGraph.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/CFG.h" #include "llvm/Support/Compiler.h" @@ -144,11 +145,10 @@ bool PruneEH::SimplifyFunction(Function *F) { if (InvokeInst *II = dyn_cast(BB->getTerminator())) if (Function *F = II->getCalledFunction()) if (DoesNotUnwind.count(CG[F])) { + SmallVector Args(II->op_begin()+3, II->op_end()); // Insert a call instruction before the invoke. CallInst *Call = new CallInst(II->getCalledValue(), - std::vector(II->op_begin()+3, - II->op_end()), - "", II); + &Args[0], Args.size(), "", II); Call->takeName(II); Call->setCallingConv(II->getCallingConv()); diff --git a/lib/Transforms/Instrumentation/ProfilingUtils.cpp b/lib/Transforms/Instrumentation/ProfilingUtils.cpp index d003f6ca914..071ca0dfdb4 100644 --- a/lib/Transforms/Instrumentation/ProfilingUtils.cpp +++ b/lib/Transforms/Instrumentation/ProfilingUtils.cpp @@ -53,7 +53,8 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName, } Args[3] = ConstantInt::get(Type::Int32Ty, NumElements); - Instruction *InitCall = new CallInst(InitFn, Args, "newargc", InsertPos); + Instruction *InitCall = new CallInst(InitFn, &Args[0], Args.size(), + "newargc", InsertPos); // If argc or argv are not available in main, just pass null values in. Function::arg_iterator AI; diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index 20e4367033b..3946f5707cd 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/lib/Transforms/Scalar/ADCE.cpp @@ -25,6 +25,7 @@ #include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h" #include "llvm/Support/Debug.h" #include "llvm/ADT/DepthFirstIterator.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Compiler.h" @@ -188,8 +189,8 @@ bool ADCE::doADCE() { if (AA.onlyReadsMemory(F)) { // The function cannot unwind. Convert it to a call with a branch // after it to the normal destination. - std::vector Args(II->op_begin()+3, II->op_end()); - CallInst *NewCall = new CallInst(F, Args, "", II); + SmallVector Args(II->op_begin()+3, II->op_end()); + CallInst *NewCall = new CallInst(F, &Args[0], Args.size(), "", II); NewCall->takeName(II); NewCall->setCallingConv(II->getCallingConv()); II->replaceAllUsesWith(NewCall); diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 556c054a994..5782260dace 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -7352,10 +7352,10 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { Instruction *NC; if (InvokeInst *II = dyn_cast(Caller)) { NC = new InvokeInst(Callee, II->getNormalDest(), II->getUnwindDest(), - Args, Caller->getName(), Caller); + &Args[0], Args.size(), Caller->getName(), Caller); cast(II)->setCallingConv(II->getCallingConv()); } else { - NC = new CallInst(Callee, Args, Caller->getName(), Caller); + NC = new CallInst(Callee, &Args[0], Args.size(), Caller->getName(), Caller); if (cast(Caller)->isTailCall()) cast(NC)->setTailCall(); cast(NC)->setCallingConv(cast(Caller)->getCallingConv()); diff --git a/lib/Transforms/Scalar/LowerGC.cpp b/lib/Transforms/Scalar/LowerGC.cpp index 20636d45a28..c10849e297f 100644 --- a/lib/Transforms/Scalar/LowerGC.cpp +++ b/lib/Transforms/Scalar/LowerGC.cpp @@ -314,10 +314,10 @@ bool LowerGC::runOnFunction(Function &F) { NewBB->getInstList().remove(CI); // Create a new invoke instruction. + std::vector Args(CI->op_begin()+1, CI->op_end()); + Value *II = new InvokeInst(CI->getCalledValue(), NewBB, Cleanup, - std::vector(CI->op_begin()+1, - CI->op_end()), - CI->getName(), CBB); + &Args[0], Args.size(), CI->getName(), CBB); CI->replaceAllUsesWith(II); delete CI; } diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp index 87a286838df..f304df2a93d 100644 --- a/lib/Transforms/Utils/CodeExtractor.cpp +++ b/lib/Transforms/Utils/CodeExtractor.cpp @@ -403,7 +403,7 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, } // Emit the call to the function - CallInst *call = new CallInst(newFunction, params, + CallInst *call = new CallInst(newFunction, ¶ms[0], params.size(), NumExitBlocks > 1 ? "targetBlock" : ""); codeReplacer->getInstList().push_back(call); diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index 054c1c77123..07194e38ad2 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/lib/Transforms/Utils/InlineFunction.cpp @@ -19,6 +19,7 @@ #include "llvm/Instructions.h" #include "llvm/Intrinsics.h" #include "llvm/Analysis/CallGraph.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/Support/CallSite.h" using namespace llvm; @@ -80,9 +81,10 @@ static void HandleInlinedInvoke(InvokeInst *II, BasicBlock *FirstNewBlock, // Next, create the new invoke instruction, inserting it at the end // of the old basic block. + SmallVector InvokeArgs(CI->op_begin()+1, CI->op_end()); InvokeInst *II = new InvokeInst(CI->getCalledValue(), Split, InvokeDest, - std::vector(CI->op_begin()+1, CI->op_end()), + &InvokeArgs[0], InvokeArgs.size(), CI->getName(), BB->getTerminator()); II->setCallingConv(CI->getCallingConv()); diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp index 5a4408f802f..d89cc95ab15 100644 --- a/lib/Transforms/Utils/LowerInvoke.cpp +++ b/lib/Transforms/Utils/LowerInvoke.cpp @@ -189,21 +189,21 @@ void LowerInvoke::writeAbortMessage(Instruction *IB) { createAbortMessage(IB->getParent()->getParent()->getParent()); // These are the arguments we WANT... - std::vector Args; - Args.push_back(ConstantInt::get(Type::Int32Ty, 2)); - Args.push_back(AbortMessage); - Args.push_back(ConstantInt::get(Type::Int32Ty, AbortMessageLength)); - (new CallInst(WriteFn, Args, "", IB))->setTailCall(); + Value* Args[3]; + Args[0] = ConstantInt::get(Type::Int32Ty, 2); + Args[1] = AbortMessage; + Args[2] = ConstantInt::get(Type::Int32Ty, AbortMessageLength); + (new CallInst(WriteFn, Args, 3, "", IB))->setTailCall(); } bool LowerInvoke::insertCheapEHSupport(Function &F) { bool Changed = false; for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) if (InvokeInst *II = dyn_cast(BB->getTerminator())) { + std::vector CallArgs(II->op_begin()+3, II->op_end()); // Insert a normal call instruction... CallInst *NewCall = new CallInst(II->getCalledValue(), - std::vector(II->op_begin()+3, - II->op_end()), "", II); + &CallArgs[0], CallArgs.size(), "", II); NewCall->takeName(II); NewCall->setCallingConv(II->getCallingConv()); II->replaceAllUsesWith(NewCall); @@ -223,7 +223,7 @@ bool LowerInvoke::insertCheapEHSupport(Function &F) { writeAbortMessage(UI); // Insert a call to abort() - (new CallInst(AbortFn, std::vector(), "", UI))->setTailCall(); + (new CallInst(AbortFn, "", UI))->setTailCall(); // Insert a return instruction. This really should be a "barrier", as it // is unreachable. @@ -258,9 +258,9 @@ void LowerInvoke::rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo, CatchSwitch->addCase(InvokeNoC, II->getUnwindDest()); // Insert a normal call instruction. + std::vector CallArgs(II->op_begin()+3, II->op_end()); CallInst *NewCall = new CallInst(II->getCalledValue(), - std::vector(II->op_begin()+3, - II->op_end()), "", + &CallArgs[0], CallArgs.size(), "", II); NewCall->takeName(II); NewCall->setCallingConv(II->getCallingConv()); @@ -533,7 +533,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) { Idx.push_back(ConstantInt::get(Type::Int32Ty, 0)); Idx[0] = new GetElementPtrInst(BufPtr, &Idx[0], 2, "JmpBuf", UnwindBlock); Idx[1] = ConstantInt::get(Type::Int32Ty, 1); - new CallInst(LongJmpFn, Idx, "", UnwindBlock); + new CallInst(LongJmpFn, &Idx[0], Idx.size(), "", UnwindBlock); new UnreachableInst(UnwindBlock); // Set up the term block ("throw without a catch"). @@ -543,7 +543,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) { writeAbortMessage(TermBlock->getTerminator()); // Insert a call to abort() - (new CallInst(AbortFn, std::vector(), "", + (new CallInst(AbortFn, "", TermBlock->getTerminator()))->setTailCall(); diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index b3a9f1d744c..92b0a9d5cda 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -21,6 +21,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Analysis/ConstantFolding.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" +#include "llvm/ADT/SmallVector.h" #include #include #include @@ -1369,9 +1370,9 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { Pred->getInstList().remove(II); // Take out of symbol table // Insert the call now... - std::vector Args(II->op_begin()+3, II->op_end()); - CallInst *CI = new CallInst(II->getCalledValue(), Args, - II->getName(), BI); + SmallVector Args(II->op_begin()+3, II->op_end()); + CallInst *CI = new CallInst(II->getCalledValue(), + &Args[0], Args.size(), II->getName(), BI); CI->setCallingConv(II->getCallingConv()); // If the invoke produced a value, the Call now does instead II->replaceAllUsesWith(CI); @@ -1741,8 +1742,9 @@ bool llvm::SimplifyCFG(BasicBlock *BB) { II->removeFromParent(); // Take out of symbol table // Insert the call now... - std::vector Args(II->op_begin()+3, II->op_end()); - CallInst *CI = new CallInst(II->getCalledValue(), Args, + SmallVector Args(II->op_begin()+3, II->op_end()); + CallInst *CI = new CallInst(II->getCalledValue(), + &Args[0], Args.size(), II->getName(), BI); CI->setCallingConv(II->getCallingConv()); // If the invoke produced a value, the Call does now instead.