[all-commits] [llvm/llvm-project] 04caa7: [CUDA][HIP] Promote const variables to constant

Yaxun (Sam) Liu via All-commits all-commits at lists.llvm.org
Tue Jun 1 18:29:23 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 04caa7c3e02f0e2f96881b2b9b5ae5fec6e59aa9
      https://github.com/llvm/llvm-project/commit/04caa7c3e02f0e2f96881b2b9b5ae5fec6e59aa9
  Author: Yaxun (Sam) Liu <yaxun.liu at amd.com>
  Date:   2021-06-01 (Tue, 01 Jun 2021)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/Sema/SemaCUDA.cpp
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Sema/SemaExpr.cpp
    M clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
    M clang/test/CodeGenCUDA/device-use-host-var.cu
    M clang/test/SemaCUDA/device-use-host-var.cu
    M clang/test/SemaCUDA/static-device-var.cu

  Log Message:
  -----------
  [CUDA][HIP] Promote const variables to constant

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.

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D103108




More information about the All-commits mailing list