summaryrefslogtreecommitdiffstats
path: root/polly/lib/Support/ScopHelper.cpp
diff options
context:
space:
mode:
authorMichael Kruse <llvm@meinersbur.de>2015-08-11 14:04:06 +0000
committerMichael Kruse <llvm@meinersbur.de>2015-08-11 14:04:06 +0000
commit23d0e83aa3745c51e1c32afa952e5bcec53cd251 (patch)
tree87175baf3a5087efef6e8d698a9883bad6f97912 /polly/lib/Support/ScopHelper.cpp
parent81f1ffdbbbc59aa98a26b7e746f9a75eeb0182ca (diff)
downloadbcm5719-llvm-23d0e83aa3745c51e1c32afa952e5bcec53cd251.tar.gz
bcm5719-llvm-23d0e83aa3745c51e1c32afa952e5bcec53cd251.zip
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 llvm-svn: 244600
Diffstat (limited to 'polly/lib/Support/ScopHelper.cpp')
-rw-r--r--polly/lib/Support/ScopHelper.cpp40
1 files changed, 36 insertions, 4 deletions
diff --git a/polly/lib/Support/ScopHelper.cpp b/polly/lib/Support/ScopHelper.cpp
index 176b30da65b..633f74bfe9a 100644
--- a/polly/lib/Support/ScopHelper.cpp
+++ b/polly/lib/Support/ScopHelper.cpp
@@ -169,6 +169,38 @@ BasicBlock *polly::simplifyRegion(Scop *S, Pass *P) {
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(BasicBlock *EntryBlock, Pass *P) {
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);
}
OpenPOWER on IntegriCloud