This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [split] Add x86 support
- From: Richard Henderson <rth at redhat dot com>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 27 Sep 2009 16:02:19 -0700
- Subject: Re: [split] Add x86 support
- References: <mcr8wg2y14c.fsf@dhcp-172-17-9-151.mtv.corp.google.com>
On 09/25/2009 05:56 PM, Ian Lance Taylor wrote:
This adds x86-specific support for -fsplit-stack. This uses the stack
protector field in the TCB. I've filed a glibc bug asking for a new
field, but no response as yet.
Don't take it as gospel, but Uli gave me 5 slots for transactional
memory, and I only really need 3. Word 15 should be free.
+(define_expand "split_stack_check_small"
+(define_expand "split_stack_check_large"
There's no point in separate patterns here, since _small is exactly
_large with stack_pointer_rtx. Although I like Ross' idea to use a
special memory thingy, to avoid new patterns at all.
+ else
+ {
+ /* FIXME: We could make this work by pushing a register
+ around the addition and comparison. */
+ sorry ("-fsplit-stack does not support 3 register parameters");
+ scratch_regno = CX_REG;
+ }
There's no reason to use a push either, so long as you're prepared to
add some extra unwind info. You can do
sub $10000, %esp
cmp %esp, %gs:0x14
lea -10000(%esp), %esp
or perhaps even begin with the assumption that the stack allocation will
succeed, and only in the failure case deallocate and call __morestack.
Something like
sub $10000, %esp
cmp $esp, %gs:0x14
jcc .Lmorestack
.Lmorestack_ret:
// rest of prologue
// rest of function
.Lmorestack:
add $10000, %esp
pushl $10000
pushl $64
call __morestack
jmp .Lmorestack_ret
+ /* Get more stack space. We pass in the desired stack space and the
+ size of the arguments to copy to the new stack. In 32-bit mode
+ we push the parameters; __morestack will return on a new stack
+ anyhow. In 64-bit mode we pass the parameters in r10 and
+ r11. */
You need to care for the static chain register. And the new static
chain push in the case of regparm=3.
r~