Adjust to new critical edge interface

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9853 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-11-10 04:10:50 +00:00
parent d9c5c5e12f
commit d23520cd94
2 changed files with 15 additions and 15 deletions

View File

@ -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();

View File

@ -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;
}