This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA][PATCH] Improve initial probe for noreturn functions for x86 target


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.
I suspect we're better off avoiding %esp as the source/dest.

And a note on the micro-optimizations. This only happens for no-return function prologues. I think we can assume they are not performance critical.

Jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]