mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-01 00:33:09 +00:00
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:
parent
d9c5c5e12f
commit
d23520cd94
@ -29,13 +29,12 @@
|
|||||||
#include "llvm/Transforms/Scalar.h"
|
#include "llvm/Transforms/Scalar.h"
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/Function.h"
|
#include "llvm/Function.h"
|
||||||
#include "llvm/iTerminators.h"
|
#include "llvm/Instructions.h"
|
||||||
#include "llvm/iPHINode.h"
|
|
||||||
#include "llvm/iOperators.h"
|
|
||||||
#include "llvm/ConstantHandling.h"
|
#include "llvm/ConstantHandling.h"
|
||||||
#include "llvm/Assembly/Writer.h"
|
|
||||||
#include "llvm/Analysis/Dominators.h"
|
#include "llvm/Analysis/Dominators.h"
|
||||||
|
#include "llvm/Assembly/Writer.h"
|
||||||
#include "llvm/Transforms/Utils/Local.h"
|
#include "llvm/Transforms/Utils/Local.h"
|
||||||
|
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
|
||||||
#include "llvm/Support/ConstantRange.h"
|
#include "llvm/Support/ConstantRange.h"
|
||||||
#include "llvm/Support/CFG.h"
|
#include "llvm/Support/CFG.h"
|
||||||
#include "Support/Debug.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
|
// If we just introduced a critical edge in the flow graph, make sure to break
|
||||||
// it right away...
|
// 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!
|
// Make sure that we don't introduce critical edges from oldsucc now!
|
||||||
for (unsigned i = 0, e = OldSucc->getTerminator()->getNumSuccessors();
|
for (unsigned i = 0, e = OldSucc->getTerminator()->getNumSuccessors();
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/Transforms/Scalar.h"
|
#include "llvm/Transforms/Scalar.h"
|
||||||
|
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
|
||||||
#include "llvm/Analysis/Dominators.h"
|
#include "llvm/Analysis/Dominators.h"
|
||||||
#include "llvm/Function.h"
|
#include "llvm/Function.h"
|
||||||
#include "llvm/iTerminators.h"
|
#include "llvm/iTerminators.h"
|
||||||
@ -66,13 +67,14 @@ bool isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum) {
|
|||||||
return I != E;
|
return I != E;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SplitCriticalEdge - Insert a new node node to split the critical edge. This
|
// SplitCriticalEdge - If this edge is a critical edge, insert a new node to
|
||||||
// will update DominatorSet, ImmediateDominator and DominatorTree information if
|
// split the critical edge. This will update DominatorSet, ImmediateDominator,
|
||||||
// it is available, thus calling this pass will not invalidate either of them.
|
// 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) {
|
bool SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P) {
|
||||||
assert(isCriticalEdge(TI, SuccNum) &&
|
if (!isCriticalEdge(TI, SuccNum)) return false;
|
||||||
"Cannot break a critical edge, if it isn't a critical edge");
|
|
||||||
BasicBlock *TIBB = TI->getParent();
|
BasicBlock *TIBB = TI->getParent();
|
||||||
BasicBlock *DestBB = TI->getSuccessor(SuccNum);
|
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 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
|
// Now update analysis information. These are the analyses that we are
|
||||||
// currently capable of updating...
|
// currently capable of updating...
|
||||||
@ -142,6 +144,7 @@ void SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P) {
|
|||||||
NewDFSet.insert(DestBB);
|
NewDFSet.insert(DestBB);
|
||||||
DF->addBasicBlock(NewBB, NewDFSet);
|
DF->addBasicBlock(NewBB, NewDFSet);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// runOnFunction - Loop over all of the edges in the CFG, breaking critical
|
// 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();
|
TerminatorInst *TI = I->getTerminator();
|
||||||
if (TI->getNumSuccessors() > 1)
|
if (TI->getNumSuccessors() > 1)
|
||||||
for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i)
|
for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i)
|
||||||
if (isCriticalEdge(TI, i)) {
|
if (SplitCriticalEdge(TI, i, this)) {
|
||||||
SplitCriticalEdge(TI, i, this);
|
|
||||||
++NumBroken;
|
++NumBroken;
|
||||||
Changed = true;
|
Changed = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user