[PATCH] D88166: [SCEV] Verify that all mapped SCEV AddRecs refer to valid loops.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 10:08:39 PDT 2020


fhahn created this revision.
fhahn added reviewers: reames, efriedma, sanjoy.google, mkazantsev.
Herald added subscribers: javed.absar, hiraditya.
Herald added a project: LLVM.
fhahn requested review of this revision.

This check helps to guard against cases where expressions referring to
invalidated/deleted loops are not properly invalidated.

The additional check is motivated by the reproducer shared for 8fdac7cb7abb <https://reviews.llvm.org/rG8fdac7cb7abbeeaed016ef9eb7a087458e41e33f>
and I think in general make sense as a sanity check.

It would probably be even better to iterate over all unique SCEVs, but
that currently causes a few assertion in loop fusion, which I still need
to investigate.

IIUC expressions should be deleted from UniqueSCEVs as soon
as the last value handle to an expression is removed from
ValueExprMap.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88166

Files:
  llvm/lib/Analysis/ScalarEvolution.cpp


Index: llvm/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -11986,6 +11986,14 @@
       std::abort();
     }
   }
+
+  // Check for SCEV expressions referencing invalid/deleted loops.
+  for (auto &KV : ValueExprMap) {
+    auto *AR = dyn_cast<SCEVAddRecExpr>(KV.second);
+    if (!AR)
+      continue;
+    assert(!AR->getLoop()->isInvalid() && "AddRec references invalid loop");
+  }
 }
 
 bool ScalarEvolution::invalidate(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88166.293786.patch
Type: text/x-patch
Size: 567 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200923/22cec445/attachment.bin>


More information about the llvm-commits mailing list