From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 4AE233857B85 for ; Wed, 14 Sep 2022 12:50:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4AE233857B85 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de 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-out2.suse.de (Postfix) with ESMTPS id 0372D1F978 for ; Wed, 14 Sep 2022 12:50:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1663159802; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=pqc9IafyOdhyLeULhh/ke5ju4n+1mrvNrEK4AF9FJ9I=; b=lh5waAGn/jv5NPBjdlU6uSK1JxPNbiAJVW+omrjJwt2ZUbdBizrieTzxPQzEqyP8ECnowJ vFE6t/vj/eCAVB3vjw/gPNbaNx9nY+GfmyeyMXpPyYKKQe91va3eTQ0pLLVhvR+vEfFxLI IJ1qXdy9+pF3F0z6zuY8uPe9REjZcN4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1663159802; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=pqc9IafyOdhyLeULhh/ke5ju4n+1mrvNrEK4AF9FJ9I=; b=wfMRamvPxR8tJ7N/zDSLXB1OSfdmcuTO+zasX8Mz9SLgkP1sQb7Ww3lasiGe0Vjckcis+o FEbOyu536/ikcqAQ== 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 E5607134B3 for ; Wed, 14 Sep 2022 12:50:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 42TfNvnNIWMaCAAAMHmgww (envelope-from ) for ; Wed, 14 Sep 2022 12:50:01 +0000 Date: Wed, 14 Sep 2022 14:50:01 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/106938 - cleanup abnormal edges after inlining MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Message-Id: <20220914125001.E5607134B3@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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: After inlining and IPA transforms we run fixup_cfg to fixup CFG effects in other functions. But that fails to clean abnormal edges from non-pure/const calls which might no longer be necessary when ->calls_setjmp is false. The following ensures this happens and refactors things so we call EH/abnormal cleanup only on the last stmt in a block. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/106938 * tree-cfg.cc (execute_fixup_cfg): Purge dead abnormal edges for all last stmts in a block. Do EH cleanup only on the last stmt in a block. * gcc.dg/pr106938.c: New testcase. --- gcc/testsuite/gcc.dg/pr106938.c | 36 +++++++++++++++++++++++++++++++++ gcc/tree-cfg.cc | 13 ++++++------ 2 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr106938.c diff --git a/gcc/testsuite/gcc.dg/pr106938.c b/gcc/testsuite/gcc.dg/pr106938.c new file mode 100644 index 00000000000..7365a8c29fb --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr106938.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fno-ipa-pure-const -fno-tree-ccp -Wuninitialized" } */ + +int n; + +void +undefined (void); + +__attribute__ ((returns_twice)) int +zero (void) +{ + return 0; +} + +void +bar (int) +{ + int i; + + for (i = 0; i < -1; ++i) + n = 0; +} + +__attribute__ ((simd)) void +foo (void) +{ + int uninitialized; + + undefined (); + + while (uninitialized < 1) /* { dg-warning "uninitialized" } */ + { + bar (zero ()); + ++uninitialized; + } +} diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc index 5cb6db337f9..48c5c4de51f 100644 --- a/gcc/tree-cfg.cc +++ b/gcc/tree-cfg.cc @@ -9828,16 +9828,12 @@ execute_fixup_cfg (void) int flags = gimple_call_flags (stmt); if (flags & (ECF_CONST | ECF_PURE | ECF_LOOPING_CONST_OR_PURE)) { - if (gimple_purge_dead_abnormal_call_edges (bb)) - todo |= TODO_cleanup_cfg; - if (gimple_in_ssa_p (cfun)) { todo |= TODO_update_ssa | TODO_cleanup_cfg; update_stmt (stmt); } } - if (flags & ECF_NORETURN && fixup_noreturn_call (stmt)) todo |= TODO_cleanup_cfg; @@ -9867,10 +9863,15 @@ execute_fixup_cfg (void) } } - if (maybe_clean_eh_stmt (stmt) + gsi_next (&gsi); + } + if (gimple *last = last_stmt (bb)) + { + if (maybe_clean_eh_stmt (last) && gimple_purge_dead_eh_edges (bb)) todo |= TODO_cleanup_cfg; - gsi_next (&gsi); + if (gimple_purge_dead_abnormal_call_edges (bb)) + todo |= TODO_cleanup_cfg; } /* If we have a basic block with no successors that does not -- 2.35.3