From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id B39EA3858D35 for ; Fri, 16 Jun 2023 19:41:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B39EA3858D35 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=none smtp.mailfrom=kam.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id F0C73284E3D; Fri, 16 Jun 2023 21:41:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1; t=1686944506; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=3boGkWD8cFhBhWnIv7IEmKMGVXIyKHVw3wG1eJoXZ/o=; b=kLKwi6OJgRL4qJraw1HBIp0j8lw16bJ31yhBiS2i6r37Kqy2Qdv4VuhSZpPsJ4v17toOKJ h52u2eGPeVi5jg00awzbVMgnbtSDdnPHjRwz95hGa7DEMzPcoisDBR0Us1Up40ivIHjGMr NWCEmJ8CpczdYjfmow7meLTNYI493rI= Date: Fri, 16 Jun 2023 21:41:46 +0200 From: Jan Hubicka To: Martin Jambor Cc: GCC Patches Subject: Re: [PATCH] ipa-sra: Disable candidates with no known callers (PR 110276) Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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: > Hi, > > In IPA-SRA we use can_be_local_p () predicate rather than just plain > local call graph flag in order to figure out whether the node is a > part of an external API that we cannot change. Although there are > cases where this can allow more transformations, it also means we can > analyze functions which have no callers at all, which is pointless. Do we also have some cost model that we do not privatize very large comdats? > > Moreover, it makes an assert of hint propagation trigger, which checks > that we have looked at callers before processing hints that come from > them. This has been reported as PR 110276. > > This patch simply adds a check that a node has at least one caller > into the early checks and makes the node a non-candidate for any > transformation if it does not. > > Bootstrapped and tested on x86_64-linux, LTO bootstrap is still > underway. OK if it passes too? OK. (It is run during WPA, not during early compilation, right?) Honza > > Thanks, > > Martin > > > gcc/ChangeLog: > > 2023-06-16 Martin Jambor > > PR ipa/110276 > * ipa-sra.cc (struct caller_issues): New field there_is_one. > (check_for_caller_issues): Set it. > (check_all_callers_for_issues): Check it. > > gcc/testsuite/ChangeLog: > > 2023-06-16 Martin Jambor > > PR ipa/110276 > * gcc.dg/ipa/pr110276.c: New test. > --- > gcc/ipa-sra.cc | 11 +++++++++++ > gcc/testsuite/gcc.dg/ipa/pr110276.c | 15 +++++++++++++++ > 2 files changed, 26 insertions(+) > create mode 100644 gcc/testsuite/gcc.dg/ipa/pr110276.c > > diff --git a/gcc/ipa-sra.cc b/gcc/ipa-sra.cc > index 3fee8fb22ce..21d281a9756 100644 > --- a/gcc/ipa-sra.cc > +++ b/gcc/ipa-sra.cc > @@ -3074,6 +3074,8 @@ struct caller_issues > cgraph_node *candidate; > /* There is a thunk among callers. */ > bool thunk; > + /* Set if there is at least one caller that is OK. */ > + bool there_is_one; > /* Call site with no available information. */ > bool unknown_callsite; > /* Call from outside the candidate's comdat group. */ > @@ -3116,6 +3118,8 @@ check_for_caller_issues (struct cgraph_node *node, void *data) > > if (csum->m_bit_aligned_arg) > issues->bit_aligned_aggregate_argument = true; > + > + issues->there_is_one = true; > } > return false; > } > @@ -3170,6 +3174,13 @@ check_all_callers_for_issues (cgraph_node *node) > for (unsigned i = 0; i < param_count; i++) > (*ifs->m_parameters)[i].split_candidate = false; > } > + if (!issues.there_is_one) > + { > + if (dump_file && (dump_flags & TDF_DETAILS)) > + fprintf (dump_file, "There is no call to %s that we can modify. " > + "Disabling all modifications.\n", node->dump_name ()); > + return true; > + } > return false; > } > > diff --git a/gcc/testsuite/gcc.dg/ipa/pr110276.c b/gcc/testsuite/gcc.dg/ipa/pr110276.c > new file mode 100644 > index 00000000000..5a1e2f3fb1c > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/ipa/pr110276.c > @@ -0,0 +1,15 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2" } */ > + > +typedef long (*EFI_PCI_IO_PROTOCOL_CONFIG)(); > +typedef struct { > + EFI_PCI_IO_PROTOCOL_CONFIG Read; > +} EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS; > +typedef struct { > + EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS Pci; > +} EFI_PCI_IO_PROTOCOL; > +int init_regs_0; > +static void __attribute__((constructor)) init(EFI_PCI_IO_PROTOCOL *pci_io) { > + if (init_regs_0) > + pci_io->Pci.Read(); > +} > -- > 2.40.1 >