This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Improve alloca alignment
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Rainer Orth <ro at cebitec dot uni-bielefeld dot de>, Jeff Law <law at redhat dot com>, nd <nd at arm dot com>
- Date: Sat, 09 Sep 2017 10:51:47 +0200
- Subject: Re: [PATCH] Improve alloca alignment
- Authentication-results: sourceware.org; auth=none
- References: <DB6PR0801MB2053EFC180A8360BC943BEB883B90@DB6PR0801MB2053.eurprd08.prod.outlook.com> <28942318.eoPupIDytn@polaris> <DB6PR0801MB2053CC1BB22D65B46DD2C2AB83950@DB6PR0801MB2053.eurprd08.prod.outlook.com>
> No, the stack never gets misaligned - my patch doesn't change that at all.
Yes, it does. Dynamic allocation works like this: the amount to be allocated
is added to VIRTUAL_STACK_DYNAMIC_REGNUM and the result is then dynamically
aligned. Your patch assumes that VIRTUAL_STACK_DYNAMIC_REGNUM is as aligned
as the stack pointer, i.e. STACK_BOUNDARY, but that's wrong for 32-bit SPARC
at least (that's why I put the ??? note at line 5746 in emit-rtl.c).
The previous attempt by Dominic Vogt was more correct in this respect:
2016-08-23 Dominik Vogt <vogt@linux.vnet.ibm.com>
* explow.c (get_dynamic_stack_size): Take known alignment of stack
pointer + STACK_DYNAMIC_OFFSET into account when calculating the
size needed.
since it was using the declared alignment of VIRTUAL_STACK_DYNAMIC_REGNUM and
not STACK_BOUNDARY directly. But the outcome was the same, since the declared
alignment is still wrong for 32-bit SPARC.
> The issue is that Sparc backend doesn't correctly set STACK_BOUNDSARY and
> neither aligns the outgoing args. Run my test which proves alloca was
> broken before my patch.
How could this have been broken for so long, realistically? The SPARC back-
end is parameterized according to the ABI and the documented interface between
middle-end and back-end.
--
Eric Botcazou