Skip to content

Commit cde8343

Browse files
committedSep 13, 2019
[BasicBlockUtils] Add optional BBName argument, in line with BB:splitBasicBlock
Reviewers: spatel, asbirlea, craig.topper Reviewed By: asbirlea Differential Revision: https://reviews.llvm.org/D67521 llvm-svn: 371819
1 parent 395a867 commit cde8343

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed
 

‎llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ BasicBlock *SplitEdge(BasicBlock *From, BasicBlock *To,
222222
/// info is updated.
223223
BasicBlock *SplitBlock(BasicBlock *Old, Instruction *SplitPt,
224224
DominatorTree *DT = nullptr, LoopInfo *LI = nullptr,
225-
MemorySSAUpdater *MSSAU = nullptr);
225+
MemorySSAUpdater *MSSAU = nullptr,
226+
const Twine &BBName = "");
226227

227228
/// This method introduces at least one new basic block into the function and
228229
/// moves some of the predecessors of BB to be predecessors of the new block.

‎llvm/lib/Transforms/Utils/BasicBlockUtils.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,13 @@ llvm::SplitAllCriticalEdges(Function &F,
365365

366366
BasicBlock *llvm::SplitBlock(BasicBlock *Old, Instruction *SplitPt,
367367
DominatorTree *DT, LoopInfo *LI,
368-
MemorySSAUpdater *MSSAU) {
368+
MemorySSAUpdater *MSSAU, const Twine &BBName) {
369369
BasicBlock::iterator SplitIt = SplitPt->getIterator();
370370
while (isa<PHINode>(SplitIt) || SplitIt->isEHPad())
371371
++SplitIt;
372-
BasicBlock *New = Old->splitBasicBlock(SplitIt, Old->getName()+".split");
372+
std::string Name = BBName.str();
373+
BasicBlock *New = Old->splitBasicBlock(
374+
SplitIt, Name.empty() ? Old->getName() + ".split" : Name);
373375

374376
// The new block lives in whichever loop the old one did. This preserves
375377
// LCSSA as well, because we force the split point to be after any PHI nodes.

‎llvm/lib/Transforms/Utils/LoopVersioning.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ void LoopVersioning::versionLoop(
9292
// Create empty preheader for the loop (and after cloning for the
9393
// non-versioned loop).
9494
BasicBlock *PH =
95-
SplitBlock(RuntimeCheckBB, RuntimeCheckBB->getTerminator(), DT, LI);
96-
PH->setName(VersionedLoop->getHeader()->getName() + ".ph");
95+
SplitBlock(RuntimeCheckBB, RuntimeCheckBB->getTerminator(), DT, LI,
96+
nullptr, VersionedLoop->getHeader()->getName() + ".ph");
9797

9898
// Clone the loop including the preheader.
9999
//

0 commit comments

Comments
 (0)
Please sign in to comment.