From patchwork Mon Feb 8 10:20:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 580216 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 B699B140B0F for ; Mon, 8 Feb 2016 21:21:25 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=LubV2Y1S; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:cc:message-id:date:mime-version:content-type; q= dns; s=default; b=glSCAYeu7qGkH71I9xi6Q9VEZkFzXzP6O7GLCPSeFv5L+U LPZOG6O+lJNgjU8Xv9bboo3Z1wcKXKQITEoIcLsHbrNP3OU9uYUGOq5vwTvKHk4A FT7zstkLDrPz9b1eSo5b3MvnJYZd+6rRig9quFcym6FYcbW7fXSNqyQ/XA0fo= 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:to :from:subject:cc:message-id:date:mime-version:content-type; s= default; bh=gUkL1tKB03slcZruX0BazJwa3x8=; b=LubV2Y1SeYavyA6B1AZ4 XMZSl7hXuT4iwFx6H8RxiPdPfQHt6TUzbJjuv2QHHdp4A1dJFCdQ/stPSkPnmzyM ePXT7ajJJtkRRSgcx0LSVOjJbs79rlUI+r0HwgxXA7csjqt7rFalwhSyLFG7cjB1 ObR/ITv6gvdvXRoZkdttQqw= Received: (qmail 19752 invoked by alias); 8 Feb 2016 10:21:17 -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 19741 invoked by uid 89); 8 Feb 2016 10:21:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=1850, 744, Hx-languages-length:2888, HX-detected-operating-system:Windows X-HELO: fencepost.gnu.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (208.118.235.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 08 Feb 2016 10:21:15 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46440) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1aSiwS-00025t-Uo for gcc-patches@gnu.org; Mon, 08 Feb 2016 05:21:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSiwO-0004Zq-K8 for gcc-patches@gnu.org; Mon, 08 Feb 2016 05:21:12 -0500 Received: from relay1.mentorg.com ([192.94.38.131]:46478) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSiwO-0004Zg-Dk for gcc-patches@gnu.org; Mon, 08 Feb 2016 05:21:08 -0500 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-02.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1aSiwL-0001LL-Pb from Tom_deVries@mentor.com ; Mon, 08 Feb 2016 02:21:06 -0800 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-02.mgc.mentorg.com (137.202.0.106) with Microsoft SMTP Server id 14.3.224.2; Mon, 8 Feb 2016 10:21:04 +0000 To: Jakub Jelinek From: Tom de Vries Subject: [PATCH, PR59627, c++] Handle DECL_OMP_DECLARE_REDUCTION in discriminator_for_local_entity CC: "gcc-patches@gnu.org" Message-ID: <56B86C09.5030903@mentor.com> Date: Mon, 8 Feb 2016 11:20:57 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 Hi, When running libgomp testsuite with -flto, we run into an ICE in the udr-*.C tests. A minimal testcase is in listed in PR59627: ... struct A { int i; }; void foo() { A a; #pragma omp declare reduction (+: A: omp_out.i += omp_in.i) #pragma omp parallel reduction (+: a) ; } ... The ICE with backtrace looks as follows: ... src/libgomp/testsuite/libgomp.c++/udr-1.C:56:13: internal compiler error: in discriminator_for_local_entity, at cp/mangle.c:1762 0x9ad52a discriminator_for_local_entity src/gcc/cp/mangle.c:1762 0x9ad8a5 write_local_name src/gcc/cp/mangle.c:1850 0x9a7975 write_name src/gcc/cp/mangle.c:882 0x9a71c0 write_encoding src/gcc/cp/mangle.c:744 0x9a6c61 write_mangled_name src/gcc/cp/mangle.c:709 0x9b6d09 mangle_decl_string src/gcc/cp/mangle.c:3509 0x9b6d4f get_mangled_id src/gcc/cp/mangle.c:3531 0x9b71d7 mangle_decl(tree_node*) src/gcc/cp/mangle.c:3598 0x14da287 decl_assembler_name(tree_node*) src/gcc/tree.c:670 0x14edf74 assign_assembler_name_if_neeeded(tree_node*) src/gcc/tree.c:5917 0x14ee0cc free_lang_data_in_cgraph src/gcc/tree.c:5972 0x14ee280 free_lang_data src/gcc/tree.c:6014 0x14ee320 execute src/gcc/tree.c:6063 Please submit a full bug report ... The problem seems to be that we're trying to get a discriminator (the lexical ordinal of a var among entities with the same name in the same function) for a DECL_OMP_DECLARE_REDUCTION_P function, which is not handled in discriminator_for_local_entity. For the test-case above the declared reduction is shown as: ... void omp declare reduction operator+~1A (struct A &); ... AFAIU, those DECL_OMP_DECLARE_REDUCTION_P decls are unique in a function, so I'd say we can simply return '0'. Bootstrapped and reg-tested on x86_64. OK for trunk, stage1? Thanks, - Tom Handle DECL_OMP_DECLARE_REDUCTION in discriminator_for_local_entity 2016-02-08 Tom de Vries PR c++/59627 * mangle.c (discriminator_for_local_entity): Handle DECL_OMP_DECLARE_REDUCTION_P function. * testsuite/libgomp.c++/udr-20.C: New test. --- gcc/cp/mangle.c | 3 +++ libgomp/testsuite/libgomp.c++/udr-20.C | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 410c7f4..e83fc0c 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -1758,6 +1758,9 @@ discriminator_for_local_entity (tree entity) return local_class_index (entity); } + else if (TREE_CODE (entity) == FUNCTION_DECL + && DECL_OMP_DECLARE_REDUCTION_P (entity)) + return 0; else gcc_unreachable (); } diff --git a/libgomp/testsuite/libgomp.c++/udr-20.C b/libgomp/testsuite/libgomp.c++/udr-20.C new file mode 100644 index 0000000..2aaf618 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/udr-20.C @@ -0,0 +1,4 @@ +// { dg-do run { target lto } } +// { dg-additional-options "-flto" } + +#include "udr-1.C"