http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59501
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to H.J. Lu from comment #2) > (In reply to Jakub Jelinek from comment #1) > > > > if (ix86_force_drap || !ACCUMULATE_OUTGOING_ARGS) > > crtl->need_drap = true; > > They are needed for -m32. Otherwise, we got > > FAIL: g++.dg/torture/stackalign/eh-fastcall-1.C -Os -fpic execution test > FAIL: g++.dg/torture/stackalign/eh-global-1.C -Os -fpic execution test > FAIL: g++.dg/torture/stackalign/eh-inline-1.C -Os -fpic execution test > FAIL: g++.dg/torture/stackalign/eh-thiscall-1.C -Os -fpic execution test I'm not saying that ix86_get_drap_rtx should be changed. But perhaps: /* If the only reason for frame_pointer_needed is that we conservatively assumed stack realignment might be needed, but in the end nothing that needed the stack alignment had been spilled, clear frame_pointer_needed and say we don't need stack realignment. */ if (stack_realign && !crtl->need_drap && frame_pointer_needed && crtl->is_leaf && flag_omit_frame_pointer && crtl->sp_is_unchanging && !ix86_current_function_calls_tls_descriptor && !crtl->accesses_prior_frames && !cfun->calls_alloca && !crtl->calls_eh_return && !(flag_stack_check && STACK_CHECK_MOVING_SP) && !ix86_frame_pointer_required () && get_frame_size () == 0 && ix86_nsaved_sseregs () == 0 && ix86_varargs_gpr_size + ix86_varargs_fpr_size == 0) in ix86_finalize_stack_realign_flags could be tweaked, not to bail out always if we have !crtl->need_drap, because then it will be set pretty much for all leaf functions. I wonder if we can e.g. ask DF whether the drap reg is live at entry, if it isn't live, supposedly we can clear crtl->need_drap or ignore it for this purpose? Also, I wonder even if we actually need the drap register we can't for the leaf functions just avoid the dynamic realignment and simply let the prologue set the drap reg to the right value.