https://github.com/mgcarrasco updated https://github.com/llvm/llvm-project/pull/229486
>From 38498cd4f855f52817fdbb5861c878648a3897df Mon Sep 17 00:00:00 2001 From: Manuel Carrasco <[email protected]> Date: Tue, 6 Oct 2026 08:03:06 -0500 Subject: [PATCH] [SPIRV] Drop the DebugTypeFunction operand cache. Each DISubroutineType is already emitted once through DebugScopeRegs. --- .../SPIRV/SPIRVNonSemanticDebugHandler.cpp | 18 ++---------------- .../SPIRV/SPIRVNonSemanticDebugHandler.h | 11 ----------- .../debug-type-function-void-prototypes.ll | 5 +++-- 3 files changed, 5 insertions(+), 29 deletions(-) diff --git a/llvm/lib/Target/SPIRV/SPIRVNonSemanticDebugHandler.cpp b/llvm/lib/Target/SPIRV/SPIRVNonSemanticDebugHandler.cpp index 21f1b930a18b2..62eb1ec0a1c34 100644 --- a/llvm/lib/Target/SPIRV/SPIRVNonSemanticDebugHandler.cpp +++ b/llvm/lib/Target/SPIRV/SPIRVNonSemanticDebugHandler.cpp @@ -348,7 +348,6 @@ void SPIRVNonSemanticDebugHandler::beginModule(Module *M) { ScalarTypeCache.clear(); ScalarConstantCache.clear(); ConstantValueRegs.clear(); - DebugTypeFunctionCache.clear(); DebugOperationCache.clear(); DebugExpressionCache.clear(); ModuleScopeIds.clear(); @@ -555,20 +554,6 @@ MCRegister SPIRVNonSemanticDebugHandler::emitExtInst( return Reg; } -MCRegister SPIRVNonSemanticDebugHandler::getOrEmitDebugTypeFunction( - ArrayRef<MCRegister> Ops, MCRegister VoidTypeReg, MCRegister ExtInstSetReg, - SPIRV::ModuleAnalysisInfo &MAI) { - auto [It, Inserted] = - DebugTypeFunctionCache.try_emplace(SmallVector<MCRegister, 8>(Ops)); - if (!Inserted) - return It->second; - - MCRegister Reg = emitExtInst(SPIRV::NonSemanticExtInst::DebugTypeFunction, - VoidTypeReg, ExtInstSetReg, Ops, MAI); - It->second = Reg; - return Reg; -} - MCRegister SPIRVNonSemanticDebugHandler::getOrEmitOpTypeVoidReg( SPIRV::ModuleAnalysisInfo &MAI) { if (!CachedOpTypeVoidReg.isValid()) @@ -985,7 +970,8 @@ SPIRVNonSemanticDebugHandler::emitDebugTypeFunctionForSubroutineType( } } return EmitResult::emitted( - getOrEmitDebugTypeFunction(Ops, VoidTypeReg, ExtInstSetReg, MAI)); + emitExtInst(SPIRV::NonSemanticExtInst::DebugTypeFunction, VoidTypeReg, + ExtInstSetReg, Ops, MAI)); } // Match SPIRV-LLVM-Translator's selection logic for the Parent operand. diff --git a/llvm/lib/Target/SPIRV/SPIRVNonSemanticDebugHandler.h b/llvm/lib/Target/SPIRV/SPIRVNonSemanticDebugHandler.h index a96ac8e33afed..0a7690efbab7b 100644 --- a/llvm/lib/Target/SPIRV/SPIRVNonSemanticDebugHandler.h +++ b/llvm/lib/Target/SPIRV/SPIRVNonSemanticDebugHandler.h @@ -190,10 +190,6 @@ class SPIRVNonSemanticDebugHandler : public DebugHandlerBase { DenseMap<std::pair<const DIBasicType *, uint64_t>, MCRegister> ConstantValueRegs; - // Cache of already-emitted DebugTypeFunction instructions, keyed by operand - // ids (flags, return type, parameters). - DenseMap<SmallVector<MCRegister, 8>, MCRegister> DebugTypeFunctionCache; - // Cache of already-emitted DebugOperation instructions, keyed by NonSemantic // opcode followed by the 32-bit operation arguments. Inline size 3 is the // spec maximum (opcode plus at most two operands: BitPiece, Fragment). @@ -362,13 +358,6 @@ class SPIRVNonSemanticDebugHandler : public DebugHandlerBase { ArrayRef<MCRegister> Operands, SPIRV::ModuleAnalysisInfo &MAI); - /// Return a cached DebugTypeFunction id when \p Ops matches a prior emission, - /// otherwise emit and cache a new instruction. - MCRegister getOrEmitDebugTypeFunction(ArrayRef<MCRegister> Ops, - MCRegister VoidTypeReg, - MCRegister ExtInstSetReg, - SPIRV::ModuleAnalysisInfo &MAI); - /// Return OpTypeVoid id for this module (lazy lookup / emit, then cache). MCRegister getOrEmitOpTypeVoidReg(SPIRV::ModuleAnalysisInfo &MAI); diff --git a/llvm/test/CodeGen/SPIRV/debug-info/debug-type-function-void-prototypes.ll b/llvm/test/CodeGen/SPIRV/debug-info/debug-type-function-void-prototypes.ll index d9f41f4cf0bab..10ef297e37876 100644 --- a/llvm/test/CodeGen/SPIRV/debug-info/debug-type-function-void-prototypes.ll +++ b/llvm/test/CodeGen/SPIRV/debug-info/debug-type-function-void-prototypes.ll @@ -2,13 +2,14 @@ ; RUN: %if spirv-tools %{ llc --verify-machineinstrs --spirv-ext=+SPV_KHR_non_semantic_info -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %} ; Void function types in LLVM metadata may be written as an empty type list (!{}) or with an explicit -; null return slot (!{null}); both should produce the same SPIR-V DebugTypeFunction (flags + void only). +; null return slot (!{null}). Those are two DISubroutineType nodes, so each gets its own +; DebugTypeFunction. Both instructions have the same operands: flags and OpTypeVoid. ; CHECK: [[ext:%[0-9]+]] = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" ; CHECK-DAG: [[type_void:%[0-9]+]] = OpTypeVoid ; CHECK-DAG: [[type_int32:%[0-9]+]] = OpTypeInt 32 0 ; CHECK-DAG: [[flag_zero:%[0-9]+]] = OpConstant [[type_int32]] 0{{$}} -; CHECK-COUNT-1: OpExtInst [[type_void]] [[ext]] DebugTypeFunction [[flag_zero]] [[type_void]] +; CHECK-COUNT-2: OpExtInst [[type_void]] [[ext]] DebugTypeFunction [[flag_zero]] [[type_void]] target triple = "spirv64-unknown-unknown" _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
