[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/CodeGen/Utils.cpp b/polly/lib/CodeGen/Utils.cpp
index 36722d3..8ea9a4a 100644
--- a/polly/lib/CodeGen/Utils.cpp
+++ b/polly/lib/CodeGen/Utils.cpp
@@ -20,18 +20,17 @@
using namespace llvm;
-BasicBlock *polly::executeScopConditionally(Scop &S, Pass *PassInfo) {
+BasicBlock *polly::executeScopConditionally(Scop &S, Pass *P, Value *RTC) {
BasicBlock *StartBlock, *SplitBlock, *NewBlock;
Region &R = S.getRegion();
PollyIRBuilder Builder(R.getEntry());
- DominatorTree &DT =
- PassInfo->getAnalysis<DominatorTreeWrapperPass>().getDomTree();
- RegionInfo &RI = PassInfo->getAnalysis<RegionInfoPass>().getRegionInfo();
- LoopInfo &LI = PassInfo->getAnalysis<LoopInfo>();
+ DominatorTree &DT = P->getAnalysis<DominatorTreeWrapperPass>().getDomTree();
+ RegionInfo &RI = P->getAnalysis<RegionInfoPass>().getRegionInfo();
+ LoopInfo &LI = P->getAnalysis<LoopInfo>();
// Split the entry edge of the region and generate a new basic block on this
// edge. This function also updates ScopInfo and RegionInfo.
- NewBlock = SplitEdge(R.getEnteringBlock(), R.getEntry(), PassInfo);
+ NewBlock = SplitEdge(R.getEnteringBlock(), R.getEntry(), P);
if (DT.dominates(R.getEntry(), NewBlock)) {
BasicBlock *OldBlock = R.getEntry();
std::string OldName = OldBlock->getName();
@@ -59,7 +58,7 @@
StartBlock = BasicBlock::Create(F->getContext(), "polly.start", F);
SplitBlock->getTerminator()->eraseFromParent();
Builder.SetInsertPoint(SplitBlock);
- Builder.CreateCondBr(Builder.getTrue(), StartBlock, R.getEntry());
+ Builder.CreateCondBr(RTC, StartBlock, R.getEntry());
if (Loop *L = LI.getLoopFor(SplitBlock))
L->addBasicBlockToLoop(StartBlock, LI.getBase());
DT.addNewBlock(StartBlock, SplitBlock);
@@ -72,7 +71,7 @@
// PHI nodes that would complicate life.
MergeBlock = R.getExit();
else {
- MergeBlock = SplitEdge(R.getExitingBlock(), R.getExit(), PassInfo);
+ MergeBlock = SplitEdge(R.getExitingBlock(), R.getExit(), P);
// SplitEdge will never split R.getExit(), as R.getExit() has more than
// one predecessor. Hence, mergeBlock is always a newly generated block.
R.replaceExitRecursive(MergeBlock);