Hi Adhemerval,

On 06/10/16 22:54, Adhemerval Zanella wrote:
+  bool split_stack_arg_pointer_used = split_stack_arg_pointer_used_p ();
if (flag_stack_usage_info)
      current_function_static_stack_size = frame_size;
@@ -3220,6 +3264,10 @@ aarch64_expand_prologue (void)
        aarch64_emit_probe_stack_range (STACK_CHECK_PROTECT, frame_size);
      }
+ /* Save split-stack argument pointer before stack adjustment. */
+  if (split_stack_arg_pointer_used)
+    emit_move_insn (gen_rtx_REG (Pmode, R10_REGNUM), stack_pointer_rtx);
+
    aarch64_add_constant (Pmode, SP_REGNUM, IP0_REGNUM, -initial_adjust, true);
if (callee_adjust != 0)
@@ -3243,6 +3291,30 @@ aarch64_expand_prologue (void)
                             callee_adjust != 0 || frame_pointer_needed);
    aarch64_add_constant (Pmode, SP_REGNUM, IP1_REGNUM, -final_adjust,
                        !frame_pointer_needed);
+
+  if (split_stack_arg_pointer_used_p ())


Redundant call? can use split_stack_arg_pointer_use"
+
+  /* Always emit two insns to calculate the requested stack, so the linker
+     can edit them when adjusting size for calling non-split-stack code.  */
+  ninsn = aarch64_internal_mov_immediate (temp, GEN_INT (-frame_size), true,
+                                         Pmode);
+  gcc_assert (ninsn == 1 || ninsn == 2);
+  if (ninsn == 1)
+    emit_insn (gen_nop ());
If you expect the nop is kept together with the other
I am still seeing nop scheduled away from the addtition.

        mov     x10, -4144
        add     x10, sp, x10
        nop

+
+#define BACKOFF                        0x2000

The BACKOFF value is 0x2000 here while in morestack-c.c it is 0x1000, is this deliberate?
+
+       # Calculate requested stack size.
+       sub     x12, sp, x10
+       # Save parameters
+       stp     x29, x30, [sp, -MORESTACK_FRAMESIZE]!
+       .cfi_def_cfa_offset MORESTACK_FRAMESIZE
+       .cfi_offset 29, -MORESTACK_FRAMESIZE
+       .cfi_offset 30, -MORESTACK_FRAMESIZE+8
+       add     x29, sp, 0
+       .cfi_def_cfa_register 29
+       # Adjust the requested stack size for the frame pointer save.
+       add     x12, x12, 16
+       stp     x0, x1, [sp, 16]
+       stp     x2, x3, [sp, 32]
+       add     x12, x12, BACKOFF
+       stp     x4, x5, [sp, 48]
+       stp     x6, x7, [sp, 64]
+       stp     x28, x12, [sp, 80]
+
+       # Setup on x28 the function initial frame pointer.  Its value will
+       # copied to function argument pointer.
+       add     x28, sp, MORESTACK_FRAMESIZE + 16
+
+       # void __morestack_block_signals (void)
+       bl      __morestack_block_signals
+
+       # void *__generic_morestack (size_t *pframe_size,
+       #                            void *old_stack,
+       #                            size_t param_size)
+       # pframe_size: is the size of the required stack frame (the function
+       #              amount of space remaining on the allocated stack).
s/pframe_size: is the size/pframe_size: points at the size/

+
+       # Set up for a call to the target function.
+       ldr     x30, [x28, STACKFRAME_BASE + 8]
+       ldp     x0, x1, [x28, STACKFRAME_BASE + 16]
+       ldp     x2, x3, [x28, STACKFRAME_BASE + 32]
+       ldp     x4, x5, [x28, STACKFRAME_BASE + 48]
+       ldp     x6, x7, [x28, STACKFRAME_BASE + 64]
+       add     x9, x30, 8
+       cmp     x30, x9
We can remove this "cmp" by using "adds x9, x30, 8"?
I am thinkg "adds" will set "c" bit in conditional flag to zero, then the bcs check in function prologue will fail, thus the argument pointer initialization
will always be executed if the execution flow is from __morestack.

        bcs     .L8
        mov     x10, x28

+       blr     x9
+
+       stp     x0, x1, [x28, STACKFRAME_BASE + 16]
+       stp     x2, x3, [x28, STACKFRAME_BASE + 32]
+       stp     x4, x5, [x28, STACKFRAME_BASE + 48]
+       stp     x6, x7, [x28, STACKFRAME_BASE + 64]
+

Reply via email to