At the moment, we mark every atomic memory access as being also volatile. This is unnecessarily conservative and prohibits many legal transforms (DCE, folding, etc..).
This patch is build on top of a series of other patches which adjust SelectionDAG code to (for the moment) be as conservative for an atomic access as for a volatile access. There are a couple already out for review, with more to follow:
* D57593 Fix a bug in the definition of isUnordered on MachineMemOperand
* D57596 [CodeGen] Be conservative about atomic accesses as for volatile
The intention once all of these land is to apply this patch as an NFC. (i.e. there should be no change in behaviour associated with this patch) Once it's in and baked for a bit, we'll start working through removing unnecessary bailouts one by one. We applied this same strategy to the middle end a few years ago, with good success.
Disturbingly, this patch in it's current state - which is known to be incorrect due to not having the supporting patches references above - does not currently trigger any test failures in a make check run. That clearly needs fixed before this can be landed.