[PATCH] D36776: [polly] Fix ScopDetectionDiagnostic test failure caused by r310940

Jakub Kuderski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 15 16:50:09 PDT 2017


kuhar created this revision.
kuhar added a project: Polly.
Herald added subscribers: kristof.beyls, aemerson.
Herald added a reviewer: bollu.

ScopDetection used to check if a loop withing a region was infinite and emitted a diagnostic in such cases. After r310940 there's no point checking against that situation, as infinite loops don't appear in regions anymore.

The test failure was observed on these two polly buildbots:
http://lab.llvm.org:8011/builders/polly-arm-linux/builds/8368
http://lab.llvm.org:8011/builders/polly-amd64-linux/builds/10310

This patch XFAILs `ReportLoopHasNoExit.ll` and turns infinite loop detection into an assert.


https://reviews.llvm.org/D36776

Files:
  lib/Analysis/ScopDetection.cpp
  test/ScopDetectionDiagnostics/ReportLoopHasNoExit.ll


Index: test/ScopDetectionDiagnostics/ReportLoopHasNoExit.ll
===================================================================
--- test/ScopDetectionDiagnostics/ReportLoopHasNoExit.ll
+++ test/ScopDetectionDiagnostics/ReportLoopHasNoExit.ll
@@ -1,3 +1,9 @@
+; XFAIL: *
+
+; The test case stopped making sense after r310940 that added infinite loops to the
+; PostDominatorTree. Infinite loops are postdominated ony by the virtual root, which
+; causes them not to appear in regions in ScopDetection anymore.
+
 ; RUN: opt %loadPolly -pass-remarks-missed="polly-detect" -polly-allow-nonaffine-loops -analyze  -polly-detect < %s 2>&1 | FileCheck %s
 ; RUN: opt %loadPolly -pass-remarks-missed="polly-detect" -polly-allow-nonaffine-loops=false -analyze  -polly-detect < %s 2>&1 | FileCheck %s
 
Index: lib/Analysis/ScopDetection.cpp
===================================================================
--- lib/Analysis/ScopDetection.cpp
+++ lib/Analysis/ScopDetection.cpp
@@ -1165,17 +1165,6 @@
   return invalid<ReportUnknownInst>(Context, /*Assert=*/true, &Inst);
 }
 
-/// Check whether @p L has exiting blocks.
-///
-/// @param L The loop of interest
-///
-/// @return True if the loop has exiting blocks, false otherwise.
-static bool hasExitingBlocks(Loop *L) {
-  SmallVector<BasicBlock *, 4> ExitingBlocks;
-  L->getExitingBlocks(ExitingBlocks);
-  return !ExitingBlocks.empty();
-}
-
 bool ScopDetection::canUseISLTripCount(Loop *L,
                                        DetectionContext &Context) const {
   // Ensure the loop has valid exiting blocks as well as latches, otherwise we
@@ -1196,34 +1185,18 @@
   // Loops that contain part but not all of the blocks of a region cannot be
   // handled by the schedule generation. Such loop constructs can happen
   // because a region can contain BBs that have no path to the exit block
-  // (Infinite loops, UnreachableInst), but such blocks are never part of a
-  // loop.
-  //
-  // _______________
-  // | Loop Header | <-----------.
-  // ---------------             |
-  //        |                    |
-  // _______________       ______________
-  // | RegionEntry |-----> | RegionExit |----->
-  // ---------------       --------------
-  //        |
-  // _______________
-  // | EndlessLoop | <--.
-  // ---------------    |
-  //       |            |
-  //       \------------/
-  //
-  // In the example above, the loop (LoopHeader,RegionEntry,RegionExit) is
-  // neither entirely contained in the region RegionEntry->RegionExit
-  // (containing RegionEntry,EndlessLoop) nor is the region entirely contained
-  // in the loop.
-  // The block EndlessLoop is contained in the region because Region::contains
-  // tests whether it is not dominated by RegionExit. This is probably to not
-  // having to query the PostdominatorTree. Instead of an endless loop, a dead
-  // end can also be formed by an UnreachableInst. This case is already caught
-  // by isErrorBlock(). We hence only have to reject endless loops here.
-  if (!hasExitingBlocks(L))
-    return invalid<ReportLoopHasNoExit>(Context, /*Assert=*/true, L);
+  // (infinite loops, UnreachableInst).
+  // We do not have to verify against infinite loops here -- they are
+  // postdominated only by the virtual exit and do not appear in regions.
+  // Instead of an infinite loop, a dead end can also be formed by an
+  // UnreachableInst. This case is already caught by isErrorBlock().
+
+#ifndef NDEBUG
+  // Make sure that the loop has exits (i.e. is not infinite).
+  SmallVector<BasicBlock *, 4> ExitingBlocks;
+  L->getExitingBlocks(ExitingBlocks);
+  assert(!ExitingBlocks.empty() && "Region with an infinite loop found!");
+#endif
 
   if (canUseISLTripCount(L, Context))
     return true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36776.111284.patch
Type: text/x-patch
Size: 3734 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170815/8e54488f/attachment-0001.bin>


More information about the llvm-commits mailing list