From patchwork Tue May 17 19:03:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1632519 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=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L2lsj102jz9s2R for ; Wed, 18 May 2022 05:04:24 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 45F4F3857342 for ; Tue, 17 May 2022 19:04:20 +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 5A4783858D3C for ; Tue, 17 May 2022 19:04:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5A4783858D3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.91,233,1647331200"; d="diff'?scan'208";a="75864017" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 17 May 2022 11:04:02 -0800 IronPort-SDR: 9XJ+RTGoPRKSdKKhTf+EtjFRsR5HKRoRM31+ytBfTEQtX2c4ah58HiWXaJtjFio7JX0tdIu454 iXWz2GP8bcJMRWE4W5C23k5jfk1gjYy4g8A5Qw4KCsi29ij6+p4FEe8SXkqAMMBYE0z79Ch9/E 0iiOfa7G6iKwmBrgABv1R6sBXKIAw5/SrYo8VGGSYzkLm/cVvFHbaxlkUsi5U0fshO+zgOIYid f0PF3Jt/0OCLW8WApzHKea2D7W9LPr2I61Ef82yHuEi3NKmEiwIW4LTFVOqD7jDkiEeZfLYHh5 ph8= Message-ID: Date: Tue, 17 May 2022 21:03:55 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: [committed] Revert 'Use more ARRAY_SIZE.' for mkoffload (was: [PATCH] Use more ARRAY_SIZE.) Content-Language: en-US To: =?utf-8?q?Martin_Li=C5=A1ka?= , Richard Biener References: <1651754853.85hnr42bjs.astroid@pulse.none> <934763f4-4d77-dd93-5d6e-1107380c5b06@suse.cz> <44ed5715-8af0-88a9-8f82-d868df9e33d7@suse.cz> <4110979b-0da8-05e8-ad9f-4e73ef56e933@suse.cz> From: Tobias Burnus In-Reply-To: <4110979b-0da8-05e8-ad9f-4e73ef56e933@suse.cz> X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Tobias Burnus , GCC Patches Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi Martin, On 16.05.22 10:39, Martin Liška wrote: > All right, CCing the following maintainers for other parts: >> - David for JIT and Analyzer >> - Tobias for Fortran part >> - Jason for C-family part Sorry for having missed that review request – and thanks to Mikael for doing the review! And thanks for the patch in general. > There are not further comments from the remaining C-family part so I'm going > to install the patch. This patch broke offloading – fixed by reverting the patch for {gcn,nvptx}/mkoffload.cc – and committed as obvious. Changing a C-code generating string without telling the then called C compiler about the macro won't fly. See attachment for r13-569-gc9852156dd2fedec130f6d8eb669579ef6237946, which reverts it for mkoffload.cc, only. Tobias ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 commit c9852156dd2fedec130f6d8eb669579ef6237946 Author: Tobias Burnus Date: Tue May 17 20:46:29 2022 +0200 Revert 'Use more ARRAY_SIZE.' for mkoffload Revert commit r13-472-gca32b29ec3e92dcf8dda5c2501d0baf9dd1cb09d partially; namely for {gcn,nvptx}/mkoffload.cc, only. The patch changed 'sizeof(...)/sizeof(...[0])' to the 'ARRAY_SIZE' macro, which is in principle a good idea – except that in the two mkoffload.cc, the change happened inside a string that is used to generate plain C code. With offlading to nvptx or gcn, the mkoffload genenates then the C file and compilation of the latter fails with "warning: implicit declaration of function 'ARRAY_SIZE'" followed by "error: initializer element is not constant" gcc/ * config/gcn/mkoffload.cc (process_obj): Revert: Use ARRAY_SIZE. * config/nvptx/mkoffload.cc (process): Likewise. --- gcc/config/gcn/mkoffload.cc | 2 +- gcc/config/nvptx/mkoffload.cc | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gcc/config/gcn/mkoffload.cc b/gcc/config/gcn/mkoffload.cc index 9db2124b129..94ba7ffa5af 100644 --- a/gcc/config/gcn/mkoffload.cc +++ b/gcc/config/gcn/mkoffload.cc @@ -723,7 +723,7 @@ process_obj (FILE *in, FILE *cfile) " unsigned global_variable_count;\n" "} target_data = {\n" " &gcn_image,\n" - " ARRAY_SIZE (gcn_kernels),\n" + " sizeof (gcn_kernels) / sizeof (gcn_kernels[0]),\n" " gcn_kernels,\n" " gcn_num_vars\n" "};\n\n"); diff --git a/gcc/config/nvptx/mkoffload.cc b/gcc/config/nvptx/mkoffload.cc index fa3b4b76821..b28c1a32292 100644 --- a/gcc/config/nvptx/mkoffload.cc +++ b/gcc/config/nvptx/mkoffload.cc @@ -316,11 +316,11 @@ process (FILE *in, FILE *out) " const struct nvptx_fn *fn_names;\n" " unsigned fn_num;\n" "} target_data = {\n" - " ptx_objs, ARRAY_SIZE (ptx_objs),\n" + " ptx_objs, sizeof (ptx_objs) / sizeof (ptx_objs[0]),\n" " var_mappings," - " ARRAY_SIZE (var_mappings),\n" + " sizeof (var_mappings) / sizeof (var_mappings[0]),\n" " func_mappings," - " ARRAY_SIZE (func_mappings)\n" + " sizeof (func_mappings) / sizeof (func_mappings[0])\n" "};\n\n"); fprintf (out, "#ifdef __cplusplus\n"