From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 902903858D33 for ; Wed, 22 Feb 2023 09:13:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 902903858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677057183; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=bNXC58d8BZHQ2/ZuEnXbBS8cc19qwuHs9oJf+sQ3YWM=; b=cx2cs7wKDukLqy5jbjXMmeqnRgDn/CHwSceH2Ci4Nsk9pq5ozoVCErOLVXxfWyYQqCYoEo cbhA7eLaHf0i3SNpliKQifCvd0m7ajJ0NmtXbIJ9nVTn1eEbLAgd46wJSRzBMR29rRNjyB 5zhP7WDThU8I/dtpOFv2k5DLkG1Ufqk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-60-59Bn4QE3MzyAwqv4_nt5Hg-1; Wed, 22 Feb 2023 04:12:58 -0500 X-MC-Unique: 59Bn4QE3MzyAwqv4_nt5Hg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 68B1A802D2E; Wed, 22 Feb 2023 09:12:58 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.62]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2831240C83B6; Wed, 22 Feb 2023 09:12:58 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 31M9Ctso4178298 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 22 Feb 2023 10:12:55 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 31M9Cs9P4178297; Wed, 22 Feb 2023 10:12:54 +0100 Date: Wed, 22 Feb 2023 10:12:54 +0100 From: Jakub Jelinek To: Richard Biener , Jan Hubicka , Martin Jambor Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] cgraph: Handle BUILT_IN_UNREACHABLE_TRAP like BUILT_IN_UNREACHABLE in more spots [PR106258] Message-ID: Reply-To: Jakub Jelinek MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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? 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. --- 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 (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