On Tue, Jul 01, 2025 at 10:43:09AM +0200, Richard Biener wrote:
> > The following patch fixes that by
> > 1) moving the musttail pass 2 passes earlier (this is mostly just
> >    for -O0/-Og, for normal optimization levels musttail calls are
> >    handled in the tailc pass), i.e. across the sanopt and cleanup_eh
> >    passes
> 
> didn't we have other cases where cleanup_eh was required for musttail
> to work?  So I think we want to have that before musttail?  We should
> be able to swap sanopt and eh_cleanup?

I think we've discussed we want to try for GCC 16 cleanup_eh somewhere in
the -O1+ optimization pass set, in between IPA and tailc (and I'll try to do
that at some point during stage1).

I've actually tried
--- gcc/passes.def      2025-06-30 22:16:11.258688529 +0200
+++ gcc/passes.def      2025-07-01 10:47:37.020634803 +0200
@@ -444,9 +444,9 @@ along with GCC; see the file COPYING3.
   NEXT_PASS (pass_lower_switch_O0);
   NEXT_PASS (pass_asan_O0);
   NEXT_PASS (pass_tsan_O0);
-  NEXT_PASS (pass_sanopt);
   NEXT_PASS (pass_cleanup_eh);
   NEXT_PASS (pass_musttail);
+  NEXT_PASS (pass_sanopt);
   NEXT_PASS (pass_lower_resx);
   NEXT_PASS (pass_nrv);
   NEXT_PASS (pass_gimple_isel);
together with the non-empty_eh_cleanup tree-tailcall.cc changes from the
patch, but that resulted in the following ICE:
/home/jakub/src/gcc/gcc/testsuite/gcc.dg/asan/pr106190.c: In function 'main':
/home/jakub/src/gcc/gcc/testsuite/gcc.dg/asan/pr106190.c:6:1: internal compiler 
error: in expand_builtin_eh_common, at except.cc:2097
0x2dc62cf internal_error(char const*, ...)
        ../../gcc/diagnostic-global-context.cc:517
0xeaeced fancy_abort(char const*, int, char const*)
        ../../gcc/diagnostic.cc:1810
0x81940a expand_builtin_eh_common
        ../../gcc/except.cc:2097
0x11ad909 expand_builtin_eh_pointer(tree_node*)
        ../../gcc/except.cc:2108
0x11deac2 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, 
expand_modifier, rtx_def**, bool)
        ../../gcc/expr.cc:12535
0x11ecddd store_expr(tree_node*, rtx_def*, int, bool, bool)
        ../../gcc/expr.cc:6762
0x11efb28 expand_assignment(tree_node*, tree_node*, bool)
        ../../gcc/expr.cc:6483
0x11efb28 expand_assignment(tree_node*, tree_node*, bool)
        ../../gcc/expr.cc:5971
0x1093629 expand_call_stmt
        ../../gcc/cfgexpand.cc:3202
0x1093629 expand_gimple_stmt_1
        ../../gcc/cfgexpand.cc:4276
0x1093629 expand_gimple_stmt
        ../../gcc/cfgexpand.cc:4423
0x1095617 expand_gimple_basic_block
        ../../gcc/cfgexpand.cc:6539
0x1097a07 execute
        ../../gcc/cfgexpand.cc:7286

Given that empty_eh_cleanup handles already almost everything, just
didn't know how to handle the resx to internal step which was quite
trivial, I thought it will be easier not to reorder cleanup_eh pass,
especially for 15.2 backport and when I have no idea what went wrong
in the pr106190 testcase (the ICE is about not finding some region).

        Jakub

Reply via email to