doc patch for memory clobbers in ASM
Geoff Keating
geoffk@cygnus.com
Mon Jun 26 13:18:00 GMT 2000
At present, gcc will still perform folding, loop hoisting, etc. on
asm statements which clobber "memory" but are not volatile; for
instance,
int main(void)
{
int t, i, z = 1;
for (i = 0; i < 10; i++)
asm ("# do something with memory and %0" : "=r"(t) : "r"(&z) : "memory");
return z;
}
gets folded down to an empty loop. This patch documents this
behaviour. The alternative would be to change it, but it needs to be
changed in lots of places; for instance, single_set needs to be taught
that the asm above isn't a single set, and so on.
Is this OK?
--
- Geoffrey Keating <geoffk@cygnus.com>
===File ~/patches/cygnus/asm-memclobberdoc.patch============
2000-06-26 Geoff Keating <geoffk@cygnus.com>
* extend.texi (Extended Asm): Mention that a memory clobber
does not count as a side-effect.
Index: extend.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/extend.texi,v
retrieving revision 1.53
diff -p -u -c -r1.53 extend.texi
cvs server: conflicting specifications of output style
*** extend.texi 2000/05/30 08:47:25 1.53
--- extend.texi 2000/06/26 20:12:30
*************** effect. But it is valid no matter what
*** 2558,2564 ****
If your assembler instruction modifies memory in an unpredictable
fashion, add @samp{memory} to the list of clobbered registers. This
will cause GNU CC to not keep memory values cached in registers across
! the assembler instruction.
You can put multiple assembler instructions together in a single
@code{asm} template, separated either with newlines (written as
--- 2558,2567 ----
If your assembler instruction modifies memory in an unpredictable
fashion, add @samp{memory} to the list of clobbered registers. This
will cause GNU CC to not keep memory values cached in registers across
! the assembler instruction. You will also want to add the
! @code{volatile} keyword if the memory affected is not listed in the
! inputs or outputs of the @code{asm}, as the @samp{memory} clobber does
! not count as a side-effect of the @code{asm}.
You can put multiple assembler instructions together in a single
@code{asm} template, separated either with newlines (written as
============================================================
More information about the Gcc-patches
mailing list