[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 03:37:03 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:
I wonder line zero scope lines can really occur "naturally", I would be slightly surprised. I suppose there's little harm in adding coverage here too but it feels to me like a scope line of 0 would probably mean there's a bug somewhere.
@jmorse do you have a gut instinct on this?
https://github.com/llvm/llvm-project/pull/166627
More information about the llvm-commits
mailing list