[llvm] [SPIRV] Emit NonSemantic DebugValue (PR #224158)

Diego Novillo via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 06:46:03 PDT 2026


================
@@ -1402,14 +1713,14 @@ void SPIRVNonSemanticDebugHandler::beginInstruction(const MachineInstr *MI) {
   if (!DebugFunctionDefinitionEmitted)
     return;
 
+  emitAnalyzedRecords(MI);
+
   std::optional<const MachineInstr *> Target = resolveDebugLocTarget(MI);
   if (!Target)
     return;
 
-  emitDebugScopeForInstruction(*Target);
+  (void)emitDebugScopeForInstruction(*Target);
   emitDebugLineForInstruction(*Target);
-
-  emitDebugDeclare(MI);
----------------
dnovillo wrote:

Mostly because of refactoring. `DebugDeclare` and `DebugValue` have the same placement constraints, so instead of each one deciding placement for itself, I created a single pass that resolves any record and a single place that emits it. The rest of the emission logic you had and the test did not need any changes.

During the refactoring I found two latent bugs: a declare between a merge and its terminator was dropped, and a `DBG_VALUE` counted as an emitted instruction, which put the merge's `DebugLine` on the wrong line.

https://github.com/llvm/llvm-project/pull/224158


More information about the llvm-commits mailing list