mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 12:43:36 +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.
|
/// to.
|
||||||
BasicBlock *SplitCriticalEdge(Instruction *TI, unsigned SuccNum,
|
BasicBlock *SplitCriticalEdge(Instruction *TI, unsigned SuccNum,
|
||||||
const CriticalEdgeSplittingOptions &Options =
|
const CriticalEdgeSplittingOptions &Options =
|
||||||
CriticalEdgeSplittingOptions());
|
CriticalEdgeSplittingOptions(),
|
||||||
|
const Twine &BBName = "");
|
||||||
|
|
||||||
inline BasicBlock *
|
inline BasicBlock *
|
||||||
SplitCriticalEdge(BasicBlock *BB, succ_iterator SI,
|
SplitCriticalEdge(BasicBlock *BB, succ_iterator SI,
|
||||||
@ -248,7 +249,8 @@ unsigned SplitAllCriticalEdges(Function &F,
|
|||||||
/// basic block between \p From and \p To.
|
/// basic block between \p From and \p To.
|
||||||
BasicBlock *SplitEdge(BasicBlock *From, BasicBlock *To,
|
BasicBlock *SplitEdge(BasicBlock *From, BasicBlock *To,
|
||||||
DominatorTree *DT = nullptr, LoopInfo *LI = nullptr,
|
DominatorTree *DT = nullptr, LoopInfo *LI = nullptr,
|
||||||
MemorySSAUpdater *MSSAU = nullptr);
|
MemorySSAUpdater *MSSAU = nullptr,
|
||||||
|
const Twine &BBName = "");
|
||||||
|
|
||||||
/// Split the specified block at the specified instruction.
|
/// 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,
|
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);
|
unsigned SuccNum = GetSuccessorNumber(BB, Succ);
|
||||||
|
|
||||||
// If this is a critical edge, let SplitCriticalEdge do it.
|
// If this is a critical edge, let SplitCriticalEdge do it.
|
||||||
Instruction *LatchTerm = BB->getTerminator();
|
Instruction *LatchTerm = BB->getTerminator();
|
||||||
if (SplitCriticalEdge(
|
if (SplitCriticalEdge(
|
||||||
LatchTerm, SuccNum,
|
LatchTerm, SuccNum,
|
||||||
CriticalEdgeSplittingOptions(DT, LI, MSSAU).setPreserveLCSSA()))
|
CriticalEdgeSplittingOptions(DT, LI, MSSAU).setPreserveLCSSA(),
|
||||||
|
BBName))
|
||||||
return LatchTerm->getSuccessor(SuccNum);
|
return LatchTerm->getSuccessor(SuccNum);
|
||||||
|
|
||||||
// If the edge isn't critical, then BB has a single successor or Succ has a
|
// 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.
|
// block.
|
||||||
assert(SP == BB && "CFG broken");
|
assert(SP == BB && "CFG broken");
|
||||||
SP = nullptr;
|
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
|
// Otherwise, if BB has a single successor, split it at the bottom of the
|
||||||
// block.
|
// block.
|
||||||
assert(BB->getTerminator()->getNumSuccessors() == 1 &&
|
assert(BB->getTerminator()->getNumSuccessors() == 1 &&
|
||||||
"Should have a single succ!");
|
"Should have a single succ!");
|
||||||
return SplitBlock(BB, BB->getTerminator(), DT, LI, MSSAU);
|
return SplitBlock(BB, BB->getTerminator(), DT, LI, MSSAU, BBName);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned
|
unsigned
|
||||||
|
@ -134,9 +134,9 @@ static void createPHIsForSplitLoopExit(ArrayRef<BasicBlock *> Preds,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicBlock *
|
BasicBlock *llvm::SplitCriticalEdge(Instruction *TI, unsigned SuccNum,
|
||||||
llvm::SplitCriticalEdge(Instruction *TI, unsigned SuccNum,
|
const CriticalEdgeSplittingOptions &Options,
|
||||||
const CriticalEdgeSplittingOptions &Options) {
|
const Twine &BBName) {
|
||||||
if (!isCriticalEdge(TI, SuccNum, Options.MergeIdenticalEdges))
|
if (!isCriticalEdge(TI, SuccNum, Options.MergeIdenticalEdges))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
@ -196,8 +196,13 @@ llvm::SplitCriticalEdge(Instruction *TI, unsigned SuccNum,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a new basic block, linking it into the CFG.
|
// Create a new basic block, linking it into the CFG.
|
||||||
BasicBlock *NewBB = BasicBlock::Create(TI->getContext(),
|
BasicBlock *NewBB = nullptr;
|
||||||
TIBB->getName() + "." + DestBB->getName() + "_crit_edge");
|
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.
|
// Create our unconditional branch.
|
||||||
BranchInst *NewBI = BranchInst::Create(DestBB, NewBB);
|
BranchInst *NewBI = BranchInst::Create(DestBB, NewBB);
|
||||||
NewBI->setDebugLoc(TI->getDebugLoc());
|
NewBI->setDebugLoc(TI->getDebugLoc());
|
||||||
|
Loading…
Reference in New Issue
Block a user