diff options
| author | Tobias Grosser <tobias@grosser.es> | 2015-12-09 11:38:22 +0000 |
|---|---|---|
| committer | Tobias Grosser <tobias@grosser.es> | 2015-12-09 11:38:22 +0000 |
| commit | 2d3d4ec860ff13494aaf56855dbe05bf1ab68a29 (patch) | |
| tree | 7e5b0a5e3d83967225b572c26c4b459a197e8e7d /polly/lib/CodeGen/Utils.cpp | |
| parent | 87a44d29a2ab3a94220dc6fcfb1de0e41a68817d (diff) | |
| download | bcm5719-llvm-2d3d4ec860ff13494aaf56855dbe05bf1ab68a29.tar.gz bcm5719-llvm-2d3d4ec860ff13494aaf56855dbe05bf1ab68a29.zip | |
executeScopConditionally: Introduce special exiting block
When introducing separate control flow for the original and optimized code we
introduce now a special 'ExitingBlock':
\ /
EnteringBB
|
SplitBlock---------\
_____|_____ |
/ EntryBB \ StartBlock
| (region) | |
\_ExitingBB_/ ExitingBlock
| |
MergeBlock---------/
|
ExitBB
/ \
This 'ExitingBlock' contains code such as the final_reloads for scalars, which
previously were just added to whichever statement/loop_exit/branch-merge block
had been generated last. Having an explicit basic block makes it easier to
find these constructs when looking at the CFG.
llvm-svn: 255107
Diffstat (limited to 'polly/lib/CodeGen/Utils.cpp')
| -rw-r--r-- | polly/lib/CodeGen/Utils.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/polly/lib/CodeGen/Utils.cpp b/polly/lib/CodeGen/Utils.cpp index dd6b162ccb0..743a0cceec0 100644 --- a/polly/lib/CodeGen/Utils.cpp +++ b/polly/lib/CodeGen/Utils.cpp @@ -141,17 +141,23 @@ BasicBlock *polly::executeScopConditionally(Scop &S, Pass *P, Value *RTC) { // ExitBB // // / \ // - // Create the start block. + // Create the start and exiting block. Function *F = SplitBlock->getParent(); BasicBlock *StartBlock = BasicBlock::Create(F->getContext(), "polly.start", F); + BasicBlock *ExitingBlock = + BasicBlock::Create(F->getContext(), "polly.exiting", F); SplitBlock->getTerminator()->eraseFromParent(); Builder.SetInsertPoint(SplitBlock); Builder.CreateCondBr(RTC, StartBlock, R.getEntry()); - if (Loop *L = LI.getLoopFor(SplitBlock)) + if (Loop *L = LI.getLoopFor(SplitBlock)) { L->addBasicBlockToLoop(StartBlock, LI); + L->addBasicBlockToLoop(ExitingBlock, LI); + } DT.addNewBlock(StartBlock, SplitBlock); + DT.addNewBlock(ExitingBlock, StartBlock); RI.setRegionFor(StartBlock, RI.getRegionFor(SplitBlock)); + RI.setRegionFor(ExitingBlock, RI.getRegionFor(SplitBlock)); // \ / // // EnteringBB // @@ -159,16 +165,21 @@ BasicBlock *polly::executeScopConditionally(Scop &S, Pass *P, Value *RTC) { // SplitBlock---------\ // // _____|_____ | // // / EntryBB \ StartBlock // - // | (region) | // - // \_ExitingBB_/ // + // | (region) | | // + // \_ExitingBB_/ ExitingBlock // // | // // MergeBlock // // | // // ExitBB // // / \ // - // Connect start block to the join block. + // Connect start block to exiting block. Builder.SetInsertPoint(StartBlock); + Builder.CreateBr(ExitingBlock); + DT.changeImmediateDominator(ExitingBlock, StartBlock); + + // Connect exiting block to join block. + Builder.SetInsertPoint(ExitingBlock); Builder.CreateBr(MergeBlock); DT.changeImmediateDominator(MergeBlock, SplitBlock); @@ -179,7 +190,7 @@ BasicBlock *polly::executeScopConditionally(Scop &S, Pass *P, Value *RTC) { // _____|_____ | // // / EntryBB \ StartBlock // // | (region) | | // - // \_ExitingBB_/ | // + // \_ExitingBB_/ ExitingBlock // // | | // // MergeBlock---------/ // // | // |

