[CUDA][HIP] Fix static device var used by host code only
authorYaxun (Sam) Liu <yaxun.liu@amd.com>
Tue, 22 Sep 2020 16:52:07 +0000 (12:52 -0400)
committerYaxun (Sam) Liu <yaxun.liu@amd.com>
Wed, 23 Sep 2020 12:18:19 +0000 (08:18 -0400)
commit301e23305d03cfb4004f845a1d9dfdc5e5931fd8
treec3a992eb5e0132b556c10fc68c8ee1d74ba73f83
parentbd72ed93d22a1579362859e64a0c7f9c68460cf8
[CUDA][HIP] Fix static device var used by host code only

A static device variable may be accessed in host code through
cudaMemCpyFromSymbol etc. Currently clang does not
emit the static device variable if it is only referenced by
host code, which causes host code to fail at run time.

This patch fixes that.

Differential Revision: https://reviews.llvm.org/D88115
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenCUDA/static-device-var-no-rdc.cu