This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFA][PATCH] Improve initial probe for noreturn functions for x86 target
- From: Uros Bizjak <ubizjak at gmail dot com>
- To: Jeff Law <law at redhat dot com>
- Cc: Richard Biener <richard dot guenther at gmail dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 3 Nov 2017 18:38:11 +0100
- Subject: Re: [RFA][PATCH] Improve initial probe for noreturn functions for x86 target
- Authentication-results: sourceware.org; auth=none
- References: <CAFULd4ZGAY1HROqLXrucaq+vOJZ7Vch5z6Yt6oeSs=ZNECZ_jg@mail.gmail.com> <CAFiYyc1oh_8p4VEpM0R9UG0n1cbrD08sSu=8skgZUcE7a_rk-Q@mail.gmail.com> <CAFULd4aVD_rJp6hK0stZQF4nqzRdJHoq2MjcwrOLV7XMaKUG_A@mail.gmail.com> <c2c1656e-e770-1734-5269-a3c80f0ccfe4@redhat.com>
On Fri, Nov 3, 2017 at 6:13 PM, Jeff Law <law@redhat.com> wrote:
> On 11/03/2017 04:46 AM, Uros Bizjak wrote:
>>
>> On Fri, Nov 3, 2017 at 11:14 AM, Richard Biener
>> <richard.guenther@gmail.com> wrote:
>>>
>>> On Fri, Nov 3, 2017 at 9:38 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
>>>>>
>>>>> * config/i386/i386.c (ix86_emit_restore_reg_using_pop):
>>>>> Prototype.
>>>>> (ix86_adjust_stack_and_probe_stack_clash): Use a push/pop
>>>>> sequence
>>>>> to probe at the start of a noreturn function.
>>>>>
>>>>> * gcc.target/i386/stack-check-12.c: New test
>>>>
>>>>
>>>> - emit_stack_probe (plus_constant (Pmode, stack_pointer_rtx,
>>>> - -GET_MODE_SIZE (word_mode)));
>>>> + rtx_insn *insn = emit_insn (gen_push (gen_rtx_REG (word_mode,
>>>> 0)));
>>>>
>>>> Please use AX_REG instead of 0.
>>>>
>>>> + RTX_FRAME_RELATED_P (insn) = 1;
>>>> + ix86_emit_restore_reg_using_pop (gen_rtx_REG (word_mode, 0));
>>>>
>>>> Also here.
>>>>
>>>> emit_insn (gen_blockage ());
>>>>
>>>> BTW: Could we use an unused register here, if available? %eax is used
>>>> to pass first argument in regparm functions on 32bit targets.
>>>
>>>
>>> Can you push %[er]sp? What about partial reg stalls when using other
>>> registers (if the last set was a movb to it)? I guess [er]sp is safe
>>> here
>>> as was [re]ax due to the ABI?
>>
>>
>> That would work, too. I believe, that this won't trigger stack engine
>> [1], but since the operation is a bit unusual, let's ask HJ to be
>> sure.
>>
>> [1] https://en.wikipedia.org/wiki/Stack_register#Stack_engine
>
> How about %esi in 32 bit mode and %rax in 64 bit mode? I think that avoids
> hitting the parameter passing registers.
That is a good choice. IMO, It warrants a small comment, in the
source, why this choice.
Uros.