From patchwork Mon Dec 16 16:34:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 1210544 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=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-516051-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="OSqWyJ/I"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47c6M438r1z9sNH for ; Tue, 17 Dec 2019 03:35:10 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=KSN+k0OWCeOhK2ECrERHErFjg9tsQ7Pve1BtV8jJhvxknw0R44 sfJoAfPvdoUN3uLLccASAZoZYgLelUHVpCCbMM/HgeI5kLtpC9+IEreoN3uppjyj jO4hvZn1Bg5lsCoSJer2EJFCxV2BnXwcYXJsIrX3D3Lq31vwBoOpCBMKo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; s= default; bh=uQ7JvOAG2AxQr+u2HVds208E8Xw=; b=OSqWyJ/IoCSwolqp4fs4 VMcPNaWtp27IGxdNCSpBofxHSeRlMr8Ah3/OyZIS71cxJQKjcKMTvXgJK9EGEEe7 W+TQ7lfCvMXWOdm0f6TOMHPjgSBMUtnfCzfMF/OA4PG/XR8X5MRt8ljhLMX+2Dc0 /zMs7Okds9Ojd/4/PVRr+LY= Received: (qmail 2747 invoked by alias); 16 Dec 2019 16:35:03 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 2739 invoked by uid 89); 16 Dec 2019 16:35:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=cgraph_node, new_node, Prevent, disappear X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 16 Dec 2019 16:35:01 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 6E2ACAFB5; Mon, 16 Dec 2019 16:34:59 +0000 (UTC) From: Martin Jambor To: GCC Patches Cc: Jan Hubicka , Jan Hubicka Subject: [PATCH] Prevent IPA-SRA from creating calls to local comdats (PR 92676) User-Agent: Notmuch/0.29.2 (https://notmuchmail.org) Emacs/26.3 (x86_64-suse-linux-gnu) Date: Mon, 16 Dec 2019 17:34:58 +0100 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi, since r278669 (fix for PR ipa/91956), IPA-SRA makes sure that the clone it creates is put into the same same_comdat as the original cgraph_node, so that it can call private comdats (such as the ipa-split bits of a comdat that is private). However, that means that if there is non-comdat caller of a public comdat that is modified by IPA-SRA, it now finds itself calling a private comdat, which call graph verifier does not like (and for a reason, in theory it can disappear and since it is private it would not be available from other CUs). The patch fixes this by performing the fix for PR 91956 only when the node in question actually calls a local comdat and when it does, also making sure that no callers come from a different same_comdat (disabling IPA-SRA if both conditions are true), so that it plays by the rules in both modes, does not violate the private comdat calling rule and at the same time does not disable the transformation unnecessarily. The patch also fixes up the calls_comdat_local of callers of the modified node, despite that not triggering any known issues. It has passed LTO-bootstrap and testing. What do you think? Thanks, Martin 2019-12-16 Martin Jambor PR ipa/92676 * ipa-sra.c (struct caller_issues): New fields candidate and call_from_outside_comdat. (check_for_caller_issues): Check for calls from outsied of candidate's same_comdat_group. (check_all_callers_for_issues): Set up issues.candidate, check result of the new check. (process_isra_node_results): Set calls_comdat_local of callers if appropriate. --- gcc/ipa-sra.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/gcc/ipa-sra.c b/gcc/ipa-sra.c index 421c0899e11..8612c8fc920 100644 --- a/gcc/ipa-sra.c +++ b/gcc/ipa-sra.c @@ -2895,10 +2895,14 @@ ipa_sra_ipa_function_checks (cgraph_node *node) struct caller_issues { + /* The candidate being considered. */ + cgraph_node *candidate; /* There is a thunk among callers. */ bool thunk; /* Call site with no available information. */ bool unknown_callsite; + /* Call from outside the the candidate's comdat group. */ + bool call_from_outside_comdat; /* There is a bit-aligned load into one of non-gimple-typed arguments. */ bool bit_aligned_aggregate_argument; }; @@ -2920,6 +2924,13 @@ check_for_caller_issues (struct cgraph_node *node, void *data) thunks. */ return true; } + if (issues->candidate->calls_comdat_local + && issues->candidate->same_comdat_group + && !issues->candidate->in_same_comdat_group_p (cs->caller)) + { + issues->call_from_outside_comdat = true; + return true; + } isra_call_summary *csum = call_sums->get (cs); if (!csum) @@ -2942,6 +2953,7 @@ check_all_callers_for_issues (cgraph_node *node) { struct caller_issues issues; memset (&issues, 0, sizeof (issues)); + issues.candidate = node; node->call_for_symbol_and_aliases (check_for_caller_issues, &issues, true); if (issues.unknown_callsite) @@ -2960,6 +2972,13 @@ check_all_callers_for_issues (cgraph_node *node) node->dump_name ()); return true; } + if (issues.call_from_outside_comdat) + { + if (dump_file) + fprintf (dump_file, "Function would become private comdat called " + "outside of its comdat group.\n"); + return true; + } if (issues.bit_aligned_aggregate_argument) { @@ -3759,8 +3778,12 @@ process_isra_node_results (cgraph_node *node, = node->create_virtual_clone (callers, NULL, new_adjustments, "isra", suffix_counter); suffix_counter++; - if (node->same_comdat_group) - new_node->add_to_same_comdat_group (node); + if (node->calls_comdat_local && node->same_comdat_group) + { + new_node->add_to_same_comdat_group (node); + for (cgraph_edge *cs = new_node->callers; cs; cs = cs->next_caller) + cs->caller->calls_comdat_local = true; + } new_node->calls_comdat_local = node->calls_comdat_local; if (dump_file)