[PATCH] D63164: [HIP] Add option to force lambda nameing following ODR in HIP/CUDA.

Michael Liao via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 11 13:31:26 PDT 2019


hliao created this revision.
hliao added reviewers: tra, yaxunl.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- Clang follows its own scheme for lambdas which don't need to follow ODR rule. That scheme will assign an unqiue ID within the TU scope and won't be unique or consistent across TUs.
- In CUDA/HIP, a lambda with `__device__` or `__host__ __device__` (or an extended lambda) may be used in `__global__` template function instantiation. If that lambda cannot be named following ODR rule, the device compilation may produce a mismatching device kernel name from the host compilation as the anonymous type ID assignment aforementioned.
- In this patch, a new language option, `-fcuda-force-lambda-odr`, is introduced to force ODR for lambda naming so that all lambda could be consistently named across TUs, including the device compilation. This solves the assertion checking device kernel names as well as ensures the named-based resolution could resolve the correct device binaries from the device name generated in the host compilation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63164

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/test/CodeGenCUDA/unnamed-types.cu

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63164.204153.patch
Type: text/x-patch
Size: 6012 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190611/951a0385/attachment.bin>


More information about the cfe-commits mailing list