On Wed, 22 Feb 2023, Jakub Jelinek wrote: > Hi! > > The following testcase ICEs because we still have some spots that > treat BUILT_IN_UNREACHABLE specially but not BUILT_IN_UNREACHABLE_TRAP > the same. > > The following patch fixes that, bootstrapped/regtested on x86_64-linux and > i686-linux, ok for trunk?
OK. > 2023-02-22 Jakub Jelinek <ja...@redhat.com> > > PR middle-end/106258 > * cgraph.cc (cgraph_edge::redirect_call_stmt_to_callee, > cgraph_update_edges_for_call_stmt_node, cgraph_node::verify_node): > Handle BUILT_IN_UNREACHABLE_TRAP like BUILT_IN_UNREACHABLE. > * cgraphclones.cc (cgraph_node::create_clone): Likewise. > > * g++.dg/ipa/pr106258.C: New test. > > --- gcc/cgraph.cc.jj 2023-02-07 10:33:46.027107080 +0100 > +++ gcc/cgraph.cc 2023-02-21 14:57:10.405454504 +0100 > @@ -1548,7 +1548,8 @@ cgraph_edge::redirect_call_stmt_to_calle > else > { > if (flag_checking > - && !fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE)) > + && !fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE) > + && !fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE_TRAP)) > ipa_verify_edge_has_no_modifications (e); > new_stmt = e->call_stmt; > gimple_call_set_fndecl (new_stmt, e->callee->decl); > @@ -1634,7 +1635,9 @@ cgraph_update_edges_for_call_stmt_node ( > { > /* Keep calls marked as dead dead. */ > if (new_stmt && is_gimple_call (new_stmt) && e->callee > - && fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE)) > + && (fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE) > + || fndecl_built_in_p (e->callee->decl, > + BUILT_IN_UNREACHABLE_TRAP))) > { > cgraph_edge::set_call_stmt (node->get_edge (old_stmt), > as_a <gcall *> (new_stmt)); > @@ -3598,7 +3601,9 @@ cgraph_node::verify_node (void) > /* Optimized out calls are redirected to __builtin_unreachable. */ > && (e->count.nonzero_p () > || ! e->callee->decl > - || !fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE)) > + || !(fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE) > + || fndecl_built_in_p (e->callee->decl, > + BUILT_IN_UNREACHABLE_TRAP))) > && count > == ENTRY_BLOCK_PTR_FOR_FN (DECL_STRUCT_FUNCTION (decl))->count > && (!e->count.ipa_p () > --- gcc/cgraphclones.cc.jj 2023-01-02 09:32:44.706962765 +0100 > +++ gcc/cgraphclones.cc 2023-02-21 14:58:11.619568895 +0100 > @@ -425,7 +425,9 @@ cgraph_node::create_clone (tree new_decl > version. The only exception is when the edge was proved to > be unreachable during the cloning procedure. */ > if (!e->callee > - || !fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE)) > + || !(fndecl_built_in_p (e->callee->decl, BUILT_IN_UNREACHABLE) > + || fndecl_built_in_p (e->callee->decl, > + BUILT_IN_UNREACHABLE_TRAP))) > e->redirect_callee_duplicating_thunks (new_node); > } > new_node->expand_all_artificial_thunks (); > --- gcc/testsuite/g++.dg/ipa/pr106258.C.jj 2023-02-21 15:02:17.251015237 > +0100 > +++ gcc/testsuite/g++.dg/ipa/pr106258.C 2023-02-21 15:02:12.255087511 > +0100 > @@ -0,0 +1,5 @@ > +// PR middle-end/106258 > +// { dg-do compile { target c++11 } } > +// { dg-options "-O2 -funreachable-traps" } > + > +#include "ipa-sra-4.C" > > Jakub > > -- Richard Biener <rguent...@suse.de> SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman; HRB 36809 (AG Nuernberg)