https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84877
Bug ID: 84877 Summary: Local stack copy of BLKmode parameter on the stack is not aligned when the requested alignment exceeds MAX_SUPPORTED_STACK_ALIGNMENT Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: renlin at gcc dot gnu.org Target Milestone: --- For a test case like this, #include <stdint.h> struct U { uint32_t M0; uint32_t M1; } __attribute((aligned(16))); void tmp (struct U *); void foo(struct U P0) { struct U P1 = P0; tmp (&P1); } void bar(struct U P0) { tmp (&P0); } The required alignment of a BLKmode parameter is truncated to MAX_SUPPORTED_STACK_ALIGNMENT when it exceeds. On the other hand, the compiler will try to dynamically align the stack slot for local variable. For example, on arm-gcc toolchain, The function foo () will return a 16-byte aligned address. However, P0 is temporarily stored on stack in an unaligned address. Function bar () will return an unaligned address which is the address of local stack copy of P0. a warning could be emitted when the alignment could not be fulfilled or dynamically align it thought it will waste stack space.