From: Owen Anderson Date: Mon, 19 Jul 2010 21:44:48 +0000 (+0000) Subject: Change the implemented interfaces list on PassInfo from a std::vector to a manually... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;ds=sidebyside;h=7ee5d354938b231b1d01a76f686ee4dcbfa27600;p=oota-llvm.git Change the implemented interfaces list on PassInfo from a std::vector to a manually implemented linked list. This is a little slower and involves more malloc'ing, but these lists are typically short, and it allows PassInfo to be entirely constant initializable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108755 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/PassSupport.h b/include/llvm/PassSupport.h index b0183513386..09abe93e916 100644 --- a/include/llvm/PassSupport.h +++ b/include/llvm/PassSupport.h @@ -36,6 +36,10 @@ class TargetMachine; class PassInfo { public: typedef Pass* (*NormalCtor_t)(); + struct InterfaceInfo { + const PassInfo *interface; + const InterfaceInfo *next; + }; private: const char *const PassName; // Nice name for Pass @@ -44,7 +48,7 @@ private: const bool IsCFGOnlyPass; // Pass only looks at the CFG. const bool IsAnalysis; // True if an analysis pass. const bool IsAnalysisGroup; // True if an analysis group. - std::vector ItfImpl;// Interfaces implemented by this pass + const InterfaceInfo *ItfImpl;// Interfaces implemented by this pass NormalCtor_t NormalCtor; @@ -116,13 +120,16 @@ public: /// template. /// void addInterfaceImplemented(const PassInfo *ItfPI) { - ItfImpl.push_back(ItfPI); + InterfaceInfo *NewInfo = new InterfaceInfo(); + NewInfo->interface = ItfPI; + NewInfo->next = ItfImpl; + ItfImpl = NewInfo; } /// getInterfacesImplemented - Return a list of all of the analysis group /// interfaces implemented by this pass. /// - const std::vector &getInterfacesImplemented() const { + const InterfaceInfo *getInterfacesImplemented() const { return ItfImpl; } diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp index 296b0d13a71..4cf5501379c 100644 --- a/lib/VMCore/PassManager.cpp +++ b/lib/VMCore/PassManager.cpp @@ -638,10 +638,14 @@ Pass *PMTopLevelManager::findAnalysisPass(AnalysisID AID) { // If Pass not found then check the interfaces implemented by Immutable Pass if (!P) { - const std::vector &ImmPI = - PI->getInterfacesImplemented(); - if (std::find(ImmPI.begin(), ImmPI.end(), AID) != ImmPI.end()) - P = *I; + const PassInfo::InterfaceInfo *ImmPI = PI->getInterfacesImplemented(); + while (ImmPI) { + if (ImmPI->interface == AID) { + P = *I; + break; + } else + ImmPI = ImmPI->next; + } } } @@ -731,9 +735,11 @@ void PMDataManager::recordAvailableAnalysis(Pass *P) { //This pass is the current implementation of all of the interfaces it //implements as well. - const std::vector &II = PI->getInterfacesImplemented(); - for (unsigned i = 0, e = II.size(); i != e; ++i) - AvailableAnalysis[II[i]] = P; + const PassInfo::InterfaceInfo *II = PI->getInterfacesImplemented(); + while (II) { + AvailableAnalysis[II->interface] = P; + II = II->next; + } } // Return true if P preserves high level analysis used by other @@ -867,12 +873,13 @@ void PMDataManager::freePass(Pass *P, StringRef Msg, // Remove all interfaces this pass implements, for which it is also // listed as the available implementation. - const std::vector &II = PI->getInterfacesImplemented(); - for (unsigned i = 0, e = II.size(); i != e; ++i) { + const PassInfo::InterfaceInfo *II = PI->getInterfacesImplemented(); + while (II) { std::map::iterator Pos = - AvailableAnalysis.find(II[i]); + AvailableAnalysis.find(II->interface); if (Pos != AvailableAnalysis.end() && Pos->second == P) AvailableAnalysis.erase(Pos); + II = II->next; } } }