[llvm-commits] [llvm] r108755 - in /llvm/trunk: include/llvm/PassSupport.h lib/VMCore/PassManager.cpp
Owen Anderson
resistor at mac.com
Mon Jul 19 14:44:49 PDT 2010
Author: resistor
Date: Mon Jul 19 16:44:48 2010
New Revision: 108755
URL: http://llvm.org/viewvc/llvm-project?rev=108755&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/PassSupport.h
llvm/trunk/lib/VMCore/PassManager.cpp
Modified: llvm/trunk/include/llvm/PassSupport.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/PassSupport.h?rev=108755&r1=108754&r2=108755&view=diff
==============================================================================
--- llvm/trunk/include/llvm/PassSupport.h (original)
+++ llvm/trunk/include/llvm/PassSupport.h Mon Jul 19 16:44:48 2010
@@ -36,6 +36,10 @@
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 @@
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<const PassInfo*> ItfImpl;// Interfaces implemented by this pass
+ const InterfaceInfo *ItfImpl;// Interfaces implemented by this pass
NormalCtor_t NormalCtor;
@@ -116,13 +120,16 @@
/// 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<const PassInfo*> &getInterfacesImplemented() const {
+ const InterfaceInfo *getInterfacesImplemented() const {
return ItfImpl;
}
Modified: llvm/trunk/lib/VMCore/PassManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=108755&r1=108754&r2=108755&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/PassManager.cpp (original)
+++ llvm/trunk/lib/VMCore/PassManager.cpp Mon Jul 19 16:44:48 2010
@@ -638,10 +638,14 @@
// If Pass not found then check the interfaces implemented by Immutable Pass
if (!P) {
- const std::vector<const PassInfo*> &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 @@
//This pass is the current implementation of all of the interfaces it
//implements as well.
- const std::vector<const PassInfo*> &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 @@
// Remove all interfaces this pass implements, for which it is also
// listed as the available implementation.
- const std::vector<const PassInfo*> &II = PI->getInterfacesImplemented();
- for (unsigned i = 0, e = II.size(); i != e; ++i) {
+ const PassInfo::InterfaceInfo *II = PI->getInterfacesImplemented();
+ while (II) {
std::map<AnalysisID, Pass*>::iterator Pos =
- AvailableAnalysis.find(II[i]);
+ AvailableAnalysis.find(II->interface);
if (Pos != AvailableAnalysis.end() && Pos->second == P)
AvailableAnalysis.erase(Pos);
+ II = II->next;
}
}
}
More information about the llvm-commits
mailing list