diff options
author | H.J. Lu <hjl@gcc.gnu.org> | 2009-10-30 07:32:26 -0700 |
---|---|---|
committer | H.J. Lu <hjl@gcc.gnu.org> | 2009-10-30 07:32:26 -0700 |
commit | 890b9b966c9b155b36cf2811be8a289eeb0d9b96 (patch) | |
tree | 34c9b70bbe8d98f1da599ea7373429d1618f4427 /gcc/cfgexpand.c | |
parent | 6528a7ede69259e73a6a560cec80d4278b89007e (diff) | |
download | gcc-890b9b966c9b155b36cf2811be8a289eeb0d9b96.zip gcc-890b9b966c9b155b36cf2811be8a289eeb0d9b96.tar.gz gcc-890b9b966c9b155b36cf2811be8a289eeb0d9b96.tar.bz2 |
Optimize -mstackrealign.
gcc/
2009-10-30 H.J. Lu <hongjiu.lu@intel.com>
PR target/40836
* cfgexpand.c (expand_stack_alignment): Call update_stack_boundary
first. Move assert on stack_alignment_estimated just before
setting stack_realign_needed.
(gimple_expand_cfg): Initialize stack_alignment_estimated to 0.
Don't call update_stack_boundary.
* config/i386/i386.c (ix86_minimum_incoming_stack_boundary): New.
(verride_options): Don't check ix86_force_align_arg_pointer here.
(ix86_function_ok_for_sibcall): Use it.
(ix86_update_stack_boundary): Likewise.
* config/i386/i386.h (STACK_REALIGN_DEFAULT): Update comments.
gcc/testsuite/
2009-10-30 H.J. Lu <hongjiu.lu@intel.com>
PR target/40838
* gcc.target/i386/incoming-6.c: New.
* gcc.target/i386/incoming-7.c: Likewise.
* gcc.target/i386/incoming-8.c: Likewise.
* gcc.target/i386/incoming-9.c: Likewise.
* gcc.target/i386/incoming-10.c: Likewise.
* gcc.target/i386/incoming-11.c: Likewise.
* gcc.target/i386/incoming-12.c: Likewise.
* gcc.target/i386/incoming-13.c: Likewise.
* gcc.target/i386/incoming-14.c: Likewise.
* gcc.target/i386/incoming-15.c: Likewise.
* gcc.target/i386/pr37843-4.c: Likewise.
From-SVN: r153750
Diffstat (limited to 'gcc/cfgexpand.c')
-rw-r--r-- | gcc/cfgexpand.c | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index fdc4de5..33e7579 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -3447,8 +3447,18 @@ expand_stack_alignment (void) || crtl->has_nonlocal_goto) crtl->need_drap = true; - gcc_assert (crtl->stack_alignment_needed - <= crtl->stack_alignment_estimated); + /* Call update_stack_boundary here again to update incoming stack + boundary. It may set incoming stack alignment to a different + value after RTL expansion. TARGET_FUNCTION_OK_FOR_SIBCALL may + use the minimum incoming stack alignment to check if it is OK + to perform sibcall optimization since sibcall optimization will + only align the outgoing stack to incoming stack boundary. */ + if (targetm.calls.update_stack_boundary) + targetm.calls.update_stack_boundary (); + + /* The incoming stack frame has to be aligned at least at + parm_stack_boundary. */ + gcc_assert (crtl->parm_stack_boundary <= INCOMING_STACK_BOUNDARY); /* Update crtl->stack_alignment_estimated and use it later to align stack. We check PREFERRED_STACK_BOUNDARY if there may be non-call @@ -3464,6 +3474,9 @@ expand_stack_alignment (void) if (preferred_stack_boundary > crtl->stack_alignment_needed) crtl->stack_alignment_needed = preferred_stack_boundary; + gcc_assert (crtl->stack_alignment_needed + <= crtl->stack_alignment_estimated); + crtl->stack_realign_needed = INCOMING_STACK_BOUNDARY < crtl->stack_alignment_estimated; crtl->stack_realign_tried = crtl->stack_realign_needed; @@ -3540,7 +3553,7 @@ gimple_expand_cfg (void) targetm.expand_to_rtl_hook (); crtl->stack_alignment_needed = STACK_BOUNDARY; crtl->max_used_stack_slot_alignment = STACK_BOUNDARY; - crtl->stack_alignment_estimated = STACK_BOUNDARY; + crtl->stack_alignment_estimated = 0; crtl->preferred_stack_boundary = STACK_BOUNDARY; cfun->cfg->max_jumptable_ents = 0; @@ -3604,23 +3617,6 @@ gimple_expand_cfg (void) if (crtl->stack_protect_guard) stack_protect_prologue (); - /* Update stack boundary if needed. */ - if (SUPPORTS_STACK_ALIGNMENT) - { - /* Call update_stack_boundary here to update incoming stack - boundary before TARGET_FUNCTION_OK_FOR_SIBCALL is called. - TARGET_FUNCTION_OK_FOR_SIBCALL needs to know the accurate - incoming stack alignment to check if it is OK to perform - sibcall optimization since sibcall optimization will only - align the outgoing stack to incoming stack boundary. */ - if (targetm.calls.update_stack_boundary) - targetm.calls.update_stack_boundary (); - - /* The incoming stack frame has to be aligned at least at - parm_stack_boundary. */ - gcc_assert (crtl->parm_stack_boundary <= INCOMING_STACK_BOUNDARY); - } - expand_phi_nodes (&SA); /* Register rtl specific functions for cfg. */ |