]> granicus.if.org Git - llvm/commitdiff
[LegacyPassManager] Attempt to fix BasicBlockManager
authorAlina Sbirlea <asbirlea@google.com>
Mon, 30 Sep 2019 17:23:49 +0000 (17:23 +0000)
committerAlina Sbirlea <asbirlea@google.com>
Mon, 30 Sep 2019 17:23:49 +0000 (17:23 +0000)
Temporarily fix BaiscBlockManager based on the code in the other
managers.
Replacement of all uses of the BasicBlockPass to follow.

Resolves PR42264.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373235 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Pass.h
lib/IR/LegacyPassManager.cpp

index 329f7eaba73dddd30ca707d99d1e89a75a481ed3..d36555cc7e729368b05b7c1989b8b8b98faa203f 100644 (file)
@@ -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.
index f03df2dec7c46213b26d6a8d73c4a97068764577..3a03c493100b4426599b07da9a7d1d34752d2313 100644 (file)
@@ -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
@@ -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