From c6987c18de486650bf51c46c625ff59b218c0f24 Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Sat, 26 Sep 2015 13:41:43 +0000 Subject: [PATCH] [FIX] Use the surrounding loop for non-affine SCoP regions When the whole SCoP is a non-affine region we need to use the surrounding loop in the construction of the schedule as that is the one that will be looked up after the schedule generation. This fixes bug 24947 llvm-svn: 248667 --- polly/include/polly/ScopInfo.h | 7 +++-- polly/lib/Analysis/ScopInfo.cpp | 3 +- ...whole-scop-non-affine-subregion-in-loop.ll | 30 +++++++++++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 polly/test/ScopInfo/NonAffine/whole-scop-non-affine-subregion-in-loop.ll diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h index 35efa7ef3a06..021f3fe8a5b8 100644 --- a/polly/include/polly/ScopInfo.h +++ b/polly/include/polly/ScopInfo.h @@ -1168,9 +1168,10 @@ private: /// @brief Build Schedule and ScopStmts. /// - /// @param R The current region traversed. - /// @param LI The LoopInfo object. - /// @param SD The ScopDetection object. + /// @param R The current region traversed. + /// @param LI The LoopInfo object. + /// @param SD The ScopDetection object. + /// @param LoopSchedules Map from loops to their schedule and progress. void buildSchedule( Region *R, LoopInfo &LI, ScopDetection &SD, DenseMap> &LoopSchedules); diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index b8c3b151b89c..564147b35853 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -2645,7 +2645,8 @@ void Scop::buildSchedule( auto *Stmt = addScopStmt(nullptr, R); auto *UDomain = isl_union_set_from_set(Stmt->getDomain()); auto *StmtSchedule = isl_schedule_from_domain(UDomain); - auto &LSchedulePair = LoopSchedules[nullptr]; + Loop *L = getLoopSurroundingRegion(*R, LI); + auto &LSchedulePair = LoopSchedules[L]; LSchedulePair.first = StmtSchedule; return; } diff --git a/polly/test/ScopInfo/NonAffine/whole-scop-non-affine-subregion-in-loop.ll b/polly/test/ScopInfo/NonAffine/whole-scop-non-affine-subregion-in-loop.ll new file mode 100644 index 000000000000..4f812d6d542e --- /dev/null +++ b/polly/test/ScopInfo/NonAffine/whole-scop-non-affine-subregion-in-loop.ll @@ -0,0 +1,30 @@ +; RUN: opt %loadPolly -polly-detect-unprofitable -polly-scops -analyze < %s +; +; Regression test that triggered a memory leak at some point (24947). +; +define void @snrm2() { +entry: + br label %for.body.56.lr.ph + +for.body.56.lr.ph: ; preds = %entry + br label %for.body.56 + +for.body.56: ; preds = %for.inc.106, %for.body.56.lr.ph + br label %if.end.73 + +if.end.73: ; preds = %for.body.56 + %cmp82 = fcmp ogt float undef, undef + br i1 %cmp82, label %if.then.84, label %if.end.100 + +if.then.84: ; preds = %if.end.73 + br label %for.inc.106 + +if.end.100: ; preds = %if.end.73 + br label %for.inc.106 + +for.inc.106: ; preds = %if.end.100, %if.then.84 + br i1 undef, label %for.body.56, label %for.end.110 + +for.end.110: ; preds = %for.inc.106 + ret void +}