This is the mail archive of the
mailing list for the GCC project.
Re: basic asm and memory clobbers - Proposed solution
- From: Andrew Haley <aph at redhat dot com>
- To: David Wohlferd <dw at LimeGreenSocks dot com>, Jeff Law <law at redhat dot com>, Joseph Myers <joseph at codesourcery dot com>, rth at redhat dot com
- Cc: Richard Earnshaw <Richard dot Earnshaw at foss dot arm dot com>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>, Paul_Koning at Dell dot com, jakub at redhat dot com, rth at gcc dot gnu dot org, pinskia at gcc dot gnu dot org, Segher Boessenkool <segher at kernel dot crashing dot org>, Ian Lance Taylor <iant at google dot com>, Sandra Loosemore <sandra at codesourcery dot com>, Hans-Peter Nilsson <hp at bitrange dot com>, bernd dot edlinger at hotmail dot de
- Date: Mon, 14 Dec 2015 09:53:21 +0000
- Subject: Re: basic asm and memory clobbers - Proposed solution
- Authentication-results: sourceware.org; auth=none
- References: <56552209 dot 1020306 at LimeGreenSocks dot com> <56592801 dot 9010606 at LimeGreenSocks dot com> <565DC5F4 dot 6080804 at foss dot arm dot com> <565E1E37 dot 9080609 at LimeGreenSocks dot com> <alpine dot DEB dot 2 dot 10 dot 1512012323160 dot 12604 at digraph dot polyomino dot org dot uk> <565E6862 dot 7070401 at redhat dot com> <566B4BA1 dot 8000509 at LimeGreenSocks dot com> <566BEE35 dot 6070804 at redhat dot com> <566D0CE6 dot 6090905 at LimeGreenSocks dot com>
On 13/12/15 06:15, David Wohlferd wrote:
> However breakage and performance issues can still result solely from
> adding memory clobbers.
> And as I mentioned, "just memory clobber" may
> not be the behavior people expect. And if we aren't solving that, might
> there be a second update later to add registers? Talk about confusing
No, there will not be.
>> It allows basic asm to be used in a sensible way by pushing and
>> popping all used registers.
> If I were using basic asm, this would indeed seem like a sensible approach.
> However, it is not the most efficient. If I can clobber registers,
> push/pop are just wasted cycles. This just seems like another argument
> for deprecating basic asm and pushing people to extended.
Yes. I am not arguing against deprecation. We should do that.
> Imagine for a moment:
> If the only way right now to do inline asm in gcc was extended, and I
> proposed adding basic, how could I justify this 'new' feature?
You couldn't. It's legacy-only.
> Contra-wise, what if starting today all new inline asm were written
> using extended? How would that be a bad thing?
It would not. You are arguing against a position that no-one holds.
> Which means (to me), the only real justification for the continued
> existence of basic asm is backward compatibility. Which makes the
> arguments for changing its behavior (whether a little or a lot)
> kinda weird.
No, it does not make them weird at all. All it does is make an
existing feature safer.
> I still vote for doing everything we can think of to discourage people
> from using basic and begin using extended:
> - Change the docs to flat out deprecate basic (excluding top-level).
> - Add the warning so people's integrated dev environments will show the
> suspect lines.
OK, if the warning is optional.
> - Make the warning a default, but overridable (-Wno-only-top-basic-asm),
> so people who HAVE to support the old syntax still can.
That's a little more dubious. Maybe.
> - Make sure the docs for the warning describe (link to?) how to change
> asm from basic to extended and why.
> - Any bugs people report or posts people make involving basic asm get
> resolved as 'Try it with extended.'
> I'm just afraid that instead of pursuing any of these solutions, we
> are going to pursue Solution #0: Do nothing. A rather unsatisfying
> outcome after all this effort.
You can't simultaenously insist that it gets fixed the way you want
and complain about the difficulty of reaching consensus, y'know. :-)
A basic asm which clobbers memory and saves registers has no
correctness problems whatsoever. There is no reason that people
should not use it, and continue to use it if it suits them.