diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp --- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp +++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp @@ -549,9 +549,8 @@ LT.addStandardOpcode(DW_LNS_const_add_pc, {}); LT.addExtendedOpcode(1, DW_LNE_end_sequence, {}); DWARFDebugLine::Prologue Prologue = LT.createBasicPrologue(); - // Set the total length to 1 higher than the actual length. The program body - // has size 5. - Prologue.TotalLength += 6; + // Set the total length to 1 higher than the actual length. + ++Prologue.TotalLength; LT.setPrologue(Prologue); generate(); diff --git a/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp b/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp --- a/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp +++ b/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp @@ -175,6 +175,7 @@ P.TotalLength += 4; P.FormParams.Format = DWARF64; } + P.TotalLength += Contents.size(); P.FormParams.Version = Version; P.MinInstLength = 1; P.MaxOpsPerInst = 1;