https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58372
--- Comment #40 from Uroš Bizjak <ubizjak at gmail dot com> --- (In reply to Terry Guo from comment #39) > (In reply to Uroš Bizjak from comment #38) > > (In reply to Terry Guo from comment #36) > > > > > OK. Do it right now. > > > > I think that latest attachment is the one that should be tested. > > Functionally it is the same, but avoids unnecessary variable updates before > > expand_stack_alignment is called. expand_stack_alignment will do everything > > for us. > > Yes. The latest one works perfectly. Bootstrap and regression test on x86_64 > show no problem. I also managed to build a gcc for i686-w64-mingw32 with > SJLJ enabled, the case can be compiled successfully. Then we can just move the call to finish_eh_generation in pass_expand::execute in front of expand_stack_alignment: --cut here-- Index: cfgexpand.c =================================================================== --- cfgexpand.c (revision 265582) +++ cfgexpand.c (working copy) @@ -6510,6 +6510,12 @@ pass_expand::execute (function *fun) find_many_sub_basic_blocks (blocks); purge_all_dead_edges (); + /* After initial rtl generation, call back to finish generating + exception support code. We need to do this before cleaning up + the CFG as the code does not expect dead landing pads. */ + if (fun->eh->region_tree != NULL) + finish_eh_generation (); + expand_stack_alignment (); /* Fixup REG_EQUIV notes in the prologue if there are tailcalls in this @@ -6517,12 +6523,6 @@ pass_expand::execute (function *fun) if (crtl->tail_call_emit) fixup_tail_calls (); - /* After initial rtl generation, call back to finish generating - exception support code. We need to do this before cleaning up - the CFG as the code does not expect dead landing pads. */ - if (fun->eh->region_tree != NULL) - finish_eh_generation (); - /* BB subdivision may have created basic blocks that are are only reachable from unlikely bbs but not marked as such in the profile. */ if (optimize) --cut here-- And indeed, the above patch works without problems for me.