diff --git a/llvm/lib/Target/SPIRV/SPIRVUtils.cpp b/llvm/lib/Target/SPIRV/SPIRVUtils.cpp index 4e2cc882ed6ba..b4b2c8d5947ce 100644 --- a/llvm/lib/Target/SPIRV/SPIRVUtils.cpp +++ b/llvm/lib/Target/SPIRV/SPIRVUtils.cpp @@ -1042,7 +1042,7 @@ getFirstValidInstructionInsertPoint(MachineBasicBlock &BB) { std::optional getSpirvLinkageTypeFor(const SPIRVSubtarget &ST, const GlobalValue &GV) { - if (GV.hasLocalLinkage() || GV.hasHiddenVisibility()) + if (GV.hasLocalLinkage()) return std::nullopt; if (GV.isDeclarationForLinker()) diff --git a/llvm/test/CodeGen/SPIRV/linkage/link-hidden.ll b/llvm/test/CodeGen/SPIRV/linkage/link-hidden.ll new file mode 100644 index 0000000000000..f4172df38ee8b --- /dev/null +++ b/llvm/test/CodeGen/SPIRV/linkage/link-hidden.ll @@ -0,0 +1,14 @@ +; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s +; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %} + +; CHECK: OpName %[[BAR:[0-9]+]] "bar" +; CHECK: OpDecorate %[[BAR]] LinkageAttributes "bar" Import +; CHECK: %[[BAR]] = OpFunction + +define hidden spir_kernel void @foo() addrspace(4) { +entry: + call spir_func addrspace(4) void @bar() + ret void +} + +declare hidden spir_func void @bar() addrspace(4)