]> granicus.if.org Git - llvm/commitdiff
[PM] Lift the analyses into the interface for
authorChandler Carruth <chandlerc@gmail.com>
Mon, 19 Jan 2015 03:03:39 +0000 (03:03 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Mon, 19 Jan 2015 03:03:39 +0000 (03:03 +0000)
SplitLandingPadPredecessors and remove the Pass argument from its
interface.

Another step to the utilities being usable with both old and new pass
managers.

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

include/llvm/Transforms/Utils/BasicBlockUtils.h
lib/Transforms/IPO/LoopExtractor.cpp
lib/Transforms/Scalar/LoopStrengthReduce.cpp
lib/Transforms/Scalar/LoopUnswitch.cpp
lib/Transforms/Utils/BasicBlockUtils.cpp
lib/Transforms/Utils/LoopSimplify.cpp
lib/Transforms/Utils/LoopUnrollRuntime.cpp

index a9b6b39c043c625e763c3d17b9305540b15b5eb8..da1988c3f2d6d9d641ed2fa840fbe4d5b2ae0912 100644 (file)
@@ -188,9 +188,14 @@ BasicBlock *SplitBlockPredecessors(BasicBlock *BB, ArrayRef<BasicBlock *> Preds,
 /// case where one of the edges being split is an exit of a loop with other
 /// exits).
 ///
-void SplitLandingPadPredecessors(BasicBlock *OrigBB,ArrayRef<BasicBlock*> Preds,
+void SplitLandingPadPredecessors(BasicBlock *OrigBB,
+                                 ArrayRef<BasicBlock *> Preds,
                                  const char *Suffix, const char *Suffix2,
-                                 Pass *P, SmallVectorImpl<BasicBlock*> &NewBBs);
+                                 SmallVectorImpl<BasicBlock *> &NewBBs,
+                                 AliasAnalysis *AA = nullptr,
+                                 DominatorTree *DT = nullptr,
+                                 LoopInfo *LI = nullptr,
+                                 bool PreserveLCSSA = false);
 
 /// FoldReturnIntoUncondBranch - This method duplicates the specified return
 /// instruction into a predecessor which ends in an unconditional branch. If
index 20414aa05b4dbf554be6bae3802f6e7873ac2f43..41334ca5b429864e3fa7a6d4695bac1460729a3e 100644 (file)
@@ -242,7 +242,7 @@ void BlockExtractorPass::SplitLandingPadPreds(Function *F) {
     if (!Split) continue;
 
     SmallVector<BasicBlock*, 2> NewBBs;
-    SplitLandingPadPredecessors(LPad, Parent, ".1", ".2", nullptr, NewBBs);
+    SplitLandingPadPredecessors(LPad, Parent, ".1", ".2", NewBBs);
   }
 }
 
index 250185cd3719d6505ea9ae398d222fa06e62bb52..629b0a2b3b005e6a10d69b5f6ae454ca958b26c9 100644 (file)
@@ -4733,7 +4733,8 @@ void LSRInstance::RewriteForPHI(PHINode *PN,
                                       /*DontDeleteUselessPhis=*/true);
           } else {
             SmallVector<BasicBlock*, 2> NewBBs;
-            SplitLandingPadPredecessors(Parent, BB, "", "", P, NewBBs);
+            SplitLandingPadPredecessors(Parent, BB, "", "", NewBBs,
+                                        /*AliasAnalysis*/ nullptr, &DT, &LI);
             NewBB = NewBBs[0];
           }
           // If NewBB==NULL, then SplitCriticalEdge refused to split because all
index cf80244bb77fb3b49f1fc4f9d896427d2c9be7f0..30d6d510acefec509ebcd5e269a8cee5c507cbd4 100644 (file)
@@ -775,7 +775,8 @@ void LoopUnswitch::SplitExitEdges(Loop *L,
     } else {
       SmallVector<BasicBlock*, 2> NewBBs;
       SplitLandingPadPredecessors(ExitBlock, Preds, ".us-lcssa", ".us-lcssa",
-                                  this, NewBBs);
+                                  NewBBs, /*AliasAnalysis*/ nullptr, DT, LI,
+                                  /*PreserveLCSSA*/ true);
     }
   }
 }
index c680788440490c67b7611b8a2554fdc092d1c886..c2304d7642bf559a118fc045157766a167817981 100644 (file)
@@ -523,10 +523,11 @@ BasicBlock *llvm::SplitBlockPredecessors(BasicBlock *BB,
 /// exits).
 ///
 void llvm::SplitLandingPadPredecessors(BasicBlock *OrigBB,
-                                       ArrayRef<BasicBlock*> Preds,
+                                       ArrayRef<BasicBlock *> Preds,
                                        const char *Suffix1, const char *Suffix2,
-                                       Pass *P,
-                                       SmallVectorImpl<BasicBlock*> &NewBBs) {
+                                       SmallVectorImpl<BasicBlock *> &NewBBs,
+                                       AliasAnalysis *AA, DominatorTree *DT,
+                                       LoopInfo *LI, bool PreserveLCSSA) {
   assert(OrigBB->isLandingPad() && "Trying to split a non-landing pad!");
 
   // Create a new basic block for OrigBB's predecessors listed in Preds. Insert
@@ -549,18 +550,11 @@ void llvm::SplitLandingPadPredecessors(BasicBlock *OrigBB,
     Preds[i]->getTerminator()->replaceUsesOfWith(OrigBB, NewBB1);
   }
 
-  // Update DominatorTree, LoopInfo, and LCCSA analysis information.
-  auto *DTWP = P->getAnalysisIfAvailable<DominatorTreeWrapperPass>();
-  auto *DT = DTWP ? &DTWP->getDomTree() : nullptr;
-  auto *LIWP = P->getAnalysisIfAvailable<LoopInfoWrapperPass>();
-  auto *LI = LIWP ? &LIWP->getLoopInfo() : nullptr;
-  bool PreserveLCSSA = P->mustPreserveAnalysisID(LCSSAID);
   bool HasLoopExit = false;
   UpdateAnalysisInformation(OrigBB, NewBB1, Preds, DT, LI, PreserveLCSSA,
                             HasLoopExit);
 
   // Update the PHI nodes in OrigBB with the values coming from NewBB1.
-  AliasAnalysis *AA = P ? P->getAnalysisIfAvailable<AliasAnalysis>() : nullptr;
   UpdatePHINodes(OrigBB, NewBB1, Preds, BI1, AA, HasLoopExit);
 
   // Move the remaining edges from OrigBB to point to NewBB2.
index 926c3a7fae2e8086ba703f21343a4d7dd63834e5..725188d1bc26ec83a6f17662796573c37422d9d2 100644 (file)
@@ -145,7 +145,7 @@ BasicBlock *llvm::InsertPreheaderForLoop(Loop *L, Pass *PP) {
   } else {
     SmallVector<BasicBlock*, 2> NewBBs;
     SplitLandingPadPredecessors(Header, OutsideBlocks, ".preheader",
-                                ".split-lp", PP, NewBBs);
+                                ".split-lp", NewBBs, AA, DT, LI, PreserveLCSSA);
     PreheaderBB = NewBBs[0];
   }
 
@@ -186,9 +186,8 @@ static BasicBlock *rewriteLoopExitBlock(Loop *L, BasicBlock *Exit,
 
   if (Exit->isLandingPad()) {
     SmallVector<BasicBlock*, 2> NewBBs;
-    SplitLandingPadPredecessors(Exit, LoopBlocks,
-                                ".loopexit", ".nonloopexit",
-                                PP, NewBBs);
+    SplitLandingPadPredecessors(Exit, LoopBlocks, ".loopexit", ".nonloopexit",
+                                NewBBs, AA, DT, LI, PreserveLCSSA);
     NewExitBB = NewBBs[0];
   } else {
     NewExitBB = SplitBlockPredecessors(Exit, LoopBlocks, ".loopexit", AA, DT,
index 82b4f0922a2786dce27694cbd1daa5a1efcb5459..2a8c20d6b1f8056d0de474da40b0ece50cc53aef 100644 (file)
@@ -125,7 +125,8 @@ static void ConnectProlog(Loop *L, Value *TripCount, unsigned Count,
   } else {
     SmallVector<BasicBlock*, 2> NewBBs;
     SplitLandingPadPredecessors(Exit, Preds, ".unr1-lcssa", ".unr2-lcssa",
-                                P, NewBBs);
+                                NewBBs, AA, DT, LI,
+                                P->mustPreserveAnalysisID(LCSSAID));
   }
   // Add the branch to the exit block (around the unrolled loop)
   BranchInst::Create(Exit, NewPH, BrLoopExit, InsertPt);