Bug 100953 - Add memory clobbers just for reads or just for writes
Summary: Add memory clobbers just for reads or just for writes
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: unknown
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: inline-asm
Depends on:
Blocks:
 
Reported: 2021-06-07 22:52 UTC by Segher Boessenkool
Modified: 2021-10-28 23:35 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-06-08 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Comment 1 Richard Biener 2021-06-08 08:00:20 UTC
Obviously "just for writes" is nonsense, but what's missing is the ability
to add a (use "memory"), which maybe just means allowing to specify
"memory" as use?  That would prevent moving stores across such asm() but
it would not cause "pointless reloading of globals".
Comment 2 Segher Boessenkool 2021-06-08 13:54:15 UTC
Sure :-)  But syntactically it probably is best put amongst the clobbers,
all code parsing that already knows about handling various special cases
of syntax (well, just "memory" and "cc", and the various ways of naming
registers).
Comment 3 James Y Knight 2021-06-22 20:38:58 UTC
For the compiler-barrier use-cases, you can use the __atomic_signal_fence builtin instead of an empty inline-asm statement.

E.g. if you want to make sure that all writes apperaing after a barrier are actually emitted after all reads/writes appearing before the barrier, use __atomic_signal_fence(__ATOMIC_RELEASE).