Skip to content

Commit

Permalink
Fix a (legacy) PassManager crash that occurs when a ModulePass
Browse files Browse the repository at this point in the history
indirectly requires a function analysis.

This bug was reported by Jason Kim. He included a test case here:
http://reviews.llvm.org/D3312

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205753 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
atrick committed Apr 8, 2014
1 parent 2424511 commit 3c1f2eb
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions lib/IR/LegacyPassManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1657,6 +1657,8 @@ void MPPassManager::addLowerLevelRequiredPass(Pass *P, Pass *RequiredPass) {
assert((P->getPotentialPassManagerType() <
RequiredPass->getPotentialPassManagerType()) &&
"Unable to handle Pass that requires lower level Analysis pass");
if (!RequiredPass)
return;

FunctionPassManagerImpl *FPP = OnTheFlyManagers[P];
if (!FPP) {
Expand All @@ -1666,14 +1668,24 @@ void MPPassManager::addLowerLevelRequiredPass(Pass *P, Pass *RequiredPass) {

OnTheFlyManagers[P] = FPP;
}
FPP->add(RequiredPass);
const PassInfo * RequiredPassPI =
PassRegistry::getPassRegistry()->getPassInfo(RequiredPass->getPassID());

// Register P as the last user of RequiredPass.
if (RequiredPass) {
SmallVector<Pass *, 1> LU;
LU.push_back(RequiredPass);
FPP->setLastUser(LU, P);
Pass *FoundPass = NULL;
if (RequiredPassPI && RequiredPassPI->isAnalysis()) {
FoundPass =
((PMTopLevelManager*)FPP)->findAnalysisPass(RequiredPass->getPassID());
}
if (!FoundPass) {
FoundPass = RequiredPass;
// This should be guaranteed to add RequiredPass to the passmanager given
// that we checked for an avaiable analysis above.
FPP->add(RequiredPass);
}
// Register P as the last user of FoundPass or RequiredPass.
SmallVector<Pass *, 1> LU;
LU.push_back(FoundPass);
FPP->setLastUser(LU, P);
}

/// Return function pass corresponding to PassInfo PI, that is
Expand Down

0 comments on commit 3c1f2eb

Please sign in to comment.