aboutsummaryrefslogtreecommitdiff
path: root/llvm
diff options
context:
space:
mode:
authorEdd Dawson <edd.dawson@sony.com>2024-07-24 09:07:25 +0100
committerGitHub <noreply@github.com>2024-07-24 09:07:25 +0100
commit3993a47bb58f7b6da9940d084e62e54a821e81fc (patch)
tree4580c0a5f133efb1a1108b2f9916cd9b50c2209b /llvm
parentc34d673b02ead039acd107f096c1f32c16b61e07 (diff)
downloadllvm-3993a47bb58f7b6da9940d084e62e54a821e81fc.zip
llvm-3993a47bb58f7b6da9940d084e62e54a821e81fc.tar.gz
llvm-3993a47bb58f7b6da9940d084e62e54a821e81fc.tar.bz2
[PS4/PS5][Driver][DWARF] Always emit .debug_aranges for SCE tuning (#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 22eb290a96 (#99629) and later reverted at 84658fb82b (#99711) due to test failures on SIE built bots. These failures shouldn't recur due to 3b24e5d450 (#99897) and the aforementioned change to debuglineinfo-path.ll. SIE tracker: TOOLCHAIN-16951
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp5
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h3
-rw-r--r--llvm/test/DebugInfo/X86/debug-aranges-sce-tuning.test41
-rw-r--r--llvm/test/DebugInfo/debuglineinfo-path.ll5
4 files changed, 51 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index f886531..5f1f315 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -354,6 +354,9 @@ DwarfDebug::DwarfDebug(AsmPrinter *A)
UseLocSection = !TT.isNVPTX();
+ // Always emit .debug_aranges for SCE tuning.
+ UseARangesSection = GenerateARangeSection || tuneForSCE();
+
HasAppleExtensionAttributes = tuneForLLDB();
// Handle split DWARF.
@@ -1450,7 +1453,7 @@ void DwarfDebug::endModule() {
emitDebugInfo();
// Emit info into a debug aranges section.
- if (GenerateARangeSection)
+ if (UseARangesSection)
emitDebugARanges();
// Emit info into a debug ranges section.
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
index 452485b..13f4c37 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -435,6 +435,9 @@ class DwarfDebug : public DebugHandlerBase {
///Allow emission of the .debug_loc section.
bool UseLocSection = true;
+ /// Allow emission of .debug_aranges section
+ bool UseARangesSection = false;
+
/// Generate DWARF v4 type units.
bool GenerateTypeUnits;
diff --git a/llvm/test/DebugInfo/X86/debug-aranges-sce-tuning.test b/llvm/test/DebugInfo/X86/debug-aranges-sce-tuning.test
new file mode 100644
index 0000000..5729155
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/debug-aranges-sce-tuning.test
@@ -0,0 +1,41 @@
+# This checks that .debug_aranges is always generated for the SCE debugger
+# tuning.
+
+RUN: rm -rf %t && split-file %s %t && cd %t
+RUN: llc -debugger-tune=sce -filetype=obj foo.ll -o foo.o
+RUN: llvm-dwarfdump -debug-aranges foo.o | FileCheck %s
+
+CHECK: .debug_aranges contents:
+CHECK-NEXT: Address Range Header:
+CHECK-SAME: length = 0x0000002c,
+
+#--- foo.c
+int foo;
+
+#--- gen
+clang --target=x86_64-linux-gnu -g -S -emit-llvm foo.c -o -
+
+#--- foo.ll
+; ModuleID = 'foo.c'
+source_filename = "foo.c"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@foo = dso_local global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!6, !7, !8, !9, !10, !11, !12}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "foo", scope: !2, file: !3, line: 1, type: !5, isLocal: false, isDefinition: true)
+!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
+!3 = !DIFile(filename: "foo.c", directory: "/proc/self/cwd", checksumkind: CSK_MD5, checksum: "e0f2c326d820c28d30f9b0ea95178f64")
+!4 = !{!0}
+!5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!6 = !{i32 7, !"Dwarf Version", i32 5}
+!7 = !{i32 2, !"Debug Info Version", i32 3}
+!8 = !{i32 1, !"wchar_size", i32 4}
+!9 = !{i32 8, !"PIC Level", i32 2}
+!10 = !{i32 7, !"PIE Level", i32 2}
+!11 = !{i32 7, !"uwtable", i32 2}
+!12 = !{i32 7, !"frame-pointer", i32 2}
diff --git a/llvm/test/DebugInfo/debuglineinfo-path.ll b/llvm/test/DebugInfo/debuglineinfo-path.ll
index f6574a2..7e408af 100644
--- a/llvm/test/DebugInfo/debuglineinfo-path.ll
+++ b/llvm/test/DebugInfo/debuglineinfo-path.ll
@@ -1,8 +1,9 @@
; Make sure that absolute source dir is detected correctly regardless of the platform.
; On powerpc llvm-nm describes win_func as a global variable, not a function. It breaks the test.
-; It is not essential to DWARF path handling code we're testing here.
-; UNSUPPORTED: target=powerpc{{.*}}
+; On PlayStation, (pre-relocated) .debug_aranges cause symbolization to fail, also breaking the test.
+; These are not essential to DWARF path handling code we're testing here.
+; UNSUPPORTED: target=powerpc{{.*}}, target=x86_64-{{.*-ps[45]}}
; REQUIRES: object-emission
; RUN: %llc_dwarf -O0 -filetype=obj -o %t < %s
; RUN: llvm-nm --radix=o %t | grep posix_absolute_func > %t.posix_absolute_func