[all-commits] [llvm/llvm-project] eba69b: Reimplement __builtin_unique_stable_name-

Erich Keane via All-commits all-commits at lists.llvm.org
Thu May 27 07:12:40 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: eba69b59d1a30dead07da2c279c8ecfd2b62ba9f
      https://github.com/llvm/llvm-project/commit/eba69b59d1a30dead07da2c279c8ecfd2b62ba9f
  Author: Erich Keane <erich.keane at intel.com>
  Date:   2021-05-27 (Thu, 27 May 2021)

  Changed paths:
    M clang/docs/LanguageExtensions.rst
    M clang/include/clang/AST/ASTContext.h
    M clang/include/clang/AST/ComputeDependence.h
    M clang/include/clang/AST/Expr.h
    M clang/include/clang/AST/JSONNodeDumper.h
    M clang/include/clang/AST/Mangle.h
    M clang/include/clang/AST/RecursiveASTVisitor.h
    M clang/include/clang/AST/TextNodeDumper.h
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/include/clang/Basic/LangOptions.h
    M clang/include/clang/Basic/StmtNodes.td
    M clang/include/clang/Basic/TokenKinds.def
    M clang/include/clang/Parse/Parser.h
    M clang/include/clang/Sema/Sema.h
    M clang/include/clang/Serialization/ASTBitCodes.h
    M clang/lib/AST/ASTContext.cpp
    M clang/lib/AST/ComputeDependence.cpp
    M clang/lib/AST/Expr.cpp
    M clang/lib/AST/ExprClassification.cpp
    M clang/lib/AST/ExprConstant.cpp
    M clang/lib/AST/ItaniumMangle.cpp
    M clang/lib/AST/JSONNodeDumper.cpp
    M clang/lib/AST/StmtPrinter.cpp
    M clang/lib/AST/StmtProfile.cpp
    M clang/lib/AST/TextNodeDumper.cpp
    M clang/lib/Basic/IdentifierTable.cpp
    M clang/lib/CodeGen/CGCUDANV.cpp
    M clang/lib/CodeGen/CGExprScalar.cpp
    M clang/lib/Parse/ParseExpr.cpp
    M clang/lib/Sema/SemaExceptionSpec.cpp
    M clang/lib/Sema/SemaExpr.cpp
    M clang/lib/Sema/SemaLambda.cpp
    M clang/lib/Sema/SemaSYCL.cpp
    M clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
    M clang/lib/Sema/TreeTransform.h
    M clang/lib/Serialization/ASTReaderStmt.cpp
    M clang/lib/Serialization/ASTWriterStmt.cpp
    M clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
    A clang/test/AST/ast-print-sycl-unique-stable-name.cpp
    A clang/test/CodeGenSYCL/unique_stable_name.cpp
    A clang/test/ParserSYCL/unique_stable_name.cpp
    A clang/test/ParserSYCL/unique_stable_name_sycl_only.cpp
    A clang/test/SemaSYCL/unique_stable_name.cpp
    M clang/tools/libclang/CXCursor.cpp

  Log Message:
  -----------
  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




More information about the All-commits mailing list