[clang] [llvm] [HLSL] Add support for user semantics (PR #153424)
Nathan Gauër via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 30 03:00:35 PDT 2025
================
@@ -562,6 +572,69 @@ static llvm::Value *createSPIRVBuiltinLoad(IRBuilder<> &B, llvm::Module &M,
return B.CreateLoad(Ty, GV);
}
+static llvm::Value *createSPIRVLocationLoad(IRBuilder<> &B, llvm::Module &M,
+ llvm::Type *Ty, unsigned Location,
+ StringRef Name = "") {
+ auto *GV = new llvm::GlobalVariable(
+ M, Ty, /* isConstant= */ true, llvm::GlobalValue::ExternalLinkage,
+ /* Initializer= */ nullptr, /* Name= */ Name, /* insertBefore= */ nullptr,
+ llvm::GlobalVariable::GeneralDynamicTLSModel,
+ /* AddressSpace */ 7, /* isExternallyInitialized= */ true);
----------------
Keenuts wrote:
This is a good point, the thing is I don't think it is well defined yet what happens if:
- input semantics are duplicated
- semantic is duplicated using HLSL semantics and `vk::builtin`
Ex: DXC fails to build SPIR-V if I have the following shader:
```hlsl
RWStructuredBuffer<uint> output;
void main(uint a : SV_GroupThreadID, uint b : SV_GroupThreadID) {
output[0] = a + b;
}
```
I don't think we should allow having an I/O semantic also be reachable with a `vk::builtin` global, nor we should have duplicated I/O semantics.
https://github.com/llvm/llvm-project/pull/153424
More information about the llvm-commits
mailing list