From patchwork Fri Nov 22 16:13:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 1199542 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-514411-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="mb5XQ/3k"; 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 47KM1y1Zmhz9sPK for ; Sat, 23 Nov 2019 03:14:12 +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=LrxMV8SxkXvJXoisBW305SkOHi0BGDXokgzOy+4fcu2BzxkFIS SNxSIqu9NfxypVeCStogz0Pxbebq78CwW+kKRlnTKsGroL5rv6yNU09uSgSfNTDd CRpJXt16XvV1EznXE8+FgrTnhw3jkYMisLWxmAxv2xW5sR0lAdOHUjNxE= 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=bmh6uRp1/p3vJAkWfphhAD5CGJA=; b=mb5XQ/3k8WAies1WCgpR Ld//CRjNFZqDrjieDrc92Eo1DBmgptRBp30oqO4S2PDZUILAdyXMSgZ0yCEoAXbE buVeOgmFiWs+EA1u16TyKEjjivOWM5E4SrrbNN73kBQOxBOykdYGqYISX4pv3WrS 3qSXUTRH1UhDzZ7AlOu5MEw= Received: (qmail 48637 invoked by alias); 22 Nov 2019 16:14:04 -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 48628 invoked by uid 89); 22 Nov 2019 16:14:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.3 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=sees, verifier X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 22 Nov 2019 16:13:54 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 30BBEABC4 for ; Fri, 22 Nov 2019 16:13:52 +0000 (UTC) From: Martin Jambor To: GCC Patches Cc: Jan Hubicka Subject: [PATCH] Make IPA-SRA follow comdat-local rules (PR 91956) User-Agent: Notmuch/0.29.1 (https://notmuchmail.org) Emacs/26.3 (x86_64-suse-linux-gnu) Date: Fri, 22 Nov 2019 17:13:51 +0100 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi, this verifier error happens because first IPA-split splits a comdat function creating a comdat local callee and then IPA-SRA comes along, modifies the caller, makes it a local clone in the process but because it does not set the comdat group to the original, the verifier sees a call from outside of the comdat group to a private comdat symbol, which it does not like. Fixed by doing what IPA-split does in the patch below. Bootstrapped and tested on x86_64-linux. OK for trunk? Thanks, Martin 2019-11-21 Martin Jambor PR ipa/91956 * ipa-sra.c (process_isra_node_results): Put the new node to the same comdat group as the original node. testsuite/ * g++.dg/ipa/pr91956.C: New test. --- gcc/ipa-sra.c | 3 +++ gcc/testsuite/g++.dg/ipa/pr91956.C | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ipa/pr91956.C diff --git a/gcc/ipa-sra.c b/gcc/ipa-sra.c index 08606aeded1..c6ed0f44b87 100644 --- a/gcc/ipa-sra.c +++ b/gcc/ipa-sra.c @@ -3759,6 +3759,9 @@ 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); + new_node->calls_comdat_local = node->calls_comdat_local; if (dump_file) fprintf (dump_file, " Created new node %s\n", new_node->dump_name ()); diff --git a/gcc/testsuite/g++.dg/ipa/pr91956.C b/gcc/testsuite/g++.dg/ipa/pr91956.C new file mode 100644 index 00000000000..6f6edc30a47 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr91956.C @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -std=c++11 -fno-strict-aliasing -fno-tree-fre -fno-tree-vrp" } */ + +int count = 0; +struct VB +{ + VB() {++count;} +}; + +struct B : virtual VB +{ + B() : B(42) {} + B(int) {} +}; + +struct D : B +{ + D() {} + D(int) : D() {} +}; + +int main() +{ + D d{42}; + if (count != 1) + __builtin_abort(); +}