From 41f046a282915f3009fd8667121467157eefd346 Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Mon, 27 Jun 2016 19:00:49 +0000 Subject: 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 llvm-svn: 273905 --- polly/lib/Analysis/ScopDetection.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'polly/lib/Analysis/ScopDetection.cpp') diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp index 7036fe525f3..d6721302b34 100644 --- a/polly/lib/Analysis/ScopDetection.cpp +++ b/polly/lib/Analysis/ScopDetection.cpp @@ -296,10 +296,28 @@ bool ScopDetection::addOverApproximatedRegion(Region *AR, // 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( + Context, /*Assert=*/true, L, AR); } return (AllowNonAffineSubLoops || Context.BoxedLoopsSet.empty()); -- cgit v1.2.3