From patchwork Fri Jun 16 16:17:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 1796024 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=WIpNHvAU; dkim=pass header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=5Gq2alOH; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QjPTf1L7sz20Wy for ; Sat, 17 Jun 2023 02:18:14 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 33DF8385697D for ; Fri, 16 Jun 2023 16:18:12 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 48C8B3856973 for ; Fri, 16 Jun 2023 16:18:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 48C8B3856973 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=suse.cz 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 81F5E1F749; Fri, 16 Jun 2023 16:17:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1686932279; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=/iYssBXJ7pUjgT8ISJiX6exDPou/gG7VntVr92W8FhE=; b=WIpNHvAU8bwAgEOlmFc5B0ZT8ijeXs6lc/wSaYCRa+I3nvdCwHb0xyiIIfdycOS90eSJTT fS0mseXMjRcTJdIZknhHE8qDTaTXcBsONEorSpYf2Bi2oN+zZb5Y6AuBIoYR8sW9mmz1V0 7gKPbVKD0HCTqB0t8V94T5SVhFeDG98= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1686932279; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=/iYssBXJ7pUjgT8ISJiX6exDPou/gG7VntVr92W8FhE=; b=5Gq2alOHepvtDvLtYeir/DdrGwGC4kzYgsfdbfRftjxk8NbR6u2090W92t7XJROdY64+8X 4Z8EqRVYxpAjZjAw== 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 76EFE138E8; Fri, 16 Jun 2023 16:17:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8EcDHTeLjGQvFgAAMHmgww (envelope-from ); Fri, 16 Jun 2023 16:17:59 +0000 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka Subject: [PATCH] ipa-sra: Disable candidates with no known callers (PR 110276) User-Agent: Notmuch/0.37 (https://notmuchmail.org) Emacs/28.2 (x86_64-suse-linux-gnu) Date: Fri, 16 Jun 2023 18:17:59 +0200 Message-ID: MIME-Version: 1.0 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_SOFTFAIL, 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 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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. 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? 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(); +}