According to cppreference, store of one volatile
qualified cannot be reordered wrt to another volatile
qualified variable. In other words, in the below example, when y becomes 20, it is guaranteed that x will be 10.
volatile int x, y;
...
x = 10;
y = 20;
According to Wikipedia, ARM processor a store can be reordered after another store. So, in the below example, second store can be executed before first store since both destinations are disjoint, and hence they can be freely reordered.
str r1, [r3]
str r2, [r3, #4]
With this understanding, I wrote a toy program:
volatile int x, y;
int main() {
x = 10;
y = 20;
}
I expected some fencing to be present in the generated assembly to guarantee the store order of x and y. But the generated assembly for ARM was:
main:
movw r3, #:lower16:.LANCHOR0
movt r3, #:upper16:.LANCHOR0
movs r1, #10
movs r2, #20
movs r0, #0
str r1, [r3]
str r2, [r3, #4]
bx lr
x:
y:
So, how storing order is enforced here?