[CUDA][HIP] Mark device var used by host only
authorYaxun (Sam) Liu <yaxun.liu@amd.com>
Wed, 17 Mar 2021 20:14:03 +0000 (16:14 -0400)
committerYaxun (Sam) Liu <yaxun.liu@amd.com>
Sat, 17 Apr 2021 15:25:25 +0000 (11:25 -0400)
commitd5c0f00e216aa6797499bb4c8aacac930d8a819b
treee1e0eff202d5b47f20c99f0ab1627f03d0707a47
parent3597f02fd5c62f7c49c71b92e467128ffe2cf9cd
[CUDA][HIP] Mark device var used by host only

Add device variables to llvm.compiler.used if they are
ODR-used by either host or device functions.

This is necessary to prevent them from being
eliminated by whole-program optimization
where the compiler has no way to know a device
variable is used by some host code.

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D98814
clang/lib/CodeGen/CGCUDANV.cpp
clang/test/CodeGenCUDA/host-used-device-var.cu [new file with mode: 0644]