patch to handle i386 stack alignment using the stack pointer
Jeffrey A Law
law@cygnus.com
Sun Mar 21 23:56:00 GMT 1999
In message <199901270648.BAA16929@jwlab.FEITH.COM>you write:
> This patch causes gcc to align the i386 stack when necessary. It works
> by using reload to eliminate the frame pointer from local variables in
> favor of the stack pointer and by aligning the stack pointer in the
> prologue.
>
> Notes:
>
> 1) In order to be useful "recommended alignment for local i386 FP
> variables patch (version 2)" and "patch to handle i386 stack
> alignment using PREFERRED_STACK_BOUNDARY" should be installed.
> However, it is * not * necessary to actually define
> PREFERRED_STACK_BOUNDARY.
>
> 2) The BRL-CAD benchmark has a total of 443 functions which desire the
> stack to be aligned on a 64 bit boundary. When compiling with a frame
> pointer 160 functions were successfully aligned. When compiling
> without a frame pointer 89 functions were successfully aligned.
>
> The crafty benchmark has a total of 2 functions which desire the
> stack to be aligned on a 64 bit boundary. When compiling with a frame
> 1 function was successfully aligned. When compiling without a frame
> 0 functions were successfully aligned.
>
> A typical reason that compiling with a frame pointer failed to align
> the stack is due to the EXIT_IGNORE_STACK optimization preventing
> reload from replacing the frame pointer with the stack pointer. A
> typical reason that compiling without a frame pointer failed to align
> the stack is due to the frame pointer register being already used
> (I don't force it to be spilled).
>
> 3) Currently aligning the stack is disabled if flag_exceptions is set
> since it potentally interacts with the ability to unwind the stack.
>
> 4) There are no regressions with the testsuite on FreeBSD 3.0.
>
> 5) This version of gdb-4.17-PatchJLW02 has been submitted to the
> gdb maintainers. It is included here only as a convenience.
I'd like to try this patch, but I get a variety of conflicts when I apply it
to the current sources. Any chance you could update and resubmit diffs
against the current tree?
[ ... ]
> Wed Jan 27 01:42:53 EST 1999 John Wehle (john@feith.com)
>
> * rtl.h (desired_stack_local_alignment): Prototype.
> * function.c (desired_stack_local_alignment): New function.
> (current_function_desired_stack_alignment): Define.
> (init_function_start): Initialize it.
> * output.h Declare it.
> * reload1.c (reload, alter_reg): Set it.
> (reload): Assign stack slots to pseudos that lack hard regs or
> equivalents before calling init_elim_table.
> (init_elim_table): Disable frame (or argument when
> -fomit-frame-pointer) pointer elimination unless stack alignment is
> desired and the hard frame pointer is available.
> (reload): Enable the proper frame (or argument when
> -fomit-frame-pointer) pointer elimination once it's known if
> stack alignment is desired and if the hard frame pointer is available.
> (update_eliminables): Don't clear frame_pointer_needed if there is
> an elimination which depends on it.
>
> * i386.h (HARD_FRAME_POINTER_REGNUM): Define.
> (FRAME_POINTER_REGNUM): Change to 17.
> (ELIMINABLE_REGS): Add frame pointer eliminations.
> (FIRST_PSEUDO_REGISTER, FIXED_REGISTERS, CALL_USED_REGISTERS,
> REG_ALLOC_ORDER, REG_CLASS_CONTENTS, INITIAL_ELIMINATION_OFFSET,
> REGNO_OK_FOR_BASE_P, REGNO_OK_FOR_BASE_NONSTRICT_P, HI_REGISTER_NAMES,
> PRINT_REG, DEBUG_PRINT_REG): Match HARD_FRAME_POINTER_REGNUM and
> FRAME_POINTER_REGNUM changes.
> * i386.c (AT_BP, regclass_map, ix86_prologue,
> ix86_can_use_return_insn_p, ix86_epilogue): Likewise.
> * i386.md (epilogue_set_stack_ptr): Likewise.
>
> * i386.c (ix86_prologue, ix86_epilogue): Align the stack.
> (ix86_compute_frame_size): Account for the stack being aligned.
> * i386.h (INITIAL_ELIMINATION_OFFSET): Likewise.
>
> * gdb-4.17-PatchJLW02: New file containing gdb support for
> debugging i386 code where the frame has been aligned.
>
jeff
More information about the Gcc-patches
mailing list