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: 126 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f503:0:0:0:0:0 with SMTP id q3csp172104wro; Fri, 22 Jul 2022 03:39:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v/f8c7mclRgZUWr9pdHVjB2wXc5FFWTY2URXa9V3J2pBjHew7REpMGCUXWLkaNXBOiy+mU X-Received: by 2002:a05:6402:194f:b0:43a:298f:f39c with SMTP id f15-20020a056402194f00b0043a298ff39cmr2960566edz.106.1658486349985; Fri, 22 Jul 2022 03:39:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658486349; cv=none; d=google.com; s=arc-20160816; b=SvRDps1hJe80r9UIhpNA/W5UFDH6ot+q9YBQE4gN04QSvRwTgSMs4AhxoAKRyJZdc/ kCGqBk0XWpop2YLsxYzXMQYS+9+xlE/Qm5p5NghksOKBSvR78wjYOsWLSyXwQ+2CESgm NLWJGY6A05jU9BjVPBHzT5bs/SjKiuAW06r/hW8MUAO6FIV+2/jTvy7X22yUKLOsCUtt vAN7opApvPKeU4BgzXHACVeMsfPx+we51rU9G/FmiUWHYkXExS/l4eScqQbv83H+wxtu n6CA0Z+Jvw9AxKZH2EU/BgU3GqKr54kNJrK6gIOuVu/rT+oxZcpnfS4xcQrhIfvX+9xJ sszA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:from:to :content-language:user-agent:mime-version:date:message-id :ironport-sdr:dmarc-filter:delivered-to; bh=B8YIvG2UGemV9YLzK41jGTBOO8B2edBheC58MXnxG7A=; b=r2B13J3vNiYKNyQdEuhQ9XrYVDrcL5W7Gm9aw0AUQoXMi0WJitEEQvgvfvCnTYWOoy x8Eh00L7HXE8Rr/hgObURxd58jsKiLqWT/aLMvwadYlvMn2OdyJojFZzOWCV66LM6agX Lw6Wz1VEQe5nD/JpSo+itg8O1PeTH4Sb6Coqi8yXTnygMtDtwLwaN0yR7Gzn8DKTLqIc HKVdhnm2O0KtTrQNj3k6GGJfPFzHMsD8azvR5bBsSX77X6oy/XqELjJoxOvKDDjWxZzb VUXlOaWzMGxl3/a8GADWH9twGBBz0xM12bIKZpzowlKBCr/g3A8BGyUyvtfXa0XPhSer 7LWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id dp19-20020a170906c15300b00726efdeaf13si6181529ejc.164.2022.07.22.03.39.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 03:39:09 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D9B9D3835420 for ; Fri, 22 Jul 2022 10:39:05 +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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1739048982756511690?= X-GMAIL-MSGID: =?utf-8?q?1739048982756511690?= 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")];