This change teaches DSE that the atomic memory intrinsics are stores
that can be eliminated, and can allow other stores to be eliminated.
This change specifically does not teach DSE that these intrinsics
can be partially eliminated (i.e. length reduced, and dest/src changed);
that will be handled in another change.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
I don't see any problems other than the comment inlined, but I don't know this part of code as well. Please wait for someone more familiar with it to take a look.
lib/Analysis/MemoryLocation.cpp | ||
---|---|---|
88 ↗ | (On Diff #142071) | What was the reason of renaming the parameter? Can it go as a separate NFC? |
Am I right in saying these are treated in the same way as unordered atomic stores are? In that they can be deleted by following non-atomic stores, even if they are "stronger" atomically? If so, this looks fine to me.
lib/Transforms/Scalar/DeadStoreElimination.cpp | ||
---|---|---|
868 ↗ | (On Diff #142071) | This one? This function does it's own special version of DSE. It's about removing stores to dead stack objects iirc. |
Yes, I believe that it correct -- at least that's the reasoning I've been going off of. The tests in test/Transforms/DeadStoreElimination/atomic.ll show unordered atomic stores essentially being treated the same as non-atomic stores, so if it's good there then it should be good here.
lib/Transforms/Scalar/DeadStoreElimination.cpp | ||
---|---|---|
868 ↗ | (On Diff #142071) | Good catch. Thanks! Looks like there might not be a test for this case at all. I'll try to add one of those as well. |
lib/Transforms/Scalar/DeadStoreElimination.cpp | ||
---|---|---|
868 ↗ | (On Diff #142071) | Made the change, but I'm having difficulty creating a test that gets to here. Calls to the memtransfer intrinsics end up getting into the conditional at line 838, above: // If the call might load from any of our allocas, then any store above // the call is live. DeadStackObjects.remove_if([&](Value *I) { // See if the call site touches the value. return isRefSet(AA->getModRefInfo(CS, I, getPointerSize(I, DL, *TLI))); }); The source argument for the intrinsic aliases the stack object(s), and this bit of code at 868 ends up having no effect. |
lib/Transforms/Scalar/DeadStoreElimination.cpp | ||
---|---|---|
868 ↗ | (On Diff #142071) | Yes, I agree it's impossible to get here because of the condition on line 825; an AnyMemTransferInst is also a CallSite. Please just delete this line, then. |