Skip to content

Commit

Permalink
[LegacyPassManager] Attempt to fix BasicBlockManager
Browse files Browse the repository at this point in the history
Temporarily fix BaiscBlockManager based on the code in the other
managers.
Replacement of all uses of the BasicBlockPass to follow.

Resolves PR42264.

llvm-svn: 373235
  • Loading branch information
alinas committed Sep 30, 2019
1 parent 299ebac commit ad88884
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions llvm/include/llvm/Pass.h
Expand Up @@ -338,6 +338,8 @@ class BasicBlockPass : public Pass {
/// do any post processing needed after all passes have run.
virtual bool doFinalization(Function &);

void preparePassManager(PMStack &PMS) override;

void assignPassManager(PMStack &PMS, PassManagerType T) override;

/// Return what kind of Pass Manager can manage this pass.
Expand Down
19 changes: 19 additions & 0 deletions llvm/lib/IR/LegacyPassManager.cpp
Expand Up @@ -1998,10 +1998,28 @@ void FunctionPass::assignPassManager(PMStack &PMS,
FPP->add(this);
}

void BasicBlockPass::preparePassManager(PMStack &PMS) {
// Find BBPassManager
while (!PMS.empty() &&
PMS.top()->getPassManagerType() > PMT_BasicBlockPassManager)
PMS.pop();

// If this pass is destroying high level information that is used
// by other passes that are managed by BBPM then do not insert
// this pass in current BBPM. Use new BBPassManager.
if (PMS.top()->getPassManagerType() == PMT_BasicBlockPassManager &&
!PMS.top()->preserveHigherLevelAnalysis(this))
PMS.pop();
}

/// Find appropriate Basic Pass Manager or Call Graph Pass Manager
/// in the PM Stack and add self into that manager.
void BasicBlockPass::assignPassManager(PMStack &PMS,
PassManagerType PreferredType) {
while (!PMS.empty() &&
PMS.top()->getPassManagerType() > PMT_BasicBlockPassManager)
PMS.pop();

BBPassManager *BBP;

// Basic Pass Manager is a leaf pass manager. It does not handle
Expand All @@ -2017,6 +2035,7 @@ void BasicBlockPass::assignPassManager(PMStack &PMS,

// [1] Create new Basic Block Manager
BBP = new BBPassManager();
BBP->populateInheritedAnalysis(PMS);

// [2] Set up new manager's top level manager
// Basic Block Pass Manager does not live by itself
Expand Down

0 comments on commit ad88884

Please sign in to comment.