From a10145fdf6325c5c528689e8952ad7e4e2a1a6b5 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 11 Jan 2008 18:43:58 +0000 Subject: [PATCH] start using smallvector to avoid vector heap thrashing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45873 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/IPO/ArgumentPromotion.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp index 5538247b7ee..0876a2bde31 100644 --- a/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -70,7 +70,8 @@ namespace { private: bool PromoteArguments(CallGraphNode *CGN); bool isSafeToPromoteArgument(Argument *Arg) const; - Function *DoPromotion(Function *F, std::vector &ArgsToPromote); + Function *DoPromotion(Function *F, + SmallVectorImpl &ArgsToPromote); }; char ArgPromotion::ID = 0; @@ -108,7 +109,7 @@ bool ArgPromotion::PromoteArguments(CallGraphNode *CGN) { if (!F || !F->hasInternalLinkage()) return false; // First check: see if there are any pointer arguments! If not, quick exit. - std::vector PointerArgs; + SmallVector PointerArgs; for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I) if (isa(I->getType())) PointerArgs.push_back(I); @@ -193,8 +194,8 @@ bool ArgPromotion::isSafeToPromoteArgument(Argument *Arg) const { // instructions (with constant indices) that are subsequently loaded. bool HasLoadInEntryBlock = false; BasicBlock *EntryBlock = Arg->getParent()->begin(); - std::vector Loads; - std::vector > GEPIndices; + SmallVector Loads; + std::vector > GEPIndices; for (Value::use_iterator UI = Arg->use_begin(), E = Arg->use_end(); UI != E; ++UI) if (LoadInst *LI = dyn_cast(*UI)) { @@ -210,7 +211,7 @@ bool ArgPromotion::isSafeToPromoteArgument(Argument *Arg) const { return isSafeToPromoteArgument(Arg); } // Ensure that all of the indices are constants. - std::vector Operands; + SmallVector Operands; for (unsigned i = 1, e = GEP->getNumOperands(); i != e; ++i) if (ConstantInt *C = dyn_cast(GEP->getOperand(i))) Operands.push_back(C); @@ -326,7 +327,7 @@ namespace { /// 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 &Args2Prom) { + SmallVectorImpl &Args2Prom) { std::set ArgsToPromote(Args2Prom.begin(), Args2Prom.end()); // Start by computing a new prototype for the function, which is the same as