From 36e7b7e277f1680cac47fd9dabb9d27146940b4e Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 8 Nov 2019 15:26:17 -0800 Subject: [PATCH] DebugInfo: Do not create a debug_macinfo section if no CUs have associated macros Patch based on Sourabh Singh's D69839 patch. --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 6 ++-- test/DebugInfo/NVPTX/cu-range-hole.ll | 5 ++- test/DebugInfo/NVPTX/debug-addr-class.ll | 5 ++- test/DebugInfo/NVPTX/debug-file-loc.ll | 5 ++- test/DebugInfo/NVPTX/debug-info.ll | 5 ++- test/DebugInfo/NVPTX/debug-loc-offset.ll | 5 ++- test/DebugInfo/RISCV/dwarf-riscv-relocs.ll | 6 ++-- test/DebugInfo/X86/empty_macinfo.ll | 5 ++- .../DebugInfo/X86/length_symbol_difference.ll | 1 - test/MC/WebAssembly/debug-info.ll | 34 ++++++++----------- 10 files changed, 31 insertions(+), 46 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index d17dd4dc3f7..56615584a18 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/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"); diff --git a/test/DebugInfo/NVPTX/cu-range-hole.ll b/test/DebugInfo/NVPTX/cu-range-hole.ll index 6849ffdc1e4..b3ca58e124d 100644 --- a/test/DebugInfo/NVPTX/cu-range-hole.ll +++ b/test/DebugInfo/NVPTX/cu-range-hole.ll @@ -269,9 +269,8 @@ entry: ; CHECK-NEXT: .b8 4 // DW_AT_byte_size ; CHECK-NEXT: .b8 0 // End Of Children Mark ; CHECK-NEXT: } -; CHECK-NEXT: .section .debug_macinfo -; CHECK-NEXT: { -; CHECK-NEXT: } +; CHECK-NEXT: .section .debug_loc { } +; CHECK-NOT: debug_ attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } attributes #1 = { nounwind readnone } diff --git a/test/DebugInfo/NVPTX/debug-addr-class.ll b/test/DebugInfo/NVPTX/debug-addr-class.ll index 50bdc2af164..c56fcda46dd 100644 --- a/test/DebugInfo/NVPTX/debug-addr-class.ll +++ b/test/DebugInfo/NVPTX/debug-addr-class.ll @@ -331,7 +331,6 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) ; CHECK-NEXT: .b8 4 // DW_AT_byte_size ; CHECK-NEXT: .b8 0 // End Of Children Mark ; CHECK-NEXT: } -; CHECK-NEXT: .section .debug_macinfo -; CHECK-NEXT: { -; CHECK-NEXT: } +; CHECK-NEXT: .section .debug_loc { } +; CHECK-NOT: debug_ diff --git a/test/DebugInfo/NVPTX/debug-file-loc.ll b/test/DebugInfo/NVPTX/debug-file-loc.ll index 124aaa097b4..09d47b3847a 100644 --- a/test/DebugInfo/NVPTX/debug-file-loc.ll +++ b/test/DebugInfo/NVPTX/debug-file-loc.ll @@ -86,9 +86,8 @@ bb: ; CHECK-NEXT: .b64 Lfunc_begin0 // DW_AT_low_pc ; CHECK-NEXT: .b64 Lfunc_end1 // DW_AT_high_pc ; CHECK-NEXT: } -; CHECK-NEXT: .section .debug_macinfo -; CHECK-NEXT: { -; CHECK-NEXT: } +; CHECK-NEXT: .section .debug_loc { } +; CHECK-NOT: debug_ !llvm.dbg.cu = !{!0} !llvm.module.flags = !{!8, !9} diff --git a/test/DebugInfo/NVPTX/debug-info.ll b/test/DebugInfo/NVPTX/debug-info.ll index 85a73e5d197..9a572ff8ac7 100644 --- a/test/DebugInfo/NVPTX/debug-info.ll +++ b/test/DebugInfo/NVPTX/debug-info.ll @@ -8401,9 +8401,8 @@ if.end: ; preds = %if.then, %entry ; CHECK-NEXT: .b8 0 // End Of Children Mark ; CHECK-NEXT: .b8 0 // End Of Children Mark ; CHECK-NEXT: } -; CHECK-NEXT: .section .debug_macinfo -; CHECK-NEXT: { -; CHECK-NEXT: } +; CHECK-NEXT: .section .debug_loc { } +; CHECK-NOT: debug_ ; Function Attrs: nounwind readnone declare i32 @llvm.nvvm.read.ptx.sreg.ctaid.x() #1 diff --git a/test/DebugInfo/NVPTX/debug-loc-offset.ll b/test/DebugInfo/NVPTX/debug-loc-offset.ll index cb18ffe64af..d1a9a3df156 100644 --- a/test/DebugInfo/NVPTX/debug-loc-offset.ll +++ b/test/DebugInfo/NVPTX/debug-loc-offset.ll @@ -470,6 +470,5 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n ; CHECK-NEXT: .b8 4 // DW_AT_byte_size ; CHECK-NEXT: .b8 0 // End Of Children Mark ; CHECK-NEXT: } -; CHECK-NEXT: .section .debug_macinfo -; CHECK-NEXT: { -; CHECK-NEXT: } +; CHECK-NEXT: .section .debug_loc { } +; CHECK-NOT: debug_ diff --git a/test/DebugInfo/RISCV/dwarf-riscv-relocs.ll b/test/DebugInfo/RISCV/dwarf-riscv-relocs.ll index e8c9b6cff42..ab2a3009dda 100644 --- a/test/DebugInfo/RISCV/dwarf-riscv-relocs.ll +++ b/test/DebugInfo/RISCV/dwarf-riscv-relocs.ll @@ -5,13 +5,13 @@ ; RUN: FileCheck -check-prefix=DWARF-DUMP %s ; Check that we actually have relocations, otherwise this is kind of pointless. -; READOBJ-RELOCS: Section (8) .rela.debug_info { +; READOBJ-RELOCS: Section ({{.*}}) .rela.debug_info { ; READOBJ-RELOCS: 0x1B R_RISCV_ADD32 - 0x0 ; READOBJ-RELOCS-NEXT: 0x1B R_RISCV_SUB32 - 0x0 -; READOBJ-RELOCS: Section (15) .rela.debug_frame { +; READOBJ-RELOCS: Section ({{.*}}) .rela.debug_frame { ; READOBJ-RELOCS: 0x20 R_RISCV_ADD32 - 0x0 ; READOBJ-RELOCS-NEXT: 0x20 R_RISCV_SUB32 - 0x0 -; READOBJ-RELOCS: Section (17) .rela.debug_line { +; READOBJ-RELOCS: Section ({{.*}}) .rela.debug_line { ; READOBJ-RELOCS: 0x5A R_RISCV_ADD16 - 0x0 ; READOBJ-RELOCS-NEXT: 0x5A R_RISCV_SUB16 - 0x0 diff --git a/test/DebugInfo/X86/empty_macinfo.ll b/test/DebugInfo/X86/empty_macinfo.ll index 40cd1449c87..9cde5cdfac7 100644 --- a/test/DebugInfo/X86/empty_macinfo.ll +++ b/test/DebugInfo/X86/empty_macinfo.ll @@ -2,9 +2,8 @@ ; Test that we don't pollute the start of the file with debug sections -; CHECK: .section .debug_macinfo,"",@progbits -; CHECK-NEXT: .section -; CHECK-NOT: .debug_macinfo +; CHECK-NOT: macinfo +; CHECK-NOT: macro define void @f() !dbg !4 { ret void, !dbg !9 diff --git a/test/DebugInfo/X86/length_symbol_difference.ll b/test/DebugInfo/X86/length_symbol_difference.ll index 78684e788cf..6736c5017b4 100644 --- a/test/DebugInfo/X86/length_symbol_difference.ll +++ b/test/DebugInfo/X86/length_symbol_difference.ll @@ -5,7 +5,6 @@ ; CHECK-NOT: .byte 0 ; CHECK: .byte 0 # End Of Children Mark ; CHECK-NEXT: .Ldebug_info_end0: -; CHECK-NEXT: .section define dso_local void @_Z2f1v() !dbg !7 { diff --git a/test/MC/WebAssembly/debug-info.ll b/test/MC/WebAssembly/debug-info.ll index 749184c548a..6121c2aeec7 100644 --- a/test/MC/WebAssembly/debug-info.ll +++ b/test/MC/WebAssembly/debug-info.ll @@ -71,68 +71,62 @@ ; CHECK-NEXT: } ; CHECK-NEXT: Section { ; CHECK-NEXT: Type: CUSTOM (0x0) -; CHECK-NEXT: Size: 0 -; CHECK-NEXT: Offset: 511 -; CHECK-NEXT: Name: .debug_macinfo -; CHECK-NEXT: } -; CHECK-NEXT: Section { -; CHECK-NEXT: Type: CUSTOM (0x0) ; CHECK-NEXT: Size: 42 -; CHECK-NEXT: Offset: 532 +; CHECK-NEXT: Offset: 511 ; CHECK-NEXT: Name: .debug_pubnames ; CHECK-NEXT: } ; CHECK-NEXT: Section { ; CHECK-NEXT: Type: CUSTOM (0x0) ; CHECK-NEXT: Size: 26 -; CHECK-NEXT: Offset: 596 +; CHECK-NEXT: Offset: 575 ; CHECK-NEXT: Name: .debug_pubtypes ; CHECK-NEXT: } ; CHECK-NEXT: Section { ; CHECK-NEXT: Type: CUSTOM (0x0) ; CHECK-NEXT: Size: 57 -; CHECK-NEXT: Offset: 644 +; CHECK-NEXT: Offset: 623 ; CHECK-NEXT: Name: .debug_line ; CHECK-NEXT: } ; CHECK-NEXT: Section { ; CHECK-NEXT: Type: CUSTOM (0x0) ; CHECK-NEXT: Size: 88 -; CHECK-NEXT: Offset: 719 +; CHECK-NEXT: Offset: 698 ; CHECK-NEXT: Name: linking ; CHECK-NEXT: } ; CHECK-NEXT: Section { ; CHECK-NEXT: Type: CUSTOM (0x0) ; CHECK-NEXT: Size: 9 -; CHECK-NEXT: Offset: 821 +; CHECK-NEXT: Offset: 800 ; CHECK-NEXT: Name: reloc.DATA ; CHECK-NEXT: } ; CHECK-NEXT: Section { ; CHECK-NEXT: Type: CUSTOM (0x0) ; CHECK-NEXT: Size: 58 -; CHECK-NEXT: Offset: 847 +; CHECK-NEXT: Offset: 826 ; CHECK-NEXT: Name: reloc..debug_info ; CHECK-NEXT: } ; CHECK-NEXT: Section { ; CHECK-NEXT: Type: CUSTOM (0x0) ; CHECK-NEXT: Size: 6 -; CHECK-NEXT: Offset: 929 +; CHECK-NEXT: Offset: 908 ; CHECK-NEXT: Name: reloc..debug_pubnames ; CHECK-NEXT: } ; CHECK-NEXT: Section { ; CHECK-NEXT: Type: CUSTOM (0x0) ; CHECK-NEXT: Size: 6 -; CHECK-NEXT: Offset: 963 +; CHECK-NEXT: Offset: 942 ; CHECK-NEXT: Name: reloc..debug_pubtypes ; CHECK-NEXT: } ; CHECK-NEXT: Section { ; CHECK-NEXT: Type: CUSTOM (0x0) ; CHECK-NEXT: Size: 6 -; CHECK-NEXT: Offset: 997 +; CHECK-NEXT: Offset: 976 ; CHECK-NEXT: Name: reloc..debug_line ; CHECK-NEXT: } ; CHECK-NEXT: Section { ; CHECK-NEXT: Type: CUSTOM (0x0) ; CHECK-NEXT: Size: 77 -; CHECK-NEXT: Offset: 1027 +; CHECK-NEXT: Offset: 1006 ; CHECK-NEXT: Name: producers ; CHECK-NEXT: } ; CHECK-NEXT:] @@ -156,13 +150,13 @@ ; CHECK-NEXT: 0x5B R_WASM_FUNCTION_OFFSET_I32 f2 0 ; CHECK-NEXT: 0x63 R_WASM_SECTION_OFFSET_I32 .debug_str 118 ; CHECK-NEXT: } -; CHECK-NEXT: Section (12) .debug_pubnames { +; CHECK-NEXT: Section (11) .debug_pubnames { ; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0 ; CHECK-NEXT: } -; CHECK-NEXT: Section (13) .debug_pubtypes { +; CHECK-NEXT: Section (12) .debug_pubtypes { ; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0 ; CHECK-NEXT: } -; CHECK-NEXT: Section (14) .debug_line { +; CHECK-NEXT: Section (13) .debug_line { ; CHECK-NEXT: 0x2B R_WASM_FUNCTION_OFFSET_I32 f2 0 ; CHECK-NEXT: } ; CHECK-NEXT:] @@ -234,7 +228,7 @@ ; CHECK-NEXT: Flags [ (0x2) ; CHECK-NEXT: BINDING_LOCAL (0x2) ; CHECK-NEXT: ] -; CHECK-NEXT: ElementIndex: 0xD +; CHECK-NEXT: ElementIndex: 0xC ; CHECK-NEXT: } ; CHECK-NEXT:]