summaryrefslogtreecommitdiff
path: root/lib/VMCore
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2012-11-12 21:42:53 +0000
committerEvan Cheng <evan.cheng@apple.com>2012-11-12 21:42:53 +0000
commit0655668b113950521c06b85ae81f0c592d755dbd (patch)
tree63bc2403ec9b6652f01fc5bef26c2ecb6dd80b56 /lib/VMCore
parent3c9e55867e2c8ae7a9e528bce865ebfa963f30a9 (diff)
downloadllvm-0655668b113950521c06b85ae81f0c592d755dbd.tar.gz
llvm-0655668b113950521c06b85ae81f0c592d755dbd.tar.bz2
llvm-0655668b113950521c06b85ae81f0c592d755dbd.tar.xz
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 'lib/VMCore')
-rw-r--r--lib/VMCore/PassManager.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp
index 53f11499e4..5c209e24d8 100644
--- a/lib/VMCore/PassManager.cpp
+++ b/lib/VMCore/PassManager.cpp
@@ -195,7 +195,7 @@ public:
}
BasicBlockPass *getContainedPass(unsigned N) {
- assert(N < PassVector.size() && "Pass number out of range!");
+ assert(N < PassVectorSize && "Pass number out of range!");
BasicBlockPass *BP = static_cast<BasicBlockPass *>(PassVector[N]);
return BP;
}
@@ -346,7 +346,7 @@ public:
}
ModulePass *getContainedPass(unsigned N) {
- assert(N < PassVector.size() && "Pass number out of range!");
+ assert(N < PassVectorSize && "Pass number out of range!");
return static_cast<ModulePass *>(PassVector[N]);
}
@@ -963,6 +963,7 @@ void PMDataManager::add(Pass *P, bool ProcessAnalysis) {
if (!ProcessAnalysis) {
// Add pass
PassVector.push_back(P);
+ ++PassVectorSize;
return;
}
@@ -1024,6 +1025,7 @@ void PMDataManager::add(Pass *P, bool ProcessAnalysis) {
// Add pass
PassVector.push_back(P);
+ ++PassVectorSize;
}