[PATCH] D124247: [Trivial Dead] Consider any non volatile load as trivially dead independent on ordering

Serguei Katkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 25 04:35:06 PDT 2022


skatkov added a comment.

Hi Eli, nice example. Do I understand correctly that here is the problem with exactly using of monotonic? If we used unordered (aka relaxed) then load2 can be safely removed?

The bad thing here is the no analysis will help me, so for the function:
f(int x) {

  load acq a
  if (x == 42) {
    sync may happend due to incoming parameter x might be result of load a monotonic.
  }

}
So generally we should check all callers for this pattern which is likely not a good idea.

However if we could say that our language/runtime does not use monotonic atomic instructions (or do not use them for pointers from some addrspace or say for gc pointers) we are safe to remove such load?
Or you have some other example in your pocket?:)


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

https://reviews.llvm.org/D124247



More information about the llvm-commits mailing list