mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
Fix a (legacy) PassManager crash that occurs when a ModulePass
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
This commit is contained in:
parent
2424511b6f
commit
3c1f2eb75d
@ -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) {
|
||||
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user