Eliminate use of ctors that take vectors.
authorChris Lattner <sabre@nondot.org>
Tue, 13 Feb 2007 02:10:56 +0000 (02:10 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 13 Feb 2007 02:10:56 +0000 (02:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34219 91177308-0d34-0410-b5e6-96231b3b80d8

12 files changed:
lib/Transforms/IPO/ArgumentPromotion.cpp
lib/Transforms/IPO/DeadArgumentElimination.cpp
lib/Transforms/IPO/LowerSetJmp.cpp
lib/Transforms/IPO/PruneEH.cpp
lib/Transforms/Instrumentation/ProfilingUtils.cpp
lib/Transforms/Scalar/ADCE.cpp
lib/Transforms/Scalar/InstructionCombining.cpp
lib/Transforms/Scalar/LowerGC.cpp
lib/Transforms/Utils/CodeExtractor.cpp
lib/Transforms/Utils/InlineFunction.cpp
lib/Transforms/Utils/LowerInvoke.cpp
lib/Transforms/Utils/SimplifyCFG.cpp

index 86f3f74db32c79e17481844b0c007ab86949afa3..7036a01f0900ec883d92f6e68552d05d75970e78 100644 (file)
@@ -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<InvokeInst>(Call)) {
       New = new InvokeInst(NF, II->getNormalDest(), II->getUnwindDest(),
-                           Args, "", Call);
+                           &Args[0], Args.size(), "", Call);
       cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
     } else {
-      New = new CallInst(NF, Args, "", Call);
+      New = new CallInst(NF, &Args[0], Args.size(), "", Call);
       cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
       if (cast<CallInst>(Call)->isTailCall())
         cast<CallInst>(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.
index 5963c9e800eeac95cdb126d62f3befb08674c6fd..d0dbc8b4288531a661a85795ee310b611ffa6783 100644 (file)
@@ -169,10 +169,10 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
     Instruction *New;
     if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
       New = new InvokeInst(NF, II->getNormalDest(), II->getUnwindDest(),
-                           Args, "", Call);
+                           &Args[0], Args.size(), "", Call);
       cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
     } else {
-      New = new CallInst(NF, Args, "", Call);
+      New = new CallInst(NF, &Args[0], Args.size(), "", Call);
       cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
       if (cast<CallInst>(Call)->isTailCall())
         cast<CallInst>(New)->setTailCall();
@@ -535,10 +535,10 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) {
     Instruction *New;
     if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
       New = new InvokeInst(NF, II->getNormalDest(), II->getUnwindDest(),
-                           Args, "", Call);
+                           &Args[0], Args.size(), "", Call);
       cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
     } else {
-      New = new CallInst(NF, Args, "", Call);
+      New = new CallInst(NF, &Args[0], Args.size(), "", Call);
       cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
       if (cast<CallInst>(Call)->isTailCall())
         cast<CallInst>(New)->setTailCall();
index fcaa4e8ac5e418eb8911ed33103fa1a44084aefe..3f32c0c76d59c7fffb9755b1fbf7bd99a80455c6 100644 (file)
@@ -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<Value*>(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<Value*>(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<Value*>(), "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<Value*>(), "LJVal");
+  CallInst* LJVal = new CallInst(GetLJValue, "LJVal");
   DecisionBBIL.push_back(LJVal);
-  CallInst* SJNum = new
-    CallInst(TryCatchLJ, make_vector<Value*>(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<Value*>(GetSetJmpMap(Func), BufPtr,
-                                   ConstantInt::get(Type::Int32Ty,
-                                                     SetJmpIDMap[Func]++), 0),
-               "", Inst);
+  std::vector<Value*> Args = 
+    make_vector<Value*>(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<Value*> 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<Value*>(), "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<Value*>(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<Value*>(GetSetJmpMap(Func), 0),
-               "", &UI);
+  new CallInst(DestroySJMap, GetSetJmpMap(Func), "", &UI);
 }
 
 ModulePass *llvm::createLowerSetJmpPass() {
index 271a8fa0d0694bab90c7874e15f4d7d1fa6774dc..6040379d58e29747ae153aa87152492c890ad68f 100644 (file)
@@ -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<InvokeInst>(BB->getTerminator()))
       if (Function *F = II->getCalledFunction())
         if (DoesNotUnwind.count(CG[F])) {
+          SmallVector<Value*, 8> Args(II->op_begin()+3, II->op_end());
           // Insert a call instruction before the invoke.
           CallInst *Call = new CallInst(II->getCalledValue(),
-                                        std::vector<Value*>(II->op_begin()+3,
-                                                            II->op_end()),
-                                        "", II);
+                                        &Args[0], Args.size(), "", II);
           Call->takeName(II);
           Call->setCallingConv(II->getCallingConv());
 
index d003f6ca914af794e22463708040a230c4c58137..071ca0dfdb48bb9d3e90737314785e0b87f9e4b9 100644 (file)
@@ -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;
index 20e4367033be4db1862b52a9d855e747662c7876..3946f5707cd161160eeccaea9338b6e76198c250 100644 (file)
@@ -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<Value*> Args(II->op_begin()+3, II->op_end());
-          CallInst *NewCall = new CallInst(F, Args, "", II);
+          SmallVector<Value*, 8> 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);
index 556c054a9941da2f5eb2e885e53f7cd365ce7dc2..5782260daceb33e7c8264b14df904f4fd745e994 100644 (file)
@@ -7352,10 +7352,10 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
   Instruction *NC;
   if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) {
     NC = new InvokeInst(Callee, II->getNormalDest(), II->getUnwindDest(),
-                        Args, Caller->getName(), Caller);
+                        &Args[0], Args.size(), Caller->getName(), Caller);
     cast<InvokeInst>(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<CallInst>(Caller)->isTailCall())
       cast<CallInst>(NC)->setTailCall();
    cast<CallInst>(NC)->setCallingConv(cast<CallInst>(Caller)->getCallingConv());
index 20636d45a2842db9cf0d9e71e4b6d2ca6129564a..c10849e297f4439fde74e6142cf3650909da7842 100644 (file)
@@ -314,10 +314,10 @@ bool LowerGC::runOnFunction(Function &F) {
       NewBB->getInstList().remove(CI);
 
       // Create a new invoke instruction.
+      std::vector<Value*> Args(CI->op_begin()+1, CI->op_end());
+
       Value *II = new InvokeInst(CI->getCalledValue(), NewBB, Cleanup,
-                                 std::vector<Value*>(CI->op_begin()+1,
-                                                     CI->op_end()),
-                                 CI->getName(), CBB);
+                                 &Args[0], Args.size(), CI->getName(), CBB);
       CI->replaceAllUsesWith(II);
       delete CI;
     }
index 87a286838dfc8359cacee36e1a67d17d77a65d97..f304df2a93dbf03d3c96099c37e1760b9d9f8542 100644 (file)
@@ -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, &params[0], params.size(),
                                 NumExitBlocks > 1 ? "targetBlock" : "");
   codeReplacer->getInstList().push_back(call);
 
index 054c1c7712392f3a65a0335663e5b7776aaa8492..07194e38ad23d5826b80b69e3477dd5dca722bf6 100644 (file)
@@ -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<Value*, 8> InvokeArgs(CI->op_begin()+1, CI->op_end());
           InvokeInst *II =
             new InvokeInst(CI->getCalledValue(), Split, InvokeDest,
-                           std::vector<Value*>(CI->op_begin()+1, CI->op_end()),
+                           &InvokeArgs[0], InvokeArgs.size(),
                            CI->getName(), BB->getTerminator());
           II->setCallingConv(CI->getCallingConv());
           
index 5a4408f802fb3f2dd75a695be6cbb39228ac48b6..d89cc95ab153f9f89757c943746b4c0236af0535 100644 (file)
@@ -189,21 +189,21 @@ void LowerInvoke::writeAbortMessage(Instruction *IB) {
     createAbortMessage(IB->getParent()->getParent()->getParent());
 
   // These are the arguments we WANT...
-  std::vector<Value*> 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<InvokeInst>(BB->getTerminator())) {
+      std::vector<Value*> CallArgs(II->op_begin()+3, II->op_end());
       // Insert a normal call instruction...
       CallInst *NewCall = new CallInst(II->getCalledValue(),
-                                       std::vector<Value*>(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<Value*>(), "", 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<Value*> CallArgs(II->op_begin()+3, II->op_end());
   CallInst *NewCall = new CallInst(II->getCalledValue(),
-                                   std::vector<Value*>(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<Value*>(), "",
+  (new CallInst(AbortFn, "",
                 TermBlock->getTerminator()))->setTailCall();
     
   
index b3a9f1d744c76fca01e919167d35d8221f18908d..92b0a9d5cda9f3a03ce99779d36e1dd5c77f02ad 100644 (file)
@@ -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 <algorithm>
 #include <functional>
 #include <set>
@@ -1369,9 +1370,9 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
           Pred->getInstList().remove(II);   // Take out of symbol table
 
           // Insert the call now...
-          std::vector<Value*> Args(II->op_begin()+3, II->op_end());
-          CallInst *CI = new CallInst(II->getCalledValue(), Args,
-                                      II->getName(), BI);
+          SmallVector<Value*,8> 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<Value*> Args(II->op_begin()+3, II->op_end());
-            CallInst *CI = new CallInst(II->getCalledValue(), Args,
+            SmallVector<Value*, 8> 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.