diff options
author | Brian Gaeke <gaeke@uiuc.edu> | 2004-07-23 19:35:50 +0000 |
---|---|---|
committer | Brian Gaeke <gaeke@uiuc.edu> | 2004-07-23 19:35:50 +0000 |
commit | 7ff4006f82e0ff65d1ab43c8a50a38da2860cfac (patch) | |
tree | e0741ec95ee27c0bb84e24e20f04ed879768f415 /lib/VMCore/PassManagerT.h | |
parent | aa14147cd6401e9c66dc9f81d1a47a90a5477159 (diff) | |
download | external_llvm-7ff4006f82e0ff65d1ab43c8a50a38da2860cfac.zip external_llvm-7ff4006f82e0ff65d1ab43c8a50a38da2860cfac.tar.gz external_llvm-7ff4006f82e0ff65d1ab43c8a50a38da2860cfac.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15140 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/PassManagerT.h')
-rw-r--r-- | lib/VMCore/PassManagerT.h | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/VMCore/PassManagerT.h b/lib/VMCore/PassManagerT.h index 463888a..6c60a2d 100644 --- a/lib/VMCore/PassManagerT.h +++ b/lib/VMCore/PassManagerT.h @@ -454,8 +454,12 @@ public: // 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 @@ public: // 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. |