From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 567CD3854816 for ; Wed, 5 May 2021 11:38:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 567CD3854816 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-329-Uly2Wt7mP1SLmGLGW4qxHg-1; Wed, 05 May 2021 07:38:04 -0400 X-MC-Unique: Uly2Wt7mP1SLmGLGW4qxHg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F2BF9126F; Wed, 5 May 2021 11:38:03 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-114-59.ams2.redhat.com [10.36.114.59]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1D7A360D08; Wed, 5 May 2021 11:38:02 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 145BbxAd3255409 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 5 May 2021 13:38:00 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 145BbxE13255408; Wed, 5 May 2021 13:37:59 +0200 Date: Wed, 5 May 2021 13:37:59 +0200 From: Jakub Jelinek To: Eric Botcazou Cc: gcc-patches@gcc.gnu.org Subject: Re: [patch] Fix PR rtl-optimization/100411 Message-ID: <20210505113759.GO1179226@tucnak> Reply-To: Jakub Jelinek References: <3286823.QJadu78ljV@fomalhaut> <20210505111003.GN1179226@tucnak> <3418561.R56niFO833@fomalhaut> MIME-Version: 1.0 In-Reply-To: <3418561.R56niFO833@fomalhaut> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Wed, 05 May 2021 11:38:08 -0000 On Wed, May 05, 2021 at 01:21:20PM +0200, Eric Botcazou wrote: > > I mean, can't we have just one while loop that skips over all debug insns, > > NOTE_INSN_BASIC_BLOCK_P, NOTE_INSN_PROLOGUE_END and NOTE_INSN_FUNCTION_BEG > > and stops on anything else, or, if we want to skip at most one of some or > > all of those note kinds, do some tracking if we've already skipped that kind > > of note? > > Revised version attached. It was meant as a question, I don't know what the right answer is. At least for NOTE_INSN_BASIC_BLOCK skipping more than one might be problematic, because that would mean we've skipped into a different basic block and it wouldn't surprise me if split_block in that case crashed or did something weird (if the first argument is not BLOCK_FOR_INSN of the second argument when it is non-NULL). For the other notes, I think they should normally appear just once and shouldn't be a problem therefore. > diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c > index f05cb6136c7..f49a34dcb0f 100644 > --- a/gcc/cfgcleanup.c > +++ b/gcc/cfgcleanup.c > @@ -2134,18 +2134,15 @@ try_crossjump_to_edge (int mode, edge e1, edge e2, > update_br_prob_note (redirect_edges_to); > > /* Edit SRC1 to go to REDIRECT_TO at NEWPOS1. */ > - > - /* Skip possible basic block header. */ > if (LABEL_P (newpos1)) > newpos1 = NEXT_INSN (newpos1); > > - while (DEBUG_INSN_P (newpos1)) > - newpos1 = NEXT_INSN (newpos1); > - > - if (NOTE_INSN_BASIC_BLOCK_P (newpos1)) > - newpos1 = NEXT_INSN (newpos1); > - > - while (DEBUG_INSN_P (newpos1)) > + /* Skip debug insns, basic block header and prologue markers. */ > + while (DEBUG_INSN_P (newpos1) > + || (NOTE_P (newpos1) > + && (NOTE_KIND (newpos1) == NOTE_INSN_BASIC_BLOCK > + || NOTE_KIND (newpos1) == NOTE_INSN_PROLOGUE_END > + || NOTE_KIND (newpos1) == NOTE_INSN_FUNCTION_BEG))) > newpos1 = NEXT_INSN (newpos1); > > redirect_from = split_block (src1, PREV_INSN (newpos1))->src; Jakub