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

Brian Gaeke gaeke at cs.uiuc.edu
Fri Jul 23 12:36:01 PDT 2004



Changes in directory llvm/lib/VMCore:

PassManagerT.h updated: 1.50 -> 1.51

---
Log message:

Fix problem with inserting FunctionPasses that depend on ImmutablePasses
(e.g., LICM) into FunctionPassManagers. The problem is that we were
using a C-style cast to cast required analysis passes to PassClass*, but
if it's a FunctionPassManager, and the required analysis pass is an
ImmutablePass, the types aren't really compatible, so the C-style cast
causes a crash.


---
Diffs of the changes:  (+12 -4)

Index: llvm/lib/VMCore/PassManagerT.h
diff -u llvm/lib/VMCore/PassManagerT.h:1.50 llvm/lib/VMCore/PassManagerT.h:1.51
--- llvm/lib/VMCore/PassManagerT.h:1.50	Thu Jul 15 19:07:44 2004
+++ llvm/lib/VMCore/PassManagerT.h	Fri Jul 23 14:35:50 2004
@@ -454,8 +454,12 @@
     // Loop over all of the analyses used by this pass,
     for (std::vector<AnalysisID>::const_iterator I = Required.begin(),
            E = Required.end(); I != E; ++I) {
-      if (getAnalysisOrNullDown(*I) == 0)
-        add((PassClass*)(*I)->createPass());
+      if (getAnalysisOrNullDown(*I) == 0) {
+        Pass *AP = (*I)->createPass();
+        if (ImmutablePass *IP = dynamic_cast<ImmutablePass *> (AP)) { add(IP); }
+        else if (PassClass *RP = dynamic_cast<PassClass *> (AP)) { add(RP); }
+        else { assert (0 && "Wrong kind of pass for this PassManager"); }
+      }
     }
 
     // Tell the pass to add itself to this PassManager... the way it does so
@@ -477,8 +481,12 @@
     // Loop over all of the analyses used by this pass,
     for (std::vector<AnalysisID>::const_iterator I = Required.begin(),
            E = Required.end(); I != E; ++I) {
-      if (getAnalysisOrNullDown(*I) == 0)
-        add((PassClass*)(*I)->createPass());
+      if (getAnalysisOrNullDown(*I) == 0) {
+        Pass *AP = (*I)->createPass();
+        if (ImmutablePass *IP = dynamic_cast<ImmutablePass *> (AP)) add(IP);
+        else if (PassClass *RP = dynamic_cast<PassClass *> (AP)) add(RP);
+        else assert (0 && "Wrong kind of pass for this PassManager");
+      }
     }
 
     // Add the ImmutablePass to this PassManager.





More information about the llvm-commits mailing list