From 0a72515d33bb1931ca8ad4022f743a33a203ea33 Mon Sep 17 00:00:00 2001 From: Sourabh Singh Tomar Date: Tue, 24 Dec 2019 11:38:38 +0530 Subject: [PATCH] [DebugInfo] Fix v4 macinfo for dwo files. Dwo files must contain have DW_AT_macro_info attribute, when macro information is emitted. Adjusted the test case for the same. --- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 13 +++++++++---- llvm/test/DebugInfo/X86/debug-macinfo-split-dwarf.ll | 5 +++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 624e1a5..b91f613 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1193,10 +1193,15 @@ void DwarfDebug::finalizeModuleInfo() { auto *CUNode = cast(P.first); // If compile Unit has macros, emit "DW_AT_macro_info" attribute. - if (CUNode->getMacros() && !useSplitDwarf()) - U.addSectionLabel(U.getUnitDie(), dwarf::DW_AT_macro_info, - U.getMacroLabelBegin(), - TLOF.getDwarfMacinfoSection()->getBeginSymbol()); + if (CUNode->getMacros()) + if (useSplitDwarf()) + TheCU.addLabelDelta(TheCU.getUnitDie(), dwarf::DW_AT_macro_info, + U.getMacroLabelBegin(), + TLOF.getDwarfMacinfoDWOSection()->getBeginSymbol()); + else + U.addSectionLabel(U.getUnitDie(), dwarf::DW_AT_macro_info, + U.getMacroLabelBegin(), + TLOF.getDwarfMacinfoSection()->getBeginSymbol()); } // Emit all frontend-produced Skeleton CUs, i.e., Clang modules. diff --git a/llvm/test/DebugInfo/X86/debug-macinfo-split-dwarf.ll b/llvm/test/DebugInfo/X86/debug-macinfo-split-dwarf.ll index 07a5322..43255f2 100644 --- a/llvm/test/DebugInfo/X86/debug-macinfo-split-dwarf.ll +++ b/llvm/test/DebugInfo/X86/debug-macinfo-split-dwarf.ll @@ -1,5 +1,10 @@ ; RUN: %llc_dwarf -O0 -split-dwarf-file=foo.dwo -filetype=obj < %s | llvm-dwarfdump -v - | FileCheck %s +; CHECK-LABEL:.debug_info.dwo contents: +; CHECK: DW_AT_GNU_dwo_name [DW_FORM_GNU_str_index] (indexed (00000006) string = "foo.dwo") +; CHECK-NEXT: DW_AT_GNU_dwo_id [DW_FORM_data8] (0xe0f109905cbe1fe4) +; CHECK-NEXT: DW_AT_macro_info [DW_FORM_data4] (0x00000000) + ;CHECK-LABEL:.debug_macinfo.dwo contents: ;CHECK-NEXT: DW_MACINFO_start_file - lineno: 0 filenum: 1 ;CHECK-NEXT: DW_MACINFO_start_file - lineno: 1 filenum: 2 -- 2.7.4