Re: inlined functions and ABI guarantees

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks Bob,
Given Diego's answer (on the effect of inlining on preserved registers), I'm now asking a slightly different question on something that might help with inlining a function that potentially destroys more registers than what GCC knows about. You can pitcure such a function as an inlined version of SystemV swapcontext: before you return you might have executed code in so many other threads that all your registers are gone. But at the same time saving all registers is a waste, as at each call site
only a few are really live and many will be reloaded anyhow.

So the new question is not which registers are callee-save and which are caller-save,
which is the only thing I believe the ABI specify.
My question is, given:

	__asm__ __volatile__ (
		"some sequence of opaque insn that (potentially destroy all registers"
		:  /* outputs */
		:  /* inputs */
		:  /* clobbers */);

which GPRs can be placed in the clobber list?
Assume empty inputs and outputs.

Placing 15 X86_64 registers (all minus rsp) causes GCC to complain
(in some cases) about inability of finding registers of a specific class,
presumably in the reload phase. I don't remember the details of the
error message, but I can reproduce the situation if useful.

The only limitation on clobbers that I've found is that register mentioned in /*inputs*/ and /*outputs*/ need not to be explicitely clobbered as GCC knows about them already.

Hope this clarifies my question.


On Feb 24, 2008, at 11:27 AM, Bob Plantz wrote:


On Sun, 2008-02-24 at 10:51 -0500, Maurizio Vitale wrote:
As a followup question (assuming I have a function that destroys all
registers
in ways the compiler cannot know about), is there documentation
(for each platform, although I'm interested in X86_64 only)
on the minimum set of registers that must be left available to GCC?
Putting all general purpose registers in the clobber set fails in
some cases, but
removing registers from the clobber set (and adding explicit saves
around the inlined asm)
until my tests pass doesn't seem very safe.

Thanks again,

	Maurizio

AMD64 Application Binary Interface (v0.99) (aka abi.pdf) provides the
rules for which registers must be preserved. It's available at
www.x86-64.org/documentation/

Bob




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux