This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: Update alignment on stack slot
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: "GCC Patches" <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 26 Mar 2008 13:59:22 -0700
- Subject: PATCH: Update alignment on stack slot
Hi,
When assign_stack_local_1 is called to allocate a slot on stack, it
never updates its alignment. As the result, stack slot is marked
with 8bit alignment, even though it may have bigger alignment.
This patch updates stack slot alignment. Does it look correct?
Thanks.
H.J.
2008-03-26 H.J. Lu <hongjiu.lu@intel.com>
* function.c (assign_stack_local_1): Set alignment on stack slot.
--- gcc/function.c.align 2008-03-19 06:38:36.000000000 -0700
+++ gcc/function.c 2008-03-26 13:50:14.000000000 -0700
@@ -403,7 +403,7 @@ assign_stack_local_1 (enum machine_mode
{
rtx x, addr;
int bigend_correction = 0;
- unsigned int alignment;
+ unsigned int alignment, alignment_in_bits;
int frame_off, frame_alignment, frame_phase;
if (align == 0)
@@ -433,6 +433,8 @@ assign_stack_local_1 (enum machine_mode
else
alignment = align / BITS_PER_UNIT;
+ alignment_in_bits = alignment * BITS_PER_UNIT;
+
if (FRAME_GROWS_DOWNWARD)
function->x_frame_offset -= size;
@@ -440,8 +442,8 @@ assign_stack_local_1 (enum machine_mode
if (alignment * BITS_PER_UNIT > PREFERRED_STACK_BOUNDARY)
alignment = PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT;
- if (function->stack_alignment_needed < alignment * BITS_PER_UNIT)
- function->stack_alignment_needed = alignment * BITS_PER_UNIT;
+ if (function->stack_alignment_needed < alignment_in_bits)
+ function->stack_alignment_needed = alignment_in_bits;
/* Calculate how many bytes the start of local variables is off from
stack alignment. */
@@ -494,6 +496,7 @@ assign_stack_local_1 (enum machine_mode
function->x_frame_offset += size;
x = gen_rtx_MEM (mode, addr);
+ set_mem_align (x, alignment_in_bits);
MEM_NOTRAP_P (x) = 1;
function->x_stack_slot_list