From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 43387 invoked by alias); 8 Feb 2016 13:01:40 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 43365 invoked by uid 89); 8 Feb 2016 13:01:38 -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=Promoting, *node, Hx-languages-length:3857, sk:xxxxxxx 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 13:01:35 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51884) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1aSlRb-0001pe-O0 for gcc-patches@gnu.org; Mon, 08 Feb 2016 08:01:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSlRY-0001jX-7P for gcc-patches@gnu.org; Mon, 08 Feb 2016 08:01:31 -0500 Received: from relay1.mentorg.com ([192.94.38.131]:34025) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSlRY-0001jL-1P for gcc-patches@gnu.org; Mon, 08 Feb 2016 08:01:28 -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 1aSlRW-0004FD-20 from Tom_deVries@mentor.com ; Mon, 08 Feb 2016 05:01:26 -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 13:00:09 +0000 From: Tom de Vries To: Jakub Jelinek CC: "gcc-patches@gnu.org" , Ilya Verbin Subject: [PATCH, PR69607] Mark offload symbols as global in lto Message-ID: <56B89150.7000209@mentor.com> Date: Mon, 08 Feb 2016 13:01:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------030704070009020706010805" X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 X-SW-Source: 2016-02/txt/msg00547.txt.bz2 --------------030704070009020706010805 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 734 Hi, when running libgomp.c testsuite with "-flto -flto-partition=1to1 -fno-toplevel-reorder" we run into many compilation failures like this: ... /tmp/xxxxxxxx.ltrans0.ltrans.o:(.gnu.offload_funcs+0x1a0): undefined reference to `MAIN__._omp_fn.0'^M ... The problem is that the offload table is in one lto partition, and the function listed in the offload table is in another, without the function having been promoted to be visible in the other partition. The patch fixes this by promoting the symbols in the offload table such that they're visible in all partitions. Bootstrapped and reg-tested on x86_64. Build for nvidia accelerator and reg-tested libgomp with various lto settings. OK for trunk, stage1? Thanks, - Tom --------------030704070009020706010805 Content-Type: text/x-patch; name="0005-Mark-offload-symbols-as-global-in-lto.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="0005-Mark-offload-symbols-as-global-in-lto.patch" Content-length: 3256 Mark offload symbols as global in lto 2016-02-08 Tom de Vries PR lto/69607 * lto-partition.c (promote_offload_tables): New function. * lto-partition.h (promote_offload_tables): Declare. * lto.c (do_whole_program_analysis): call promote_offload_tables. * testsuite/libgomp.c/target-36.c: New test. --- gcc/lto/lto-partition.c | 28 ++++++++++++++++++++++++++++ gcc/lto/lto-partition.h | 1 + gcc/lto/lto.c | 2 ++ libgomp/testsuite/libgomp.c/target-36.c | 4 ++++ 4 files changed, 35 insertions(+) diff --git a/gcc/lto/lto-partition.c b/gcc/lto/lto-partition.c index 9eb63c2..56598d4 100644 --- a/gcc/lto/lto-partition.c +++ b/gcc/lto/lto-partition.c @@ -34,6 +34,7 @@ along with GCC; see the file COPYING3. If not see #include "ipa-prop.h" #include "ipa-inline.h" #include "lto-partition.h" +#include "omp-low.h" vec ltrans_partitions; @@ -1003,6 +1004,33 @@ promote_symbol (symtab_node *node) "Promoting as hidden: %s\n", node->name ()); } +/* Promote the symbols in the offload tables. */ + +void +promote_offload_tables (void) +{ + if (vec_safe_is_empty (offload_funcs) && vec_safe_is_empty (offload_vars)) + return; + + for (unsigned i = 0; i < vec_safe_length (offload_funcs); i++) + { + tree fn_decl = (*offload_funcs)[i]; + cgraph_node *node = cgraph_node::get (fn_decl); + if (node->externally_visible) + continue; + promote_symbol (node); + } + + for (unsigned i = 0; i < vec_safe_length (offload_vars); i++) + { + tree var_decl = (*offload_vars)[i]; + varpool_node *node = varpool_node::get (var_decl); + if (node->externally_visible) + continue; + promote_symbol (node); + } +} + /* Return true if NODE needs named section even if it won't land in the partition symbol table. FIXME: we should really not use named sections for inline clones and master diff --git a/gcc/lto/lto-partition.h b/gcc/lto/lto-partition.h index 31e3764..1a38126 100644 --- a/gcc/lto/lto-partition.h +++ b/gcc/lto/lto-partition.h @@ -36,6 +36,7 @@ extern vec ltrans_partitions; void lto_1_to_1_map (void); void lto_max_map (void); void lto_balanced_map (int); +extern void promote_offload_tables (void); void lto_promote_cross_file_statics (void); void free_ltrans_partitions (void); void lto_promote_statics_nonwpa (void); diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c index 6718fbbe..ecec1bc 100644 --- a/gcc/lto/lto.c +++ b/gcc/lto/lto.c @@ -3138,6 +3138,8 @@ do_whole_program_analysis (void) to globals with hidden visibility because they are accessed from multiple partitions. */ lto_promote_cross_file_statics (); + /* Promote all the offload symbols. */ + promote_offload_tables (); timevar_pop (TV_WHOPR_PARTITIONING); timevar_stop (TV_PHASE_OPT_GEN); diff --git a/libgomp/testsuite/libgomp.c/target-36.c b/libgomp/testsuite/libgomp.c/target-36.c new file mode 100644 index 0000000..bafb718 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/target-36.c @@ -0,0 +1,4 @@ +/* { dg-do run { target lto } } */ +/* { dg-additional-options "-flto -flto-partition=1to1 -fno-toplevel-reorder" } */ + +#include "target-1.c" --------------030704070009020706010805--