diff options
author | Yaxun (Sam) Liu <yaxun.liu@amd.com> | 2024-07-12 10:08:34 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-12 10:08:34 -0400 |
commit | 77fd30f7ce0795b4bbc22e65b3ff42856839d708 (patch) | |
tree | 53400a2dff51c571bae1a859f157b79d719aa058 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | e616fa5bc0c628962afec7ee51288b442fbb09d6 (diff) | |
download | llvm-77fd30f7ce0795b4bbc22e65b3ff42856839d708.zip llvm-77fd30f7ce0795b4bbc22e65b3ff42856839d708.tar.gz llvm-77fd30f7ce0795b4bbc22e65b3ff42856839d708.tar.bz2 |
[CUDA][HIP] Fix template static member (#98580)
Should check host/device attributes before emitting static member of
template instantiation.
Fixes: https://github.com/llvm/llvm-project/issues/98151
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index d9dded9..08cfa69 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -5933,7 +5933,8 @@ static void ReplaceUsesOfNonProtoTypeWithRealFunction(llvm::GlobalValue *Old, void CodeGenModule::HandleCXXStaticMemberVarInstantiation(VarDecl *VD) { auto DK = VD->isThisDeclarationADefinition(); - if (DK == VarDecl::Definition && VD->hasAttr<DLLImportAttr>()) + if ((DK == VarDecl::Definition && VD->hasAttr<DLLImportAttr>()) || + (LangOpts.CUDA && !shouldEmitCUDAGlobalVar(VD))) return; TemplateSpecializationKind TSK = VD->getTemplateSpecializationKind(); |