This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: basic asm and memory clobbers
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: David Wohlferd <dw at LimeGreenSocks dot com>
- Cc: Jeff Law <law at redhat dot com>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>, rth at gcc dot gnu dot org, pinskia at gcc dot gnu dot org, Sandra Loosemore <sandra at codesourcery dot com>
- Date: Thu, 19 Nov 2015 21:14:31 -0600
- Subject: Re: basic asm and memory clobbers
- Authentication-results: sourceware.org; auth=none
- References: <563FE459 dot 3000003 at LimeGreenSocks dot com> <20151109093229 dot GA5260 at gate dot crashing dot org> <56493010 dot 9070707 at LimeGreenSocks dot com> <564A4AA5 dot 1080706 at redhat dot com> <564AC155 dot 4040601 at LimeGreenSocks dot com> <564B9CB1 dot 1060001 at redhat dot com> <564E762B dot 6070705 at LimeGreenSocks dot com>
On Thu, Nov 19, 2015 at 05:23:55PM -0800, David Wohlferd wrote:
> For that reason, I'd like to propose adding 2 new clobbers to extended
> asm as part of this work:
>
> "clobberall" - This gives extended the same semantics as whatever the
> new basic asm will be using.
> "clobbernone" - This gives the same semantics as the current basic asm.
I don't think this is necessary or useful. They are also awful names:
"clobberall" cannot clobber everything (think of the stack pointer),
and "clobbernone" does clobber some (those clobbered by any asm),
> Clobbernone may seem redundant, since not specifying any clobbers should
> do the same thing. But actually it doesn't, at least on i386. At
> present, there is no way for extended asm to not clobber "cc". I don't
> know if other platforms have similar issues.
Some do. The purpose is to stay compatible with asm written for older
versions of the compiler.
> When basic asm changes, I expect that having a way to "just do what it
> used to do" is going to be useful for some people.
24414 says the documented behaviour hasn't been true for at least
fourteen years. It isn't likely anyone is relying on that behaviour.
> but perhaps the solution here is to just say that it doesn't
> clobber flags (currently the most common case?), and update the docs if
> and when people complain? Yes, that's bad, but saying nothing at all
> isn't any better. And we know it's true for at least 2 platforms.
Saying nothing at all at least is *correct*.
It isn't necessary for users to know what registers the compiler
considers to be clobbered by an asm, unless they actually clobber
something in the assembler code themselves. They can write extended
asm in that case.
Maybe you can put that in the doc? "If you modify any register or
memory, use an extended asm"? Jeff, do you agree with that?
Segher