From 736273c7fe3e88baf548cd555f21eb123f81381d Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 8 Nov 2019 15:26:17 -0800 Subject: DebugInfo: Do not create a debug_macinfo section if no CUs have associated macros Patch based on Sourabh Singh's D69839 patch. --- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp') diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index d17dd4dc3f7..56615584a18 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -2737,10 +2737,6 @@ void DwarfDebug::emitDebugMacinfo() { })) return; - // Start the dwarf macinfo section. - Asm->OutStreamer->SwitchSection( - Asm->getObjFileLowering().getDwarfMacinfoSection()); - for (const auto &P : CUMap) { auto &TheCU = *P.second; if (TheCU.getCUNode()->isDebugDirectivesOnly()) @@ -2750,6 +2746,8 @@ void DwarfDebug::emitDebugMacinfo() { auto *CUNode = cast(P.first); DIMacroNodeArray Macros = CUNode->getMacros(); if (!Macros.empty()) { + Asm->OutStreamer->SwitchSection( + Asm->getObjFileLowering().getDwarfMacinfoSection()); Asm->OutStreamer->EmitLabel(U.getMacroLabelBegin()); handleMacroNodes(Macros, U); Asm->OutStreamer->AddComment("End Of Macro List Mark"); -- cgit v1.2.3