[PATCH] D103108: [CUDA][HIP] Promote const variables to constant

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 25 11:42:41 PDT 2021


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

Recently we added diagnosing ODR-use of host variables
in device functions, which includes ODR-use of const
host variables since they are not really emitted on
device side. This caused regressions since we used
to allow ODR-use of const host variables in device
functions.

This patch allows ODR-use of const variables in device
functions if the const variables can be statically initialized
and have an empty dtor. Such variables are marked with
implicit constant attrs and emitted on device side. This is
in line with what clang does for constexpr variables.


https://reviews.llvm.org/D103108

Files:
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenCUDA/device-use-host-var.cu
  clang/test/SemaCUDA/device-use-host-var.cu

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103108.347741.patch
Type: text/x-patch
Size: 15280 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210525/ed7d6ce2/attachment-0001.bin>


More information about the cfe-commits mailing list