From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id F075D3857C56 for ; Wed, 23 Sep 2020 21:29:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org F075D3857C56 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Tobias_Burnus@mentor.com IronPort-SDR: /aATcdC83xs9mWK9of5vCgDlNh4VXabO4l1CjSNYpJsd10bNQ1BuW6jxqGs+OtH7kt2yESf0fR DGmhZSLGF2Re8vD5abWzt3ytniZdd80YW55r9/z9l18tpJ9xzrUgXDi5/NciYsFJmGS26NsoSd j2YfiBw3/AiOXxoILeJzenieedLESSiKFB4jIVqZQLat3aY1QM0/YAlzkau4rDyIWd7lzQ9WcC TNQqhrhbb2J9jhcvujq5ACDGz7dMNCYbmGSt6Op7v5MhQSOsL2Lo5mQvWJp3vSwFXRGNeSOvfB eE0= X-IronPort-AV: E=Sophos;i="5.77,295,1596528000"; d="diff'?scan'208";a="53246945" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 23 Sep 2020 13:29:54 -0800 IronPort-SDR: Sac0Nk40zBJqLGh+yrVT+OUef/g+m/hpJfetaNexkNz6eHp1kgQ7Tgw2duZtu1aKfHy9HIjZd1 EdCgiuKWmeNf9viVNIgmEeb4QzUaEu3fFM7+WNhwXbnQT7zpAzZUZP7C3hW5Vnv8PDT7YiFFjm YqcH4ACiOhmL4MIRqjmsAgb/Xg2LFLVGdNqxiNLMU/Cz/P/G7hAf2ke/3vAG56M8O7PvLKdYfH yhBnJhGHPS1ULIrHtH7js70XxP8iLvu3VVwBns9YgxvOZjwiQM4hkMAjgZe9mH2ycq8dfj1G2r QIY= Subject: Re: [Patch] LTO: Force externally_visible for offload_vars/funcs (PR97179) From: Tobias Burnus To: Richard Biener CC: gcc-patches , Jakub Jelinek References: <4250958d-f7bf-1a0a-31d2-63eff191b258@codesourcery.com> <0e22d8c5-1008-cad4-c131-57ee3950a73a@codesourcery.com> <26b07ad0-ba42-b2c6-2325-cad7360f8e2c@codesourcery.com> Message-ID: Date: Wed, 23 Sep 2020 23:29:49 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <26b07ad0-ba42-b2c6-2325-cad7360f8e2c@codesourcery.com> Content-Type: multipart/mixed; boundary="------------56783EF9F8C64FA3431D126C" Content-Language: en-US X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-08.mgc.mentorg.com (139.181.222.8) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , X-List-Received-Date: Wed, 23 Sep 2020 21:29:57 -0000 --------------56783EF9F8C64FA3431D126C Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: quoted-printable Actually working patch attached. As mentioned, just using TREE_PUBLIC in input_offload_tables works for functions but for variables this gets overridden. The externally_visible is set to avoid running into the promote_symbol code (=E2=86=92 visibility hidden) later in the function. On 9/23/20 5:47 PM, Tobias Burnus wrote: > ... > On 9/23/20 4:23 PM, Tobias Burnus wrote: >> On 9/23/20 3:10 PM, Richard Biener wrote: >> >>> On Wed, 23 Sep 2020, Richard Biener wrote: >>>> LTRANS usually makes the symbols hidden, not local. >> Could also be =E2=80=93 whatever the 'nm' output means. >>>> So are you >>>> sure this isn't a target bug (hidden symbols not implemented >>>> but the host compiler obviously having checked that but assuming >>>> the target behaves the same as the host) or a linker bug? >> >> Unlikely, I assume the Linux x86-64 linker is rather well tested. >> As written this is the host =E2=80=93 just the offloading symbol table i= s >> device specific. >> >>> See lto/lto-partition.c:promote_symbol btw. >> >> Thanks for the pointer; it pointed me to node->externally_visible, ... Tobias ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstra=C3=9Fe 201, 80634 M=C3=BCnch= en / Germany Registergericht M=C3=BCnchen HRB 106955, Gesch=C3=A4ftsf=C3=BChrer: Thomas = Heurung, Alexander Walter --------------56783EF9F8C64FA3431D126C Content-Type: text/x-patch; charset="UTF-8"; name="lto-offload-v2.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="lto-offload-v2.diff" LTO: Force externally_visible+tree_public for offload_vars/funcs (PR97179) gcc/ChangeLog: PR lto/97179 * lto-cgraph.c (input_offload_tables): diff --git a/gcc/lto/lto-partition.c b/gcc/lto/lto-partition.c index 8e0488a..52f4811 100644 --- a/gcc/lto/lto-partition.c +++ b/gcc/lto/lto-partition.c @@ -35,6 +35,7 @@ along with GCC; see the file COPYING3. If not see #include "ipa-fnsummary.h" #include "lto-partition.h" #include "sreal.h" +#include "omp-offload.h" /* For offload_funcs and offload_vars. */ vec ltrans_partitions; @@ -1120,6 +1121,7 @@ void lto_promote_cross_file_statics (void) { unsigned i, n_sets; + tree decl; gcc_assert (flag_wpa); @@ -1135,6 +1137,20 @@ lto_promote_cross_file_statics (void) part->encoder = compute_ltrans_boundary (part->encoder); } + /* Ensure that all offload table referenced vars/funcs are available. */ + if (offload_funcs) + FOR_EACH_VEC_ELT (*offload_funcs, i, decl) + { + cgraph_node::get (decl)->externally_visible = 1; + TREE_PUBLIC (decl) = 1; + } + if (offload_vars) + FOR_EACH_VEC_ELT (*offload_vars, i, decl) + { + varpool_node::get (decl)->externally_visible = 1; + TREE_PUBLIC (decl) = 1; + } + lto_clone_numbers = new hash_map; /* Look at boundaries and promote symbols as needed. */ --------------56783EF9F8C64FA3431D126C--