From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 0A09F385840A for ; Fri, 29 Jul 2022 08:47:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0A09F385840A 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 D3AA3208EA for ; Fri, 29 Jul 2022 08:47:01 +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 C077113A1B for ; Fri, 29 Jul 2022 08:47:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id vPXQLYWe42IPUQAAMHmgww (envelope-from ) for ; Fri, 29 Jul 2022 08:47:01 +0000 Date: Fri, 29 Jul 2022 10:47:01 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/106422 - verify block copying in forward threading MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Message-Id: <20220729084701.C077113A1B@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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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, 29 Jul 2022 08:47:04 -0000 The forward threader failed to check whether it can actually duplicate blocks. The following adds this in a similar place the backwards threader performs this check. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/106422 * tree-ssa-threadupdate.cc (fwd_jt_path_registry::update_cfg): Check whether we can copy thread blocks and cancel the thread if not. * gcc.dg/torture/pr106422.c: New testcase. --- gcc/testsuite/gcc.dg/torture/pr106422.c | 14 ++++++++++++++ gcc/tree-ssa-threadupdate.cc | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr106422.c diff --git a/gcc/testsuite/gcc.dg/torture/pr106422.c b/gcc/testsuite/gcc.dg/torture/pr106422.c new file mode 100644 index 00000000000..a2cef1aecb6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr106422.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ + +void vfork() __attribute__((__leaf__)); +void semanage_reload_policy(char *arg, void cb(void)) +{ + if (!arg) + { + cb(); + return; + } + vfork(); + if (arg) + __builtin_free(arg); +} diff --git a/gcc/tree-ssa-threadupdate.cc b/gcc/tree-ssa-threadupdate.cc index f901c7759e3..0f2b319d44a 100644 --- a/gcc/tree-ssa-threadupdate.cc +++ b/gcc/tree-ssa-threadupdate.cc @@ -2678,7 +2678,9 @@ fwd_jt_path_registry::update_cfg (bool may_peel_loop_headers) for (j = 0; j < path->length (); j++) { edge e = (*path)[j]->e; - if (m_removed_edges->find_slot (e, NO_INSERT)) + if (m_removed_edges->find_slot (e, NO_INSERT) + || ((*path)[j]->type == EDGE_COPY_SRC_BLOCK + && !can_duplicate_block_p (e->src))) break; } -- 2.35.3