From: Chris Lattner Date: Mon, 10 Nov 2003 04:10:50 +0000 (+0000) Subject: Adjust to new critical edge interface X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d23520cd9403c3c6fe8e7ea974ae0b593772345c;p=oota-llvm.git Adjust to new critical edge interface git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9853 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/CorrelatedExprs.cpp b/lib/Transforms/Scalar/CorrelatedExprs.cpp index 8e6a2ae5b84..aad9b7f3096 100644 --- a/lib/Transforms/Scalar/CorrelatedExprs.cpp +++ b/lib/Transforms/Scalar/CorrelatedExprs.cpp @@ -29,13 +29,12 @@ #include "llvm/Transforms/Scalar.h" #include "llvm/Pass.h" #include "llvm/Function.h" -#include "llvm/iTerminators.h" -#include "llvm/iPHINode.h" -#include "llvm/iOperators.h" +#include "llvm/Instructions.h" #include "llvm/ConstantHandling.h" -#include "llvm/Assembly/Writer.h" #include "llvm/Analysis/Dominators.h" +#include "llvm/Assembly/Writer.h" #include "llvm/Transforms/Utils/Local.h" +#include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Support/ConstantRange.h" #include "llvm/Support/CFG.h" #include "Support/Debug.h" @@ -605,8 +604,7 @@ void CEE::ForwardSuccessorTo(TerminatorInst *TI, unsigned SuccNo, // If we just introduced a critical edge in the flow graph, make sure to break // it right away... - if (isCriticalEdge(TI, SuccNo)) - SplitCriticalEdge(TI, SuccNo, this); + SplitCriticalEdge(TI, SuccNo, this); // Make sure that we don't introduce critical edges from oldsucc now! for (unsigned i = 0, e = OldSucc->getTerminator()->getNumSuccessors(); diff --git a/lib/Transforms/Utils/BreakCriticalEdges.cpp b/lib/Transforms/Utils/BreakCriticalEdges.cpp index 8f8f0eea2da..5d31016fe8b 100644 --- a/lib/Transforms/Utils/BreakCriticalEdges.cpp +++ b/lib/Transforms/Utils/BreakCriticalEdges.cpp @@ -16,6 +16,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Transforms/Scalar.h" +#include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Analysis/Dominators.h" #include "llvm/Function.h" #include "llvm/iTerminators.h" @@ -66,13 +67,14 @@ bool isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum) { return I != E; } -// SplitCriticalEdge - Insert a new node node to split the critical edge. This -// will update DominatorSet, ImmediateDominator and DominatorTree information if -// it is available, thus calling this pass will not invalidate either of them. +// SplitCriticalEdge - If this edge is a critical edge, insert a new node to +// split the critical edge. This will update DominatorSet, ImmediateDominator, +// DominatorTree, and DominatorFrontier information if it is available, thus +// calling this pass will not invalidate either of them. This returns true if +// the edge was split, false otherwise. // -void SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P) { - assert(isCriticalEdge(TI, SuccNum) && - "Cannot break a critical edge, if it isn't a critical edge"); +bool SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P) { + if (!isCriticalEdge(TI, SuccNum)) return false; BasicBlock *TIBB = TI->getParent(); BasicBlock *DestBB = TI->getSuccessor(SuccNum); @@ -100,7 +102,7 @@ void SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P) { } // If we don't have a pass object, we can't update anything... - if (P == 0) return; + if (P == 0) return true; // Now update analysis information. These are the analyses that we are // currently capable of updating... @@ -142,6 +144,7 @@ void SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P) { NewDFSet.insert(DestBB); DF->addBasicBlock(NewBB, NewDFSet); } + return true; } // runOnFunction - Loop over all of the edges in the CFG, breaking critical @@ -153,8 +156,7 @@ bool BreakCriticalEdges::runOnFunction(Function &F) { TerminatorInst *TI = I->getTerminator(); if (TI->getNumSuccessors() > 1) for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i) - if (isCriticalEdge(TI, i)) { - SplitCriticalEdge(TI, i, this); + if (SplitCriticalEdge(TI, i, this)) { ++NumBroken; Changed = true; }