https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77359
Dominik Vogt <vogt at linux dot vnet.ibm.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |uweigand at gcc dot gnu.org --- Comment #3 from Dominik Vogt <vogt at linux dot vnet.ibm.com> --- This test program shows what's happening: -- #include <stdio.h> #define ALIGN __attribute__ ((aligned(2))) __attribute__ ((noinline)) void foo(int sz, int x) { ALIGN char s[sz]; printf("!!! %p %d\n", (void *)s, x); } int main(int sz, char **argv) { int x; foo(sz, x); return 0; } -- (Not sure if "x" is really necessary). With a 2 byte alignment, the printed address is aligned to 8 bytes but not to 16 bytes, i.e. no more than an 8 byte alignment is guaranteed for the dynamic stack area. When compiling the test with 16 byte alignment in the ALIGN macro, the code generated looks as if the dynamic stack area were 16 byte aligned. When get_dynamic_stack_size is called the value of REGNO_POINTER_ALIGN (VIRTUAL_STACK_DYNAMIC_REGNUM) is indeed 128. ._Z3fooii: LFB..1: mflr 0 stw 31,-4(1) addi 3,3,15 <--- was 30 before the patch So, on AIX "REGNO_POINTER_ALIGN (VIRTUAL_STACK_DYNAMIC_REGNUM)" lies about the actual alignment of the dynamic area. This may also cause problems with other users of the expression. -- As far as I can see, the value is hard coded to STACK_BOUNDARY (emit-rtl.c:init-emit()) which is hard coded to 128 in aix.h. If STACK_BOUNDARY cannot be used as this alignment on all targets, we could add something like #ifdef STACK_VIRTUAL_STACK_DYNAMIC_ALIGN REGNO_POINTER_ALIGN (VIRTUAL_STACK_DYNAMIC_REGNUM) = STACK_VIRTUAL_STACK_DYNAMIC_ALIGN; #endif and put the correct value in aix.h: #define STACK_VIRTUAL_STACK_DYNAMIC_ALIGN 8 -- (Actually, this may be necessary on s390 too which has STACK_BOUNDARY 8 but the alignment of the dynamic area is only 4.) -- Comments?