From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 108673858D33 for ; Wed, 18 Oct 2023 17:54:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 108673858D33 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 108673858D33 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=1697651647; cv=none; b=G+0neYdozo9MU6mFNxcnpxG/taHSb9cn3zlWVW50nd6Z1u/DDkRgzGDw1bcmzSB0Zzf3gzQ5qu6wtMDGJjSF25QTh0RA3aQEjfnIKb8hB1/VqDj3yfIOdokZShiJ4J7i75CQbkbL1CXb/oiUFT25dt7jk3uUuWFDK8MTRuWTSNQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697651647; c=relaxed/simple; bh=R7K/rixJ0gtlB4no9QT0yAP+Skph2ks+kwBQEMQpPqM=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=E90QLNTxCfsEeeCXyq3ZvI+on9SGFZgriraMKp5iqX16qZqyGL/cCpoX6nDqfqvEQsgDqkJB7w0kckuW/bW0pjBI8aLhObrJPDVeUBB/v7Q4rtXPH1V1cm97L7GP8RMXPHm4UzWI94Ogv/mzOleI3zpnQQHT7qsWV3S/2f5gvqM= 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 EE13D2F4; Wed, 18 Oct 2023 10:54:46 -0700 (PDT) Received: from localhost (unknown [10.32.110.65]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 585163F5A1; Wed, 18 Oct 2023 10:54:05 -0700 (PDT) From: Richard Sandiford To: Alex Coplan Mail-Followup-To: Alex Coplan ,gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH 01/11] rtl-ssa: Fix bug in function_info::add_insn_after References: Date: Wed, 18 Oct 2023 18:54:04 +0100 In-Reply-To: (Alex Coplan's message of "Tue, 17 Oct 2023 21:46:00 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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 List-Id: Alex Coplan writes: > In the case that !insn->is_debug_insn () && next->is_debug_insn (), this > function was missing an update of the prev pointer on the first nondebug > insn following the sequence of debug insns starting at next. > > This can lead to corruption of the insn chain, in that we end up with: > > insn->next_any_insn ()->prev_any_insn () != insn > > in this case. This patch fixes that. > > Bootstrapped/regtested as a series on aarch64-linux-gnu, OK for trunk? > > gcc/ChangeLog: > > * rtl-ssa/insns.cc (function_info::add_insn_after): Ensure we > update the prev pointer on the following nondebug insn in the > case that !insn->is_debug_insn () && next->is_debug_insn (). OK, thanks. Richard > --- > gcc/rtl-ssa/insns.cc | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-) > > diff --git a/gcc/rtl-ssa/insns.cc b/gcc/rtl-ssa/insns.cc > index a0c2fec2b70..f970375d906 100644 > --- a/gcc/rtl-ssa/insns.cc > +++ b/gcc/rtl-ssa/insns.cc > @@ -291,9 +291,17 @@ function_info::add_insn_after (insn_info *insn, insn_info *after) > first->set_last_debug_insn (insn); > } > else // !insn->is_debug_insn () && next->is_debug_insn () > - // At present we don't (need to) support inserting a nondebug > - // instruction between two existing debug instructions. > - gcc_assert (!after->is_debug_insn ()); > + { > + // At present we don't (need to) support inserting a nondebug > + // instruction between two existing debug instructions. > + gcc_assert (!after->is_debug_insn ()); > + > + // Find the next nondebug insn and update its previous pointer > + // to point to INSN. > + auto next_nondebug = next->last_debug_insn ()->next_any_insn (); > + gcc_checking_assert (!next_nondebug->is_debug_insn ()); > + next_nondebug->set_prev_sametype_insn (insn); > + } > > // If AFTER and NEXT are separated by at least two points, we can > // use a unique point number for INSN. Otherwise INSN will have