[polly] r244600 - Introduce splitBlock and use it in splitEntryBlockForAlloca
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 11 07:04:07 PDT 2015
Author: meinersbur
Date: Tue Aug 11 09:04:06 2015
New Revision: 244600
URL: http://llvm.org/viewvc/llvm-project?rev=244600&view=rev
Log:
Introduce splitBlock and use it in splitEntryBlockForAlloca
RegionInfo::splitBlock did not update RegionInfo correctly. Specifically, it tried to make the new block the entry block if possible. This breaks for nested regions that have edges to the old block.
We simply do not change the entry block. Updating RegionInfo becomes trivial as both block will always be in the same region.
splitEntryBlockForAlloca makes use of the new splitBlock.
Reviewers: grosser
Part of Differential Revision: http://reviews.llvm.org/D11867
Modified:
polly/trunk/lib/Support/ScopHelper.cpp
Modified: polly/trunk/lib/Support/ScopHelper.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Support/ScopHelper.cpp?rev=244600&r1=244599&r2=244600&view=diff
==============================================================================
--- polly/trunk/lib/Support/ScopHelper.cpp (original)
+++ polly/trunk/lib/Support/ScopHelper.cpp Tue Aug 11 09:04:06 2015
@@ -169,6 +169,38 @@ BasicBlock *polly::simplifyRegion(Scop *
return EnteringBB;
}
+// Split the block into two successive blocks.
+//
+// Like llvm::SplitBlock, but also preserves RegionInfo
+static BasicBlock *splitBlock(BasicBlock *Old, Instruction *SplitPt,
+ DominatorTree *DT, llvm::LoopInfo *LI,
+ RegionInfo *RI) {
+ assert(Old && SplitPt);
+
+ // Before:
+ //
+ // \ / //
+ // Old //
+ // / \ //
+
+ BasicBlock *NewBlock = llvm::SplitBlock(Old, SplitPt, DT, LI);
+
+ if (RI) {
+ Region *R = RI->getRegionFor(Old);
+ RI->setRegionFor(NewBlock, R);
+ }
+
+ // After:
+ //
+ // \ / //
+ // Old //
+ // | //
+ // NewBlock //
+ // / \ //
+
+ return NewBlock;
+}
+
void polly::splitEntryBlockForAlloca(BasicBlock *EntryBlock, Pass *P) {
// Find first non-alloca instruction. Every basic block has a non-alloc
// instruction, as every well formed basic block has a terminator.
@@ -180,9 +212,9 @@ void polly::splitEntryBlockForAlloca(Bas
auto *DT = DTWP ? &DTWP->getDomTree() : nullptr;
auto *LIWP = P->getAnalysisIfAvailable<LoopInfoWrapperPass>();
auto *LI = LIWP ? &LIWP->getLoopInfo() : nullptr;
+ RegionInfoPass *RIP = P->getAnalysisIfAvailable<RegionInfoPass>();
+ RegionInfo *RI = RIP ? &RIP->getRegionInfo() : nullptr;
- // SplitBlock updates DT, DF and LI.
- BasicBlock *NewEntry = SplitBlock(EntryBlock, I, DT, LI);
- if (RegionInfoPass *RIP = P->getAnalysisIfAvailable<RegionInfoPass>())
- RIP->getRegionInfo().splitBlock(NewEntry, EntryBlock);
+ // splitBlock updates DT, LI and RI.
+ splitBlock(EntryBlock, I, DT, LI, RI);
}
More information about the llvm-commits
mailing list