NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: port-macppc/54827: alloca() is broken in gcc 8 on powerpc
The following reply was made to PR port-macppc/54827; it has been noted by GNATS.
From: Valery Ushakov <uwe%stderr.spb.ru@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc:
Subject: Re: port-macppc/54827: alloca() is broken in gcc 8 on powerpc
Date: Wed, 22 Jan 2020 17:23:19 +0300
I think I found a real fix, though I have no idea why does it work and
how the old code did ever work before :)
As mentioned earlier, our in-tree rs6000/netbsd.h overrides
STACK_BOUNDARY to always be 16 bytes:
/* Override STACK_BOUNDARY to use Altivec compliant one. */
#undef STACK_BOUNDARY
#define STACK_BOUNDARY 128
Stock gcc rs6000/netbsd.h doesn't have that override, but still emits
asm for stack frame aligned to 16 bytes.
This is b/c the SYSV ABI that we use already mandates 16 bytes aligned
stack frames (8 bytes alignment only seems to be used by the embedded
EABI). This is effected by rs6000/sysv4.h
#undef PREFERRED_STACK_BOUNDARY
#define PREFERRED_STACK_BOUNDARY 128
It's included by tm.h before netbsd.h
defaults.h takes care of defining PREFERRED_STACK_BOUNDARY if
necessary
/* If PREFERRED_STACK_BOUNDARY is not defined, set it to STACK_BOUNDARY.
STACK_BOUNDARY is required. */
#ifndef PREFERRED_STACK_BOUNDARY
#define PREFERRED_STACK_BOUNDARY STACK_BOUNDARY
#endif
Another relevant comment can be found in combine-stack-adj.c:
[...] It is of significantly more value to targets that define
PREFERRED_STACK_BOUNDARY more aligned than STACK_BOUNDARY [...]
So it looks like netbsd.h 1) overrides wrong define, 2) that is
already overriden by a "base" header. And so we ended up with
STACK_BOUNDARY == PREFERRED_STACK_BOUNDARY == 16 instead of stock
version STACK_BOUNDARY == 8 and PREFERRED_STACK_BOUNDARY == 16.
I'm not qualified to comment on why ppc code is written the way it is
(using STACK_BOUNDARY that is not actually used by the ABI it emits
the code for) and what broke between 7 and 8 to make our old
arrangement fail. Dropping the override from netbsd.h makes in-tree
compiler emit the same asm for all the four -O{0,2} -m{no-,}altivec
combinations as the stock gcc for the alloca-test.c above. The stack
frames are still 16 bytes aligned (as mandated by SYSV ABI).
--- netbsd.h.~1.14.~ 2020-01-22 16:31:12.806472210 +0300
+++ netbsd.h 2020-01-22 16:31:28.902491784 +0300
@@ -138,10 +138,6 @@
#define TRAMPOLINE_SIZE 48
#endif
-/* Override STACK_BOUNDARY to use Altivec compliant one. */
-#undef STACK_BOUNDARY
-#define STACK_BOUNDARY 128
-
/* Use standard DWARF numbering for DWARF debugging information. */
#define RS6000_USE_DWARF_NUMBERING
-uwe
Home |
Main Index |
Thread Index |
Old Index