[CUDA][HIP] Fix device variable linkage
authorYaxun (Sam) Liu <yaxun.liu@amd.com>
Tue, 2 Feb 2021 23:06:33 +0000 (18:06 -0500)
committerYaxun (Sam) Liu <yaxun.liu@amd.com>
Fri, 5 Feb 2021 20:11:12 +0000 (15:11 -0500)
commitb008ea304d438f0aa818918caceb3bd864412304
tree4162dba4bc94d01f43961b686854465ee5455683
parentc981f6f8e16effdbd5f8c98a80ee8d677fdf8503
[CUDA][HIP] Fix device variable linkage

For -fgpu-rdc, shadow variables should not be internalized, otherwise
they cannot be accessed by other TUs. This is necessary because
the shadow variable of external device variables are always
emitted as undefined symbols, which need to resolve to a global
symbols.

Managed variables need to be emitted as undefined symbols
in device compilations.

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D95901
clang/lib/AST/ASTContext.cpp
clang/lib/CodeGen/CGCUDANV.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenCUDA/device-stub.cu
clang/test/CodeGenCUDA/device-var-linkage.cu [new file with mode: 0644]
clang/test/CodeGenCUDA/managed-var.cu