| Message ID | 20250210180725.2076678-1-sloosemore@baylibre.com |
|---|---|
| Headers |
Return-Path: <gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A12B4385AC0F for <patchwork@sourceware.org>; Mon, 10 Feb 2025 18:10:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A12B4385AC0F Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=IlU+pECD X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by sourceware.org (Postfix) with ESMTPS id BED273857830 for <gcc-patches@gcc.gnu.org>; Mon, 10 Feb 2025 18:07:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BED273857830 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=baylibre.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BED273857830 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::129 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1739210858; cv=none; b=qC5AfF9wtsojfq4MT6ajhC17pRXizRfv2aH9vLb10Aaw4iTK88w9dmdHUy2eJUCNof9TqF/Z+hxJRmsH34NNKhX0yLHaDZC/tTRnGW0Uinr8RmYrPStzaHFFra0bY9s4+7NGudDMOT1RfHw9bhBhaluTo1R8Rd1/HGwFWuPeb5A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1739210858; c=relaxed/simple; bh=QXR4Gb9kZrAdoMzDc/2pS98dc70y2zMt0hNfWmn+mxM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=V+37LyxK/DJ+Z3uhahdhN2Z4Bj0IXmoPyatAPTTHcfjNc9GGKYaEeDfVnX8vJfzSzQhvtyPJ/VK86C7nqjcQE+L+iuSJLYBIuR9le6hwQlOSE+lXLj1jAZgNVQWJ4eJGnc9MZ7f9lsycQrlRDRwJDp7bs7LCYBTUxEYoTKz0lEc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BED273857830 Received: by mail-il1-x129.google.com with SMTP id e9e14a558f8ab-3cfeff44d94so13652785ab.0 for <gcc-patches@gcc.gnu.org>; Mon, 10 Feb 2025 10:07:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1739210856; x=1739815656; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=AzTUC7zG6lZ2mO56bFILvstWquGv28W6gCHDYbtRKAU=; b=IlU+pECDgMlLlujTdibUn1En/D/dhfhQ8WtUfL/HAExyjWfLLXcevUHOUbhYdk3VJZ 9hFWbaRJjJSd3xNQO9WcNOK/5MbDkAA0oxiTZuvAmcbHfS4wv0KOlbeqooD3zwqlACEG E3ke4BfgdtMvQxudzFZ+yUifXRmmZBTFbl26d7ul3NwyNQxJdYGqrKyQj+6z18qD0Se0 LQuLv4Juzm7+Uj+fVdnlHkVD6aFIkpg6RmaMQsgl3RV8e2JicSd6TxjCKpsoV7BTcSxm pee3dLGl+jj/RcMRmdQ1bh2o4adQvyV0SeW6keXxAJuxYH535rmi8gCKCw5ImPXJ17be qmHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739210856; x=1739815656; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AzTUC7zG6lZ2mO56bFILvstWquGv28W6gCHDYbtRKAU=; b=kLCL/EMtYNcsEUZXXijiD+heRjJFeXPyNWDH92Yxh7LKpioNQQPPsrHrkLwEtkJpyT 6q8OlS594phQwaWSOvZWb403HlSyJOiISWzwTLJmP0zCum8UhftmPTvM5anjV9ob9R80 lfAfTq37G0t2JP/AEiRzxvsksZMrN5h77Vtfw10vc1xeO79I3UnlhN37+qsiJuszF3oN M0KiiM8L6wRJbpsh+od4oHb3aYd5ISFQLIsPo0swB/v7kCUGEW6eokDRVI/TUDe+LoN7 J18h/zVxalOuQSt08ren+GdxeF4qW3ygru6niOQlNS78JKTzJsj1bIVjafVJfaQld3gi AnIw== X-Gm-Message-State: AOJu0Yzgld7VA2YPJ/EKLQw3EqT3wtyWpV+kbEA5yko+hU8SyrLjpgR7 x6x3pe9VcZWvW3zMvQNTdTyffy9xZZX/zqNS00pksOMtO0bvqrK7aHpHKCxM1Ye+icBkvPWf2AL + X-Gm-Gg: ASbGncvPaKH78LOjcvQsmVd42FwZJLF6FTmLn2IwhMBUNVW0Vxdu6UbD2OwFr9lS6UO RyRl3kJgHlntNlF0Huoz71faTwX54PQlr7tYMlSTTvsWoHZi65TUOad51xwr7CycMbcJLivOLDH rx0XLVWtAktB2ZjxMEymEtLmbLe8E2r5A+V1nPQZ2CHfPA2ej4XH9uN+922Yz2/ry3tfMr8wrCJ RbNljjAL9uUKXG7V0PzJ26gjLUzk5wf6KRkl1JDDhXlGJCEEpBt4usDpULCP7AhjstIYbRTT6Ix 6nWhREDXMnIYP6EnlMBYrhFqlu0= X-Google-Smtp-Source: AGHT+IE3s2wHmwArgr6GvmwwpmbE6OVKCVc5UDUVhadtc5kIAUIjarkowo35fyOc/xwCdterHAKMZQ== X-Received: by 2002:a92:cda2:0:b0:3d0:2a04:1ce2 with SMTP id e9e14a558f8ab-3d13deeabfemr94837205ab.16.1739210855825; Mon, 10 Feb 2025 10:07:35 -0800 (PST) Received: from pondscum.hsd1.co.comcast.net ([2601:281:d901:97c0::af71]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3d13d83c967sm19615365ab.45.2025.02.10.10.07.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2025 10:07:34 -0800 (PST) From: Sandra Loosemore <sloosemore@baylibre.com> To: gcc-patches@gcc.gnu.org Cc: jakub@redhat.com, tburnus@baylibre.com Subject: [PATCH 0/7] [stage1 + og14] OpenMP: Implement "begin declare variant" Date: Mon, 10 Feb 2025 11:07:18 -0700 Message-Id: <20250210180725.2076678-1-sloosemore@baylibre.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org |
| Series |
OpenMP: Implement "begin declare variant"
|
|
Message
Sandra Loosemore
Feb. 10, 2025, 6:07 p.m. UTC
This patch set is almost certainly too late to make it in GCC 15, except
possibly the first two pieces (a bug fix and an internal interface
cleanup). These patches are against current mainline head, but I am
planning to shortly commit a near-identical version to the OG14
development branch and I hope it will be possible to get (perhaps a
revised version of) this into mainline early in stage 1.
This set of patches implements the delimited form of the OpenMP
declare variant construct. Julian Brown previously posted some
initial work on this last year
https://gcc.gnu.org/pipermail/gcc-patches/2024-January/642738.html
but I have taken a different approach in the current implementation.
I thought it was a clear design mistake to mix up the implicitly-named
variant functions with C++ overloading, since that wasn't going to work
for C. Even in C++, resolution of "declare variant" is independent of
overloading; it happens much later in compilation, during gimplification
or later in the compilation process, not in the front end. Instead, I've
simply assigned the variant functions unique internal names. I also
discarded Julian's complicated name-mangling code because it wasn't clear
how to uniquely encode arbitrary expressions in dynamic selectors, or why
it was even necessary to have a reproducible mangling across compilation
units when there is no way to directly reference the variant functions by
name even within a single compilation unit.
The C++ implementation uses the existing omp_declare_variant_finalize_one
function "backwards" to map the variant decl onto the corresponding base
decl, instead of the opposite base->variant for regular "declare variant".
In C, this is just a simple name lookup. For both languages, the variant
info is stored in an attribute on the base function decl in the same way
as regular "declare variant" and from there everything proceeds using the
same existing mechanisms.
Some aspects of the interaction between "begin declare variant" and C++
language features are not particularly clear in the OpenMP specification,
but I tried to implement and test features that users would likely expect
to work. Variant functions for class methods do work with the caveat that
you have to define them inside the class with an unqualified name;
similarly with namespaces. Variants for template functions and methods
inside a template class work in simple test cases, but there's a known bug
where it emits a "sorry" when it cannot resolve the base function for a
template variant without instantiating the variant. (It seems to me that
is a chicken-and-egg problem since you don't know how to instantiate the
variant to match the base function until you actually have a base
function.) Additionally, the reverse lookup in
omp_declare_variant_finalize_one is affected by the same existing bugs it
has for regular "declare variant" (e.g. PR118530 and PR118791) causing some
bogus errors that are xfailed in the corresponding test cases.
-Sandra
Sandra Loosemore (7):
OpenMP: Bug fixes for comparing context selectors
OpenMP: Pass a 3-way flag to omp_check_context_selector instead of a
bool.
OpenMP: Support functions for nested "begin declare variant"
OpenMP: Add flag for code elision to omp_context_selector_matches.
OpenMP: C++ front end support for "begin declare variant"
OpenMP: C front end support for "begin declare variant"
OpenMP: C/C++ common testcases for "omp begin declare variant"
gcc/c/c-decl.cc | 3 +
gcc/c/c-lang.h | 8 +
gcc/c/c-parser.cc | 353 +++++++++--
gcc/cp/cp-tree.h | 6 +
gcc/cp/decl.cc | 15 +
gcc/cp/parser.cc | 550 ++++++++++++++++--
gcc/cp/parser.h | 5 +
gcc/cp/semantics.cc | 7 +
gcc/fortran/trans-openmp.cc | 5 +-
gcc/omp-general.cc | 266 ++++++++-
gcc/omp-general.h | 13 +-
.../gomp/delim-declare-variant-1.c | 55 ++
.../gomp/delim-declare-variant-2.c | 66 +++
.../gomp/delim-declare-variant-3.c | 50 ++
.../gomp/delim-declare-variant-4.c | 31 +
.../gomp/delim-declare-variant-5.c | 26 +
.../gomp/delim-declare-variant-6.c | 71 +++
.../gomp/delim-declare-variant-7.c | 27 +
.../g++.dg/gomp/delim-declare-variant-1.C | 39 ++
.../g++.dg/gomp/delim-declare-variant-2.C | 53 ++
.../g++.dg/gomp/delim-declare-variant-3.C | 37 ++
.../g++.dg/gomp/delim-declare-variant-4.C | 57 ++
.../g++.dg/gomp/delim-declare-variant-40.C | 51 ++
.../g++.dg/gomp/delim-declare-variant-41.C | 31 +
.../g++.dg/gomp/delim-declare-variant-5.C | 53 ++
.../g++.dg/gomp/delim-declare-variant-50.C | 99 ++++
.../g++.dg/gomp/delim-declare-variant-51.C | 181 ++++++
.../g++.dg/gomp/delim-declare-variant-52.C | 24 +
.../g++.dg/gomp/delim-declare-variant-6.C | 72 +++
.../g++.dg/gomp/delim-declare-variant-7.C | 57 ++
.../g++.dg/gomp/delim-declare-variant-70.C | 206 +++++++
.../g++.dg/gomp/delim-declare-variant-71.C | 157 +++++
.../libgomp.c++/delim-declare-variant-1.C | 29 +
.../libgomp.c++/delim-declare-variant-2.C | 37 ++
.../libgomp.c++/delim-declare-variant-7.C | 39 ++
.../delim-declare-variant-1.c | 45 ++
36 files changed, 2735 insertions(+), 89 deletions(-)
create mode 100644 gcc/testsuite/c-c++-common/gomp/delim-declare-variant-1.c
create mode 100644 gcc/testsuite/c-c++-common/gomp/delim-declare-variant-2.c
create mode 100644 gcc/testsuite/c-c++-common/gomp/delim-declare-variant-3.c
create mode 100644 gcc/testsuite/c-c++-common/gomp/delim-declare-variant-4.c
create mode 100644 gcc/testsuite/c-c++-common/gomp/delim-declare-variant-5.c
create mode 100644 gcc/testsuite/c-c++-common/gomp/delim-declare-variant-6.c
create mode 100644 gcc/testsuite/c-c++-common/gomp/delim-declare-variant-7.c
create mode 100644 gcc/testsuite/g++.dg/gomp/delim-declare-variant-1.C
create mode 100644 gcc/testsuite/g++.dg/gomp/delim-declare-variant-2.C
create mode 100644 gcc/testsuite/g++.dg/gomp/delim-declare-variant-3.C
create mode 100644 gcc/testsuite/g++.dg/gomp/delim-declare-variant-4.C
create mode 100644 gcc/testsuite/g++.dg/gomp/delim-declare-variant-40.C
create mode 100644 gcc/testsuite/g++.dg/gomp/delim-declare-variant-41.C
create mode 100644 gcc/testsuite/g++.dg/gomp/delim-declare-variant-5.C
create mode 100644 gcc/testsuite/g++.dg/gomp/delim-declare-variant-50.C
create mode 100644 gcc/testsuite/g++.dg/gomp/delim-declare-variant-51.C
create mode 100644 gcc/testsuite/g++.dg/gomp/delim-declare-variant-52.C
create mode 100644 gcc/testsuite/g++.dg/gomp/delim-declare-variant-6.C
create mode 100644 gcc/testsuite/g++.dg/gomp/delim-declare-variant-7.C
create mode 100644 gcc/testsuite/g++.dg/gomp/delim-declare-variant-70.C
create mode 100644 gcc/testsuite/g++.dg/gomp/delim-declare-variant-71.C
create mode 100644 libgomp/testsuite/libgomp.c++/delim-declare-variant-1.C
create mode 100644 libgomp/testsuite/libgomp.c++/delim-declare-variant-2.C
create mode 100644 libgomp/testsuite/libgomp.c++/delim-declare-variant-7.C
create mode 100644 libgomp/testsuite/libgomp.c-c++-common/delim-declare-variant-1.c