[llvm] 9725cb8 - [SPIR-V] Fix Linkage capability with pushconstant (#175192)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 12 01:23:18 PST 2026
Author: Nathan Gauër
Date: 2026-01-12T10:23:13+01:00
New Revision: 9725cb8ede9de6b006398e46b1360dc86e5d866f
URL: https://github.com/llvm/llvm-project/commit/9725cb8ede9de6b006398e46b1360dc86e5d866f
DIFF: https://github.com/llvm/llvm-project/commit/9725cb8ede9de6b006398e46b1360dc86e5d866f.diff
LOG: [SPIR-V] Fix Linkage capability with pushconstant (#175192)
When the SPIR-V backend handles a push constant, a new global with a
target-specific is generated. This global should have the same
visibility as the source, but turns out it was not the case: linkage was
still external, but visibility went from hidden to visible.
This causes the later passes to generate a Linkage decoration, adding
the Linkage capability, which is not compatible with Vulkan. Fixing
this.
Added:
Modified:
llvm/lib/Target/SPIRV/SPIRVPushConstantAccess.cpp
llvm/test/CodeGen/SPIRV/vk-pushconstant-access.ll
llvm/test/CodeGen/SPIRV/vk-pushconstant-layout.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/SPIRV/SPIRVPushConstantAccess.cpp b/llvm/lib/Target/SPIRV/SPIRVPushConstantAccess.cpp
index 1ce476cef6688..8ec05271fc8fb 100644
--- a/llvm/lib/Target/SPIRV/SPIRVPushConstantAccess.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVPushConstantAccess.cpp
@@ -44,6 +44,7 @@ static bool replacePushConstantAccesses(Module &M, SPIRVGlobalRegistry *GR) {
/* initializer= */ nullptr, GV.getName(),
/* InsertBefore= */ &GV, GV.getThreadLocalMode(),
GV.getAddressSpace(), GV.isExternallyInitialized());
+ NewGV->setVisibility(GV.getVisibility());
for (User *U : make_early_inc_range(GV.users())) {
Instruction *I = cast<Instruction>(U);
diff --git a/llvm/test/CodeGen/SPIRV/vk-pushconstant-access.ll b/llvm/test/CodeGen/SPIRV/vk-pushconstant-access.ll
index 079d9025ec4df..4b272eaf3577c 100644
--- a/llvm/test/CodeGen/SPIRV/vk-pushconstant-access.ll
+++ b/llvm/test/CodeGen/SPIRV/vk-pushconstant-access.ll
@@ -2,6 +2,8 @@
%struct.S = type <{ float }>
+; CHECK-NOT: OpCapability Linkage
+
; CHECK-DAG: %[[#F32:]] = OpTypeFloat 32
; CHECK-DAG: %[[#UINT:]] = OpTypeInt 32 0
; CHECK-DAG: %[[#S_S:]] = OpTypeStruct %[[#F32]]
diff --git a/llvm/test/CodeGen/SPIRV/vk-pushconstant-layout.ll b/llvm/test/CodeGen/SPIRV/vk-pushconstant-layout.ll
index 3c5391b532fd1..c61375e85c47f 100644
--- a/llvm/test/CodeGen/SPIRV/vk-pushconstant-layout.ll
+++ b/llvm/test/CodeGen/SPIRV/vk-pushconstant-layout.ll
@@ -5,6 +5,8 @@
%struct.T = type { [3 x <2 x float>] }
%struct.S = type <{ float, <3 x float>, %struct.T }>
+; CHECK-NOT: OpCapability Linkage
+
; CHECK-DAG: %[[#PTR_PCS:]] = OpTypePointer PushConstant %[[#S_S:]]
; CHECK-DAG: %[[#F32:]] = OpTypeFloat 32
More information about the llvm-commits
mailing list