https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124218
Bug ID: 124218
Summary: ipa ignores memory clobbers for non-static variables.
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ipa
Assignee: unassigned at gcc dot gnu.org
Reporter: chris.n.copeland at gmail dot com
Target Milestone: ---
A memory clobber isn't respected when using -O1 -fwhole-program. This example
is minimized from a larger example where the memory clobber is on an inline asm
statement that triggers a context switch, and the new context can then modify
the variable, so the variable should be re-loaded after this clobber. I see the
same behavior on all versions of arm-none-eabi-gcc available on godbolt, going
back to 5.4.1.
https://godbolt.org/z/eG4h39Kx5
I see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80728 which seems related,
but the example there used statics, whereas here a different translation unit
should be allowed to modify the variable.