https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82602
--- Comment #8 from Xi Ruoyao <ryxi at stu dot xidian.edu.cn> ---
(In reply to David Brown from comment #7)
> There is no intention to make "asm volatile" a barrier, as you get with a
> memory clobber. The intention is to stop it moving past other volatile code
> (such as other asm volatiles, and volatile memory accesses). An "asm
> volatile" statement should still be moveable across other "normal" code.
I see... But then your code in the maillist
uint32_t status;
/* save the PRIMASK into 'status' */
__asm volatile ("mrs %0,PRIMASK" : "=r" (status) :: );
/* set PRIMASK to disable interrupts */
__asm volatile ("cpsid i");
foo(); /* call a function */
/* restore PRIMASK from 'status' */
__asm volatile ("msr PRIMASK,%0" :: "r" (status) : );
could still become
uint32_t status;
/* save the PRIMASK into 'status' */
__asm volatile ("mrs %0,PRIMASK" : "=r" (status) :: );
foo(); /* call a function */
/* set PRIMASK to disable interrupts */
__asm volatile ("cpsid i");
/* restore PRIMASK from 'status' */
__asm volatile ("msr PRIMASK,%0" :: "r" (status) : );
and still need a "memory" clobber.