From patchwork Thu Jul 16 13:53:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1330299 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=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B6whw72BXz9sQt for ; Thu, 16 Jul 2020 23:54:07 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DCF97388E818; Thu, 16 Jul 2020 13:54:03 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 98F6C384240C for ; Thu, 16 Jul 2020 13:54:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 98F6C384240C 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: qC79Hio+2u7VIKt5ybCb7F4QjSvQ3tTxvkFXoJ/BsAJhNkTKqYdeT3M/Cn+gaWm8T0V22wVY6s v5VMr3S7a0qJDjOlVLh49VQyo0m/SxUa5/ZIF0D6hnLX/OIAiDeIjSgwulT/YW5BXs0gK4/xb7 jm0NBG6GHa/6qLmNpxzwPF4xufhxt9iMLG6TNjjXKcNWJRFikdM4muzW3L2c56Fs/QuZgvRoyC Qpl41+qUoV6RUvq0rMlL3aeX9ejGAWdFpdjHObBClaR63eEdxNuFtKH+ROGTkaZEw4w+YJ/BUf Dqg= X-IronPort-AV: E=Sophos;i="5.75,359,1589270400"; d="diff'?scan'208";a="50974415" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 16 Jul 2020 05:54:00 -0800 IronPort-SDR: Mdw5Mu/KWxLlr5sCJTk/1ZIoI5TJwee8Ois8fd6Kyq9aNyNgGdrRl+j9VoaI3Qn8LwpBskkSxw 6YuDLglpqEyCfjD6iikpBidpn44bds62y9WOMcnZ5yrNTW/s+zaWujO33EBvB1wvX5ykqXsJ3p wbJfDlToKlce4lq2tSCiv+xVqQe1pdqORDkzchxsWVBL56Ng30ZAcQcUq8vFOPYI/11ABhRXKl AEGS8Kih4kfmiKBjQjRJWX+Yg0Rw0KrQEemRicfE1kTSyIeXSZzg+GfhwHCtJjKd2jQ58WS0ZC y/U= From: Tobias Burnus Subject: [Patch][OG10] omp-low.c: Avoid offload-target lto1 is-missing error by not-privatizing TREE_READONLY vars To: gcc-patches Message-ID: <4e717a91-6752-1e5e-6af4-89ee01693977@codesourcery.com> Date: Thu, 16 Jul 2020 15:53:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 Content-Language: en-US X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, 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: , Cc: Jakub Jelinek , Thomas Schwinge Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" [This is an OpenACC issue but I would not completely surprised if something similar could occur for OpenMP offloading as well. However, the patch is for an OpenACC-specific function.] This issue occurs for libgomp.oacc-fortran/privatized-ref-2.f90, for which on the device lto1 complains: lto1: fatal error: /tmp/ccEGJTZN.o: section A.13.1.21 is missing Here, "A.13" is a TREE_STATIC, TREE_READONLY array generated by the Fortran front-end and containing the array-constructor values, i.e. RHS of: array = [(-2*i, i = 1, size(array))] That testcase works on the trunk or on the OG10 (= devel/omp/gcc-10) branch if one reverts the patch "Re-do OpenACC private variable resolution" https://gcc.gnu.org/g:2f4b477223fddb84f66e494eb88d1defbd5e04a2 which is scheduled but not yet submitted for mainline inclusion. The offloading variable table contains the variable as "A.13.10" (which works fine) and the problem-causing patch causes that the code .UNIQUE (OACC_PRIVATE, 0, 0, &parm.9, &A.13); gets inserted (via the then-added make_oacc_private_marker in omp-low.c). Here, the decl for 'A.13' does not have a varpool_node entry – and it is not streamed out as separate entity. (This IFN_ is then later processed by the target lto1 via omp-offload.c's execute_oacc_device_lower – where the asm_name "A.13.1" appears.) [While I do not completely understand why the target LTO does not contain the symbol, I think the following still makes sense. (I do understand why the offload var table does not contain it.)] If the variable is TREE_READONLY, there is no need to pass it through the variable-privatization bits. The current check is for VAR_P and TREE_ADDRESSABLE. For the fix, one could use: !TREE_READONLY or !(TREE_READONLY && TREE_STATIC) or !(TREE_READONLY && (TREE_STATIC || DECL_EXTERNAL) I am not sure what makes more sense. I initially used the first version and then moved to the last. Thoughts? Additional comments? Does it look OK for OG10? Tobias ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter omp-low.c: Avoid offload-target lto1 is-missing error by not-privatizing TREE_READONLY vars gcc/ChangeLog: * omp-low.c (oacc_record_private_var_clauses, oacc_record_vars_in_bind): Do not privatize read-only static/exernal variables. diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 09603635350..bd3866c4d2e 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -9813,7 +9813,9 @@ oacc_record_private_var_clauses (omp_context *ctx, tree clauses) if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE) { tree decl = OMP_CLAUSE_DECL (c); - if (VAR_P (decl) && TREE_ADDRESSABLE (decl)) + if (VAR_P (decl) && TREE_ADDRESSABLE (decl) + && !(TREE_READONLY (decl) + && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)))) ctx->oacc_addressable_var_decls->safe_push (decl); } } @@ -9828,7 +9830,8 @@ oacc_record_vars_in_bind (omp_context *ctx, tree bindvars) return; for (tree v = bindvars; v; v = DECL_CHAIN (v)) - if (VAR_P (v) && TREE_ADDRESSABLE (v)) + if (VAR_P (v) && TREE_ADDRESSABLE (v) + && !(TREE_READONLY (v) && (TREE_STATIC (v) || DECL_EXTERNAL (v)))) ctx->oacc_addressable_var_decls->safe_push (v); }