https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70439
Bug ID: 70439 Summary: Incorrect DRAP check in ix86_expand_epilogue Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: hjl.tools at gmail dot com CC: ubizjak at gmail dot com Target Milestone: --- Target: x86 ix86_expand_epilogue has /* eh_return epilogues need %ecx added to the stack pointer. */ if (style == 2) { rtx sa = EH_RETURN_STACKADJ_RTX; rtx_insn *insn; /* Stack align doesn't work with eh_return. */ gcc_assert (!stack_realign_drap); /* Neither does regparm nested functions. */ gcc_assert (!ix86_static_chain_on_stack); EH_RETURN_STACKADJ_RTX is defined to %ecx, which conflicts with DRAP which also uses %ecx. When stack_realign_drap is true, ix86_get_drap_rtx emits DRAP register. But ix86_finalize_stack_realign_flags may set crtl->stack_realign_needed to false later. When we get ix86_expand_epilogue, stack_realign_drap is false, but DRAP is actually used, which leads to wrong code.