diff options
author | Evan Cheng <evan.cheng@apple.com> | 2012-11-12 21:42:53 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2012-11-12 21:42:53 +0000 |
commit | 0655668b113950521c06b85ae81f0c592d755dbd (patch) | |
tree | 63bc2403ec9b6652f01fc5bef26c2ecb6dd80b56 /include | |
parent | 3c9e55867e2c8ae7a9e528bce865ebfa963f30a9 (diff) | |
download | external_llvm-0655668b113950521c06b85ae81f0c592d755dbd.zip external_llvm-0655668b113950521c06b85ae81f0c592d755dbd.tar.gz external_llvm-0655668b113950521c06b85ae81f0c592d755dbd.tar.bz2 |
Cache size of PassVector to speed up getNumContainedPasses().
getNumContainedPasses() used to compute the size of the vector on demand. It is
called repeated in loops (such as runOnFunction()) and it can be updated while
inside the loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167759 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/PassManagers.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/include/llvm/PassManagers.h b/include/llvm/PassManagers.h index 0af5853..3acbf0e 100644 --- a/include/llvm/PassManagers.h +++ b/include/llvm/PassManagers.h @@ -263,7 +263,7 @@ private: class PMDataManager { public: - explicit PMDataManager() : TPM(NULL), Depth(0) { + explicit PMDataManager() : TPM(NULL), PassVectorSize(0), Depth(0) { initializeAnalysisInfo(); } @@ -344,7 +344,7 @@ public: void dumpPreservedSet(const Pass *P) const; virtual unsigned getNumContainedPasses() const { - return (unsigned)PassVector.size(); + return PassVectorSize; } virtual PassManagerType getPassManagerType() const { @@ -369,14 +369,16 @@ protected: // Top level manager. PMTopLevelManager *TPM; - // Collection of pass that are managed by this manager - SmallVector<Pass *, 16> PassVector; - // Collection of Analysis provided by Parent pass manager and // used by current pass manager. At at time there can not be more // then PMT_Last active pass mangers. std::map<AnalysisID, Pass *> *InheritedAnalysis[PMT_Last]; + // Collection of pass that are managed by this manager + SmallVector<Pass *, 16> PassVector; + + // Cache the size of PassVector + unsigned PassVectorSize; /// isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions /// or higher is specified. @@ -444,7 +446,7 @@ public: } FunctionPass *getContainedPass(unsigned N) { - assert ( N < PassVector.size() && "Pass number out of range!"); + assert ( N < PassVectorSize && "Pass number out of range!"); FunctionPass *FP = static_cast<FunctionPass *>(PassVector[N]); return FP; } |