From patchwork Wed Feb 22 09:12:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 60378 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp467999wrd; Wed, 22 Feb 2023 01:13:48 -0800 (PST) X-Google-Smtp-Source: AK7set85izThtN72oov5nE196snWyCzLs9Xncl11lj4ilzn62krFU6IrVl6pscEJtW587/8F5EiP X-Received: by 2002:a17:906:5a42:b0:8b1:7ac6:3186 with SMTP id my2-20020a1709065a4200b008b17ac63186mr18467939ejc.68.1677057228694; Wed, 22 Feb 2023 01:13:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677057228; cv=none; d=google.com; s=arc-20160816; b=1KeAq3q+7f3iVJ0oh7rZwhtyjAjvUQG0FMpdBOGgiUl4w+NVLATBU4v6pSH7qqsPog K7TFOamUubPaAopHU3LCTXPlVjKCV5LweC2PKF9fr+1Rvqer+wuYHp6YUOtmxal7R8dZ I6GSA9Ibtah5YdeSDOds7LstJdSP/OY/1xoJbYTJgmPTFE+iRMTR/2balNoeTNjxDoV3 W+R6eLYwTLVWlillpkdKbQqIrCItWa0p4K8RvI7wfAfj14VXmC/g5kZlcSoiqhhIimmX ppUZRA+938qmRmaPCejvXymEGHexVxXn+1FLJca5Wpkdo3wr8K5ZCEPMBYtNDw/r3n05 qQwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=bNXC58d8BZHQ2/ZuEnXbBS8cc19qwuHs9oJf+sQ3YWM=; b=giCyZ9rItmQ4+yOipZ1I7FSslc/+L8amHaO25VGwgdp3RYHDfvr1FnJFFDBSmkpKKF g6FR06YPOgx/115pmnK0IcdBs3dh4nTp2OaWekKtgo5UN5D6HNhxdcCoIQVoT/bGz7JM gzO2TudnM3ZRTA7ZVjWdrmsuMEy3+p5Fx40JBzTZ2YQoujEdoJX2CSoar2sBuj6Th8gi qCnE98bMvVJ3cdaoRCa5EByIJGFhi18sNnsI8n18a/1GrANAi64bw9pNgIBgMIsvYE+Y nMX39W7yIbzDf6AZmC49aI9OIbK1U01gO7lpyhvTMP04XUajS3bQHKOhhzbJ3e8tFJ36 /5zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="tiTx/dm6"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id wl17-20020a170907311100b007a1d4f0e7fcsi18531387ejb.655.2023.02.22.01.13.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Feb 2023 01:13:48 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="tiTx/dm6"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 803A13858C66 for ; Wed, 22 Feb 2023 09:13:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 803A13858C66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677057227; bh=bNXC58d8BZHQ2/ZuEnXbBS8cc19qwuHs9oJf+sQ3YWM=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=tiTx/dm6vM+ouhGJEwT6hq5x0t1M/fLeNlTfRzfuGUV0tggQ4UvCl3w3xskrfptXi RN7Repv+1Z3MtFOpwvDDkqt/6c3xdpZM/1+KdeQHN5AkfwjHG9SaBMlb48ZLvBqEiq ziHgS6fmub+QeWQ3k3RcVKgOau+Us0tuhg8wK0ns= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 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 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: 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-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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758521960512252415?= X-GMAIL-MSGID: =?utf-8?q?1758521960512252415?= 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. Jakub --- 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"