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 9A0923858D37 for ; Fri, 28 Jan 2022 10:29:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9A0923858D37 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 68363212BA; Fri, 28 Jan 2022 10:29:39 +0000 (UTC) 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 4C0CF13D17; Fri, 28 Jan 2022 10:29:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UGxjEZPF82HQGwAAMHmgww (envelope-from ); Fri, 28 Jan 2022 10:29:39 +0000 Date: Fri, 28 Jan 2022 11:29:38 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: Jakub Jelinek , ebotcazou@adacore.com Subject: [PATCH] tree-optimization/104263 - avoid retaining abnormal edges for non-call/goto stmts MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Message-Id: <20220128102939.4C0CF13D17@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Fri, 28 Jan 2022 10:29:41 -0000 This removes a premature optimization from gimple_purge_dead_abnormal_call_edges which, after eliding the last setjmp (or computed goto) statement from a function and thus clearing cfun->calls_setjmp, leaves us with the abnormal edges from other calls that are elided for example via inlining or DCE. That's a CFG / IL combination that should be impossible (not addressing the fact that with cfun->calls_setjmp and cfun->has_nonlocal_label cleared we should not have any abnormal edge at all). For the testcase in the PR this means that IPA inlining will remove the abormal edges from the block after inlining the call the edge was coming from. Bootstrap / regtest running on x86_64-unknown-linux-gnu. 2022-01-28 Richard Biener PR tree-optimization/104263 * tree-cfg.cc (gimple_purge_dead_abnormal_call_edges): Purge edges also when !cfun->has_nonlocal_label and !cfun->calls_setjmp. * gcc.dg/tree-ssa/inline-13.c: New testcase. --- gcc/testsuite/gcc.dg/tree-ssa/inline-13.c | 27 +++++++++++++++++++++++ gcc/tree-cfg.cc | 4 ---- 2 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/inline-13.c diff --git a/gcc/testsuite/gcc.dg/tree-ssa/inline-13.c b/gcc/testsuite/gcc.dg/tree-ssa/inline-13.c new file mode 100644 index 00000000000..94d8a9c709e --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/inline-13.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-early-inlining -fdump-tree-fixup_cfg3" } */ + +int n; + +static int +bar (void) +{ + int a; + + n = 0; + a = 0; + + return n; +} + +__attribute__ ((pure, returns_twice)) int +foo (void) +{ + n = bar () + 1; + foo (); + + return 0; +} + +/* Abnormal edges should be properly elided after IPA inlining of bar. */ +/* { dg-final { scan-tree-dump-times "bb" 1 "fixup_cfg3" } } */ diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc index 2340cd7cef0..260a7fb97c6 100644 --- a/gcc/tree-cfg.cc +++ b/gcc/tree-cfg.cc @@ -8916,10 +8916,6 @@ gimple_purge_dead_abnormal_call_edges (basic_block bb) edge_iterator ei; gimple *stmt = last_stmt (bb); - if (!cfun->has_nonlocal_label - && !cfun->calls_setjmp) - return false; - if (stmt && stmt_can_make_abnormal_goto (stmt)) return false; -- 2.31.1