diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -869,6 +869,8 @@ Offset = Header.getNextUnitOffset(); } }); + if (Map.empty()) + return; for (DWARFUnitIndex::Entry &E : Index.getMutableRows()) { if (!E.isValid()) continue; diff --git a/llvm/test/DebugInfo/X86/dwp-v5-tu-index.s b/llvm/test/DebugInfo/X86/dwp-v5-tu-index.s --- a/llvm/test/DebugInfo/X86/dwp-v5-tu-index.s +++ b/llvm/test/DebugInfo/X86/dwp-v5-tu-index.s @@ -1,11 +1,12 @@ ## The test checks that we can parse and dump a TU index section that is ## compliant to the DWARFv5 standard. -# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o - | \ -# RUN: llvm-dwarfdump -debug-tu-index - | \ -# RUN: FileCheck %s +# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o +# RUN: llvm-dwarfdump %t.o -debug-tu-index &> %t.txt +# RUN: cat %t.txt | FileCheck %s # CHECK: .debug_tu_index contents: +# CHECK-NOT: Could not find unit with signature 0x1100001122222222 in the Map # CHECK-NEXT: version = 5, units = 1, slots = 2 # CHECK-EMPTY: # CHECK-NEXT: Index Signature INFO ABBREV LINE STR_OFFSETS