From patchwork Fri Jul 22 10:38:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1659478 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 4Lq5X02wCXz9sGP for ; Fri, 22 Jul 2022 20:38:56 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F1C0938356AA for ; Fri, 22 Jul 2022 10:38:53 +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 7F4923857C5D for ; Fri, 22 Jul 2022 10:38:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7F4923857C5D 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.93,185,1654588800"; d="diff'?scan'208";a="80045948" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 22 Jul 2022 02:38:38 -0800 IronPort-SDR: 81/y0p1ej0ngebGronQ6C9Bk6aPaht1tZk5/DxpH8D5feNMADhYTuBSMBhGxAWhxlp/PpiATKX w60YUuTLInRhwmQIVXQ3Jf2xHGijJBWK+OsUiO5rHBILUyZ5s3hEL0fH5fpexUYWjSQiEQlhFm TY+0DWzhZkjClB1rh4WZHB7AsGlc12zMh7n4VNAdhuVzat6NioqimYTmPPp7yV+2O9368vXkcc acTAV0uLQRjNohFBIk0lQNH12Upr/sujTJlveyzqljlXThacXueWXliIzziTHcRoS/O+tgX4Lt hcA= Message-ID: Date: Fri, 22 Jul 2022 12:38:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Content-Language: en-US To: gcc-patches , Jakub Jelinek From: Tobias Burnus Subject: [Patch] OpenMP requires: Fix diagnostic filename corner case 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 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: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This patch addresses a corner case which causes a filename confusion: lto1: error: OpenMP 'requires' directive with 'unified_address' specified only in some compilation units lto1: note: '1.c' has 'unified_address' lto1: note: but '1.c' has not lto1: fatal error: errors during merging of translation units This happens, e.g., for a source code like the following, where two files are identical except that only one has an additional '#pragma omp requires': ---------------- int main () { int i; #pragma omp target map(from:i) i = 1; return i; } ---------------- Both have 'main._omp_fn.0' - which gets merged to the same decl such that the source file will be identical. Without the fatal error shown for requires, it would fail later during liking due to having the same symbol ('main') multiple times - but that additional diagnostic is not reached, leaving one puzzled. I did run into this with 'gcc -fopenmp test_*.c' missing that I had a second file in that dir which also started with test_... OK for mainline? Or do you think adding a testcase makes sense? Tobias PS: It might also be possible to generate this with class instantiations for valid code - other than the requires mismatch. PPS: If compiles as 'gcc -fopenmp .c' / in the testsuite, the new inform will be: lto1: note: '/tmp/ccAs0w67.o' has 'unified_address' lto1: note: but '/tmp/ccv6XCfc.o' has not That avoids the issue with showing the sane name but is not perfect, either. But that's a known issue and splittitng compiling from linking will improve the diagnostic! ----------------- 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 OpenMP requires: Fix diagnostic filename corner case The issue occurs when there is, e.g., main._omp_fn.0 in two files with different OpenMP requires clauses. The function entries in the offload table ends up having the same decl tree and, hence, the diagnostic showed the same filename for both. Solution: Use the .o filename in this case. Note that the issue does not occur with same-named 'static' functions and without the fatal error from the requires diagnostic, there would be later a linker error due to having two 'main'. gcc/ * lto-cgraph.cc (input_offload_tables): Improve requires diagnostic when filenames come out identically. diff --git a/gcc/lto-cgraph.cc b/gcc/lto-cgraph.cc index 062677a32eb..350195d86db 100644 --- a/gcc/lto-cgraph.cc +++ b/gcc/lto-cgraph.cc @@ -1893,6 +1893,11 @@ input_offload_tables (bool do_force_output) if (tmp_decl != NULL_TREE) fn2 = IDENTIFIER_POINTER (DECL_NAME (tmp_decl)); } + if (fn1 == fn2) + { + fn1 = requires_fn; + fn2 = file_data->file_name; + } char buf1[sizeof ("unified_address, unified_shared_memory, " "reverse_offload")];