From patchwork Wed Oct 14 08:40:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1381898 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 4CB5V20cyyz9sVJ for ; Wed, 14 Oct 2020 19:40:56 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 698AF3870876; Wed, 14 Oct 2020 08:40:54 +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 CAD443854822 for ; Wed, 14 Oct 2020 08:40:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CAD443854822 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 272D128262C; Wed, 14 Oct 2020 10:40:48 +0200 (CEST) Date: Wed, 14 Oct 2020 10:40:48 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix SCC discovery in ipa-modref Message-ID: <20201014084048.GC88069@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=-14.6 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 fixes SCC discovery in ipa-modref which is causing misoptimization of gnat bootstrapped with LTO, PGO and -O3. I also improved debug info and spotted wrong parameter to ignore_stores_p (which is probably quite harmless since we only inline matching functions, but it is better to be consistent). Bootstrapped/regtested x86_64-linux, will commit it shortly. gcc/ChangeLog: 2020-10-14 Jan Hubicka PR bootstrap/97350 * ipa-modref.c (ignore_edge): Do not ignore inlined edes. (ipa_merge_modref_summary_after_inlining): Improve debug output and fix parameter of ignore_stores_p. diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c index 4f86b9ccea1..771a0a88f9a 100644 --- a/gcc/ipa-modref.c +++ b/gcc/ipa-modref.c @@ -1603,6 +1603,11 @@ make_pass_ipa_modref (gcc::context *ctxt) static bool ignore_edge (struct cgraph_edge *e) { + /* We merge summaries of inline clones into summaries of functions they + are inlined to. For that reason the complete function bodies must + act as unit. */ + if (!e->inline_failed) + return false; enum availability avail; cgraph_node *callee = e->callee->function_or_virtual_thunk_symbol (&avail, e->caller); @@ -1723,7 +1728,7 @@ ipa_merge_modref_summary_after_inlining (cgraph_edge *edge) if (!callee_info && to_info) { - if (ignore_stores_p (edge->callee->decl, flags)) + if (ignore_stores_p (edge->caller->decl, flags)) to_info->loads->collapse (); else { @@ -1733,7 +1738,7 @@ ipa_merge_modref_summary_after_inlining (cgraph_edge *edge) } if (!callee_info_lto && to_info_lto) { - if (ignore_stores_p (edge->callee->decl, flags)) + if (ignore_stores_p (edge->caller->decl, flags)) to_info_lto->loads->collapse (); else { @@ -1747,7 +1752,7 @@ ipa_merge_modref_summary_after_inlining (cgraph_edge *edge) compute_parm_map (edge, &parm_map); - if (!ignore_stores_p (edge->callee->decl, flags)) + if (!ignore_stores_p (edge->caller->decl, flags)) { if (to_info && callee_info) to_info->stores->merge (callee_info->stores, &parm_map); @@ -1762,14 +1767,38 @@ ipa_merge_modref_summary_after_inlining (cgraph_edge *edge) if (summaries) { if (to_info && !to_info->useful_p (flags)) - summaries->remove (to); + { + if (dump_file) + fprintf (dump_file, "Removed mod-ref summary for %s\n", + to->dump_name ()); + summaries->remove (to); + } + else if (to_info && dump_file) + { + if (dump_file) + fprintf (dump_file, "Updated mod-ref summary for %s\n", + to->dump_name ()); + to_info->dump (dump_file); + } if (callee_info) summaries->remove (edge->callee); } if (summaries_lto) { if (to_info_lto && !to_info_lto->useful_p (flags)) - summaries_lto->remove (to); + { + if (dump_file) + fprintf (dump_file, "Removed mod-ref summary for %s\n", + to->dump_name ()); + summaries_lto->remove (to); + } + else if (to_info_lto && dump_file) + { + if (dump_file) + fprintf (dump_file, "Updated mod-ref summary for %s\n", + to->dump_name ()); + to_info_lto->dump (dump_file); + } if (callee_info_lto) summaries_lto->remove (edge->callee); }