From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id E521E3858D1E for ; Tue, 3 Jan 2023 11:01:19 +0000 (GMT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A084138628; Tue, 3 Jan 2023 11:01:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1672743678; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/RHdiWVBUo7nsKhdlIQtXjvUGc/RxL7/TcFL4ZZq+ok=; b=nUrHeqQ43b6hxNtjucs3k21LTK1zNv2+zhRvRQgPZRQ+0vM25OIUtQbEbybZSB2JRpbuB0 HxaMooisNakxayogzr4QdM9517NEdS22yB8F9MEuN8jDiAU4xj5W2JDsP92Vs9usfOEd+2 FlV4duAQq6gIzy5NeXtLQyjzc9qWnLs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1672743678; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/RHdiWVBUo7nsKhdlIQtXjvUGc/RxL7/TcFL4ZZq+ok=; b=85yE5tuwfgHjMEgz/ZZtVNMljM/f3N3PoiANld8oCOvkdLtr2VaPzjrh3cE/E5vaQ5wJW7 ua1BNOdZeQ12JmCg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 93B321390C; Tue, 3 Jan 2023 11:01:18 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id WW4HJP4KtGPmVAAAMHmgww (envelope-from ); Tue, 03 Jan 2023 11:01:18 +0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Richard Biener Mime-Version: 1.0 (1.0) Subject: Re: [PATCH] cfgrtl: Don't try to redirect asm goto to EXIT [PR108263] Date: Tue, 3 Jan 2023 12:01:08 +0100 Message-Id: References: Cc: Jeff Law , gcc-patches@gcc.gnu.org In-Reply-To: To: Jakub Jelinek X-Mailer: iPhone Mail (20C65) X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 List-Id: > Am 03.01.2023 um 11:29 schrieb Jakub Jelinek via Gcc-patches : >=20 > =EF=BB=BFHi! >=20 > The following testcase distilled from Linux kernel on ppc64le ICEs, > because fixup_reorder_chain sees a bb with a single fallthru edge > falling into a bb with simple return and decides to redirect > that fallthru edge to EXIT. That is possible if the bb ending > in the fallthru edge doesn't end with a jump or ends with a normal > unconditional jump, but not when the bb ends with asm goto which can despi= te > a single fallthru have multiple labels to the fallthrough basic block. >=20 > The following patch makes sure we never try to redirect such cases to EXIT= . >=20 > Bootstrapped/regtested on x86_64-linux, i686-linux and s390x-linux, ok for= > trunk? Ok Richard=20 > 2023-01-03 Jakub Jelinek >=20 > PR rtl-optimization/108263 > * cfgrtl.cc (fixup_reorder_chain): Avoid trying to redirect > asm goto to EXIT. >=20 > * gcc.dg/pr108263.c: New test. >=20 > --- gcc/cfgrtl.cc.jj 2023-01-02 09:32:32.000000000 +0100 > +++ gcc/cfgrtl.cc 2023-01-02 14:13:40.658338194 +0100 > @@ -3910,6 +3910,7 @@ fixup_reorder_chain (void) > rtx ret_label =3D NULL_RTX; > basic_block nb; > edge_iterator ei; > + bool asm_goto =3D false; >=20 > if (EDGE_COUNT (bb->succs) =3D=3D 0) > continue; > @@ -4016,7 +4017,9 @@ fixup_reorder_chain (void) > || e_fall->dest =3D=3D EXIT_BLOCK_PTR_FOR_FN (cfun)) > continue; >=20 > - /* Otherwise we'll have to use the fallthru fixup below. */ > + /* Otherwise we'll have to use the fallthru fixup below. > + But avoid redirecting asm goto to EXIT. */ > + asm_goto =3D true; > } > else > { > @@ -4048,7 +4051,8 @@ fixup_reorder_chain (void) > return rather than a jump to the return block. */ > rtx_insn *ret, *use; > basic_block dest; > - if (bb_is_just_return (e_fall->dest, &ret, &use) > + if (!asm_goto > + && bb_is_just_return (e_fall->dest, &ret, &use) > && ((PATTERN (ret) =3D=3D simple_return_rtx && targetm.have_simple_re= turn ()) > || (PATTERN (ret) =3D=3D ret_rtx && targetm.have_return ()))) > { > --- gcc/testsuite/gcc.dg/pr108263.c.jj 2023-01-02 14:09:49.381614027 +0= 100 > +++ gcc/testsuite/gcc.dg/pr108263.c 2023-01-02 14:07:16.899772608 +0100= > @@ -0,0 +1,25 @@ > +/* PR rtl-optimization/108263 */ > +/* { dg-do compile } */ > +/* { dg-options "-O2" } */ > + > +int v, *p; > + > +void > +foo (void) > +{ > + int i; > + for (i =3D 0; ; i++) > + { > + if (v) > + { > + __label__ l1; > + asm goto ("" : : : : l1); > + l1: > + return; > + } > + if (p[i]) > + break; > + } > + asm goto ("" : : "r" (i) : : l2); > +l2:; > +} >=20 > Jakub >=20