diff options
author | Yaxun (Sam) Liu <yaxun.liu@amd.com> | 2022-04-21 11:44:11 -0400 |
---|---|---|
committer | Tom Stellard <tstellar@redhat.com> | 2022-05-24 15:02:58 -0700 |
commit | 29f1039a7285a5c3a9c353d054140bf2556d4c4d (patch) | |
tree | 2aceb3755416852906643b4734fa9b9c0940203e /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | e6de9ed37308e46560243229dd78e84542f37ead (diff) | |
download | llvmorg-14.0.4.tar.gz |
[CUDA][HIP] Externalize kernels with internal linkagellvmorg-14.0.4
This patch is a continuation of https://reviews.llvm.org/D123353.
Not only kernels in anonymous namespace, but also template
kernels with template arguments in anonymous namespace
need to be externalized.
To be more generic, this patch checks the linkage of a kernel
assuming the kernel does not have __global__ attribute. If
the linkage is internal then clang will externalize it.
This patch also fixes the postfix for externalized symbol
since nvptx does not allow '.' in symbol name.
Reviewed by: Artem Belevich
Differential Revision: https://reviews.llvm.org/D124189
Fixes: https://github.com/llvm/llvm-project/issues/54560
(cherry picked from commit 04fb81674ed7981397ffe70fe6a07b7168f6fe2f)
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 65b9f4e40dc1..2777fc22600d 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -6647,6 +6647,12 @@ bool CodeGenModule::stopAutoInit() { void CodeGenModule::printPostfixForExternalizedDecl(llvm::raw_ostream &OS, const Decl *D) const { - OS << (isa<VarDecl>(D) ? "__static__" : ".anon.") - << getContext().getCUIDHash(); + StringRef Tag; + // ptxas does not allow '.' in symbol names. On the other hand, HIP prefers + // postfix beginning with '.' since the symbol name can be demangled. + if (LangOpts.HIP) + Tag = (isa<VarDecl>(D) ? ".static." : ".intern."); + else + Tag = (isa<VarDecl>(D) ? "__static__" : "__intern__"); + OS << Tag << getContext().getCUIDHash(); } |