[llvm] [SPIRV] Emit NonSemantic DebugGlobalVariable (PR #207230)
Manuel Carrasco via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 13 03:36:52 PDT 2026
================
@@ -256,6 +273,42 @@ class SPIRVNonSemanticDebugHandler : public DebugHandlerBase {
MCRegister I32TypeReg, MCRegister ExtInstSetReg,
SPIRV::ModuleAnalysisInfo &MAI);
+ /// Emit \c DebugGlobalVariable for the source global variable \p GV.
+ ///
+ /// (\c SPIRVDebug::Operand::GlobalVariable): Name, Type, Source, Line,
+ /// Column, Parent, Linkage Name, Variable, Flags, and an optional Static
+ /// Member Declaration. Line, Column, and Flags are emitted as \c OpConstant
+ /// ids as required for non-semantic debug info.
+ ///
+ /// \c DebugInfoNone is used for two operands when LLVM has no value to
+ /// supply:
+ /// \c Type when \p GV is a declaration with no DI type (e.g. \c extern void;
+ /// valid IR, \c isDefinition: false); \c Variable when no \c
+ /// llvm::GlobalVariable in this module carries \p GV in its \c !dbg metadata.
+ ///
+ /// \returns The result id register on success. Returns \c std::nullopt and
+ /// emits nothing if a non-null \p GV type was not emitted in \c
+ /// DebugTypeRegs,
+ /// \p GV has a static data member declaration that was not emitted in
+ /// \c DebugTypeRegs, or \c resolveGlobalVariableParent returns no id for the
+ /// \c Parent operand.
+ std::optional<MCRegister>
+ emitDebugGlobalVariable(const DIGlobalVariable *GV, MCRegister VoidTypeReg,
+ MCRegister I32TypeReg, MCRegister ExtInstSetReg,
+ SPIRV::ModuleAnalysisInfo &MAI);
+
+ /// Resolve the \c Parent operand for \c DebugGlobalVariable.
+ std::optional<MCRegister>
+ resolveGlobalVariableParent(const DIGlobalVariable *GV) const;
+
+ /// Emit \c DebugExpression for \p Expr. Unimplemented: defined as a no-op
+ /// (\returns \c std::nullopt, emits nothing) so \c emitDebugGlobalVariable
+ /// can complete Variable-operand resolution for the opcodes we support today.
+ std::optional<MCRegister> emitDebugExpression(const DIExpression *Expr,
----------------
mgcarrasco wrote:
I was already implementing the handler for `DebugGlobalVariable` support, and wanted it to leave its logic ready for when DIExpression can be supported. Once DIExpressions are supported it won't require changing anything in the `DebugGlobalVariable` handler.
https://github.com/llvm/llvm-project/pull/207230
More information about the llvm-commits
mailing list