[PATCH] D129636: Fix a LSR debug invariance issue

Markus Lavin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 4 00:43:33 PDT 2022


markus added a comment.

In D129636#3696750 <https://reviews.llvm.org/D129636#3696750>, @fhahn wrote:

> I think I am missing some context here, but this looks a bit suspicious. I am not sure if exposing and checking whether a SCEV exists is the right way to go.

Right. I am not so sure this is a good idea either.

The underlaying problem, as I understand it and see it, is that due to the caching in `SE.ExprValueMap` past calls to `getSCEV` will affect IR generated by future calls to `SCEVExpander` and this is not obvious. While it is a reasonable optimization to try and reuse IR during `SCEVExpander` based on what has already been analyzed I think this 'side-effect' of `getSCEV` is somewhat unfortunate in the context of debug intrinsics that are not supposed to affect code generation.

Another, also ugly, solution could be to add a flag to `getSCEV` so that caching can be inhibited for certain calls.

> IIUC the main issue seems to be that we try to create SCEVs for all dbg intrinsics? Would it be possible to instead only get SCEV expressions for values we really need (that/s the induction variable I assume, for which there already should be SCEV expression)?

That is possibly a better solution but I do not have sufficient insight into the salvaging algorithm to comment on that (@chrisjackson)


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

https://reviews.llvm.org/D129636



More information about the llvm-commits mailing list