]> granicus.if.org Git - llvm/commitdiff
[BasicBlockUtils] Add optional BBName argument, in line with BB:splitBasicBlock
authorFlorian Hahn <flo@fhahn.com>
Fri, 13 Sep 2019 08:03:32 +0000 (08:03 +0000)
committerFlorian Hahn <flo@fhahn.com>
Fri, 13 Sep 2019 08:03:32 +0000 (08:03 +0000)
Reviewers: spatel, asbirlea, craig.topper

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D67521

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371819 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Transforms/Utils/BasicBlockUtils.h
lib/Transforms/Utils/BasicBlockUtils.cpp
lib/Transforms/Utils/LoopVersioning.cpp

index 4d861ffe9a312765cee7a1d4c78a6ae6115ffea0..45c30fc5a268cc34b1f9fc6ba425e7a14a9a1d82 100644 (file)
@@ -222,7 +222,8 @@ BasicBlock *SplitEdge(BasicBlock *From, BasicBlock *To,
 /// info is updated.
 BasicBlock *SplitBlock(BasicBlock *Old, Instruction *SplitPt,
                        DominatorTree *DT = nullptr, LoopInfo *LI = nullptr,
-                       MemorySSAUpdater *MSSAU = nullptr);
+                       MemorySSAUpdater *MSSAU = nullptr,
+                       const Twine &BBName = "");
 
 /// This method introduces at least one new basic block into the function and
 /// moves some of the predecessors of BB to be predecessors of the new block.
index 5fa371377c85a1689b965a7dcce3e4b7b3913f7a..6e20ef21d9c956aa4f7a4ab58775a2d7d87e82e3 100644 (file)
@@ -365,11 +365,13 @@ llvm::SplitAllCriticalEdges(Function &F,
 
 BasicBlock *llvm::SplitBlock(BasicBlock *Old, Instruction *SplitPt,
                              DominatorTree *DT, LoopInfo *LI,
-                             MemorySSAUpdater *MSSAU) {
+                             MemorySSAUpdater *MSSAU, const Twine &BBName) {
   BasicBlock::iterator SplitIt = SplitPt->getIterator();
   while (isa<PHINode>(SplitIt) || SplitIt->isEHPad())
     ++SplitIt;
-  BasicBlock *New = Old->splitBasicBlock(SplitIt, Old->getName()+".split");
+  std::string Name = BBName.str();
+  BasicBlock *New = Old->splitBasicBlock(
+      SplitIt, Name.empty() ? Old->getName() + ".split" : Name);
 
   // The new block lives in whichever loop the old one did. This preserves
   // LCSSA as well, because we force the split point to be after any PHI nodes.
index a9a480a4b7f9c552a71bf0422de8436bc1637548..5d7759056c7d348a26e76ea3d4fa7a72d7f85447 100644 (file)
@@ -92,8 +92,8 @@ void LoopVersioning::versionLoop(
   // Create empty preheader for the loop (and after cloning for the
   // non-versioned loop).
   BasicBlock *PH =
-      SplitBlock(RuntimeCheckBB, RuntimeCheckBB->getTerminator(), DT, LI);
-  PH->setName(VersionedLoop->getHeader()->getName() + ".ph");
+      SplitBlock(RuntimeCheckBB, RuntimeCheckBB->getTerminator(), DT, LI,
+                 nullptr, VersionedLoop->getHeader()->getName() + ".ph");
 
   // Clone the loop including the preheader.
   //