From eba69b59d1a30dead07da2c279c8ecfd2b62ba9f Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Fri, 23 Apr 2021 08:22:35 -0700 Subject: Reimplement __builtin_unique_stable_name- The original version of this was reverted, and @rjmcall provided some advice to architect a new solution. This is that solution. This implements a builtin to provide a unique name that is stable across compilations of this TU for the purposes of implementing the library component of the unnamed kernel feature of SYCL. It does this by running the Itanium mangler with a few modifications. Because it is somewhat common to wrap non-kernel-related lambdas in macros that aren't present on the device (such as for logging), this uniquely generates an ID for all lambdas involved in the naming of a kernel. It uses the lambda-mangling number to do this, except replaces this with its own number (starting at 10000 for readabililty reasons) for lambdas used to name a kernel. Additionally, this implements itself as constexpr with a slight catch: if a name would be invalidated by the use of this lambda in a later kernel invocation, it is diagnosed as an error (see the Sema tests). Differential Revision: https://reviews.llvm.org/D103112 --- clang/lib/Basic/IdentifierTable.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'clang/lib/Basic/IdentifierTable.cpp') diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp index 3c18219..dafacaf 100644 --- a/clang/lib/Basic/IdentifierTable.cpp +++ b/clang/lib/Basic/IdentifierTable.cpp @@ -107,8 +107,9 @@ namespace { KEYCXX20 = 0x200000, KEYOPENCLCXX = 0x400000, KEYMSCOMPAT = 0x800000, + KEYSYCL = 0x1000000, KEYALLCXX = KEYCXX | KEYCXX11 | KEYCXX20, - KEYALL = (0xffffff & ~KEYNOMS18 & + KEYALL = (0xfffffff & ~KEYNOMS18 & ~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude. }; @@ -155,6 +156,8 @@ static KeywordStatus getKeywordStatus(const LangOptions &LangOpts, if (LangOpts.CPlusPlus && (Flags & KEYALLCXX)) return KS_Future; if (LangOpts.CPlusPlus && !LangOpts.CPlusPlus20 && (Flags & CHAR8SUPPORT)) return KS_Future; + if (LangOpts.isSYCL() && (Flags & KEYSYCL)) + return KS_Enabled; return KS_Disabled; } -- cgit v1.1