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 @@ -442,12 +442,14 @@ if (shouldDump(Explicit, ".debug_macinfo", DIDT_ID_DebugMacro, DObj->getMacinfoSection())) { - getDebugMacro()->dump(OS); + if (!DObj->getMacinfoSection().empty()) + getDebugMacro()->dump(OS); } if (shouldDump(Explicit, ".debug_macinfo.dwo", DIDT_ID_DebugMacro, DObj->getMacinfoDWOSection())) { - getDebugMacroDWO()->dump(OS); + if (!DObj->getMacinfoDWOSection().empty()) + getDebugMacroDWO()->dump(OS); } if (shouldDump(Explicit, ".debug_aranges", DIDT_ID_DebugAranges,