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: Sat, 12 Dec 2015 09:51:49 +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>
On 11/12/15 22:18, David Wohlferd wrote:
> And here are the three solutions that have been proposed:
> Solution 1:
> Just document the current behavior of basic asm.
> People who have written incorrect code can be pointed at the text and
> told to fix their code. People whose code is damaged by optimizations
> can rewrite using extended to add dependencies (possibly doc this?).
> Solution 2:
> Change the docs to say that basic asm clobbers everything (memory, all
> registers, etc) or perhaps just memory (some debate here), but that due
> to bugs that will eventually be addressed, it doesn't currently work
> this way.
It's not just bugs which make clobbering all registers unwise and/or
> Eventually (presumably in a future phase 1) modify the code to
> implement this.
> People who have written their code incorrectly may have some
> hard-to-find problems solved for them. This is particularly valuable
> for projects that are no longer being maintained. And while clobbers
> aren't the best solution to dependencies, they can help.
> Solution 3:
> Deprecate (and eventually disallow) the use of basic asm within
> functions (perhaps excluding asm("") and naked functions). Do this by
> emitting warnings (and eventually fatal errors). Doc this plan.
You've missed the most practical solution, which meets most common
usage: clobber memory, but not registers. That allows most of the
effects that people intuitively want and expect, but avoids the
breakage of register clobbers. It allows basic asm to be used in a
sensible way by pushing and popping all used registers.