From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 8A6693858D33; Wed, 22 Feb 2023 10:22:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8A6693858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677061369; bh=SWXVZJD8yYBIZAyM2ohDrn6/RKsAOUw8CuRyKdMge4A=; h=From:To:Subject:Date:From; b=OTVcXSloUwK5tmkH3qTLLrSIO+Gtjh0FpwaELf7eKNHLJOFZgpa5TzeU3F1B3TILS XfnbCqaCscxFLpPXCzD2RYvUzGkAL44t9S2ExvQ2g6JmuwF30mqnbGAchj30vczouq rE0AQRVLmir5wGdsA+cKbP+HkzPznQayvJSYFirI= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-6273] cgraph: Handle BUILT_IN_UNREACHABLE_TRAP like BUILT_IN_UNREACHABLE in more spots [PR106258] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: 334f23d83261997ca89d8919b94b97aa22003a65 X-Git-Newrev: fb5365907317551cf9e4661aa78dd4f773e7a18a Message-Id: <20230222102249.8A6693858D33@sourceware.org> Date: Wed, 22 Feb 2023 10:22:49 +0000 (GMT) List-Id: https://gcc.gnu.org/g:fb5365907317551cf9e4661aa78dd4f773e7a18a commit r13-6273-gfb5365907317551cf9e4661aa78dd4f773e7a18a Author: Jakub Jelinek Date: Wed Feb 22 11:22:03 2023 +0100 cgraph: Handle BUILT_IN_UNREACHABLE_TRAP like BUILT_IN_UNREACHABLE in more spots [PR106258] The following testcase ICEs because we still have some spots that treat BUILT_IN_UNREACHABLE specially but not BUILT_IN_UNREACHABLE_TRAP the same. 2023-02-22 Jakub Jelinek 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. Diff: --- gcc/cgraph.cc | 11 ++++++++--- gcc/cgraphclones.cc | 4 +++- gcc/testsuite/g++.dg/ipa/pr106258.C | 5 +++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc index f352212e463..ec663d23385 100644 --- a/gcc/cgraph.cc +++ b/gcc/cgraph.cc @@ -1548,7 +1548,8 @@ cgraph_edge::redirect_call_stmt_to_callee (cgraph_edge *e) 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 (cgraph_node *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 (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 () diff --git a/gcc/cgraphclones.cc b/gcc/cgraphclones.cc index 3d97ee42f77..4a4773ec565 100644 --- a/gcc/cgraphclones.cc +++ b/gcc/cgraphclones.cc @@ -425,7 +425,9 @@ cgraph_node::create_clone (tree new_decl, profile_count prof_count, 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 (); diff --git a/gcc/testsuite/g++.dg/ipa/pr106258.C b/gcc/testsuite/g++.dg/ipa/pr106258.C new file mode 100644 index 00000000000..974c8303f71 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr106258.C @@ -0,0 +1,5 @@ +// PR middle-end/106258 +// { dg-do compile { target c++11 } } +// { dg-options "-O2 -funreachable-traps" } + +#include "ipa-sra-4.C"