From: Viktoria Maximova Date: Mon, 11 May 2026 16:49:21 +0200 Subject: [05/13] [Backport to 22] [DebugInfo] Fix NonSemantic DebugTypeBasic Flags operand (#3740) Origin: upstream, https://github.com/KhronosGroup/SPIRV-LLVM-Translator/commit/b1106b6797e392c653aaa0dd016db0aa39cba71c The NonSemantic.Shader.DebugInfo spec requires the Flags operand of DebugTypeBasic to be a 32-bit integer constant. The translator was emitting `DebugInfoNone` instead of `OpConstant 0`. `spirv-val` on the NonSemantic path cannot be enabled yet due to other spec-compliance issues to be fixed in subsequent changes. --- lib/SPIRV/LLVMToSPIRVDbgTran.cpp | 3 ++- test/DebugInfo/DebugInfoTypeBasic.ll | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/SPIRV/LLVMToSPIRVDbgTran.cpp b/lib/SPIRV/LLVMToSPIRVDbgTran.cpp index 25f26680..db46dc70 100644 --- a/lib/SPIRV/LLVMToSPIRVDbgTran.cpp +++ b/lib/SPIRV/LLVMToSPIRVDbgTran.cpp @@ -633,7 +633,8 @@ SPIRVEntry *LLVMToSPIRVDbgTran::transDbgBaseType(const DIBasicType *BT) { if (isNonSemanticDebugInfo()) { transformToConstant(Ops, {EncodingIdx}); // Flags value could not be generated by clang or by LLVM environment. - Ops.push_back(getDebugInfoNoneId()); + // The spec requires a 32-bit integer constant, not DebugInfoNone. + Ops.push_back(SPIRVWriter->transValue(getUInt32(M, 0), nullptr)->getId()); } return BM->addDebugInfo(SPIRVDebug::TypeBasic, getVoidTy(), Ops); } diff --git a/test/DebugInfo/DebugInfoTypeBasic.ll b/test/DebugInfo/DebugInfoTypeBasic.ll index f76eb847..c010000e 100644 --- a/test/DebugInfo/DebugInfoTypeBasic.ll +++ b/test/DebugInfo/DebugInfoTypeBasic.ll @@ -22,10 +22,10 @@ ; CHECK-LLVM: !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) ; CHECK-SPIRV: String [[#Name:]] "int" +; CHECK-SPIRV-NONSEM: Constant [[#]] [[#Flags:]] 0 ; CHECK-SPIRV-NONSEM: Constant [[#]] [[#Encoding:]] 4 ; CHECK-SPIRV: Constant [[#]] [[#Size:]] 32 ; CHECK-SPIRV-OCL: DebugTypeBasic [[#Name]] [[#Size]] 4 {{$}} -; CHECK-SPIRV-NONSEM: [[#Flags:]] [[#]] DebugInfoNone ; CHECK-SPIRV-NONSEM: DebugTypeBasic [[#Name]] [[#Size]] [[#Encoding]] [[#Flags]] {{$}} target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" -- 2.55.0