[PATCH] D129636: Fix a LSR debug invariance issue

Chris Jackson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 11 03:06:30 PDT 2022


chrisjackson added a comment.

In D129636#3715417 <https://reviews.llvm.org/D129636#3715417>, @mkazantsev wrote:

> Did you consider that `forgetValue` in fact does not only forget the value you are aiming, but also all its users recursively? Not SCEV users (they likely don't exist), but instruction users.
>
> Imagine that some of the users had no-wrap flags inferred from other queries. Now you forget it, and the flags get lost. Won't this introruce a similar issue in another place? It may also affect some loops into which these values are involved.
>
> Generally, exposing API about existing SCEVs isn't a great idea, and I don't see enough justification in your case.
>
> The best alternative I can suggest is to create a new ScalarEvolution instance and use it for dbg value queries. It should be good enough if the only purpose of that is to find undefs.
>
> Anyways, why do you need SCEV at all to find undefs? Can we instead traverse through instructions and get rid of SCEV query at all?

SCEV is not being used to find undefs. The SCEV for a location referenced in a dbg.value is recorded, and if that location is optimised away, then the SCEV is used to generate a DWARF expression that  computes the value of the locations and allows the dbg.value to be retained instead of dropped.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129636/new/

https://reviews.llvm.org/D129636



More information about the llvm-commits mailing list