This is an archive of the discontinued LLVM Phabricator instance.

[MemoryDepndency] Relax the re-ordering with volatile store.
ClosedPublic

Authored by skatkov on Feb 15 2022, 1:56 AM.

Details

Summary

Volatile store does not provide any special rules for reordering with atomics.
Usual must alias analysis is enough here.

This makes the behavior similar to how volatile load is handled.

Diff Detail

Event Timeline

skatkov created this revision.Feb 15 2022, 1:56 AM
skatkov requested review of this revision.Feb 15 2022, 1:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 15 2022, 1:56 AM

@reames , last time this part was touched (https://reviews.llvm.org/D16857, ooch 2016) you provided the meaningful review. I would appreciate if you could look at this at some point.

To be honest I do not have a motivation example for this change and probably it terms of "do not touch if it works" I can abandon this patch.
I just mentioned inconsistency in handling Load and Store and according to my understanding of spec there is no difference and decided it is better to improve it.

nikic added a comment.Feb 15 2022, 2:19 AM

This looks correct to me, but I'm not an expert on volatile/atomic semantics.

reames accepted this revision.Feb 15 2022, 9:30 AM

LGTM w/required changes pre-commit.

llvm/test/Analysis/MemoryDependenceAnalysis/reorder-volatile.ll
11

Autogen this please. And precommit the test before landing the change.

29

Please add a test with a volatile load wrapped between two acquires, and a separate one with it wrapped by seq_cst loads. They *should not* fold. (Well, with the current logic at least.)

This revision is now accepted and ready to land.Feb 15 2022, 9:30 AM
skatkov updated this revision to Diff 409132.Feb 15 2022, 7:56 PM

Handled comments. Will land soon.

This revision was landed with ongoing or failed builds.Feb 15 2022, 7:59 PM
This revision was automatically updated to reflect the committed changes.