Re: asm volatile statement reordering

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 17, 2017 at 11:13:36AM +0200, David Brown wrote:
> My solution to this
> particular ordering problem is:
> 
>     uint32_t status;
>     asm volatile ("mrs %0, PRIMASK" : "=r" (status) :: );
>     asm volatile ("cpsid i" :: "" (status) :);
> 
>     foo();
> 
>     asm volatile ("msr PRIMASK, %0" :: "r" (status) : );

And that only works for you because you have foo() separately compiled.
If it was inlined (say with LTO) its instructions could move anywhere.
That is without changing a character in your source code; your program
simply does not mean what you think it means.


Segher



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux