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: 109245 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1460167vqr; Fri, 16 Jun 2023 09:18:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ61ovoWNBXyGJo/SJQZvpel655Z4c/EnHXg7/w03silK4W2axhQW4q2iCfkFMZ/AEvbVBFu X-Received: by 2002:a17:907:26cb:b0:982:bbc7:15c0 with SMTP id bp11-20020a17090726cb00b00982bbc715c0mr2294833ejc.66.1686932325591; Fri, 16 Jun 2023 09:18:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686932325; cv=none; d=google.com; s=arc-20160816; b=V+JTc2Gew+/mPSy4VZkYGslFsGp1KyLwYFBNmDljA1QsJdL7H3GIP4BUpoX2lzMFEf BVt8wFw4umRYuoSDJJ5TQDTUz576apSWV4mCa9Q7mevtDYCTXhHSZJLvUQ3lEZJUYLNK T+IRyP1i3+G3J0OJ7Tuh0mj779QRLHRVFXQh3DKtkAxbnAzio0+2i+aofObVKmJn8kob SpPF91VqvUMIr6WIqw50i2EfvzEZ1ulqe3PMXKKEay0MHHI3SL7XBWd5UfI1F7zyDVWk lE/RtwEGSGYhRLBTVyy2/JI4MPy9L6AylHo8x3vsdbfRmZwqiKkAACfgrU3mwFBhGG9r yXrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:message-id:date :user-agent:subject:cc:to:from:dkim-signature:dkim-signature :dmarc-filter:delivered-to; bh=/iYssBXJ7pUjgT8ISJiX6exDPou/gG7VntVr92W8FhE=; b=0t00kemyOXluU02M8XOLIzHsS6bZP8DrSIMLOyu3+XwA6bGQQU9lsa0XqPIG+ltM0K +FlQWkrl3yDfGsuBhW4nWLhxwN5AK1bYOUc3K+DZCSLOml9bchKpsXpTQH8JXxEl/RpD nx+ZCtAUJS4LfKQnmpaDDeZM+Ev2/wf6UYqvoA1DtBLr4gmAMkFZ+jANIVIhVNe+LGnt sfeFChhPVdJakg9CAxtuDUGw1hOR0W3EZIOCGpxeOB0mItIZfy5vQqe2qcwc5b8v80ZT MYZ5KV2ADSC7twjag0eWrQmEXS9P3WZ7KQN8Kg2EgUBYBPdQZSp153IpsPNFJybBRq2d F+tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=WIpNHvAU; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=5Gq2alOH; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id g21-20020a1709063b1500b00982bb6615bbsi1844941ejf.772.2023.06.16.09.18.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jun 2023 09:18:45 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=WIpNHvAU; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=5Gq2alOH; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9610F385660A for ; Fri, 16 Jun 2023 16:18:24 +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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768876750437961182?= X-GMAIL-MSGID: =?utf-8?q?1768876750437961182?= 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(); +}