mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 04:38:24 +00:00
[PM] Remove the Pass argument from all of the critical edge splitting
APIs and replace it and numerous booleans with an option struct. The critical edge splitting API has a really large surface of flags and so it seems worth burning a small option struct / builder. This struct can be constructed with the various preserved analyses and then flags can be flipped in a builder style. The various users are now responsible for directly passing along their analysis information. This should be enough for the critical edge splitting to work cleanly with the new pass manager as well. This API is still pretty crufty and could be cleaned up a lot, but I've focused on this change just threading an option struct rather than a pass through the API. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226456 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -234,15 +234,20 @@ void llvm::ReplaceInstWithInst(Instruction *From, Instruction *To) {
|
||||
BasicBlock *llvm::SplitEdge(BasicBlock *BB, BasicBlock *Succ, Pass *P) {
|
||||
unsigned SuccNum = GetSuccessorNumber(BB, Succ);
|
||||
|
||||
// If this is a critical edge, let SplitCriticalEdge do it.
|
||||
TerminatorInst *LatchTerm = BB->getTerminator();
|
||||
if (SplitCriticalEdge(LatchTerm, SuccNum, P))
|
||||
return LatchTerm->getSuccessor(SuccNum);
|
||||
|
||||
auto *AA = P->getAnalysisIfAvailable<AliasAnalysis>();
|
||||
auto *DTWP = P->getAnalysisIfAvailable<DominatorTreeWrapperPass>();
|
||||
auto *DT = DTWP ? &DTWP->getDomTree() : nullptr;
|
||||
auto *LIWP = P->getAnalysisIfAvailable<LoopInfoWrapperPass>();
|
||||
auto *LI = LIWP ? &LIWP->getLoopInfo() : nullptr;
|
||||
bool PreserveLCSSA = P->mustPreserveAnalysisID(LCSSAID);
|
||||
auto Options = CriticalEdgeSplittingOptions(AA, DT, LI);
|
||||
if (PreserveLCSSA)
|
||||
Options.setPreserveLCSSA();
|
||||
|
||||
// If this is a critical edge, let SplitCriticalEdge do it.
|
||||
TerminatorInst *LatchTerm = BB->getTerminator();
|
||||
if (SplitCriticalEdge(LatchTerm, SuccNum, Options))
|
||||
return LatchTerm->getSuccessor(SuccNum);
|
||||
|
||||
// If the edge isn't critical, then BB has a single successor or Succ has a
|
||||
// single pred. Split the block.
|
||||
@ -261,13 +266,15 @@ BasicBlock *llvm::SplitEdge(BasicBlock *BB, BasicBlock *Succ, Pass *P) {
|
||||
return SplitBlock(BB, BB->getTerminator(), DT, LI);
|
||||
}
|
||||
|
||||
unsigned llvm::SplitAllCriticalEdges(Function &F, Pass *P) {
|
||||
unsigned
|
||||
llvm::SplitAllCriticalEdges(Function &F,
|
||||
const CriticalEdgeSplittingOptions &Options) {
|
||||
unsigned NumBroken = 0;
|
||||
for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) {
|
||||
TerminatorInst *TI = I->getTerminator();
|
||||
if (TI->getNumSuccessors() > 1 && !isa<IndirectBrInst>(TI))
|
||||
for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i)
|
||||
if (SplitCriticalEdge(TI, i, P))
|
||||
if (SplitCriticalEdge(TI, i, Options))
|
||||
++NumBroken;
|
||||
}
|
||||
return NumBroken;
|
||||
|
Reference in New Issue
Block a user