This is an archive of the discontinued LLVM Phabricator instance.

[SimplifyCFG] Volatile memory operations do not trap
ClosedPublic

Authored by lebedev.ri on Jul 2 2021, 4:28 AM.

Details

Summary

Somewhat related to D105338.
While it is up for disscussion whether or not volatile store traps,
so far there has been no complaints that volatile load/cmpxchg/atomicrmw also may trap.
And even if simplifycfg currently concervatively believes that to be the case,
instcombine does not: https://godbolt.org/z/5vhv4K5b8

Diff Detail

Event Timeline

lebedev.ri created this revision.Jul 2 2021, 4:28 AM
lebedev.ri requested review of this revision.Jul 2 2021, 4:28 AM
nikic added a comment.Jul 2 2021, 8:25 AM

This whole code doesn't really make sense. Can we switch it to isGuaranteedToTransferExecutionToSuccessor() (plus the volatile store exception)?

lebedev.ri added a comment.EditedJul 2 2021, 9:41 AM

This whole code doesn't really make sense. Can we switch it to isGuaranteedToTransferExecutionToSuccessor() (plus the volatile store exception)?

Yep, this code is really broken.
I'm intentionally not just doing that because i want to make the test diff smaller. (i.e. isGuaranteedToTransferExecutionToSuccessor() will be either next patch, or one after that)

nikic accepted this revision.Jul 2 2021, 11:45 AM

Okay, LGTM then. This converges on guaranteed-to-execute, and InstCombine has been doing this for quite a while now, so it's clearly fine in practice as well.

This revision is now accepted and ready to land.Jul 2 2021, 11:45 AM

Yep.
Thank you for the review.

This revision was automatically updated to reflect the committed changes.