You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
gcc only generates one store, a = 2;, while clang keeps both. clang seems to treat asm volatile(""); as a memory barrier, gcc doesn't. afaik, asm volatile("" ::: "memory"); is the only thing that works on gcc.
The text was updated successfully, but these errors were encountered:
int main(void)
{
a = 1;
asm volatile ("");
a = 2;
return a;
}
gcc only generates one store, `a = 2;`, while clang keeps both. clang seems to treat `asm volatile("");` as a memory barrier, gcc doesn't. afaik, `asm volatile("" ::: "memory");` is the only thing that works on gcc.
</details>
For basic asm with non-empty assembler string GCC assumes the assembler block does not change any general purpose registers, but it may read or write any globally accessible variable.
This means asm(""); is not a compiler memory barrier but asm(";"); will be.
gcc only generates one store,
a = 2;
, while clang keeps both. clang seems to treatasm volatile("");
as a memory barrier, gcc doesn't. afaik,asm volatile("" ::: "memory");
is the only thing that works on gcc.The text was updated successfully, but these errors were encountered: