Skip to content

Commit

Permalink
[CUDA][HIP] Externalize kernels in anonymous name space
Browse files Browse the repository at this point in the history
kernels in anonymous name space needs to have unique name
to avoid duplicate symbols.

Fixes: llvm#54560

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D123353

(cherry picked from commit 4ea1d43)
  • Loading branch information
yxsamliu authored and tarunprabhu committed Apr 4, 2023
1 parent b310589 commit b69baac
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions clang/lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,11 @@ StringRef CodeGenModule::getMangledName(GlobalDecl GD) {
// directly between host- and device-compilations, the host- and
// device-mangling in host compilation could help catching certain ones.
assert(!isa<FunctionDecl>(ND) || !ND->hasAttr<CUDAGlobalAttr>() ||
<<<<<<< HEAD
getContext().shouldExternalize(ND) || getLangOpts().CUDAIsDevice ||
=======
getContext().shouldExternalizeStaticVar(ND) || getLangOpts().CUDAIsDevice ||
>>>>>>> e6de9ed37308 ([CUDA][HIP] Externalize kernels in anonymous name space)
(getContext().getAuxTargetInfo() &&
(getContext().getAuxTargetInfo()->getCXXABI() !=
getContext().getTargetInfo().getCXXABI())) ||
Expand Down Expand Up @@ -7149,6 +7153,7 @@ bool CodeGenModule::stopAutoInit() {

void CodeGenModule::printPostfixForExternalizedDecl(llvm::raw_ostream &OS,
const Decl *D) const {
<<<<<<< HEAD
// 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)
Expand Down Expand Up @@ -7213,4 +7218,8 @@ void CodeGenModule::moveLazyEmissionStates(CodeGenModule *NewBuilder) {
NewBuilder->EmittedDeferredDecls = std::move(EmittedDeferredDecls);

NewBuilder->ABI->MangleCtx = std::move(ABI->MangleCtx);
=======
OS << (isa<VarDecl>(D) ? "__static__" : ".anon.")
<< getContext().getCUIDHash();
>>>>>>> e6de9ed37308 ([CUDA][HIP] Externalize kernels in anonymous name space)
}

0 comments on commit b69baac

Please sign in to comment.