[llvm] Omit .debug_aranges if it is empty (PR #99897)
Edd Dawson via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 22 09:53:38 PDT 2024
https://github.com/playstation-edd created https://github.com/llvm/llvm-project/pull/99897
SIE tracker: https://jira.sie.sony.com/browse/TOOLCHAIN-16575
>From 5fdbc568fde551a3f70c2261e96c9d3b0cd9091f Mon Sep 17 00:00:00 2001
From: Edd Dawson <edd.dawson at sony.com>
Date: Mon, 22 Jul 2024 17:50:58 +0100
Subject: [PATCH] Omit .debug_aranges if it is empty
SIE tracker: https://jira.sie.sony.com/browse/TOOLCHAIN-16575
---
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 6 ++++--
llvm/test/DebugInfo/omit-empty.ll | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 80cd5ec501f25..f88653146cc6f 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -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;
@@ -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.
diff --git a/llvm/test/DebugInfo/omit-empty.ll b/llvm/test/DebugInfo/omit-empty.ll
index 0267ec5556f11..351d3055e039b 100644
--- a/llvm/test/DebugInfo/omit-empty.ll
+++ b/llvm/test/DebugInfo/omit-empty.ll
@@ -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_
More information about the llvm-commits
mailing list