summaryrefslogtreecommitdiffstats
path: root/polly/lib/Analysis/ScopInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'polly/lib/Analysis/ScopInfo.cpp')
-rw-r--r--polly/lib/Analysis/ScopInfo.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp
index b61d9fa81d7..f3271c20334 100644
--- a/polly/lib/Analysis/ScopInfo.cpp
+++ b/polly/lib/Analysis/ScopInfo.cpp
@@ -3618,8 +3618,15 @@ void Scop::buildSchedule(ScopDetection &SD, LoopInfo &LI) {
Loop *L = getLoopSurroundingRegion(getRegion(), LI);
LoopStackTy LoopStack({LoopStackElementTy(L, nullptr, 0)});
buildSchedule(getRegion().getNode(), LoopStack, SD, LI);
- assert(LoopStack.size() == 1 && LoopStack.back().L == L);
- Schedule = LoopStack[0].Schedule;
+ assert(!LoopStack.empty());
+ if (LoopStack.size() == 1 && LoopStack.back().L == L) {
+ Schedule = LoopStack[0].Schedule;
+ } else {
+ // If something went wrong we have to cleanup.
+ assert(!hasFeasibleRuntimeContext());
+ while (!LoopStack.empty())
+ isl_schedule_free(LoopStack.pop_back_val().Schedule);
+ }
}
/// To generate a schedule for the elements in a Region we traverse the Region
@@ -3662,9 +3669,22 @@ void Scop::buildSchedule(Region *R, LoopStackTy &LoopStack, ScopDetection &SD,
// iterator. If it is set we have to explore the next sub-region/block from
// the iterator (if any) to guarantee progress. If it is not set we first try
// the next queued sub-region/blocks.
+ unsigned RemainingWork = WorkList.size() + DelayList.size() + 1;
while (!WorkList.empty() || !DelayList.empty()) {
+ Loop *LastLoop = LoopStack.back().L;
RegionNode *RN;
+ // FIXME: We will bail out if we cannot make progress. So far that is only
+ // known to happen in the presence of infinite loops without an exit
+ // edge. For such cases there is no region covering only the loop and
+ // our reasoning fails.
+ if (WorkList.size() + DelayList.size() >= RemainingWork) {
+ invalidate(INFINITELOOP, R->getEntry()->getTerminator()->getDebugLoc());
+ LastLoop = nullptr;
+ }
+
+ RemainingWork = WorkList.size() + DelayList.size();
+
if ((LastRNWaiting && !WorkList.empty()) || DelayList.size() == 0) {
RN = WorkList.front();
WorkList.pop_front();
@@ -3678,9 +3698,8 @@ void Scop::buildSchedule(Region *R, LoopStackTy &LoopStack, ScopDetection &SD,
if (!getRegion().contains(L))
L = OuterScopLoop;
- Loop *LastLoop = LoopStack.back().L;
if (LastLoop != L) {
- if (!LastLoop->contains(L)) {
+ if (LastLoop && !LastLoop->contains(L)) {
LastRNWaiting = true;
DelayList.push_back(RN);
continue;
OpenPOWER on IntegriCloud