diff options
author | Siddharth Bhat <siddu.druid@gmail.com> | 2017-08-08 12:00:59 +0000 |
---|---|---|
committer | Siddharth Bhat <siddu.druid@gmail.com> | 2017-08-08 12:00:59 +0000 |
commit | 71dfb3eb074eb6237f631c23ba24fd5ca5fdd917 (patch) | |
tree | 6c57d6c68c7e65dafc9d8a862ff9a4ed1302b3cd /polly/lib/CodeGen/PPCGCodeGeneration.cpp | |
parent | e528bd219343140d00293421279918a598834f62 (diff) | |
download | bcm5719-llvm-71dfb3eb074eb6237f631c23ba24fd5ca5fdd917.tar.gz bcm5719-llvm-71dfb3eb074eb6237f631c23ba24fd5ca5fdd917.zip |
[Polly] [PPCGCodeGeneration] Handle failing of invariant load hoisting gracefully.
To do this, we replicate what `CodeGeneration` does. We expose
`markNodeUnreachable` from `CodeGeneration` to `PPCGCodeGeneration`.
Differential Revision: https://reviews.llvm.org/D36457
llvm-svn: 310350
Diffstat (limited to 'polly/lib/CodeGen/PPCGCodeGeneration.cpp')
-rw-r--r-- | polly/lib/CodeGen/PPCGCodeGeneration.cpp | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/polly/lib/CodeGen/PPCGCodeGeneration.cpp b/polly/lib/CodeGen/PPCGCodeGeneration.cpp index d3a13edc3b6..3ab1b6496c3 100644 --- a/polly/lib/CodeGen/PPCGCodeGeneration.cpp +++ b/polly/lib/CodeGen/PPCGCodeGeneration.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "polly/CodeGen/PPCGCodeGeneration.h" +#include "polly/CodeGen/CodeGeneration.h" #include "polly/CodeGen/IslAst.h" #include "polly/CodeGen/IslNodeBuilder.h" #include "polly/CodeGen/Utils.h" @@ -3373,7 +3374,6 @@ public: // TODO: Handle LICM auto SplitBlock = StartBlock->getSinglePredecessor(); Builder.SetInsertPoint(SplitBlock->getTerminator()); - NodeBuilder.addParameters(S->getContext().release()); isl_ast_build *Build = isl_ast_build_alloc(S->getIslCtx()); isl_ast_expr *Condition = IslAst::buildRunCondition(*S, Build); @@ -3383,17 +3383,34 @@ public: // preload invariant loads. Note: This should happen before the RTC // because the RTC may depend on values that are invariant load hoisted. - if (!NodeBuilder.preloadInvariantLoads()) - report_fatal_error("preloading invariant loads failed in function: " + - S->getFunction().getName() + - " | Scop Region: " + S->getNameStr()); + if (!NodeBuilder.preloadInvariantLoads()) { + DEBUG(dbgs() << "preloading invariant loads failed in function: " + + S->getFunction().getName() + + " | Scop Region: " + S->getNameStr()); + // adjust the dominator tree accordingly. + auto *ExitingBlock = StartBlock->getUniqueSuccessor(); + assert(ExitingBlock); + auto *MergeBlock = ExitingBlock->getUniqueSuccessor(); + assert(MergeBlock); + polly::markBlockUnreachable(*StartBlock, Builder); + polly::markBlockUnreachable(*ExitingBlock, Builder); + auto *ExitingBB = S->getExitingBlock(); + assert(ExitingBB); + + DT->changeImmediateDominator(MergeBlock, ExitingBB); + DT->eraseNode(ExitingBlock); + isl_ast_expr_free(Condition); + isl_ast_node_free(Root); + } else { - Value *RTC = NodeBuilder.createRTC(Condition); - Builder.GetInsertBlock()->getTerminator()->setOperand(0, RTC); + NodeBuilder.addParameters(S->getContext().release()); + Value *RTC = NodeBuilder.createRTC(Condition); + Builder.GetInsertBlock()->getTerminator()->setOperand(0, RTC); - Builder.SetInsertPoint(&*StartBlock->begin()); + Builder.SetInsertPoint(&*StartBlock->begin()); - NodeBuilder.create(Root); + NodeBuilder.create(Root); + } /// In case a sequential kernel has more surrounding loops as any parallel /// kernel, the SCoP is probably mostly sequential. Hence, there is no |