Fix assertion due to loop overlap with nonaffine region.
Reject and report regions that contains loops overlapping nonaffine region.
This situation typically happens in the presence of inifinite loops.
This addresses bug llvm.org/PR28071.
Differential Revision: http://reviews.llvm.org/D21312
Contributed-by: Huihui Zhang <huihuiz@codeaurora.org>
llvm-svn: 273905
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index 7036fe5..d672130 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -296,10 +296,28 @@
// All loops in the region have to be overapproximated too if there
// are accesses that depend on the iteration count.
+
+ BoxedLoopsSetTy ARBoxedLoopsSet;
+
for (BasicBlock *BB : AR->blocks()) {
Loop *L = LI->getLoopFor(BB);
- if (AR->contains(L))
+ if (AR->contains(L)) {
Context.BoxedLoopsSet.insert(L);
+ ARBoxedLoopsSet.insert(L);
+ }
+ }
+
+ // Reject if the surrounding loop does not entirely contain the nonaffine
+ // subregion.
+ BasicBlock *BBEntry = AR->getEntry();
+ Loop *L = LI->getLoopFor(BBEntry);
+ while (L && AR->contains(L))
+ L = L->getParentLoop();
+ if (L) {
+ for (const auto *ARBoxedLoop : ARBoxedLoopsSet)
+ if (!L->contains(ARBoxedLoop))
+ return invalid<ReportLoopOverlapWithNonAffineSubRegion>(
+ Context, /*Assert=*/true, L, AR);
}
return (AllowNonAffineSubLoops || Context.BoxedLoopsSet.empty());