summaryrefslogtreecommitdiffstats
path: root/polly/lib/Analysis/ScopDetection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'polly/lib/Analysis/ScopDetection.cpp')
-rw-r--r--polly/lib/Analysis/ScopDetection.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index 889d2989ee9..14f9e3e08de 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -402,11 +402,15 @@ bool ScopDetection::isValidBranch(BasicBlock &BB, BranchInst *BI,
}
bool ScopDetection::isValidCFG(BasicBlock &BB, bool IsLoopBranch,
+ bool AllowUnreachable,
DetectionContext &Context) const {
Region &CurRegion = Context.CurRegion;
TerminatorInst *TI = BB.getTerminator();
+ if (AllowUnreachable && isa<UnreachableInst>(TI))
+ return true;
+
// Return instructions are only valid if the region is the top level region.
if (isa<ReturnInst>(TI) && !CurRegion.getExit() && TI->getNumOperands() == 0)
return true;
@@ -768,7 +772,7 @@ bool ScopDetection::canUseISLTripCount(Loop *L,
L->getLoopLatches(LoopControlBlocks);
L->getExitingBlocks(LoopControlBlocks);
for (BasicBlock *ControlBB : LoopControlBlocks) {
- if (!isValidCFG(*ControlBB, true, Context))
+ if (!isValidCFG(*ControlBB, true, false, Context))
return false;
}
@@ -977,12 +981,17 @@ bool ScopDetection::allBlocksValid(DetectionContext &Context) const {
}
for (BasicBlock *BB : CurRegion.blocks()) {
- // Do not check exception blocks as we will never include them in the SCoP.
- if (isErrorBlock(*BB, CurRegion, *LI, *DT))
- continue;
+ bool IsErrorBlock = isErrorBlock(*BB, CurRegion, *LI, *DT);
- if (!isValidCFG(*BB, false, Context) && !KeepGoing)
+ // Also check exception blocks (and possibly register them as non-affine
+ // regions). Even though exception blocks are not modeled, we use them
+ // to forward-propagate domain constraints during ScopInfo construction.
+ if (!isValidCFG(*BB, false, IsErrorBlock, Context) && !KeepGoing)
return false;
+
+ if (IsErrorBlock)
+ continue;
+
for (BasicBlock::iterator I = BB->begin(), E = --BB->end(); I != E; ++I)
if (!isValidInstruction(*I, Context) && !KeepGoing)
return false;
OpenPOWER on IntegriCloud