[llvm-commits] [llvm] r45873 - /llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp

Chris Lattner sabre at nondot.org
Fri Jan 11 10:43:58 PST 2008


Author: lattner
Date: Fri Jan 11 12:43:58 2008
New Revision: 45873

URL: http://llvm.org/viewvc/llvm-project?rev=45873&view=rev
Log:
start using smallvector to avoid vector heap thrashing.

Modified:
    llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp

Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=45873&r1=45872&r2=45873&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Fri Jan 11 12:43:58 2008
@@ -70,7 +70,8 @@
   private:
     bool PromoteArguments(CallGraphNode *CGN);
     bool isSafeToPromoteArgument(Argument *Arg) const;
-    Function *DoPromotion(Function *F, std::vector<Argument*> &ArgsToPromote);
+    Function *DoPromotion(Function *F, 
+                          SmallVectorImpl<Argument*> &ArgsToPromote);
   };
 
   char ArgPromotion::ID = 0;
@@ -108,7 +109,7 @@
   if (!F || !F->hasInternalLinkage()) return false;
 
   // First check: see if there are any pointer arguments!  If not, quick exit.
-  std::vector<Argument*> PointerArgs;
+  SmallVector<Argument*, 16> PointerArgs;
   for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I)
     if (isa<PointerType>(I->getType()))
       PointerArgs.push_back(I);
@@ -193,8 +194,8 @@
   // instructions (with constant indices) that are subsequently loaded.
   bool HasLoadInEntryBlock = false;
   BasicBlock *EntryBlock = Arg->getParent()->begin();
-  std::vector<LoadInst*> Loads;
-  std::vector<std::vector<ConstantInt*> > GEPIndices;
+  SmallVector<LoadInst*, 16> Loads;
+  std::vector<SmallVector<ConstantInt*, 8> > GEPIndices;
   for (Value::use_iterator UI = Arg->use_begin(), E = Arg->use_end();
        UI != E; ++UI)
     if (LoadInst *LI = dyn_cast<LoadInst>(*UI)) {
@@ -210,7 +211,7 @@
         return isSafeToPromoteArgument(Arg);
       }
       // Ensure that all of the indices are constants.
-      std::vector<ConstantInt*> Operands;
+      SmallVector<ConstantInt*, 8> Operands;
       for (unsigned i = 1, e = GEP->getNumOperands(); i != e; ++i)
         if (ConstantInt *C = dyn_cast<ConstantInt>(GEP->getOperand(i)))
           Operands.push_back(C);
@@ -326,7 +327,7 @@
 /// arguments, and returns the new function.  At this point, we know that it's
 /// safe to do so.
 Function *ArgPromotion::DoPromotion(Function *F,
-                                    std::vector<Argument*> &Args2Prom) {
+                                    SmallVectorImpl<Argument*> &Args2Prom) {
   std::set<Argument*> ArgsToPromote(Args2Prom.begin(), Args2Prom.end());
 
   // Start by computing a new prototype for the function, which is the same as





More information about the llvm-commits mailing list