This is the patch 3/3 resulting from the split of D4797.
Even loads/stores that have a stronger ordering than monotonic can be safe.
The rule is no release-acquire pair on the path from the QueryInst, assuming that
the QueryInst is not atomic itself.
I also cleaned up a bit the test DeadStoreElimination/atomic.ll
as I was adding tests to it
I'm still not finding this explanation particularly clear. I'm going to ask you not to commit this until you can justify why this approach is correct.
A potentially more intuitive way to explain this is to why this reordering is valid:
store x = 0
acquire operator
release operation
load x < -- okay to use zero
This is valid because the first pair of operations and the second pair can both be reordered. i.e. the intermediate state is:
acquire operation
store x = 0
load x < -- now obviously zero
release operation
What is "discriminating context"? What does it mean to "clobber"?