https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119599
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #6) > Actually you are right inliner should be fixed. Let me try to do that > instead. ``` diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc index 05843b8ccf0..da403cd1456 100644 --- a/gcc/tree-inline.cc +++ b/gcc/tree-inline.cc @@ -4832,6 +4832,7 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id, gimple *simtenter_stmt = NULL; vec<tree> *simtvars_save; tree save_stack = NULL_TREE; + bool was_noreturn; /* The gimplifier uses input_location in too many places, such as internal_get_tmp_var (). */ @@ -4843,6 +4844,8 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id, if (!call_stmt) goto egress; + was_noreturn = gimple_call_noreturn_p (call_stmt); + cg_edge = id->dst_node->get_edge (stmt); gcc_checking_assert (cg_edge); /* First, see if we can figure out what function is being called. @@ -5376,6 +5379,18 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id, if (purge_dead_abnormal_edges) bitmap_set_bit (to_purge, return_block->index); + /* If this was a noreturn function and if the return block is still + reachable, then add a call to __builtin_unreachable(). */ + if (was_noreturn && EDGE_COUNT (return_block->preds) != 0) + { + gcall *call_stmt = gimple_build_builtin_unreachable (input_location); + gimple_stmt_iterator gsi = gsi_last_bb (return_block); + gsi_insert_after (&gsi, call_stmt, GSI_NEW_STMT); + tree fndecl = gimple_call_fndecl (call_stmt); + cg_edge->caller->create_edge (cgraph_node::get_create (fndecl), + call_stmt, return_block->count); + } + /* If the value of the new expression is ignored, that's OK. We don't warn about this for CALL_EXPRs, so we shouldn't warn about the equivalent inlined version either. */ ``` I am not going to remove the fixup in fixup_cfg at least for GCC 15.