[HIP] Fix device stub name
authorYaxun (Sam) Liu <yaxun.liu@amd.com>
Thu, 5 Mar 2020 17:59:33 +0000 (12:59 -0500)
committerYaxun (Sam) Liu <yaxun.liu@amd.com>
Mon, 9 Mar 2020 20:40:05 +0000 (16:40 -0400)
commit22c457a869d5dd9d7e6ca0f97e2a8408bf7326f2
treeafd898d77070dcd22c791bdf570eea0e3abe7652
parent3262319806d76056a58abe56d1d6a37d296d8ad8
[HIP] Fix device stub name

HIP emits a device stub function for each kernel in host code.

The HIP debugger requires device stub function to have a different unmangled name as the kernel.

Currently the name of the device stub function is the mangled name with a postfix .stub. However,
this does not work with the HIP debugger since the unmangled name is the same as the kernel.

This patch adds prefix __device__stub__ to the unmangled name of the device stub before mangling,
therefore the device stub function has a valid mangled name which is different than the device kernel
name. The device side kernel name is kept unchanged. kernels with extern "C" also gets the prefix added
to the corresponding device stub function.

Differential Revision: https://reviews.llvm.org/D68578
13 files changed:
clang/include/clang/AST/GlobalDecl.h
clang/lib/AST/Expr.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/Mangle.cpp
clang/lib/CodeGen/CGCUDANV.cpp
clang/lib/CodeGen/CGCUDARuntime.h
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
clang/test/CodeGenCUDA/kernel-stub-name.cu
clang/test/CodeGenCUDA/unnamed-types.cu