[llvm-commits] CVS: llvm/lib/VMCore/PassManagerT.h

Chris Lattner lattner at cs.uiuc.edu
Thu Apr 24 15:08:01 PDT 2003


Changes in directory llvm/lib/VMCore:

PassManagerT.h updated: 1.37 -> 1.38

---
Log message:

Fix a nasty bug where the ConstantMerge pass was invalidating the TargetData pass
even though it was immutable.  Immutable passes should never end up in CurrentAnalyses!


---
Diffs of the changes:

Index: llvm/lib/VMCore/PassManagerT.h
diff -u llvm/lib/VMCore/PassManagerT.h:1.37 llvm/lib/VMCore/PassManagerT.h:1.38
--- llvm/lib/VMCore/PassManagerT.h:1.37	Wed Feb 26 13:10:57 2003
+++ llvm/lib/VMCore/PassManagerT.h	Thu Apr 24 15:07:38 2003
@@ -332,12 +332,32 @@
     }
   }
 
+  Pass *getImmutablePassOrNull(const PassInfo *ID) const {
+    for (unsigned i = 0, e = ImmutablePasses.size(); i != e; ++i) {
+      const PassInfo *IPID = ImmutablePasses[i]->getPassInfo();
+      if (IPID == ID)
+        return ImmutablePasses[i];
+      
+      // This pass is the current implementation of all of the interfaces it
+      // implements as well.
+      //
+      const std::vector<const PassInfo*> &II =
+        IPID->getInterfacesImplemented();
+      for (unsigned j = 0, e = II.size(); j != e; ++j)
+        if (II[j] == ID) return ImmutablePasses[i];
+    }
+    return 0;
+  }
+
   Pass *getAnalysisOrNullDown(const PassInfo *ID) const {
     std::map<AnalysisID, Pass*>::const_iterator I = CurrentAnalyses.find(ID);
 
     if (I != CurrentAnalyses.end())
       return I->second;  // Found it.
 
+    if (Pass *P = getImmutablePassOrNull(ID))
+      return P;
+
     if (Batcher)
       return ((AnalysisResolver*)Batcher)->getAnalysisOrNullDown(ID);
     return 0;
@@ -350,6 +370,8 @@
 
     if (Parent)          // Try scanning...
       return Parent->getAnalysisOrNullUp(ID);
+    else if (!ImmutablePasses.empty())
+      return getImmutablePassOrNull(ID);
     return 0;
   }
 
@@ -386,7 +408,9 @@
       if (Parent) {
         Parent->markPassUsed(P, this);
       } else {
-        assert(0 && "Pass available but not found! "
+        assert(getAnalysisOrNullUp(P) && 
+               dynamic_cast<ImmutablePass*>(getAnalysisOrNullUp(P)) &&
+               "Pass available but not found! "
                "Perhaps this is a module pass requiring a function pass?");
       }
     }
@@ -556,18 +580,6 @@
     
     // Initialize the immutable pass...
     IP->initializePass();
-
-    // Add this pass to the currently available set...
-    if (const PassInfo *PI = IP->getPassInfo()) {
-      CurrentAnalyses[PI] = IP;
-
-      // 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)
-        CurrentAnalyses[II[i]] = IP;
-    }
   }
 };
 





More information about the llvm-commits mailing list