[llvm] r373235 - [LegacyPassManager] Attempt to fix BasicBlockManager
Alina Sbirlea via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 30 10:23:50 PDT 2019
Author: asbirlea
Date: Mon Sep 30 10:23:49 2019
New Revision: 373235
URL: http://llvm.org/viewvc/llvm-project?rev=373235&view=rev
Log:
[LegacyPassManager] Attempt to fix BasicBlockManager
Temporarily fix BaiscBlockManager based on the code in the other
managers.
Replacement of all uses of the BasicBlockPass to follow.
Resolves PR42264.
Modified:
llvm/trunk/include/llvm/Pass.h
llvm/trunk/lib/IR/LegacyPassManager.cpp
Modified: llvm/trunk/include/llvm/Pass.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Pass.h?rev=373235&r1=373234&r2=373235&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Pass.h (original)
+++ llvm/trunk/include/llvm/Pass.h Mon Sep 30 10:23:49 2019
@@ -338,6 +338,8 @@ public:
/// 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.
Modified: llvm/trunk/lib/IR/LegacyPassManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LegacyPassManager.cpp?rev=373235&r1=373234&r2=373235&view=diff
==============================================================================
--- llvm/trunk/lib/IR/LegacyPassManager.cpp (original)
+++ llvm/trunk/lib/IR/LegacyPassManager.cpp Mon Sep 30 10:23:49 2019
@@ -1998,10 +1998,28 @@ void FunctionPass::assignPassManager(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
@@ -2017,6 +2035,7 @@ void BasicBlockPass::assignPassManager(P
// [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
More information about the llvm-commits
mailing list