summaryrefslogtreecommitdiff
path: root/lib/VMCore/Pass.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-07-29 21:02:31 +0000
committerChris Lattner <sabre@nondot.org>2002-07-29 21:02:31 +0000
commit44050fb25a37a72ba74da9b0c8b41973325a7995 (patch)
tree5aeeac3864ad6dc9f7a4aa5946522f51a5ee4d32 /lib/VMCore/Pass.cpp
parentf9b2297380d57d35c707864a9d55c1e00da39700 (diff)
downloadllvm-44050fb25a37a72ba74da9b0c8b41973325a7995.tar.gz
llvm-44050fb25a37a72ba74da9b0c8b41973325a7995.tar.bz2
llvm-44050fb25a37a72ba74da9b0c8b41973325a7995.tar.xz
* PassInfo is allowed to be missing now (ie, not all passes need be registered)
* getPassName uses PassInfo if it's available * PassInfo is now cached in the pass so that it is only looked up once, maximum git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3123 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Pass.cpp')
-rw-r--r--lib/VMCore/Pass.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp
index fb751b5db0..06e77e7fe1 100644
--- a/lib/VMCore/Pass.cpp
+++ b/lib/VMCore/Pass.cpp
@@ -217,7 +217,11 @@ void Pass::addToPassManager(PassManagerT<Module> *PM, AnalysisUsage &AU) {
// getPassName - Use C++ RTTI to get a SOMEWHAT intelligable name for the pass.
//
-const char *Pass::getPassName() const { return typeid(*this).name(); }
+const char *Pass::getPassName() const {
+ if (const PassInfo *PI = getPassInfo())
+ return PI->getPassName();
+ return typeid(*this).name();
+}
// print - Print out the internal state of the pass. This is called by Analyse
// to print out the contents of an analysis. Otherwise it is not neccesary to
@@ -310,11 +314,10 @@ static std::vector<PassRegistrationListener*> *Listeners = 0;
// getPassInfo - Return the PassInfo data structure that corresponds to this
// pass...
const PassInfo *Pass::getPassInfo() const {
- assert(PassInfoMap && "PassInfoMap not constructed yet??");
- std::map<TypeInfo, PassInfo*>::iterator I =
- PassInfoMap->find(typeid(*this));
- assert(I != PassInfoMap->end() && "Pass has not been registered!");
- return I->second;
+ if (PassInfoCache) return PassInfoCache;
+ if (PassInfoMap == 0) return 0;
+ std::map<TypeInfo, PassInfo*>::iterator I = PassInfoMap->find(typeid(*this));
+ return (I != PassInfoMap->end()) ? I->second : 0;
}
void RegisterPassBase::registerPass(PassInfo *PI) {