From: Michael Ilseman Date: Tue, 26 Feb 2013 01:31:59 +0000 (+0000) Subject: Use a DenseMap instead of a std::map for AnalysisID -> Pass* maps. This reduces the... X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=ce522ee0a27062390f13e7ccb53fcff4fc36c473;p=oota-llvm.git Use a DenseMap instead of a std::map for AnalysisID -> Pass* maps. This reduces the pass-manager overhead from FPPassManager::runOnFunction() by about 10%. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176072 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/PassManagers.h b/include/llvm/PassManagers.h index fac792824fc..7afb0a0fbf9 100644 --- a/include/llvm/PassManagers.h +++ b/include/llvm/PassManagers.h @@ -352,7 +352,7 @@ public: return PMT_Unknown; } - std::map *getAvailableAnalysis() { + DenseMap *getAvailableAnalysis() { return &AvailableAnalysis; } @@ -375,8 +375,7 @@ protected: // 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 *InheritedAnalysis[PMT_Last]; - + DenseMap *InheritedAnalysis[PMT_Last]; /// isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions /// or higher is specified. @@ -390,7 +389,7 @@ private: // pass. If a pass requires an analysis which is not available then // the required analysis pass is scheduled to run before the pass itself is // scheduled to run. - std::map AvailableAnalysis; + DenseMap AvailableAnalysis; // Collection of higher level analysis used by the pass managed by // this manager. diff --git a/lib/IR/PassManager.cpp b/lib/IR/PassManager.cpp index 2bdfd988faf..5a8df703dbe 100644 --- a/lib/IR/PassManager.cpp +++ b/lib/IR/PassManager.cpp @@ -874,9 +874,9 @@ void PMDataManager::removeNotPreservedAnalysis(Pass *P) { return; const AnalysisUsage::VectorType &PreservedSet = AnUsage->getPreservedSet(); - for (std::map::iterator I = AvailableAnalysis.begin(), + for (DenseMap::iterator I = AvailableAnalysis.begin(), E = AvailableAnalysis.end(); I != E; ) { - std::map::iterator Info = I++; + DenseMap::iterator Info = I++; if (Info->second->getAsImmutablePass() == 0 && std::find(PreservedSet.begin(), PreservedSet.end(), Info->first) == PreservedSet.end()) { @@ -897,10 +897,10 @@ void PMDataManager::removeNotPreservedAnalysis(Pass *P) { if (!InheritedAnalysis[Index]) continue; - for (std::map::iterator + for (DenseMap::iterator I = InheritedAnalysis[Index]->begin(), E = InheritedAnalysis[Index]->end(); I != E; ) { - std::map::iterator Info = I++; + DenseMap::iterator Info = I++; if (Info->second->getAsImmutablePass() == 0 && std::find(PreservedSet.begin(), PreservedSet.end(), Info->first) == PreservedSet.end()) { @@ -960,7 +960,7 @@ void PMDataManager::freePass(Pass *P, StringRef Msg, // listed as the available implementation. const std::vector &II = PInf->getInterfacesImplemented(); for (unsigned i = 0, e = II.size(); i != e; ++i) { - std::map::iterator Pos = + DenseMap::iterator Pos = AvailableAnalysis.find(II[i]->getTypeInfo()); if (Pos != AvailableAnalysis.end() && Pos->second == P) AvailableAnalysis.erase(Pos); @@ -1100,7 +1100,7 @@ void PMDataManager::initializeAnalysisImpl(Pass *P) { Pass *PMDataManager::findAnalysisPass(AnalysisID AID, bool SearchParent) { // Check if AvailableAnalysis map has one entry. - std::map::const_iterator I = AvailableAnalysis.find(AID); + DenseMap::const_iterator I = AvailableAnalysis.find(AID); if (I != AvailableAnalysis.end()) return I->second;