From 81f28f603ac31349643d132e50768b062d7675a2 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sat, 3 May 2014 15:50:37 +0000 Subject: SLPVectorizer: Lazily allocate the map for block numbering. There is no point in creating it if we're not going to vectorize anything. Creating the map is expensive as it creates large values. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207916 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/IPO/GlobalOpt.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'lib/Transforms/IPO') diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index ce49b7f4a9..3db0abf89f 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -42,6 +42,7 @@ #include "llvm/Transforms/Utils/GlobalStatus.h" #include "llvm/Transforms/Utils/ModuleUtils.h" #include +#include using namespace llvm; #define DEBUG_TYPE "globalopt" @@ -2166,7 +2167,7 @@ class Evaluator { public: Evaluator(const DataLayout *DL, const TargetLibraryInfo *TLI) : DL(DL), TLI(TLI) { - ValueStack.push_back(make_unique>()); + ValueStack.emplace_back(); } ~Evaluator() { @@ -2191,13 +2192,13 @@ public: Constant *getVal(Value *V) { if (Constant *CV = dyn_cast(V)) return CV; - Constant *R = ValueStack.back()->lookup(V); + Constant *R = ValueStack.back().lookup(V); assert(R && "Reference to an uncomputed value!"); return R; } void setVal(Value *V, Constant *C) { - (*ValueStack.back())[V] = C; + ValueStack.back()[V] = C; } const DenseMap &getMutatedMemory() const { @@ -2212,9 +2213,9 @@ private: Constant *ComputeLoadResult(Constant *P); /// ValueStack - As we compute SSA register values, we store their contents - /// here. The back of the vector contains the current function and the stack + /// here. The back of the deque contains the current function and the stack /// contains the values in the calling frames. - SmallVector>, 4> ValueStack; + std::deque> ValueStack; /// CallStack - This is used to detect recursion. In pathological situations /// we could hit exponential behavior, but at least there is nothing @@ -2526,7 +2527,7 @@ bool Evaluator::EvaluateBlock(BasicBlock::iterator CurInst, Constant *RetVal = nullptr; // Execute the call, if successful, use the return value. - ValueStack.push_back(make_unique>()); + ValueStack.emplace_back(); if (!EvaluateFunction(Callee, RetVal, Formals)) { DEBUG(dbgs() << "Failed to evaluate function.\n"); return false; -- cgit v1.2.3