From patchwork Mon Oct 26 13:12:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1387733 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ucw.cz Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CKZy246Xqz9sTK for ; Tue, 27 Oct 2020 00:12:40 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4B20A3894C00; Mon, 26 Oct 2020 13:12:37 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id BE5B2386F47D for ; Mon, 26 Oct 2020 13:12:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BE5B2386F47D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=none smtp.mailfrom=hubicka@kam.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 82E1E282B3D; Mon, 26 Oct 2020 14:12:31 +0100 (CET) Date: Mon, 26 Oct 2020 14:12:31 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix simdclones pass Message-ID: <20201026131231.GA46622@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-16.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi, this patch makes cleaning of stmt pointers in references more robust so late IPA passes do not break. Bootstrapped/regtested x86_64-linux, comitted. Honza gcc/ChangeLog: 2020-10-26 Jan Hubicka PR ipa/97576 * cgraphclones.c (cgraph_node::materialize_clone): Clear stmt references. * cgraphunit.c (mark_functions_to_output): Do not clear them here. * ipa-inline-transform.c (inline_transform): Clear stmt references. * symtab.c (symtab_node::clear_stmts_in_references): Make recursive for clones. * tree-ssa-structalias.c (ipa_pta_execute): Do not clear references. gcc/testsuite/ChangeLog: 2020-10-26 Jan Hubicka PR ipa/97576 * gcc.c-torture/compile/pr97576.c: New test. diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c index 41c6efb10ac..0ed63078c91 100644 --- a/gcc/cgraphclones.c +++ b/gcc/cgraphclones.c @@ -1115,6 +1115,7 @@ cgraph_node::materialize_clone () if (clone.param_adjustments) clone.param_adjustments->dump (symtab->dump_file); } + clear_stmts_in_references (); /* Copy the OLD_VERSION_NODE function tree to the new version. */ tree_function_versioning (clone_of->decl, decl, clone.tree_map, clone.param_adjustments, diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index d2d98c8dc8a..08b93cb00ee 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -1600,7 +1600,6 @@ mark_functions_to_output (void) FOR_EACH_FUNCTION (node) { tree decl = node->decl; - node->clear_stmts_in_references (); gcc_assert (!node->process || node->same_comdat_group); if (node->process) diff --git a/gcc/ipa-inline-transform.c b/gcc/ipa-inline-transform.c index 279ba2f7cb0..4df1b7fb9ee 100644 --- a/gcc/ipa-inline-transform.c +++ b/gcc/ipa-inline-transform.c @@ -716,6 +716,7 @@ inline_transform (struct cgraph_node *node) if (n->decl != node->decl) n->materialize_clone (); } + node->clear_stmts_in_references (); /* We might need the body of this function so that we can expand it inline somewhere else. */ diff --git a/gcc/symtab.c b/gcc/symtab.c index bc2865f4121..067ae2e28a0 100644 --- a/gcc/symtab.c +++ b/gcc/symtab.c @@ -752,7 +752,8 @@ symtab_node::remove_stmt_references (gimple *stmt) i++; } -/* Remove all stmt references in non-speculative references. +/* Remove all stmt references in non-speculative references in THIS + and all clones. Those are not maintained during inlining & cloning. The exception are speculative references that are updated along with callgraph edges associated with them. */ @@ -770,6 +771,13 @@ symtab_node::clear_stmts_in_references (void) r->lto_stmt_uid = 0; r->speculative_id = 0; } + cgraph_node *cnode = dyn_cast (this); + if (cnode) + { + if (cnode->clones) + for (cnode = cnode->clones; cnode; cnode = cnode->next_sibling_clone) + cnode->clear_stmts_in_references (); + } } /* Remove all references in ref list. */ diff --git a/gcc/testsuite/gcc.c-torture/compile/pr97576.c b/gcc/testsuite/gcc.c-torture/compile/pr97576.c new file mode 100644 index 00000000000..8d6a6c6d634 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr97576.c @@ -0,0 +1,18 @@ +void +pc (void); + +void __attribute__ ((simd)) +ty (void); + +void __attribute__ ((simd)) +gf () +{ + ty (); +} + +void __attribute__ ((simd)) +ty (void) +{ + gf (pc); + gf (gf); +} diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 9bac06f97af..a4832b75436 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -8138,10 +8138,6 @@ ipa_pta_execute (void) from = constraints.length (); } - /* FIXME: Clone materialization is not preserving stmt references. */ - FOR_EACH_DEFINED_FUNCTION (node) - node->clear_stmts_in_references (); - /* Build the constraints. */ FOR_EACH_DEFINED_FUNCTION (node) {