[ScopDetection] Do not detect scops that exit to an unreachable
Scops that exit with an unreachable are today still permitted, but make little
sense to optimize. We therefore can already skip them during scop detection.
This speeds up scop detection in certain cases and also ensures that bugpoint
does not introduce unreachables when reducing test cases.
In practice this change should have little impact, as the performance of
unreachable code is unlikely to matter.
This commit is part of a series that makes Polly more robust in the presence
of unreachables.
llvm-svn: 297151
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index a637afa..6906552 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -1428,6 +1428,13 @@
return false;
}
+ DebugLoc DbgLoc;
+ if (isa<UnreachableInst>(CurRegion.getExit()->getTerminator())) {
+ DEBUG(dbgs() << "Unreachable in exit\n");
+ return invalid<ReportUnreachableInExit>(Context, /*Assert=*/true,
+ CurRegion.getExit(), DbgLoc);
+ }
+
if (!CurRegion.getEntry()->getName().count(OnlyRegion)) {
DEBUG({
dbgs() << "Region entry does not match -polly-region-only";
@@ -1445,7 +1452,6 @@
if (!allBlocksValid(Context))
return false;
- DebugLoc DbgLoc;
if (!isReducibleRegion(CurRegion, DbgLoc))
return invalid<ReportIrreducibleRegion>(Context, /*Assert=*/true,
&CurRegion, DbgLoc);