atomic_ operations not safe from compiler optimizations
I don't have/know of any test or app that exposes this. In particular, looking at objdump currently - at least on my machine - the compiler doesn't take advantage of the hole. Currently, we C-code
ATOMIC_OP (e.g. inc, compare/exchange etc.) SET (flag operation)
Both statements are "asm volatile". Theoretically, the compiler is allowed to move flag modifying instructions in between the statements. To fix, we need to either
- move all instructions into the same asm volatile statement OR
- at least add "cc" clobber to both asm volatile statements (and I would add "memory" to both as well).