mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[SplitEdge] Add new parameter to SplitEdge to name the newly created basic block
Summary: Currently SplitEdge does not support passing in parameter which allows you to name the newly created BasicBlock. This patch updates the function such that the name of the block can be passed in, if users of this utility decide to do so. Reviewed By: Whitney, bmahjour, asbirlea, jamieschmeiser Differential Revision: https://reviews.llvm.org/D94176
This commit is contained in:
parent
bae712927d
commit
13c023db8b
@ -196,7 +196,8 @@ struct CriticalEdgeSplittingOptions {
|
||||
/// to.
|
||||
BasicBlock *SplitCriticalEdge(Instruction *TI, unsigned SuccNum,
|
||||
const CriticalEdgeSplittingOptions &Options =
|
||||
CriticalEdgeSplittingOptions());
|
||||
CriticalEdgeSplittingOptions(),
|
||||
const Twine &BBName = "");
|
||||
|
||||
inline BasicBlock *
|
||||
SplitCriticalEdge(BasicBlock *BB, succ_iterator SI,
|
||||
@ -248,7 +249,8 @@ unsigned SplitAllCriticalEdges(Function &F,
|
||||
/// basic block between \p From and \p To.
|
||||
BasicBlock *SplitEdge(BasicBlock *From, BasicBlock *To,
|
||||
DominatorTree *DT = nullptr, LoopInfo *LI = nullptr,
|
||||
MemorySSAUpdater *MSSAU = nullptr);
|
||||
MemorySSAUpdater *MSSAU = nullptr,
|
||||
const Twine &BBName = "");
|
||||
|
||||
/// Split the specified block at the specified instruction.
|
||||
///
|
||||
|
@ -495,14 +495,16 @@ void llvm::ReplaceInstWithInst(Instruction *From, Instruction *To) {
|
||||
}
|
||||
|
||||
BasicBlock *llvm::SplitEdge(BasicBlock *BB, BasicBlock *Succ, DominatorTree *DT,
|
||||
LoopInfo *LI, MemorySSAUpdater *MSSAU) {
|
||||
LoopInfo *LI, MemorySSAUpdater *MSSAU,
|
||||
const Twine &BBName) {
|
||||
unsigned SuccNum = GetSuccessorNumber(BB, Succ);
|
||||
|
||||
// If this is a critical edge, let SplitCriticalEdge do it.
|
||||
Instruction *LatchTerm = BB->getTerminator();
|
||||
if (SplitCriticalEdge(
|
||||
LatchTerm, SuccNum,
|
||||
CriticalEdgeSplittingOptions(DT, LI, MSSAU).setPreserveLCSSA()))
|
||||
CriticalEdgeSplittingOptions(DT, LI, MSSAU).setPreserveLCSSA(),
|
||||
BBName))
|
||||
return LatchTerm->getSuccessor(SuccNum);
|
||||
|
||||
// If the edge isn't critical, then BB has a single successor or Succ has a
|
||||
@ -512,14 +514,15 @@ BasicBlock *llvm::SplitEdge(BasicBlock *BB, BasicBlock *Succ, DominatorTree *DT,
|
||||
// block.
|
||||
assert(SP == BB && "CFG broken");
|
||||
SP = nullptr;
|
||||
return SplitBlock(Succ, &Succ->front(), DT, LI, MSSAU, "", /*Before=*/true);
|
||||
return SplitBlock(Succ, &Succ->front(), DT, LI, MSSAU, BBName,
|
||||
/*Before=*/true);
|
||||
}
|
||||
|
||||
// Otherwise, if BB has a single successor, split it at the bottom of the
|
||||
// block.
|
||||
assert(BB->getTerminator()->getNumSuccessors() == 1 &&
|
||||
"Should have a single succ!");
|
||||
return SplitBlock(BB, BB->getTerminator(), DT, LI, MSSAU);
|
||||
return SplitBlock(BB, BB->getTerminator(), DT, LI, MSSAU, BBName);
|
||||
}
|
||||
|
||||
unsigned
|
||||
|
@ -134,9 +134,9 @@ static void createPHIsForSplitLoopExit(ArrayRef<BasicBlock *> Preds,
|
||||
}
|
||||
}
|
||||
|
||||
BasicBlock *
|
||||
llvm::SplitCriticalEdge(Instruction *TI, unsigned SuccNum,
|
||||
const CriticalEdgeSplittingOptions &Options) {
|
||||
BasicBlock *llvm::SplitCriticalEdge(Instruction *TI, unsigned SuccNum,
|
||||
const CriticalEdgeSplittingOptions &Options,
|
||||
const Twine &BBName) {
|
||||
if (!isCriticalEdge(TI, SuccNum, Options.MergeIdenticalEdges))
|
||||
return nullptr;
|
||||
|
||||
@ -196,8 +196,13 @@ llvm::SplitCriticalEdge(Instruction *TI, unsigned SuccNum,
|
||||
}
|
||||
|
||||
// Create a new basic block, linking it into the CFG.
|
||||
BasicBlock *NewBB = BasicBlock::Create(TI->getContext(),
|
||||
TIBB->getName() + "." + DestBB->getName() + "_crit_edge");
|
||||
BasicBlock *NewBB = nullptr;
|
||||
if (BBName.str() != "")
|
||||
NewBB = BasicBlock::Create(TI->getContext(), BBName);
|
||||
else
|
||||
NewBB = BasicBlock::Create(TI->getContext(), TIBB->getName() + "." +
|
||||
DestBB->getName() +
|
||||
"_crit_edge");
|
||||
// Create our unconditional branch.
|
||||
BranchInst *NewBI = BranchInst::Create(DestBB, NewBB);
|
||||
NewBI->setDebugLoc(TI->getDebugLoc());
|
||||
|
Loading…
Reference in New Issue
Block a user