mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 21:29:20 +00:00
Expose isCriticalEdge & SplitCriticalEdge methods from crit-edges pass
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4075 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7ca266fe1f
commit
e802a023d9
@ -11,6 +11,7 @@
|
||||
class Pass;
|
||||
class GetElementPtrInst;
|
||||
class PassInfo;
|
||||
class TerminatorInst;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
@ -188,6 +189,21 @@ Pass *createCFGSimplificationPass();
|
||||
Pass *createBreakCriticalEdgesPass();
|
||||
extern const PassInfo *BreakCriticalEdgesID;
|
||||
|
||||
// The BreakCriticalEdges pass also exposes some low-level functionality that
|
||||
// may be used by other passes.
|
||||
|
||||
/// isCriticalEdge - Return true if the specified edge is a critical edge.
|
||||
/// Critical edges are edges from a block with multiple successors to a block
|
||||
/// with multiple predecessors.
|
||||
///
|
||||
bool isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum);
|
||||
|
||||
/// SplitCriticalEdge - Insert a new node node to split the critical edge. This
|
||||
/// will update DominatorSet, ImmediateDominator and DominatorTree information
|
||||
/// if a pass is specified, thus calling this pass will not invalidate these
|
||||
/// analyses.
|
||||
///
|
||||
void SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P = 0);
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
|
@ -28,8 +28,6 @@ namespace {
|
||||
AU.addPreserved<DominatorTree>();
|
||||
AU.addPreservedID(LoopPreheadersID); // No preheaders deleted.
|
||||
}
|
||||
private:
|
||||
void SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum);
|
||||
};
|
||||
|
||||
RegisterOpt<BreakCriticalEdges> X("break-crit-edges",
|
||||
@ -45,9 +43,9 @@ Pass *createBreakCriticalEdgesPass() { return new BreakCriticalEdges(); }
|
||||
// Critical edges are edges from a block with multiple successors to a block
|
||||
// with multiple predecessors.
|
||||
//
|
||||
static bool isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum) {
|
||||
bool isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum) {
|
||||
assert(SuccNum < TI->getNumSuccessors() && "Illegal edge specification!");
|
||||
assert (TI->getNumSuccessors() > 1);
|
||||
if (TI->getNumSuccessors() == 1) return false;
|
||||
|
||||
const BasicBlock *Dest = TI->getSuccessor(SuccNum);
|
||||
pred_const_iterator I = pred_begin(Dest), E = pred_end(Dest);
|
||||
@ -62,7 +60,7 @@ static bool isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum) {
|
||||
// will update DominatorSet, ImmediateDominator and DominatorTree information if
|
||||
// it is available, thus calling this pass will not invalidate either of them.
|
||||
//
|
||||
void BreakCriticalEdges::SplitCriticalEdge(TerminatorInst *TI,unsigned SuccNum){
|
||||
void SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P) {
|
||||
assert(isCriticalEdge(TI, SuccNum) &&
|
||||
"Cannot break a critical edge, if it isn't a critical edge");
|
||||
BasicBlock *TIBB = TI->getParent();
|
||||
@ -90,12 +88,15 @@ void BreakCriticalEdges::SplitCriticalEdge(TerminatorInst *TI,unsigned SuccNum){
|
||||
PN->replaceUsesOfWith(TIBB, NewBB);
|
||||
}
|
||||
|
||||
// If we don't have a pass object, we can't update anything...
|
||||
if (P == 0) return;
|
||||
|
||||
// Now update analysis information. These are the analyses that we are
|
||||
// currently capable of updating...
|
||||
//
|
||||
|
||||
// Should we update DominatorSet information?
|
||||
if (DominatorSet *DS = getAnalysisToUpdate<DominatorSet>()) {
|
||||
if (DominatorSet *DS = P->getAnalysisToUpdate<DominatorSet>()) {
|
||||
// The blocks that dominate the new one are the blocks that dominate TIBB
|
||||
// plus the new block itself.
|
||||
DominatorSet::DomSetType DomSet = DS->getDominators(TIBB);
|
||||
@ -104,14 +105,14 @@ void BreakCriticalEdges::SplitCriticalEdge(TerminatorInst *TI,unsigned SuccNum){
|
||||
}
|
||||
|
||||
// Should we update ImmdediateDominator information?
|
||||
if (ImmediateDominators *ID = getAnalysisToUpdate<ImmediateDominators>()) {
|
||||
if (ImmediateDominators *ID = P->getAnalysisToUpdate<ImmediateDominators>()) {
|
||||
// TIBB is the new immediate dominator for NewBB. NewBB doesn't dominate
|
||||
// anything.
|
||||
ID->addNewBlock(NewBB, TIBB);
|
||||
}
|
||||
|
||||
// Should we update DominatorTree information?
|
||||
if (DominatorTree *DT = getAnalysisToUpdate<DominatorTree>()) {
|
||||
if (DominatorTree *DT = P->getAnalysisToUpdate<DominatorTree>()) {
|
||||
DominatorTree::Node *TINode = DT->getNode(TIBB);
|
||||
|
||||
// The new block is not the immediate dominator for any other nodes, but
|
||||
@ -131,7 +132,7 @@ bool BreakCriticalEdges::runOnFunction(Function &F) {
|
||||
if (TI->getNumSuccessors() > 1)
|
||||
for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i)
|
||||
if (isCriticalEdge(TI, i)) {
|
||||
SplitCriticalEdge(TI, i);
|
||||
SplitCriticalEdge(TI, i, this);
|
||||
++NumBroken;
|
||||
Changed = true;
|
||||
}
|
||||
|
@ -28,8 +28,6 @@ namespace {
|
||||
AU.addPreserved<DominatorTree>();
|
||||
AU.addPreservedID(LoopPreheadersID); // No preheaders deleted.
|
||||
}
|
||||
private:
|
||||
void SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum);
|
||||
};
|
||||
|
||||
RegisterOpt<BreakCriticalEdges> X("break-crit-edges",
|
||||
@ -45,9 +43,9 @@ Pass *createBreakCriticalEdgesPass() { return new BreakCriticalEdges(); }
|
||||
// Critical edges are edges from a block with multiple successors to a block
|
||||
// with multiple predecessors.
|
||||
//
|
||||
static bool isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum) {
|
||||
bool isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum) {
|
||||
assert(SuccNum < TI->getNumSuccessors() && "Illegal edge specification!");
|
||||
assert (TI->getNumSuccessors() > 1);
|
||||
if (TI->getNumSuccessors() == 1) return false;
|
||||
|
||||
const BasicBlock *Dest = TI->getSuccessor(SuccNum);
|
||||
pred_const_iterator I = pred_begin(Dest), E = pred_end(Dest);
|
||||
@ -62,7 +60,7 @@ static bool isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum) {
|
||||
// will update DominatorSet, ImmediateDominator and DominatorTree information if
|
||||
// it is available, thus calling this pass will not invalidate either of them.
|
||||
//
|
||||
void BreakCriticalEdges::SplitCriticalEdge(TerminatorInst *TI,unsigned SuccNum){
|
||||
void SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P) {
|
||||
assert(isCriticalEdge(TI, SuccNum) &&
|
||||
"Cannot break a critical edge, if it isn't a critical edge");
|
||||
BasicBlock *TIBB = TI->getParent();
|
||||
@ -90,12 +88,15 @@ void BreakCriticalEdges::SplitCriticalEdge(TerminatorInst *TI,unsigned SuccNum){
|
||||
PN->replaceUsesOfWith(TIBB, NewBB);
|
||||
}
|
||||
|
||||
// If we don't have a pass object, we can't update anything...
|
||||
if (P == 0) return;
|
||||
|
||||
// Now update analysis information. These are the analyses that we are
|
||||
// currently capable of updating...
|
||||
//
|
||||
|
||||
// Should we update DominatorSet information?
|
||||
if (DominatorSet *DS = getAnalysisToUpdate<DominatorSet>()) {
|
||||
if (DominatorSet *DS = P->getAnalysisToUpdate<DominatorSet>()) {
|
||||
// The blocks that dominate the new one are the blocks that dominate TIBB
|
||||
// plus the new block itself.
|
||||
DominatorSet::DomSetType DomSet = DS->getDominators(TIBB);
|
||||
@ -104,14 +105,14 @@ void BreakCriticalEdges::SplitCriticalEdge(TerminatorInst *TI,unsigned SuccNum){
|
||||
}
|
||||
|
||||
// Should we update ImmdediateDominator information?
|
||||
if (ImmediateDominators *ID = getAnalysisToUpdate<ImmediateDominators>()) {
|
||||
if (ImmediateDominators *ID = P->getAnalysisToUpdate<ImmediateDominators>()) {
|
||||
// TIBB is the new immediate dominator for NewBB. NewBB doesn't dominate
|
||||
// anything.
|
||||
ID->addNewBlock(NewBB, TIBB);
|
||||
}
|
||||
|
||||
// Should we update DominatorTree information?
|
||||
if (DominatorTree *DT = getAnalysisToUpdate<DominatorTree>()) {
|
||||
if (DominatorTree *DT = P->getAnalysisToUpdate<DominatorTree>()) {
|
||||
DominatorTree::Node *TINode = DT->getNode(TIBB);
|
||||
|
||||
// The new block is not the immediate dominator for any other nodes, but
|
||||
@ -131,7 +132,7 @@ bool BreakCriticalEdges::runOnFunction(Function &F) {
|
||||
if (TI->getNumSuccessors() > 1)
|
||||
for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i)
|
||||
if (isCriticalEdge(TI, i)) {
|
||||
SplitCriticalEdge(TI, i);
|
||||
SplitCriticalEdge(TI, i, this);
|
||||
++NumBroken;
|
||||
Changed = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user