From patchwork Tue Oct 24 10:29:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1854293 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SF7ch1x0bz23kh for ; Tue, 24 Oct 2023 21:30:44 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5A1693858025 for ; Tue, 24 Oct 2023 10:30:42 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 86C573858CDB for ; Tue, 24 Oct 2023 10:30:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 86C573858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 86C573858CDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698143430; cv=none; b=q+FBzc/x3XsjgTzrhMvs89E8uULd6/w/G/kctwmSbxrCqORIdC8opQk1929i2UimzfzlbCnEZ76xNKp3xPFpAm4EFCsmcCUHWFi2tGajUfsooi0DqNhgofKLiSjehOi8VBusho0Ib1HoUgogHMfThsiP1in5qARyDtz5a4xWTfk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698143430; c=relaxed/simple; bh=Mn3zMihwTZRwQptwwWv3OJQ3XAbcxYbu/gT7qJpJ18E=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=fLc+vMDz1YmRoyTN/bcgJhta/vJTSf4iolHcur6UXjR4GrzFWtYxUBmw6y0CVXN92FrMw2cXa+E74Ea+An7da1IEUnSu8VymgVNIAlRnBEBDiGkKeu0LR1BVzK8pyMV9qb+5I2vVvSmNytNjaCMwKeF5VlYHwVPyuR7OOEqfNHs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4926BC15; Tue, 24 Oct 2023 03:31:06 -0700 (PDT) Received: from e121540-lin.manchester.arm.com (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CC41D3F64C; Tue, 24 Oct 2023 03:30:24 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Cc: Richard Sandiford Subject: [PATCH 1/4] rtl-ssa: Fix null deref in first_any_insn_use Date: Tue, 24 Oct 2023 11:29:57 +0100 Message-Id: <20231024103000.3334790-2-richard.sandiford@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231024103000.3334790-1-richard.sandiford@arm.com> References: <20231024103000.3334790-1-richard.sandiford@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-24.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org first_any_insn_use implicitly (but contrary to its documentation) assumed that there was at least one use. gcc/ * rtl-ssa/member-fns.inl (first_any_insn_use): Handle null m_first_use. --- gcc/rtl-ssa/member-fns.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/rtl-ssa/member-fns.inl b/gcc/rtl-ssa/member-fns.inl index c127fab8b98..3fdca14e0ef 100644 --- a/gcc/rtl-ssa/member-fns.inl +++ b/gcc/rtl-ssa/member-fns.inl @@ -215,7 +215,7 @@ set_info::last_nondebug_insn_use () const inline use_info * set_info::first_any_insn_use () const { - if (m_first_use->is_in_any_insn ()) + if (m_first_use && m_first_use->is_in_any_insn ()) return m_first_use; return nullptr; } From patchwork Tue Oct 24 10:29:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1854295 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SF7dG3Z6Jz23jV for ; Tue, 24 Oct 2023 21:31:14 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 74F6D3858C27 for ; Tue, 24 Oct 2023 10:31:12 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 2F2F43858C60 for ; Tue, 24 Oct 2023 10:30:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2F2F43858C60 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2F2F43858C60 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698143436; cv=none; b=KDK/Lv9amGKMRCCXd4yDL3ZO8A7hnQlF5ARz+lg/UINEpL3GFrozTkzRSu5HHyl2MPho8TNn3zKcJWfyMzFQyLwDbvKrU5S8NwHGOqO6eiXv8feLnvUA0XO8c0Wddc6L+1SFrgSfMHSCSof2mO37fjllYa+WnB8vZ/1ypVmdHi4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698143436; c=relaxed/simple; bh=nwC3HBE1BdSjeSF6nAYkK898J8SZ0fLLnP/jE5QKBQE=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=sIS+nuZhh3wZExuM6O7BGn135l0JR6flVNfNBghkWTRqIGBuOHOo4d+KWyf+JlTumHpAzm3HNZhGy+xL8UCY8sediOFVBZ8DLn1Ka39+Pg1Zx0cFlYd6FppCeZVZ4kJoA32Jzd0EkFUZzf6uM7u/r0wbG9KT3Am3po7S5SeCEOo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E97B42F4; Tue, 24 Oct 2023 03:31:11 -0700 (PDT) Received: from e121540-lin.manchester.arm.com (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7893F3F64C; Tue, 24 Oct 2023 03:30:30 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Cc: Richard Sandiford Subject: [PATCH 2/4] rtl-ssa: Fix handling of deleted insns Date: Tue, 24 Oct 2023 11:29:58 +0100 Message-Id: <20231024103000.3334790-3-richard.sandiford@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231024103000.3334790-1-richard.sandiford@arm.com> References: <20231024103000.3334790-1-richard.sandiford@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-24.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org RTL-SSA queues up some invasive changes for later. But sometimes the insns involved in those changes can be deleted by later optimisations, making the queued change unnecessary. This patch checks for that case. gcc/ * rtl-ssa/changes.cc (function_info::perform_pending_updates): Check whether an insn has been replaced by a note. --- gcc/rtl-ssa/changes.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/rtl-ssa/changes.cc b/gcc/rtl-ssa/changes.cc index 73ab3ccfd24..de6222ae736 100644 --- a/gcc/rtl-ssa/changes.cc +++ b/gcc/rtl-ssa/changes.cc @@ -983,7 +983,10 @@ function_info::perform_pending_updates () for (insn_info *insn : m_queued_insn_updates) { rtx_insn *rtl = insn->rtl (); - if (JUMP_P (rtl)) + if (NOTE_P (rtl)) + // The insn was later optimized away, typically to a NOTE_INSN_DELETED. + ; + else if (JUMP_P (rtl)) { if (INSN_CODE (rtl) == NOOP_MOVE_INSN_CODE) { From patchwork Tue Oct 24 10:29:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1854296 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SF7dJ6bYlz23jV for ; Tue, 24 Oct 2023 21:31:16 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A488C3857C40 for ; Tue, 24 Oct 2023 10:31:14 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 89B8A3857B98 for ; Tue, 24 Oct 2023 10:30:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 89B8A3857B98 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 89B8A3857B98 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698143441; cv=none; b=EjMHMilr5A8o/gQqhaOZc8hlDen7k7B57cGWqGg1/uIyO03PhlXRJFmVfY2FwIxHFhPmNh1XCTfqQr/1pfaLV6P+FKoE5+fz+C3/ZL4VjeILAxyAdCiGwqZVXmZlNXBK7PAy50YtklaX5UvkvhMqdM4YLfCmFmX5IPTSjuzHi5s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698143441; c=relaxed/simple; bh=qsCP35HIjdambzq8CKhoh3i0Q0JPnKDiSEecc2Elapw=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=WbGq7ySjaZugSkKEQiHVMst4wKSBaaCwo/cc6iU8kSLqXma28wvQCS6VvEyLBflmSvlNIpyrYe41pUqipmW3IM9fvCmJVTd9ASfsg6vyw0+3MV88JByfcXxh7fxEfkzCOp+KyhheE2buRaebvgZMsDcI1NttRze2rAW7V/8lnag= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4CF322F4; Tue, 24 Oct 2023 03:31:17 -0700 (PDT) Received: from e121540-lin.manchester.arm.com (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D07733F64C; Tue, 24 Oct 2023 03:30:35 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Cc: Richard Sandiford Subject: [PATCH 3/4] rtl-ssa: Don't insert after insns that can throw Date: Tue, 24 Oct 2023 11:29:59 +0100 Message-Id: <20231024103000.3334790-4-richard.sandiford@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231024103000.3334790-1-richard.sandiford@arm.com> References: <20231024103000.3334790-1-richard.sandiford@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-24.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org rtl_ssa::can_insert_after didn't handle insns that can throw. Fixing that avoids a regression with a later patch. gcc/ * rtl-ssa.h: Include cfgbuild.h. * rtl-ssa/movement.h (can_insert_after): Replace is_jump with the more comprehensive control_flow_insn_p. --- gcc/rtl-ssa.h | 1 + gcc/rtl-ssa/movement.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/rtl-ssa.h b/gcc/rtl-ssa.h index 7355c6c4463..3a3c8b50ee2 100644 --- a/gcc/rtl-ssa.h +++ b/gcc/rtl-ssa.h @@ -49,6 +49,7 @@ #include "obstack-utils.h" #include "mux-utils.h" #include "rtlanal.h" +#include "cfgbuild.h" // Provides the global crtl->ssa. #include "memmodel.h" diff --git a/gcc/rtl-ssa/movement.h b/gcc/rtl-ssa/movement.h index d9945f49172..67370947dbd 100644 --- a/gcc/rtl-ssa/movement.h +++ b/gcc/rtl-ssa/movement.h @@ -61,7 +61,8 @@ move_earlier_than (insn_range_info range, insn_info *insn) inline bool can_insert_after (insn_info *insn) { - return insn->is_bb_head () || (insn->is_real () && !insn->is_jump ()); + return (insn->is_bb_head () + || (insn->is_real () && !control_flow_insn_p (insn->rtl ()))); } // Try to restrict move range MOVE_RANGE so that it is possible to From patchwork Tue Oct 24 10:30:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1854294 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SF7d60DcLz23jV for ; Tue, 24 Oct 2023 21:31:06 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 19CF03857730 for ; Tue, 24 Oct 2023 10:31:04 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 976A33858284 for ; Tue, 24 Oct 2023 10:30:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 976A33858284 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 976A33858284 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698143451; cv=none; b=dQpqK3+4+zLoj7rP2ezHp3EBoMqfXkZ6dhXk9xTcMkkhJxMJN2IUd1hhNmArqhCfcoWwRS4oFOoKDZA2S+utBaKbgskc+IIQhruIom7CGa/fuoXAUm53Jx0r0d0X2dzT5O+mbg2umjLpiHtlTr/dsHN0iwRlrpItgvaw3XsRBt4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698143451; c=relaxed/simple; bh=mFK7hXORNfQXV9NnzbdwVY7TD1qhzky5JCvXV1N8zM0=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=Zz3+7WxGRU5Nv1+Qmn6HoUidSeluRRiOMsmvR4iE8v1XtIaZnC1LzPhrBF5tTYn5jyxysRNQQR6iZd33J+1gAoaywcWOCPueYDbxwAKrMIdIPcAxek48ELd70o/VH82zhGMBKVJuob91W0GlIejQnHG10fku/y6XMj3RM0AGQRY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4C962C15; Tue, 24 Oct 2023 03:31:22 -0700 (PDT) Received: from e121540-lin.manchester.arm.com (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CFFA83F64C; Tue, 24 Oct 2023 03:30:40 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Cc: Richard Sandiford Subject: [PATCH 4/4] rtl-ssa: Avoid creating duplicated phis Date: Tue, 24 Oct 2023 11:30:00 +0100 Message-Id: <20231024103000.3334790-5-richard.sandiford@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231024103000.3334790-1-richard.sandiford@arm.com> References: <20231024103000.3334790-1-richard.sandiford@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-24.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org If make_uses_available was called twice for the same use, we could end up trying to create duplicate definitions for the same extended live range. gcc/ * rtl-ssa/blocks.cc (function_info::create_degenerate_phi): Check whether the requested phi already exists. --- gcc/rtl-ssa/blocks.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gcc/rtl-ssa/blocks.cc b/gcc/rtl-ssa/blocks.cc index d46cbf1e388..ecce7a68c59 100644 --- a/gcc/rtl-ssa/blocks.cc +++ b/gcc/rtl-ssa/blocks.cc @@ -525,6 +525,11 @@ function_info::create_phi (ebb_info *ebb, resource_info resource, phi_info * function_info::create_degenerate_phi (ebb_info *ebb, set_info *def) { + // Allow the function to be called twice in succession for the same def. + def_lookup dl = find_def (def->resource (), ebb->phi_insn ()); + if (set_info *set = dl.matching_set ()) + return as_a (set); + access_info *input = def; phi_info *phi = create_phi (ebb, def->resource (), &input, 1); if (def->is_reg ())