Skip to content

Commit

Permalink
Omit .debug_aranges if it is empty (llvm#99897)
Browse files Browse the repository at this point in the history
  • Loading branch information
playstation-edd authored and sgundapa committed Jul 23, 2024
1 parent 558e480 commit 67f8f46
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2990,6 +2990,9 @@ struct ArangeSpan {
// Emit a debug aranges section, containing a CU lookup for any
// address we can tie back to a CU.
void DwarfDebug::emitDebugARanges() {
if (ArangeLabels.empty())
return;

// Provides a unique id per text section.
MapVector<MCSection *, SmallVector<SymbolCU, 8>> SectionMap;

Expand All @@ -3012,8 +3015,7 @@ void DwarfDebug::emitDebugARanges() {
for (auto &I : SectionMap) {
MCSection *Section = I.first;
SmallVector<SymbolCU, 8> &List = I.second;
if (List.size() < 1)
continue;
assert(!List.empty());

// If we have no section (e.g. common), just write out
// individual spans for each symbol.
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/DebugInfo/omit-empty.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: %llc_dwarf %s -filetype=obj -o - | llvm-objdump -h - | FileCheck %s
; RUN: %llc_dwarf %s -filetype=obj -generate-arange-section -o - | llvm-objdump -h - | FileCheck %s
; REQUIRES: object-emission

; CHECK-NOT: .debug_
Expand Down

0 comments on commit 67f8f46

Please sign in to comment.