/// case where one of the edges being split is an exit of a loop with other
/// exits).
///
-void SplitLandingPadPredecessors(BasicBlock *OrigBB,ArrayRef<BasicBlock*> Preds,
+void SplitLandingPadPredecessors(BasicBlock *OrigBB,
+ ArrayRef<BasicBlock *> Preds,
const char *Suffix, const char *Suffix2,
- Pass *P, SmallVectorImpl<BasicBlock*> &NewBBs);
+ SmallVectorImpl<BasicBlock *> &NewBBs,
+ AliasAnalysis *AA = nullptr,
+ DominatorTree *DT = nullptr,
+ LoopInfo *LI = nullptr,
+ bool PreserveLCSSA = false);
/// FoldReturnIntoUncondBranch - This method duplicates the specified return
/// instruction into a predecessor which ends in an unconditional branch. If
if (!Split) continue;
SmallVector<BasicBlock*, 2> NewBBs;
- SplitLandingPadPredecessors(LPad, Parent, ".1", ".2", nullptr, NewBBs);
+ SplitLandingPadPredecessors(LPad, Parent, ".1", ".2", NewBBs);
}
}
/*DontDeleteUselessPhis=*/true);
} else {
SmallVector<BasicBlock*, 2> NewBBs;
- SplitLandingPadPredecessors(Parent, BB, "", "", P, NewBBs);
+ SplitLandingPadPredecessors(Parent, BB, "", "", NewBBs,
+ /*AliasAnalysis*/ nullptr, &DT, &LI);
NewBB = NewBBs[0];
}
// If NewBB==NULL, then SplitCriticalEdge refused to split because all
} else {
SmallVector<BasicBlock*, 2> NewBBs;
SplitLandingPadPredecessors(ExitBlock, Preds, ".us-lcssa", ".us-lcssa",
- this, NewBBs);
+ NewBBs, /*AliasAnalysis*/ nullptr, DT, LI,
+ /*PreserveLCSSA*/ true);
}
}
}
/// exits).
///
void llvm::SplitLandingPadPredecessors(BasicBlock *OrigBB,
- ArrayRef<BasicBlock*> Preds,
+ ArrayRef<BasicBlock *> Preds,
const char *Suffix1, const char *Suffix2,
- Pass *P,
- SmallVectorImpl<BasicBlock*> &NewBBs) {
+ SmallVectorImpl<BasicBlock *> &NewBBs,
+ AliasAnalysis *AA, DominatorTree *DT,
+ LoopInfo *LI, bool PreserveLCSSA) {
assert(OrigBB->isLandingPad() && "Trying to split a non-landing pad!");
// Create a new basic block for OrigBB's predecessors listed in Preds. Insert
Preds[i]->getTerminator()->replaceUsesOfWith(OrigBB, NewBB1);
}
- // Update DominatorTree, LoopInfo, and LCCSA analysis information.
- 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);
bool HasLoopExit = false;
UpdateAnalysisInformation(OrigBB, NewBB1, Preds, DT, LI, PreserveLCSSA,
HasLoopExit);
// Update the PHI nodes in OrigBB with the values coming from NewBB1.
- AliasAnalysis *AA = P ? P->getAnalysisIfAvailable<AliasAnalysis>() : nullptr;
UpdatePHINodes(OrigBB, NewBB1, Preds, BI1, AA, HasLoopExit);
// Move the remaining edges from OrigBB to point to NewBB2.
} else {
SmallVector<BasicBlock*, 2> NewBBs;
SplitLandingPadPredecessors(Header, OutsideBlocks, ".preheader",
- ".split-lp", PP, NewBBs);
+ ".split-lp", NewBBs, AA, DT, LI, PreserveLCSSA);
PreheaderBB = NewBBs[0];
}
if (Exit->isLandingPad()) {
SmallVector<BasicBlock*, 2> NewBBs;
- SplitLandingPadPredecessors(Exit, LoopBlocks,
- ".loopexit", ".nonloopexit",
- PP, NewBBs);
+ SplitLandingPadPredecessors(Exit, LoopBlocks, ".loopexit", ".nonloopexit",
+ NewBBs, AA, DT, LI, PreserveLCSSA);
NewExitBB = NewBBs[0];
} else {
NewExitBB = SplitBlockPredecessors(Exit, LoopBlocks, ".loopexit", AA, DT,
} else {
SmallVector<BasicBlock*, 2> NewBBs;
SplitLandingPadPredecessors(Exit, Preds, ".unr1-lcssa", ".unr2-lcssa",
- P, NewBBs);
+ NewBBs, AA, DT, LI,
+ P->mustPreserveAnalysisID(LCSSAID));
}
// Add the branch to the exit block (around the unrolled loop)
BranchInst::Create(Exit, NewPH, BrLoopExit, InsertPt);