[llvm] [SPIR-V] Fix lowering of declarations with hidden visibility (PR #185029)

Steven Perron via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 10 10:32:39 PDT 2026


================
@@ -1197,11 +1197,28 @@ Type *reconstitutePeeledArrayType(Type *Ty) {
 
 std::optional<SPIRV::LinkageType::LinkageType>
 getSpirvLinkageTypeFor(const SPIRVSubtarget &ST, const GlobalValue &GV) {
-  if (GV.hasLocalLinkage() || GV.hasHiddenVisibility())
+  if (GV.hasLocalLinkage())
     return std::nullopt;
 
-  if (GV.isDeclarationForLinker())
+  // Shader targets do not support the Linkage capability unless the module
+  // is a shader library.
+  if (ST.isShader() && !ST.isShaderLibrary())
+    return std::nullopt;
----------------
s-perron wrote:

I'm not sure this is useful.  I don't think we do anything special in the backend with the environment. It is used in clang to modify how the entry points are identified, and allows some other things like `export`. However, I don't want to import that HLSL distinction into the backend.

Do any tests fail if you remove this?

I've also been thinking of getting an option for spirv-val where it won't issue an error when linkage is used for shaders.


https://github.com/llvm/llvm-project/pull/185029


More information about the llvm-commits mailing list