On Sun, Nov 08, 2015 at 04:10:01PM -0800, David Wohlferd wrote: > It seems like a doc update is what is needed to close PR24414 (Old-style > asms don't clobber memory).
What is needed to close the bug is to make the compiler work properly. Whether that means clobbering memory or not, I don't much care -- with the status quo, if you want your asm to clobber memory you have to use extended asm; if basic asm is made to clobber memory, if you want your asm to *not* clobber memory you have to use extended asm (which you can with no operands by writing e.g. asm("bork" : ); ). So both behaviours are available whether we make a change or not. But changing things now will likely break user code. > Safely accessing C data and calling functions from basic @code{asm} is more > -complex than it may appear. To access C data, it is better to use extended > +complex than it may appear. To access C data (including both local and > +global register variables), use extended > @code{asm}. I don't think this makes things clearer. Register vars are described elsewhere already; if you really think it needs mentioning here, put it at the end (in its own sentence), don't break up this sentence. (dot space space). > +Basic @code{asm} statements are not treated as though they used a "memory" > +clobber, although they do implicitly perform a clobber of the flags > +(@pxref{Clobbers}). They do not clobber the flags. Observe: === void f(int a) { a = a >> 2; if (a <= 0) asm("OHAI"); if (a >= 0) asm("OHAI2"); } === Compiling this for powerpc gives (-m32, edited): f: srawi. 9,3,2 # this sets cr0 ble 0,.L5 # this uses cr0 .L2: OHAI2 blr .p2align 4,,15 .L5: OHAI bnelr 0 # this uses cr0 b .L2 which shows that CR0 (which is "cc") is live over the asm. So are all other condition regs. It is true for cc0 targets I guess, but there aren't many of those left. > Also, there is no implicit clobbering of registers, > +so any registers changed must be restored to their original value before > +exiting the @code{asm}. One of the important uses of asm is to set registers GCC does not know about, so you might want to phrase this differently. Segher