[PATCH] D25848: [PM/OptBisect] Don't crash with some particular values of -opt-bisect-limit=

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 20 16:15:16 PDT 2016


davide created this revision.
davide added reviewers: mkuper, chandlerc, eli.friedman.
davide added a subscriber: llvm-commits.
Herald added a subscriber: mzolotukhin.

So,  while trying to reduce a testcase I realized I can trigger a crash in LICM if I specify a given value of -opt-bisect-limit
(the repro is the one from https://llvm.org/bugs/show_bug.cgi?id=30708)

  $ ./opt unopt.ll -opt-bisect-limit=53 -O3
  [...]
  BISECT: running pass (43) Loop Invariant Code Motion on loop                                                                                                                                                                                                                                                                                   │··························
  BISECT: running pass (44) Unswitch loops on loop                                                                                                                                                                                                                                                                                               │··························
  BISECT: running pass (45) Rotate Loops on loop                                                                                                                                                                                                                                                                                                 │··························
  BISECT: running pass (46) Loop Invariant Code Motion on loop                                                                                                                                                                                                                                                                                   │··························
  BISECT: running pass (47) Unswitch loops on loop                                                                                                                                                                                                                                                                                               │··························
  BISECT: running pass (48) Rotate Loops on loop                                                                                                                                                                                                                                                                                                 │··························
  BISECT: running pass (49) Loop Invariant Code Motion on loop                                                                                                                                                                                                                                                                                   │··························
  BISECT: running pass (50) Unswitch loops on loop                                                                                                                                                                                                                                                                                               │··························
  BISECT: running pass (51) Rotate Loops on loop                                                                                                                                                                                                                                                                                                 │··························
  BISECT: running pass (52) Loop Invariant Code Motion on loop                                                                                                                                                                                                                                                                                   │··························
  BISECT: running pass (53) Unswitch loops on loop                                                                                                                                                                                                                                                                                               │··························
  BISECT: NOT running pass (54) Rotate Loops on loop                                                                                                                                                                                                                                                                                             │··························
  BISECT: NOT running pass (55) Loop Invariant Code Motion on loop                                                                                                                                                                                                                                                                               │··························
  BISECT: NOT running pass (56) Unswitch loops on loop                                                                                                                                                                                                                                                                                           │··························
  BISECT: NOT running pass (57) Rotate Loops on loop                                                                                                                                                                                                                                                                                             │··························
  [...]
  opt: /home/davide/work/llvm-monorepo/llvm/lib/Transforms/Scalar/LICM.cpp:156: virtual bool {anonymous}::LegacyLICMPass::doFinalization(): Assertion `LICM.getLoopToAliasSetMap().empty() && "Didn't free loop alias sets"' failed.                                                                                                      

I do think that the problem here is that if `skipLoop(L)` is true, we don't call the deleteSimpleAnalysisLoop() hook in the Loop Pass Manager, this leaves some pending elements inside LICM internal data structures -> `doFinalization()` checks for the map to be empty, and hits the assertion.


https://reviews.llvm.org/D25848

Files:
  include/llvm/Analysis/LoopPass.h
  lib/Analysis/LoopPass.cpp


Index: lib/Analysis/LoopPass.cpp
===================================================================
--- lib/Analysis/LoopPass.cpp
+++ lib/Analysis/LoopPass.cpp
@@ -205,7 +205,7 @@
                                     : CurrentLoop->getHeader()->getName());
       dumpPreservedSet(P);
 
-      if (LoopWasDeleted) {
+      if (LoopWasDeleted || P->skipLoop(CurrentLoop)) {
         // Notify passes that the loop is being deleted.
         deleteSimpleAnalysisLoop(CurrentLoop);
       } else {
Index: include/llvm/Analysis/LoopPass.h
===================================================================
--- include/llvm/Analysis/LoopPass.h
+++ include/llvm/Analysis/LoopPass.h
@@ -87,7 +87,7 @@
   /// associated analysis values can be deleted.
   virtual void deleteAnalysisLoop(Loop *L) {}
 
-protected:
+public:
   /// Optional passes call this function to check whether the pass should be
   /// skipped. This is the case when Attribute::OptimizeNone is set or when
   /// optimization bisect is over the limit.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25848.75363.patch
Type: text/x-patch
Size: 1017 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161020/bb3819c3/attachment-0001.bin>


More information about the llvm-commits mailing list