Local variables reordering and 'asm volatile("" ::: "memory");'

Segher Boessenkool segher@kernel.crashing.org
Sun Sep 8 21:12:00 GMT 2019


On Sun, Sep 08, 2019 at 11:48:22PM +0300, Alexander Monakov wrote:
> (in general empty volatile asms with non-empty constraints is a nice tool for
> limiting what the compiler may do)

Yup.  But if you want to save yourself some headaches don't do an empty
template.  Inline asm with an empty template does not end up in the
resulting output file at all.  For "empty" asm that does in fact have
operands you can write e.g.

  asm("# %0" :: "g"(x));

which also nicely shows you where that input lives.  This isn't fully
portable (the comment character is different for different assembler
dialects).  You can just write a single space character in the template
if all you want is for the asm to show up in the assembler output.


Segher



More information about the Gcc-help mailing list