[llvm-commits] CVS: llvm/lib/VMCore/Pass.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Jan 22 17:01:17 PST 2006
Changes in directory llvm/lib/VMCore:
Pass.cpp updated: 1.67 -> 1.68
---
Log message:
Speedup and simplify pass registration by the observation that there is
exactly one PassInfo object per RegisterPass object and that their lifetimes
are the same. As such, there is no reason for the RegisterPass object to
dynamically allocate the PassInfo object at compiler startup time: just inline
the object by-value. This should reduce codesize, heap size, and startup time. Yaay.
---
Diffs of the changes: (+17 -20)
Pass.cpp | 37 +++++++++++++++++--------------------
1 files changed, 17 insertions(+), 20 deletions(-)
Index: llvm/lib/VMCore/Pass.cpp
diff -u llvm/lib/VMCore/Pass.cpp:1.67 llvm/lib/VMCore/Pass.cpp:1.68
--- llvm/lib/VMCore/Pass.cpp:1.67 Wed Jan 4 01:47:13 2006
+++ llvm/lib/VMCore/Pass.cpp Sun Jan 22 19:01:04 2006
@@ -38,7 +38,7 @@
}
void RegisterPassBase::setOnlyUsesCFG() {
- getCFGOnlyAnalyses().push_back(PIObj);
+ getCFGOnlyAnalyses().push_back(&PIObj);
}
//===----------------------------------------------------------------------===//
@@ -332,26 +332,25 @@
return (I != PassInfoMap->end()) ? I->second : 0;
}
-void RegisterPassBase::registerPass(PassInfo *PI) {
+void RegisterPassBase::registerPass() {
if (PassInfoMap == 0)
PassInfoMap = new std::map<TypeInfo, PassInfo*>();
- assert(PassInfoMap->find(PI->getTypeInfo()) == PassInfoMap->end() &&
+ assert(PassInfoMap->find(PIObj.getTypeInfo()) == PassInfoMap->end() &&
"Pass already registered!");
- PIObj = PI;
- PassInfoMap->insert(std::make_pair(TypeInfo(PI->getTypeInfo()), PI));
+ PassInfoMap->insert(std::make_pair(TypeInfo(PIObj.getTypeInfo()), &PIObj));
// Notify any listeners...
if (Listeners)
for (std::vector<PassRegistrationListener*>::iterator
I = Listeners->begin(), E = Listeners->end(); I != E; ++I)
- (*I)->passRegistered(PI);
+ (*I)->passRegistered(&PIObj);
}
-void RegisterPassBase::unregisterPass(PassInfo *PI) {
+void RegisterPassBase::unregisterPass() {
assert(PassInfoMap && "Pass registered but not in map!");
std::map<TypeInfo, PassInfo*>::iterator I =
- PassInfoMap->find(PI->getTypeInfo());
+ PassInfoMap->find(PIObj.getTypeInfo());
assert(I != PassInfoMap->end() && "Pass registered but not in map!");
// Remove pass from the map...
@@ -365,10 +364,7 @@
if (Listeners)
for (std::vector<PassRegistrationListener*>::iterator
I = Listeners->begin(), E = Listeners->end(); I != E; ++I)
- (*I)->passUnregistered(PI);
-
- // Delete the PassInfo object itself...
- delete PI;
+ (*I)->passUnregistered(&PIObj);
}
//===----------------------------------------------------------------------===//
@@ -387,14 +383,14 @@
//
RegisterAGBase::RegisterAGBase(const std::type_info &Interface,
const std::type_info *Pass, bool isDefault)
- : ImplementationInfo(0), isDefaultImplementation(isDefault) {
+ : RegisterPassBase(Interface, PassInfo::AnalysisGroup),
+ ImplementationInfo(0), isDefaultImplementation(isDefault) {
InterfaceInfo = const_cast<PassInfo*>(Pass::lookupPassInfo(Interface));
- if (InterfaceInfo == 0) { // First reference to Interface, add it now.
- InterfaceInfo = // Create the new PassInfo for the interface...
- new PassInfo("", "", Interface, PassInfo::AnalysisGroup, 0, 0);
- registerPass(InterfaceInfo);
- PIObj = 0;
+ if (InterfaceInfo == 0) {
+ // First reference to Interface, register it now.
+ registerPass();
+ InterfaceInfo = &PIObj;
}
assert(InterfaceInfo->getPassType() == PassInfo::AnalysisGroup &&
"Trying to join an analysis group that is a normal pass!");
@@ -455,10 +451,11 @@
delete AnalysisGroupInfoMap;
AnalysisGroupInfoMap = 0;
}
-
- unregisterPass(InterfaceInfo);
}
}
+
+ if (InterfaceInfo == &PIObj)
+ unregisterPass();
}
More information about the llvm-commits
mailing list