-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Omit .debug_aranges if it is empty #99897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-debuginfo Author: Edd Dawson (playstation-edd) ChangesSIE tracker: https://jira.sie.sony.com/browse/TOOLCHAIN-16575 Full diff: https://github.com/llvm/llvm-project/pull/99897.diff 2 Files Affected:
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_
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems quite reasonable. LGTM.
if (List.size() < 1) | ||
continue; | ||
assert(!List.empty()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After convincing myself that any List
must be non-empty, I was confident that the early return
could be placed above this loop. I replaced the dead check with an assert to avoid similar head scratching in future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the assert is appropriate even without the early return. If ArangeLabels is empty, SectionMap will also be empty, and the loop body will not execute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, agreed. Just wanted to explain why I touched this seemingly unrelated part, for posterity.
Some of SIE's post-mortem analysis infrastructure currently makes use of .debug_aranges, so we'd like to ensure the section's presence in PlayStation binaries. The simplest way to do this is to force emission when the debugger tuning is set to SCE (which is in turn typically initialized from the target triple). This also simplifies the driver. llvm/test/DebugInfo/debuglineinfo-path.ll has been marked as UNSUPPORTED on PlayStation. When aranges are emitted, the DWARF in the test case is such that relocations need to be applied to the aranges section in order for symbolization to work. An alternative approach would be to implement the application of relocations in DWARFDebugArangeSet. While experiments show that this can be made to work with a modest patch, the test cases would be rather contrived. Since I expect the only utility for such a change would be to make this test case pass for PlayStation targets, and few - if any - outside of PlayStation care about aranges, UNSUPPORTED would seem to be a more practical option. This was originally commited as 22eb290 (llvm#99629) and later reverted at 84658fb (llvm#99711) due to test failures on SIE built bots. These failures shouldn't recur due to 3b24e5d (llvm#99897) and the aforementioned change to debuglineinfo-path.ll. SIE tracker: TOOLCHAIN-16951
…100160) Some of SIE's post-mortem analysis infrastructure currently makes use of .debug_aranges, so we'd like to ensure the section's presence in PlayStation binaries. The simplest way to do this is to force emission when the debugger tuning is set to SCE (which is in turn typically initialized from the target triple). This also simplifies the driver. llvm/test/DebugInfo/debuglineinfo-path.ll has been marked as UNSUPPORTED on PlayStation. When aranges are emitted, the DWARF in the test case is such that relocations need to be applied to the aranges section in order for symbolization to work. An alternative approach would be to implement the application of relocations in DWARFDebugArangeSet. While experiments show that this can be made to work with a modest patch, the test cases would be rather contrived. Since I expect the only utility for such a change would be to make this test case pass for PlayStation targets, and few - if any - outside of PlayStation care about aranges, UNSUPPORTED would seem to be a more practical option. This was originally commited as 22eb290 (#99629) and later reverted at 84658fb (#99711) due to test failures on SIE built bots. These failures shouldn't recur due to 3b24e5d (#99897) and the aforementioned change to debuglineinfo-path.ll. SIE tracker: TOOLCHAIN-16951
Summary: SIE tracker: https://jira.sie.sony.com/browse/TOOLCHAIN-16575 Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251220
…100160) Summary: Some of SIE's post-mortem analysis infrastructure currently makes use of .debug_aranges, so we'd like to ensure the section's presence in PlayStation binaries. The simplest way to do this is to force emission when the debugger tuning is set to SCE (which is in turn typically initialized from the target triple). This also simplifies the driver. llvm/test/DebugInfo/debuglineinfo-path.ll has been marked as UNSUPPORTED on PlayStation. When aranges are emitted, the DWARF in the test case is such that relocations need to be applied to the aranges section in order for symbolization to work. An alternative approach would be to implement the application of relocations in DWARFDebugArangeSet. While experiments show that this can be made to work with a modest patch, the test cases would be rather contrived. Since I expect the only utility for such a change would be to make this test case pass for PlayStation targets, and few - if any - outside of PlayStation care about aranges, UNSUPPORTED would seem to be a more practical option. This was originally commited as 22eb290 (#99629) and later reverted at 84658fb (#99711) due to test failures on SIE built bots. These failures shouldn't recur due to 3b24e5d (#99897) and the aforementioned change to debuglineinfo-path.ll. SIE tracker: TOOLCHAIN-16951 Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60250743
SIE tracker: https://jira.sie.sony.com/browse/TOOLCHAIN-16575