It seems like a doc update is what is needed to close PR24414 (Old-style
asms don't clobber memory). I'm working on this now (phase 1) in the
unlikely event that someone is inspired to make a code change here instead.
Like Richard Henderson, I rather expected basic (or "old-style") asm to
perform a memory clobber (it doesn't). This bug is now over a decade
old, so presumably the question of how this is going to work is
settled. IAC, the docs should reflect the current behavior.
Based on this issue plus what I have learned since last updating this
page, I'm proposing the attached patch.
dw
CCing the commenters from the bug.
Index: extend.texi
===================================================================
--- extend.texi (revision 229910)
+++ extend.texi (working copy)
@@ -7353,7 +7353,8 @@
@end itemize
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}.
Do not expect a sequence of @code{asm} statements to remain perfectly
@@ -7376,6 +7377,12 @@
visibility of any symbols it references. This may result in GCC discarding
those symbols as unreferenced.
+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}). Also, there is no implicit clobbering of registers,
+so any registers changed must be restored to their original value before
+exiting the @code{asm}.
+
The compiler copies the assembler instructions in a basic @code{asm}
verbatim to the assembly language output file, without
processing dialects or any of the @samp{%} operators that are available with