[Patch] PR 65315 - Fix alignment of local variables

Jeff Law law@redhat.com
Thu Mar 5 16:19:00 GMT 2015


On 03/04/15 12:50, Steve Ellcey  wrote:
> While examining some MIPS code I noticed that GCC did not seem to be
> fully honoring the aligned attribute on some local variables.  I submitted
> PR middle-end/65315 to record the bug and I think I now understand it and
> have a fix.  The problem was that expand_stack_vars seemed to think that
> the first entry in stack_vars_sorted would have the largest alignment but
> while all the variables that had alignment greater then
> MAX_SUPPORTED_STACK_ALIGNMENT would come before all variables whose
> alignment was less than MAX_SUPPORTED_STACK_ALIGNMENT, within the variables
> with the alignment greater than MAX_SUPPORTED_STACK_ALIGNMENT, they
> were sorted by size, not by alignment.
>
> So my fix was to update large_align in expand_stack_vars if needed.
>
> I have verified the fix on the MIPS test case in PR 65315 and am doing a
> regression test now.  OK to checkin if there are no regressions?
>
> I wasn't sure how to create a generic test case, I was checking the
> alignment on MIPS by hand by looking for the shift-right/shift-left
> instructions that create an aligned pointer but that obviously doesn't
> work on other architectures.
>
> Steve Ellcey
> sellcey@imgtec.com
>
>
> 2015-03-04  Steve Ellcey  <sellcey@imgtec.com>
>
> 	PR middle-end/65315
> 	* cfgexpand.c (expand_stack_vars): Update large_align to maximum
> 	needed alignment.
Please include a testcase for the testsuite if at all possible.

OK for the trunk.

jeff



More information about the Gcc-patches mailing list