llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-backend-spir-v Author: Manuel Carrasco (mgcarrasco) <details> <summary>Changes</summary> Move the emission of some remaining cases under `getOrCreateDebugScope`. --- Full diff: https://github.com/llvm/llvm-project/pull/229487.diff 3 Files Affected: - (modified) llvm/lib/Target/SPIRV/SPIRVNonSemanticDebugHandler.cpp (+14-10) - (modified) llvm/lib/Target/SPIRV/SPIRVNonSemanticDebugHandler.h (+6-7) - (modified) llvm/test/CodeGen/SPIRV/debug-info/debug-global-variable-skip-static-member.ll (+19-6) ``````````diff diff --git a/llvm/lib/Target/SPIRV/SPIRVNonSemanticDebugHandler.cpp b/llvm/lib/Target/SPIRV/SPIRVNonSemanticDebugHandler.cpp index 85ecd56df158b..902b16d805abb 100644 --- a/llvm/lib/Target/SPIRV/SPIRVNonSemanticDebugHandler.cpp +++ b/llvm/lib/Target/SPIRV/SPIRVNonSemanticDebugHandler.cpp @@ -896,6 +896,8 @@ SPIRVNonSemanticDebugHandler::emitDebugTypeForDerivedType( return emitDebugTypePointer(DT, ExtInstSetReg, MAI); case dwarf::DW_TAG_typedef: return emitDebugTypedef(DT, VoidTypeReg, I32TypeReg, ExtInstSetReg, MAI); + case dwarf::DW_TAG_member: + return emitDebugTypeMember(DT, VoidTypeReg, I32TypeReg, ExtInstSetReg, MAI); default: return EmitResult::unsupported(); } @@ -1298,9 +1300,10 @@ std::optional<MCRegister> SPIRVNonSemanticDebugHandler::emitDebugGlobalVariable( std::optional<MCRegister> StaticMemberRegOpt; if (const DIDerivedType *SM = GV->getStaticDataMemberDeclaration()) { - StaticMemberRegOpt = lookupOptReg(DebugScopeRegs, SM); - if (!StaticMemberRegOpt) + EmitResult StaticMember = getOrCreateDebugScope(SM); + if (!StaticMember) return std::nullopt; + StaticMemberRegOpt = StaticMember.Reg; } MCRegister NameReg = getCachedOpStringReg(GV->getName()); @@ -1456,15 +1459,16 @@ SPIRVNonSemanticDebugHandler::emitDebugTypeArray( ExtInstSetReg, Ops, MAI)); } -std::optional<MCRegister> SPIRVNonSemanticDebugHandler::emitDebugTypeMember( +SPIRVNonSemanticDebugHandler::EmitResult +SPIRVNonSemanticDebugHandler::emitDebugTypeMember( const DIDerivedType *M, MCRegister VoidTypeReg, MCRegister I32TypeReg, MCRegister ExtInstSetReg, SPIRV::ModuleAnalysisInfo &MAI) { EmitResult Ty = getOrCreateDebugScope(M->getBaseType()); if (!Ty) - return std::nullopt; + return Ty; if (!isUInt<32>(M->getOffsetInBits()) || !isUInt<32>(M->getSizeInBits())) - return std::nullopt; + return EmitResult::unsupported(); MCRegister NameReg = getCachedOpStringReg(M->getName()); MCRegister FileStrReg = getCachedScopePathOpStringReg( @@ -1491,10 +1495,10 @@ std::optional<MCRegister> SPIRVNonSemanticDebugHandler::emitDebugTypeMember( // available but is not emitted as the optional Value operand, and under DWARF // 5 a static member is tagged DW_TAG_variable, which the caller's member loop // skips. - return emitExtInst( + return EmitResult::emitted(emitExtInst( SPIRV::NonSemanticExtInst::DebugTypeMember, VoidTypeReg, ExtInstSetReg, {NameReg, Ty.Reg, SrcReg, LineReg, ColReg, OffsetReg, SizeReg, FlagsReg}, - MAI); + MAI)); } SPIRVNonSemanticDebugHandler::EmitResult @@ -1515,9 +1519,9 @@ SPIRVNonSemanticDebugHandler::emitDebugTypeComposite( const auto *M = dyn_cast<DIDerivedType>(Element); if (!M || M->getTag() != dwarf::DW_TAG_member) continue; - if (auto MemberReg = - emitDebugTypeMember(M, VoidTypeReg, I32TypeReg, ExtInstSetReg, MAI)) - MemberRegs.push_back(*MemberReg); + EmitResult Member = getOrCreateDebugScope(M); + if (Member) + MemberRegs.push_back(Member.Reg); } MCRegister NameReg = getCachedOpStringReg(CT->getName()); diff --git a/llvm/lib/Target/SPIRV/SPIRVNonSemanticDebugHandler.h b/llvm/lib/Target/SPIRV/SPIRVNonSemanticDebugHandler.h index 0a7690efbab7b..efbabd280ea24 100644 --- a/llvm/lib/Target/SPIRV/SPIRVNonSemanticDebugHandler.h +++ b/llvm/lib/Target/SPIRV/SPIRVNonSemanticDebugHandler.h @@ -607,13 +607,12 @@ class SPIRVNonSemanticDebugHandler : public DebugHandlerBase { /// Size, Flags. NonSemantic \c DebugTypeMember carries no Parent operand: the /// enclosing \c DebugTypeComposite references its members, not the reverse. /// - /// \returns The result id register on success. Returns \c std::nullopt and - /// emits nothing if \p M's type cannot be emitted. - std::optional<MCRegister> emitDebugTypeMember(const DIDerivedType *M, - MCRegister VoidTypeReg, - MCRegister I32TypeReg, - MCRegister ExtInstSetReg, - SPIRV::ModuleAnalysisInfo &MAI); + /// \returns Emitted with the result id on success. Returns the base's status + /// and emits nothing if \p M's type cannot be emitted. + EmitResult emitDebugTypeMember(const DIDerivedType *M, MCRegister VoidTypeReg, + MCRegister I32TypeReg, + MCRegister ExtInstSetReg, + SPIRV::ModuleAnalysisInfo &MAI); /// Emit \c DebugTypeComposite for the struct, class, or union \p CT, after a /// \c DebugTypeMember for each data member whose type can be emitted. A diff --git a/llvm/test/CodeGen/SPIRV/debug-info/debug-global-variable-skip-static-member.ll b/llvm/test/CodeGen/SPIRV/debug-info/debug-global-variable-skip-static-member.ll index f8b4cc38c8951..a6fee1e937c4b 100644 --- a/llvm/test/CodeGen/SPIRV/debug-info/debug-global-variable-skip-static-member.ll +++ b/llvm/test/CodeGen/SPIRV/debug-info/debug-global-variable-skip-static-member.ll @@ -1,14 +1,27 @@ ; RUN: llc --verify-machineinstrs --spirv-ext=+SPV_KHR_non_semantic_info -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s ; 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 %} -; A DIGlobalVariable that is the definition of a static data member. Its -; declaration DIDerivedType (DW_TAG_member) is not emitted into DebugTypeRegs -; (member types are not supported yet), so the Static Member Declaration operand -; cannot be resolved and the whole DebugGlobalVariable is skipped. +; A DIGlobalVariable that is the definition of a static data member. The +; declaration is a DW_TAG_member, so getOrCreateDebugScope emits it as +; DebugTypeMember. DebugGlobalVariable names that id. Its Flags operand is +; FlagStaticMember (512). ; CHECK-DAG: [[EXT:%[0-9]+]] = OpExtInstImport "NonSemantic.Shader.DebugInfo.100" -; CHECK-DAG: OpExtInst {{.*}} DebugCompilationUnit -; CHECK-NOT: DebugGlobalVariable +; CHECK-DAG: [[VOID:%[0-9]+]] = OpTypeVoid +; CHECK-DAG: [[I32T:%[0-9]+]] = OpTypeInt 32 0 +; CHECK-DAG: [[NAME:%[0-9]+]] = OpString "member" +; CHECK-DAG: [[STR_INT:%[0-9]+]] = OpString "int" +; CHECK-DAG: [[C0:%[0-9]+]] = OpConstant [[I32T]] 0{{$}} +; CHECK-DAG: [[C8:%[0-9]+]] = OpConstant [[I32T]] 8{{$}} +; CHECK-DAG: [[C32:%[0-9]+]] = OpConstant [[I32T]] 32{{$}} +; CHECK-DAG: [[C42:%[0-9]+]] = OpConstant [[I32T]] 42{{$}} +; CHECK-DAG: [[C512:%[0-9]+]] = OpConstant [[I32T]] 512{{$}} +; CHECK-DAG: [[DS:%[0-9]+]] = OpExtInst [[VOID]] [[EXT]] DebugSource +; CHECK-DAG: [[CU:%[0-9]+]] = OpExtInst [[VOID]] [[EXT]] DebugCompilationUnit +; CHECK-DAG: [[DTI:%[0-9]+]] = OpExtInst [[VOID]] [[EXT]] DebugTypeBasic [[STR_INT]] +; CHECK-DAG: [[MEM:%[0-9]+]] = OpExtInst [[VOID]] [[EXT]] DebugTypeMember [[NAME]] [[DTI]] [[DS]] {{%[0-9]+}} [[C0]] [[C0]] [[C0]] [[C512]] +; CHECK-DAG: [[GV:%[0-9]+]] = OpVariable {{.*}} CrossWorkgroup +; CHECK-DAG: OpExtInst [[VOID]] [[EXT]] DebugGlobalVariable [[NAME]] [[DTI]] [[DS]] [[C42]] [[C0]] [[CU]] [[NAME]] [[GV]] [[C8]] [[MEM]] target triple = "spirv64-unknown-unknown" `````````` </details> https://github.com/llvm/llvm-project/pull/229487 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
