diff options
-rw-r--r-- | gcc/ChangeLog.stackalign | 12 | ||||
-rw-r--r-- | gcc/cfgexpand.c | 8 | ||||
-rw-r--r-- | gcc/defaults.h | 15 | ||||
-rw-r--r-- | gcc/doc/tm.texi | 2 | ||||
-rw-r--r-- | gcc/function.c | 46 |
5 files changed, 43 insertions, 40 deletions
diff --git a/gcc/ChangeLog.stackalign b/gcc/ChangeLog.stackalign index 11a91cf1ef2..c63c8abcca9 100644 --- a/gcc/ChangeLog.stackalign +++ b/gcc/ChangeLog.stackalign @@ -1,3 +1,15 @@ +2008-06-07 H.J. Lu <hongjiu.lu@intel.com> + + * defaults.h (MAX_STACK_ALIGNMENT): Update comments. + (MAX_SUPPORTED_STACK_ALIGNMENT): New. + + * cfgexpand.c (get_decl_align_unit): Ignore alignment if it + exceeds MAX_SUPPORTED_STACK_ALIGNMENT. + * function.c (assign_stack_local_1): Likewise. + (locate_and_pad_parm): Likewise. + + * doc/tm.texi (MAX_STACK_ALIGNMENT): Updated. + 2008-06-05 H.J. Lu <hongjiu.lu@intel.com> * config/i386/i386.c (ix86_get_drap_rtx): Update comments. diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 5465ff22a45..be9996645ef 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -158,6 +158,9 @@ get_decl_align_unit (tree decl) align = DECL_ALIGN (decl); align = LOCAL_ALIGNMENT (TREE_TYPE (decl), align); + if (align > MAX_SUPPORTED_STACK_ALIGNMENT) + align = MAX_SUPPORTED_STACK_ALIGNMENT; + if (SUPPORTS_STACK_ALIGNMENT) { if (crtl->stack_alignment_estimated < align) @@ -166,11 +169,6 @@ get_decl_align_unit (tree decl) crtl->stack_alignment_estimated = align; } } - else - { - if (align > PREFERRED_STACK_BOUNDARY) - align = PREFERRED_STACK_BOUNDARY; - } /* stack_alignment_needed > PREFERRED_STACK_BOUNDARY is permitted. So here we only make sure stack_alignment_needed >= align. */ diff --git a/gcc/defaults.h b/gcc/defaults.h index c86dc8b84a6..e6325685e5f 100644 --- a/gcc/defaults.h +++ b/gcc/defaults.h @@ -950,12 +950,17 @@ along with GCC; see the file COPYING3. If not see #define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 0 #endif -/* FIXME: The default should be PREFERRED_STACK_BOUNDARY. But the fix - for PR 32893 indicates that we can only guarantee maximum stack - alignment on stack up to STACK_BOUNDARY, not PREFERRED_STACK_BOUNDARY, - if stack alignment isn't supported. */ -#ifndef MAX_STACK_ALIGNMENT +/* MAX_STACK_ALIGNMENT is the maximum stack alignment guaranteed by + the backend. MAX_SUPPORTED_STACK_ALIGNMENT is the maximum best + effort stack alignment supported by the backend. If the backend + supports stack alignment, MAX_SUPPORTED_STACK_ALIGNMENT and + MAX_STACK_ALIGNMENT are the same. Otherwise, the incoming stack + boundary will limit the maximum guaranteed stack alignment. */ +#ifdef MAX_STACK_ALIGNMENT +#define MAX_SUPPORTED_STACK_ALIGNMENT MAX_STACK_ALIGNMENT +#else #define MAX_STACK_ALIGNMENT STACK_BOUNDARY +#define MAX_SUPPORTED_STACK_ALIGNMENT PREFERRED_STACK_BOUNDARY #endif #define SUPPORTS_STACK_ALIGNMENT (MAX_STACK_ALIGNMENT > STACK_BOUNDARY) diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index be51151d461..e165ab0d7cd 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -1125,7 +1125,7 @@ field alignment has not been set by the @end defmac @defmac MAX_STACK_ALIGNMENT -Biggest stack alignment supported by the backend. Use this macro +Biggest stack alignment guaranteed by the backend. Use this macro to specify the maximum alignment of a variable on stack. If not defined, the default value is @code{STACK_BOUNDARY}. diff --git a/gcc/function.c b/gcc/function.c index 7060c120de5..277dde88561 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -384,17 +384,19 @@ assign_stack_local_1 (enum machine_mode mode, HOST_WIDE_INT size, if (FRAME_GROWS_DOWNWARD) frame_offset -= size; + /* Ignore alignment if it exceeds MAX_SUPPORTED_STACK_ALIGNMENT. */ + if (alignment_in_bits >= MAX_SUPPORTED_STACK_ALIGNMENT) + { + alignment_in_bits = MAX_SUPPORTED_STACK_ALIGNMENT; + alignment = alignment_in_bits / BITS_PER_UNIT; + } + if (SUPPORTS_STACK_ALIGNMENT) { if (crtl->stack_alignment_estimated < alignment_in_bits) { if (!crtl->stack_realign_processed) - { - /* Can't exceed MAX_STACK_ALIGNMENT. */ - if (alignment_in_bits >= MAX_STACK_ALIGNMENT) - alignment_in_bits = MAX_STACK_ALIGNMENT; - crtl->stack_alignment_estimated = alignment_in_bits; - } + crtl->stack_alignment_estimated = alignment_in_bits; else { gcc_assert (!crtl->stack_realign_finalized); @@ -413,16 +415,7 @@ assign_stack_local_1 (enum machine_mode mode, HOST_WIDE_INT size, } } } - else - { - /* Ignore alignment we can't do with expected alignment of the - boundary. */ - if (alignment * BITS_PER_UNIT > PREFERRED_STACK_BOUNDARY) - { - alignment_in_bits = PREFERRED_STACK_BOUNDARY; - alignment = PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT; - } - } + if (crtl->stack_alignment_needed < alignment_in_bits) crtl->stack_alignment_needed = alignment_in_bits; if (crtl->max_used_stack_slot_alignment < crtl->stack_alignment_needed) @@ -3378,6 +3371,12 @@ locate_and_pad_parm (enum machine_mode passed_mode, tree type, int in_regs, locate->where_pad = where_pad; locate->boundary = boundary; + /* We can't exceed MAX_SUPPORTED_STACK_ALIGNMENT when we remember + if the outgoing parameter requires extra alignment on the calling + function side. */ + if (boundary >= MAX_SUPPORTED_STACK_ALIGNMENT) + boundary = MAX_SUPPORTED_STACK_ALIGNMENT; + if (SUPPORTS_STACK_ALIGNMENT) { /* stack_alignment_estimated can't change after stack has been @@ -3385,24 +3384,13 @@ locate_and_pad_parm (enum machine_mode passed_mode, tree type, int in_regs, if (crtl->stack_alignment_estimated < boundary) { if (!crtl->stack_realign_processed) - { - /* Can't exceed MAX_STACK_ALIGNMENT. */ - if (boundary >= MAX_STACK_ALIGNMENT) - boundary = MAX_STACK_ALIGNMENT; - crtl->stack_alignment_estimated = boundary; - } + crtl->stack_alignment_estimated = boundary; else gcc_assert (!crtl->stack_realign_finalized && crtl->stack_realign_needed); } } - else - { - /* Remember if the outgoing parameter requires extra alignment on - the calling function side. */ - if (boundary > PREFERRED_STACK_BOUNDARY) - boundary = PREFERRED_STACK_BOUNDARY; - } + if (crtl->stack_alignment_needed < boundary) crtl->stack_alignment_needed = boundary; if (crtl->max_used_stack_slot_alignment < crtl->stack_alignment_needed) |