https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104414
Bug ID: 104414 Summary: [AArch64] About the condition of calls_alloca in aarch64_layout_frame Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: ashimida at linux dot alibaba.com Target Milestone: --- There is the following code in aarch64_layout_frame: else if (crtl->outgoing_args_size.is_constant (&const_outgoing_args_size) && frame.saved_regs_size.is_constant (&const_saved_regs_size) && const_outgoing_args_size + const_saved_regs_size < 512 && (!saves_below_hard_fp_p || const_outgoing_args_size == 0) // 1) && !(cfun->calls_alloca && frame.hard_fp_offset.is_constant (&const_fp_offset) && const_fp_offset < max_push_offset)) { /* Frame with small outgoing arguments: sub sp, sp, frame_size stp reg1, reg2, [sp, outgoing_args_size] stp reg3, reg4, [sp, outgoing_args_size + 16] */ frame.initial_adjust = frame.frame_size; frame.callee_offset = const_outgoing_args_size; } ...... else if (frame.hard_fp_offset.is_constant (&const_fp_offset) && const_fp_offset < max_push_offset) { // 2) /* Frame with large outgoing arguments or SVE saves, but with a small local area: stp reg1, reg2, [sp, -hard_fp_offset]! stp reg3, reg4, [sp, 16] [sub sp, sp, below_hard_fp_saved_regs_size] [save SVE registers relative to SP] sub sp, sp, outgoing_args_size */ As described in 2), "Frame with large outgoing arguments or SVE saves, but with a small local area". But due to the condition at 1), the following code (small outgoing with a small local area) also uses the insns in 2), which is slightly different from the description: #include <stdio.h> #include <alloca.h> #define REP9(X) X,X,X,X,X,X,X,X,X int alloc_size; void outgoing_1 (int x, ...) { return 0; } int main(void) { outgoing1 (REP9(1)); char * y = alloca(alloc_size); return 0; } Could the condition in 1) be removed, or am I missing something? Thanks, Dan.