[llvm] r237176 - [PlaceSafepoints] Use analysis infrastructure to get dominator tree

Philip Reames listmail at philipreames.com
Tue May 12 13:56:33 PDT 2015


Author: reames
Date: Tue May 12 15:56:33 2015
New Revision: 237176

URL: http://llvm.org/viewvc/llvm-project?rev=237176&view=rev
Log:
[PlaceSafepoints] Use analysis infrastructure to get dominator tree

The old code computed dominators for every loop. This was terribly slow with no good reason. Just use the standard infrastructure for analysis passes.

Differential Revision: http://reviews.llvm.org/D9586


Modified:
    llvm/trunk/lib/Transforms/Scalar/PlaceSafepoints.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/PlaceSafepoints.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/PlaceSafepoints.cpp?rev=237176&r1=237175&r2=237176&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/PlaceSafepoints.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/PlaceSafepoints.cpp Tue May 12 15:56:33 2015
@@ -130,6 +130,7 @@ struct PlaceBackedgeSafepointsImpl : pub
   bool runOnLoop(Loop *, LPPassManager &LPM) override;
 
   void getAnalysisUsage(AnalysisUsage &AU) const override {
+    AU.addRequired<DominatorTreeWrapperPass>();
     AU.addRequired<ScalarEvolution>();
     // We no longer modify the IR at all in this pass.  Thus all
     // analysis are preserved.
@@ -312,6 +313,7 @@ static void scanInlinedCode(Instruction
 
 bool PlaceBackedgeSafepointsImpl::runOnLoop(Loop *L, LPPassManager &LPM) {
   ScalarEvolution *SE = &getAnalysis<ScalarEvolution>();
+  DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
 
   // Loop through all loop latches (branches controlling backedges).  We need
   // to place a safepoint on every backedge (potentially). 
@@ -320,11 +322,6 @@ bool PlaceBackedgeSafepointsImpl::runOnL
   // w.r.t. loops with multiple backedges.
   BasicBlock *header = L->getHeader();
 
-  // TODO: Use the analysis pass infrastructure for this.  There is no reason
-  // to recalculate this here.
-  DominatorTree DT;
-  DT.recalculate(*header->getParent());
-
   SmallVector<BasicBlock*, 16> LoopLatches;
   L->getLoopLatches(LoopLatches);
   for (BasicBlock *pred : LoopLatches) {
@@ -341,7 +338,7 @@ bool PlaceBackedgeSafepointsImpl::runOnL
         continue;
       }
       if (CallSafepointsEnabled &&
-          containsUnconditionalCallSafepoint(L, header, pred, DT)) {
+          containsUnconditionalCallSafepoint(L, header, pred, *DT)) {
         // Note: This is only semantically legal since we won't do any further
         // IPO or inlining before the actual call insertion..  If we hadn't, we
         // might latter loose this call safepoint.
@@ -746,6 +743,7 @@ INITIALIZE_PASS_BEGIN(PlaceBackedgeSafep
                       "place-backedge-safepoints-impl",
                       "Place Backedge Safepoints", false, false)
 INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
+INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
 INITIALIZE_PASS_END(PlaceBackedgeSafepointsImpl,
                     "place-backedge-safepoints-impl",
                     "Place Backedge Safepoints", false, false)





More information about the llvm-commits mailing list