From patchwork Tue Jul 19 15:15:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 61 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a98:d5ce:0:b0:178:cc93:bf7d with SMTP id g14csp2513898eik; Tue, 19 Jul 2022 08:16:32 -0700 (PDT) X-Google-Smtp-Source: AGRyM1suc4mu4njpvmP7x/a1LoY2cbo7rIaNA8/WijJNqFHdiz5xx/Rdfla2A6IbUVX3LTJIJ38j X-Received: by 2002:a17:907:3e0e:b0:72b:568f:7fa7 with SMTP id hp14-20020a1709073e0e00b0072b568f7fa7mr31637954ejc.119.1658243792685; Tue, 19 Jul 2022 08:16:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658243792; cv=none; d=google.com; s=arc-20160816; b=yIoZ3nkgaf9Vs7BenZqnEW6ulySUozOGCsR9dMmqDqB8rFLqkIsl2HNKUh+KaEfRYD /ghYKbqjzpFgvFk/nIWaclUxMO/Dl+W2ae9ClpTvjMNIaNjx3Qiy/esX7OCltMTfHWRE eayXzv1rjr+EpmF4vLsnPJ2W2fSi44PeJnoBT8UYqW4HZie+6JxFXciGDVS+D2zuQdnL U1hWjyLugyZAy4YsBj1wflhd0Syyf9n5w0nfyyDgETBFlM0Vsl9wEX/1ebJGUaPnI6x1 KQ0awuwM3jLLJw+AXyAdDZN0WtuFZl4xwskmfi+CGpizOphL8Tzxc0vOv44fH8rrVudi OHcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=M/dBMsy+MxU0vvJCCNqMWY54nn0XsGxoFLrYharar88=; b=VUYoYEc9gFZumBNdYXxD0ZwC+ui7LbHAFGUBkdd+yvaEFF3qUbs9BUn5YBZBBNS+Ai n2bxXA+cvM1x7p47x8KpqZ0gfPmKkQY/qdMEbKAwz0vEEyhPXl8Q2RI4aZisgxOWbBvJ Q5R2pNNEaFTx8xcl822Nm3nYKh9AqPTIpkXHidu4PU7E4liy9RVIb/rVX/aYFgrD5G4m V+ADj6WnTYT/tfEIjOkGe8lC9KPacNtWAnwR+Zt7jvLHau5NAvfvdtSzDGVikOb4pXeV h1vyKaPoXoi9JZcMWb2k0NQViEuM+zhoGHLhKspWl0OHwarLNY9c5M2yQk9q3Lmazq7n POXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ZS4sFggo; 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 eb13-20020a0564020d0d00b0043a7e6e24e9si21001705edb.383.2022.07.19.08.16.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jul 2022 08:16:32 -0700 (PDT) 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=ZS4sFggo; 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 7E4E13857825 for ; Tue, 19 Jul 2022 15:16:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7E4E13857825 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1658243791; bh=M/dBMsy+MxU0vvJCCNqMWY54nn0XsGxoFLrYharar88=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=ZS4sFggojKJfZNy/pQZZEYhtO+0ycmvCS6ECuQn4I+XELkBbJJYCyi0cYdslm3dHc 9G+yEWm7IIpS+RK0evErPgFz5CsjSaryHXEbGTXcmIFA+f/ubjdu1Mg19Sxvc+flgm K8NyLaAfBVBk9Lsfp7HVuN85E/JkhojzNIqMqhrA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by sourceware.org (Postfix) with ESMTPS id D3E6F3858281 for ; Tue, 19 Jul 2022 15:15:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D3E6F3858281 Received: from localhost.intra.ispras.ru (unknown [10.10.3.121]) by mail.ispras.ru (Postfix) with ESMTP id C201F407624D; Tue, 19 Jul 2022 15:15:44 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/2] Remove unused remove_node_from_expr_list Date: Tue, 19 Jul 2022 18:15:31 +0300 Message-Id: <20220719151532.8206-1-amonakov@ispras.ru> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, 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: Alexander Monakov via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: Alexander Monakov Cc: Alexander Monakov 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?1738794643255368892?= X-GMAIL-MSGID: =?utf-8?q?1738794643255368892?= This function remains unused since remove_node_from_insn_list was cloned from it. gcc/ChangeLog: * rtl.h (remove_node_from_expr_list): Remove declaration. * rtlanal.cc (remove_node_from_expr_list): Remove (no uses). --- gcc/rtl.h | 1 - gcc/rtlanal.cc | 29 ----------------------------- 2 files changed, 30 deletions(-) diff --git a/gcc/rtl.h b/gcc/rtl.h index 488016bb4..645c009a3 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -3712,7 +3712,6 @@ extern unsigned hash_rtx_cb (const_rtx, machine_mode, int *, int *, extern rtx regno_use_in (unsigned int, rtx); extern int auto_inc_p (const_rtx); extern bool in_insn_list_p (const rtx_insn_list *, const rtx_insn *); -extern void remove_node_from_expr_list (const_rtx, rtx_expr_list **); extern void remove_node_from_insn_list (const rtx_insn *, rtx_insn_list **); extern int loc_mentioned_in_p (rtx *, const_rtx); extern rtx_insn *find_first_parameter_load (rtx_insn *, rtx_insn *); diff --git a/gcc/rtlanal.cc b/gcc/rtlanal.cc index d78cc6024..ec95ecd6c 100644 --- a/gcc/rtlanal.cc +++ b/gcc/rtlanal.cc @@ -2878,35 +2878,6 @@ in_insn_list_p (const rtx_insn_list *listp, const rtx_insn *node) return false; } -/* Search LISTP (an EXPR_LIST) for an entry whose first operand is NODE and - remove that entry from the list if it is found. - - A simple equality test is used to determine if NODE matches. */ - -void -remove_node_from_expr_list (const_rtx node, rtx_expr_list **listp) -{ - rtx_expr_list *temp = *listp; - rtx_expr_list *prev = NULL; - - while (temp) - { - if (node == temp->element ()) - { - /* Splice the node out of the list. */ - if (prev) - XEXP (prev, 1) = temp->next (); - else - *listp = temp->next (); - - return; - } - - prev = temp; - temp = temp->next (); - } -} - /* Search LISTP (an INSN_LIST) for an entry whose first operand is NODE and remove that entry from the list if it is found. From patchwork Tue Jul 19 15:15:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 62 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a98:d5ce:0:b0:178:cc93:bf7d with SMTP id g14csp2514513eik; Tue, 19 Jul 2022 08:17:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u6ObLS7M5024PHV0lrcOJRmvpH0t0AMsscddxqOokBWq1QpdQxt14zgV7zCWdWA1fUjFaa X-Received: by 2002:a17:906:99c5:b0:6fe:b069:4ab6 with SMTP id s5-20020a17090699c500b006feb0694ab6mr30633440ejn.436.1658243849484; Tue, 19 Jul 2022 08:17:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658243849; cv=none; d=google.com; s=arc-20160816; b=y6pXGSiV/elbOqfNiZUFL8XaQGi5cPd6bH5DLD4kxIJSrrePb2IWMayXK1zTm3Nf/O YtKwfyV0TTOgy75O6pvxKNKGDGweAKAiF1KJXlqzM72MgjMeq7l3cVdoqKE6hBmM3ocm I7Am6OuXIQrqX5kjFVGUda/OZyJkIyM80zMAAY1aFiwKTqDh1r+oU4r1kgenM/kNFwCd MGiJZHRNGd5a9ej8rq1izVeOO6utghJ6FOp0bPjXE2OrrKt/1Nho8GyYKp0FVuahqNFm 9a0yRnPxqiA78mmUSMjyB4LaVXSn+SudkZXl7sNwpDHsvB2eq4v7D3q8OWYQcehUdhQU tDLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=A0I0KNlB4NksvNCprfY6E7jmCCCGME+Zmx373ahN+u4=; b=Yiz2uR3Ho26QsBemfqkwhAMqjMHZp1Glz8ZxPs7MMFO3/NstVnKHdC9icKYXqsPJtt Ss+e6LnAvBwh8I2g2yimlF20FnwHYvHGfsRaXnfgFb144WR8S85UfnFzGo8Tn5iE2RhO mR/88JOFSFQlCuueqnpQjxUsvMAPIx+BAm2zVgUJQ6bQYbgT9EQoEADhcXbfJ/DZKUEJ hZID3zl1SNghpgrhgWeSHZiaY0n1hdHzRuuL8Yahrz0JBNGXHTTbPg0BiA44PPnKasn3 JRXE4+FOpLdzQzDMDvlV5JKo8isx+uym1BtXVtzc7TjVZniQNgsxfAuWSHgx8n3sx+QQ dYGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=nWktvDE3; 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 k17-20020a170906055100b00726a885d35bsi13387087eja.811.2022.07.19.08.17.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jul 2022 08:17:29 -0700 (PDT) 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=nWktvDE3; 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 500AA3857038 for ; Tue, 19 Jul 2022 15:17:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 500AA3857038 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1658243848; bh=A0I0KNlB4NksvNCprfY6E7jmCCCGME+Zmx373ahN+u4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=nWktvDE3yIMRzOTLk8pjgtN3P5I5PQVyDYsp8yDUjVHOJp12A5gQjlrIWBMvVSk45 8nlYAgHYYI6dTNWqzpakyo4hn3mfb0Cf/rqHun38qjspIaXr+XHYKU21mFdR/WaCe8 Z1E6V2z0A7MhD6HqrMOG/p8Po0xZ/MzjH2NuENgI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by sourceware.org (Postfix) with ESMTPS id C3C573858293 for ; Tue, 19 Jul 2022 15:15:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C3C573858293 Received: from localhost.intra.ispras.ru (unknown [10.10.3.121]) by mail.ispras.ru (Postfix) with ESMTP id 897F1407624D; Tue, 19 Jul 2022 15:15:54 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/2] Avoid registering __builtin_setjmp_receiver label twice [PR101347] Date: Tue, 19 Jul 2022 18:15:32 +0300 Message-Id: <20220719151532.8206-2-amonakov@ispras.ru> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220719151532.8206-1-amonakov@ispras.ru> References: <20220719151532.8206-1-amonakov@ispras.ru> MIME-Version: 1.0 X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, 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: Alexander Monakov via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: Alexander Monakov Cc: Alexander Monakov 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?1738794702583068717?= X-GMAIL-MSGID: =?utf-8?q?1738794702583068717?= The testcase in the PR demonstrates how it is possible for one __builtin_setjmp_receiver label to appear in nonlocal_goto_handler_labels list twice (after the block with __builtin_setjmp_setup referring to it was duplicated). remove_node_from_insn_list did not account for this possibility and removed only the first copy from the list. Add an assert verifying that duplicates are not present. To avoid adding a label to the list twice, move registration of the label from __builtin_setjmp_setup handling to __builtin_setjmp_receiver. gcc/ChangeLog: PR rtl-optimization/101347 * builtins.cc (expand_builtin) [BUILT_IN_SETJMP_SETUP]: Move population of nonlocal_goto_handler_labels from here ... (expand_builtin) [BUILT_IN_SETJMP_RECEIVER]: ... to here. * rtlanal.cc (remove_node_from_insn_list): Verify that a duplicate is not present in the remainder of the list. --- gcc/builtins.cc | 15 +++++++-------- gcc/rtlanal.cc | 1 + 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gcc/builtins.cc b/gcc/builtins.cc index e6816d5c8..12a688dd8 100644 --- a/gcc/builtins.cc +++ b/gcc/builtins.cc @@ -7467,15 +7467,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, machine_mode mode, tree label = TREE_OPERAND (CALL_EXPR_ARG (exp, 1), 0); rtx_insn *label_r = label_rtx (label); - /* This is copied from the handling of non-local gotos. */ expand_builtin_setjmp_setup (buf_addr, label_r); - nonlocal_goto_handler_labels - = gen_rtx_INSN_LIST (VOIDmode, label_r, - nonlocal_goto_handler_labels); - /* ??? Do not let expand_label treat us as such since we would - not want to be both on the list of non-local labels and on - the list of forced labels. */ - FORCED_LABEL (label) = 0; return const0_rtx; } break; @@ -7488,6 +7480,13 @@ expand_builtin (tree exp, rtx target, rtx subtarget, machine_mode mode, rtx_insn *label_r = label_rtx (label); expand_builtin_setjmp_receiver (label_r); + nonlocal_goto_handler_labels + = gen_rtx_INSN_LIST (VOIDmode, label_r, + nonlocal_goto_handler_labels); + /* ??? Do not let expand_label treat us as such since we would + not want to be both on the list of non-local labels and on + the list of forced labels. */ + FORCED_LABEL (label) = 0; return const0_rtx; } break; diff --git a/gcc/rtlanal.cc b/gcc/rtlanal.cc index ec95ecd6c..56da7435a 100644 --- a/gcc/rtlanal.cc +++ b/gcc/rtlanal.cc @@ -2899,6 +2899,7 @@ remove_node_from_insn_list (const rtx_insn *node, rtx_insn_list **listp) else *listp = temp->next (); + gcc_checking_assert (!in_insn_list_p (temp->next (), node)); return; }