[PATCH] D114112: [SCEVAA] Avoid forming malformed pointer diff expressions

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 17 10:58:09 PST 2021


reames created this revision.
reames added reviewers: efriedma, nikic, fhahn, lebedev.ri.
Herald added subscribers: jeroen.dobbelaere, javed.absar, bollu, hiraditya, mcrosier.
reames requested review of this revision.
Herald added a project: LLVM.

This solves the same crash as in D104503 <https://reviews.llvm.org/D104503>, but with a different approach.

The test case test_non_dom demonstrates a case where scev-aa crashes today. (If exercised either by -eval-aa or -licm.) The basic problem is that SCEV-AA expects to be able to compute a pointer difference between two SCEVs for any two pair of pointers we do an alias query on. For (valid, but out of scope) reasons, we can end up asking whether expressions in different sub-loops can alias each other. This results in a subtraction expression being formed where neither operand dominates the other.

The approach this patch takes is to leverage the "defining scope" notion we introduced for flag semantics to detect and disallow the formation of the problematic SCEV.  This ends up being relatively straight forward on that new infrastructure.  This change does hint that we should probably be verifying a similar property for all SCEVs somewhere, but I'll leave that to a follow on change if we decide to take this approach.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114112

Files:
  llvm/include/llvm/Analysis/ScalarEvolution.h
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/lib/Analysis/ScalarEvolutionAliasAnalysis.cpp
  llvm/test/Analysis/ScalarEvolution/scev-aa.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114112.387995.patch
Type: text/x-patch
Size: 9580 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211117/c03a5aac/attachment.bin>


More information about the llvm-commits mailing list