[llvm] [DebugInfo] Fix line 0 records incorrectly having is_stmt set (PR #166627)

Orlando Cazalet-Hyams via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 20 06:19:40 PST 2025


================
@@ -2400,8 +2404,11 @@ DwarfDebug::emitInitialLocDirective(const MachineFunction &MF, unsigned CUID) {
   (void)getOrCreateDwarfCompileUnit(SP->getUnit());
   // We'd like to list the prologue as "not statements" but GDB behaves
   // poorly if we do that. Revisit this with caution/GDB (7.5+) testing.
-  ::recordSourceLine(*Asm, SP->getScopeLine(), 0, SP, DWARF2_FLAG_IS_STMT,
-                     CUID, getDwarfVersion(), getUnits());
+  // However, we should not set is_stmt for line 0.
+  unsigned ScopeLine = SP->getScopeLine();
+  unsigned Flags = (ScopeLine != 0) ? DWARF2_FLAG_IS_STMT : 0;
+  ::recordSourceLine(*Asm, ScopeLine, 0, SP, Flags, CUID, getDwarfVersion(),
----------------
OCHyams wrote:

In which case I feel it's better to keep this code as it was previously, as it's almost certainly a bug if this is a line 0 and not particularly harmful if that occurs. So overall better to minimise change and complexity.

I don't feel massively strongly about it, as long as it's consistent between this line and the other scopeLine usage in this file, so if others feel differently I wouldn't insist.

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


More information about the llvm-commits mailing list