[PATCH] D102270: [CUDA][HIP] Fix device template variables

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 11 12:07:47 PDT 2021


yaxunl created this revision.
yaxunl added a reviewer: tra.
yaxunl requested review of this revision.

Currently clang does not emit device template variables
instantiated only in host functions, however, nvcc is
able to do that:

https://godbolt.org/z/fneEfferY

This patch fixes this issue by refactoring and extending
the existing mechanism for emitting static device
var ODR-used by host only. Basically clang records
device variables ODR-used by host code and force
them to be emitted in device compilation. The existing
mechanism makes sure these device variables ODR-used
by host code are added to llvm.compiler-used, therefore
they are guaranteed not to be deleted.


https://reviews.llvm.org/D102270

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCUDA/device-stub.cu
  clang/test/CodeGenCUDA/host-used-device-var.cu

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102270.344522.patch
Type: text/x-patch
Size: 10993 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210511/8806f70f/attachment.bin>


More information about the cfe-commits mailing list