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: 157370 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1844495vqx; Tue, 24 Oct 2023 03:30:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHiQ6O6ti6ejUvhVDFwrRTzBPP4sTY110kQ16pOAx6CdaCATxG2pWyt5SH5aLcIvUrGqEiL X-Received: by 2002:aca:1004:0:b0:3a9:e8e2:57a7 with SMTP id 4-20020aca1004000000b003a9e8e257a7mr10717026oiq.53.1698143455758; Tue, 24 Oct 2023 03:30:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698143455; cv=pass; d=google.com; s=arc-20160816; b=PCZkSVpcrYQKu7bbPhCfIYis6B7RIzNFOGe6MZ8xRP8CUdLOqS9fsV35lUmp+tRhhJ u238UPDmqwrRUF8mIVPwibcGGQGdeTY7X30k0w0rnuW9lafCjbCAtUqT2o54wazZ9i8E GphQZSs246ttN/EIzhqtHdmEp1QbJURvSSmSAHJC64A4nXJni7D0jNX+++1wHNaGvEiZ G8UVzgMehhZ8hUgVpvWy+S4A8+BpBO82ovzs1zuvraObuQrIzXBhjZuDSKqPoiQMAnQ/ zPxXB4YoWstJjFTf+soTgco6VW0fZcTZhkHofbxNikPbc8Z5mNa0TJ19fO0mxuoVMwRx cVew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to: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:cc:to :from:arc-filter:dmarc-filter:delivered-to; bh=CHJ5GU5wy1tDHsvROYekGEVDhi6hv+9FVTPQIvHzVq0=; fh=C4nEn4uRKApr1WsFtLyJD8L5BeRuRc+JFyqoopFjd9M=; b=LJMVqo9OsGTZicRQr7nsaiWOaPDiwcbJzjxbnrKzMqC8dfx//YOe+JKUpQEQXgIRSS Gmd/vPJIOp4PTnGPcYkRKM//AWk9wuyFZ3aN8DS4m7fD8HsRaM2VBRqXLf6c38mwniHR nUJDcV7P87aV+zBXeRzJWO9+yQBxqMAiwrl9kxdGRgguf4aZUU1GG2XDatv7VL7pYs+2 vEjEqYhjuYTKLEA2MEgf7I9zuogs3vdgr0fEHRmfY26vZvXlemTTK/vRY6dCVynT8iWA Q8ugPAyBwjp3bb34meBJnElPDs/hf2V/X5V/6LgtebQAZYqRcOGh20fEEHxs7a4sH9sa gmzA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id j4-20020a0cc344000000b0066cf06339c8si6856628qvi.197.2023.10.24.03.30.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 03:30:55 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 152353857345 for ; Tue, 24 Oct 2023 10:30:55 +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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780632472011772478 X-GMAIL-MSGID: 1780632472011772478 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: 157372 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1844845vqx; Tue, 24 Oct 2023 03:31:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJWFGjuGu/tsyt1HJBSm9Es4QizegbrW5D/imePQjCujn3TPFMNnUVhaw93NzSEsg17v7G X-Received: by 2002:a05:620a:bcb:b0:770:f346:e9e8 with SMTP id s11-20020a05620a0bcb00b00770f346e9e8mr13406476qki.10.1698143489941; Tue, 24 Oct 2023 03:31:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698143489; cv=pass; d=google.com; s=arc-20160816; b=KE5j4jIS2NyoAkhrBK+eBLbXXWX+X4YvdUdspEFP8ra7aWR98DNrzTGKE8iANDXWde PtpQDMBopoLzz/JZAoI8LFnSxxbn3iRVE+nbMpt4vSuG36cVxRiMBK6Rlb39AmN28AwX Ylh0DEtwlVpZAsAG4xqex2061eiAamaYTEbxvJ9Bo0aaM9jj07P6nUfrv9NPhWxFlpDc XS682Ztj/pDUmu7iV95vCbBOIn91zJApidv2+sYJOAt+veKfCpM7kQQ+i0emIAZiVSyW yCEVcusOsqDRJFgVDRM8g/zPINTsX+yHdGCDlUzWvIc/zV1iGBFuJGTtQMb9QKoPQme9 6agg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to: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:cc:to :from:arc-filter:dmarc-filter:delivered-to; bh=r1DAlY0Xp1kdQrgXcUOCkD5A2liDZWZgwBDrFOLumy0=; fh=C4nEn4uRKApr1WsFtLyJD8L5BeRuRc+JFyqoopFjd9M=; b=ddj7xat40N1aHSN12bM0sGuZ62+x70guqMXJ9Jd5LfaqbgJ/wO1FvwxGtJZC/ccsDn vUl1UIwMv3ZNRsnYslygOhH3+b/Vw5Fl4eEg7OHryqNJQmvvK/r/AUZ2uqEU8OrjzKW1 laU3I0xDlgk2uXxBHcDxzCkEf8zXQrSjTa+uAPZi6hnZXlCaw6defo/kyaeD/AnlkQ0k qOZUQQtTwq5eutnKdO/R9oEPQvflQUbw6b4KH83dE772/eGs8oo0drvzW5HE9IRuMve5 eLjVvKo0YpucsUMYwmIDNb81wjTGaD4BXwUpRcYvcfLDYWyCHrCK292zYGwwQYICNbR4 7Agg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id s8-20020a05620a0bc800b0076d9d0b221csi7042002qki.366.2023.10.24.03.31.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 03:31:29 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 29EB73856263 for ; Tue, 24 Oct 2023 10:31:25 +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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780632507812725615 X-GMAIL-MSGID: 1780632507812725615 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: 157373 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1844872vqx; Tue, 24 Oct 2023 03:31:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH78sPUoWwQw9resYq7vWA6QdvSPc3Pr+p3sJd/nWRn0KRGe6CQ04UN0KOaZ/5/kYM8ffnd X-Received: by 2002:ac8:7f82:0:b0:417:a862:4b with SMTP id z2-20020ac87f82000000b00417a862004bmr12331065qtj.33.1698143493038; Tue, 24 Oct 2023 03:31:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698143493; cv=pass; d=google.com; s=arc-20160816; b=mW14/j8gHeE3Xqr8EcVNVwqV4gijbA9cTJoNTMDLpMI8iRM5A/2ok62UDZ3o87CnTa 4KJ1lcysIgu1/SItvNfFSdusEAcbMPJ9y0KAZ7B6KSMcsHlsOtpJ61Mji8CXztTUKa4K 6TqGMTeBQfP/5l1kbq+WyJcDpAf7AOpD6SEavKgml9VdbnYW23MoizpHhzVKHLo4UpVg g/7xDQzic9kzWOtNaisoUy5zzTWLlQA/2EatOgyKroynf2ciENiJDPDWlTwJgIrV/VTw i2/eZ1QQSDD0SQOxOY8OxMWNdS+9+h+cyEYoXv+pnICQjou1cPf1Epn23BI4SRlckf7p S1LQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to: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:cc:to :from:arc-filter:dmarc-filter:delivered-to; bh=fnS/Ex5aDRoZ/A8Bzr1KI8WDgwXHdUCQOtLuxi8bHW0=; fh=C4nEn4uRKApr1WsFtLyJD8L5BeRuRc+JFyqoopFjd9M=; b=r3Il2QgHnqdt6mJIokl44ypjxBm6tNuH+Oh+MYRFuZseDkDQ/AhBYb3m2x2BfPVTrK EcoSIQ1VNpZsHV5e0EbnPNTNBCl7ujtAz+KHvbaWIlELqks2cQk5MasJlesp0Q7kh8bO S8eyVvBWYF62N9KNhhdb3TZly9h7VglEpR3CiXEnxOmUPnU8k9RalZxo803uTSbdWwMf Uya4V9xFlU9s0acNPTUbHb/XapHWkP5g5rbrBdKwBcYusziCyeV/CtYzklgXRfS/b/Fc LICTEab07vsvRY3U39ZNSv/JplBz9nPksihE445lI9VjsMnP2/IWhSull4mWxHn0ybbB CHQg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id l13-20020a05622a050d00b0040fe32ab0b6si6776349qtx.286.2023.10.24.03.31.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 03:31:33 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 632CE385C6E4 for ; Tue, 24 Oct 2023 10:31:27 +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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780632511433347862 X-GMAIL-MSGID: 1780632511433347862 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: 157371 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1844748vqx; Tue, 24 Oct 2023 03:31:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGWfNcqBILqyvgbv0rWtQtAKo7F9qViuxI4SbZSUvXBy9I/q1qmet3AdeBM/eQoToQGD7P/ X-Received: by 2002:a05:622a:2c9:b0:419:8f42:8c45 with SMTP id a9-20020a05622a02c900b004198f428c45mr14878860qtx.8.1698143479502; Tue, 24 Oct 2023 03:31:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698143479; cv=pass; d=google.com; s=arc-20160816; b=KEXulVw4wSTk0XTL+xr88u/XJLgB4Qj7Jd3oCPtLSW00rG1+E/wtsqpoSmPGiWD6ai uUeFdR1jpZqGcdDSnfBmjTfPUGk8TXT5/tRUTjMO6zO0joCSQ8WcB7ZmXz1PbHrkojeX W+8b/1uAUhYONHLZB+qiOg6rNmeTC9haB6NpXWu3QU2unmButVxEoWVvT2Efs77W0V3q B6taaKkoxfGgK0H/MksAr+wvlGpgIfYLjKM/7uVUcYscF9uc+ohvsBlCHwCmMWqnUj+W CNnA5O3HlciLk8LBJPfpYYZ0bYbQ+8Gwv7d63Z9W6aZfW7LjXuuwCOaJjJaB0VKrT6RX +Eyg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to: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:cc:to :from:arc-filter:dmarc-filter:delivered-to; bh=FHmLXry/0tRTr+Wrx2KI9m7l6JxBuV6fLBJdkZWhVSY=; fh=C4nEn4uRKApr1WsFtLyJD8L5BeRuRc+JFyqoopFjd9M=; b=JewgPno1qoSNicrhLIQnzksAUqcjVuPJ8YuYY3gzyAE55x65hckSDRN6Pf9fmnXeWj QJuzAp2iz81IfGDnKiSL0Agxn3U8y+OcsAdspSgen5VMFNhYzW89Nhpr4Bn8QaHhxZnG pQhL7Ji7app4NnXpGtECCJ55zldMN5B834KxWrSfpKiIosKDVWsSnk2LCAgdL1dSwogw dcMCUx5dnp6KKUvbg06d/QYuXlhsPOLaURjNCw/3VKglnoo8YFdd83jGqwG7qe5wQGEc +07mCZyr0iD6H047nTdEiaYydk9hFpr8Qy/ww+JK3xY0zfdZxhg25ICvBGKH+db143hd F1tw== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id x9-20020ac85f09000000b0041974779343si6638355qta.479.2023.10.24.03.31.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 03:31:19 -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; arc=pass (i=1); 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6329D3856DE8 for ; Tue, 24 Oct 2023 10:31:16 +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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780632497288615674 X-GMAIL-MSGID: 1780632497288615674 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 ())