[Refactor] Cleanup isl code generation
Summary:
+ Refactor the runtime check (RTC) build function
+ Added helper function to create an PollyIRBuilder
+ Change the simplify region function to create not
only unique entry and exit edges but also enfore that
the entry edge is unconditional
+ Cleaned the IslCodeGeneration runOnScop function:
- less post-creation changes of the created IR
+ Adjusted and added test cases
Reviewers: grosser, sebpop, simbuerg, dpeixott
Subscribers: llvm-commits, #polly
Differential Revision: http://reviews.llvm.org/D5076
llvm-svn: 217508
diff --git a/polly/lib/Support/ScopHelper.cpp b/polly/lib/Support/ScopHelper.cpp
index 15adf2d..01c1dd0 100644
--- a/polly/lib/Support/ScopHelper.cpp
+++ b/polly/lib/Support/ScopHelper.cpp
@@ -86,11 +86,14 @@
return SplitBlockPredecessors(BB, Preds, ".region", P);
}
-void polly::simplifyRegion(Scop *S, Pass *P) {
+BasicBlock *polly::simplifyRegion(Scop *S, Pass *P) {
Region *R = &S->getRegion();
+ // The entering block for the region.
+ BasicBlock *EnteringBB = R->getEnteringBlock();
+
// Create single entry edge if the region has multiple entry edges.
- if (!R->getEnteringBlock()) {
+ if (!EnteringBB) {
BasicBlock *OldEntry = R->getEntry();
BasicBlock *NewEntry = SplitBlock(OldEntry, OldEntry->begin(), P);
@@ -101,6 +104,13 @@
}
R->replaceEntryRecursive(NewEntry);
+ EnteringBB = OldEntry;
+ }
+
+ // Create an unconditional entry edge.
+ if (EnteringBB->getTerminator()->getNumSuccessors() != 1) {
+ EnteringBB = SplitEdge(EnteringBB, R->getEntry(), P);
+ EnteringBB->setName("polly.entering.block");
}
// Create single exit edge if the region has multiple exit edges.
@@ -110,6 +120,8 @@
for (auto &&SubRegion : *R)
SubRegion->replaceExitRecursive(NewExit);
}
+
+ return EnteringBB;
}
void polly::splitEntryBlockForAlloca(BasicBlock *EntryBlock, Pass *P) {