summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWouter van Oortmerssen <aardappel@gmail.com>2021-11-08 15:27:14 -0800
committerWouter van Oortmerssen <aardappel@gmail.com>2021-11-08 15:55:17 -0800
commita630217313fcd38fa0071206ab832c081d0eac37 (patch)
tree98c8726c31a687fe0ee07b3956116edc18f08400
parent4a0c89a6cf8f368583f9c0724dbcb04fb17204ec (diff)
downloadllvm-aranges.tar.gz
[WebAssembly] fix __stack_pointer being added to .debug_arangesaranges
When emitting a reloc for the Wasm global __stack_pointer, it was inadvertedly added to the symbols used for generating aranges, which caused some aranges to use it as the end symbol in a symbol diff, which caused a reloc for it to be emitted, which then caused an assert in `wasm64` since we have no 64-bit relocs for Wasm globals. Fixes: https://bugs.llvm.org/show_bug.cgi?id=52376 Differential Revision: https://reviews.llvm.org/D113438
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp1
-rw-r--r--llvm/test/MC/WebAssembly/debug-info.ll52
-rw-r--r--llvm/test/MC/WebAssembly/debug-info64.ll54
3 files changed, 71 insertions, 36 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index b4c27dc86d8d..f51fb041f559 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -490,7 +490,6 @@ DIE &DwarfCompileUnit::updateSubprogramScopeDIE(const DISubprogram *SP) {
addSInt(*Loc, dwarf::DW_FORM_sdata, TI_GLOBAL_RELOC);
if (!isDwoUnit()) {
addLabel(*Loc, dwarf::DW_FORM_data4, SPSym);
- DD->addArangeLabel(SymbolCU(this, SPSym));
} else {
// FIXME: when writing dwo, we need to avoid relocations. Probably
// the "right" solution is to treat globals the way func and data
diff --git a/llvm/test/MC/WebAssembly/debug-info.ll b/llvm/test/MC/WebAssembly/debug-info.ll
index a4a9ed9ed193..d2a815f09716 100644
--- a/llvm/test/MC/WebAssembly/debug-info.ll
+++ b/llvm/test/MC/WebAssembly/debug-info.ll
@@ -1,4 +1,4 @@
-; RUN: llc -filetype=obj %s -o - | llvm-readobj -S -r --symbols - | FileCheck %s
+; RUN: llc -generate-arange-section -filetype=obj %s -o - | llvm-readobj -S -r --symbols - | FileCheck %s
; CHECK: Format: WASM
; CHECK-NEXT:Arch: wasm32
@@ -65,68 +65,80 @@
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
-; CHECK-NEXT: Size: 121
+; CHECK-NEXT: Size: 48
; CHECK-NEXT: Offset: 406
+; CHECK-NEXT: Name: .debug_aranges
+; CHECK-NEXT: }
+; CHECK-NEXT: Section {
+; CHECK-NEXT: Type: CUSTOM (0x0)
+; CHECK-NEXT: Size: 121
+; CHECK-NEXT: Offset: 475
; CHECK-NEXT: Name: .debug_str
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 42
-; CHECK-NEXT: Offset: 544
+; CHECK-NEXT: Offset: 613
; CHECK-NEXT: Name: .debug_pubnames
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 26
-; CHECK-NEXT: Offset: 608
+; CHECK-NEXT: Offset: 677
; CHECK-NEXT: Name: .debug_pubtypes
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 57
-; CHECK-NEXT: Offset: 656
+; CHECK-NEXT: Offset: 725
; CHECK-NEXT: Name: .debug_line
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 91
-; CHECK-NEXT: Offset: 731
+; CHECK-NEXT: Offset: 800
; CHECK-NEXT: Name: linking
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 9
-; CHECK-NEXT: Offset: 836
+; CHECK-NEXT: Offset: 905
; CHECK-NEXT: Name: reloc.DATA
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 61
-; CHECK-NEXT: Offset: 862
+; CHECK-NEXT: Offset: 931
; CHECK-NEXT: Name: reloc..debug_info
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
+; CHECK-NEXT: Size: 18
+; CHECK-NEXT: Offset: 1016
+; CHECK-NEXT: Name: reloc..debug_aranges
+; CHECK-NEXT: }
+; CHECK-NEXT: Section {
+; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 6
-; CHECK-NEXT: Offset: 947
+; CHECK-NEXT: Offset: 1061
; CHECK-NEXT: Name: reloc..debug_pubnames
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 6
-; CHECK-NEXT: Offset: 981
+; CHECK-NEXT: Offset: 1095
; CHECK-NEXT: Name: reloc..debug_pubtypes
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 6
-; CHECK-NEXT: Offset: 1015
+; CHECK-NEXT: Offset: 1129
; CHECK-NEXT: Name: reloc..debug_line
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 77
-; CHECK-NEXT: Offset: 1045
+; CHECK-NEXT: Offset: 1159
; CHECK-NEXT: Name: producers
; CHECK-NEXT: }
; CHECK-NEXT:]
@@ -151,13 +163,19 @@
; CHECK-NEXT: 0x66 R_WASM_GLOBAL_INDEX_I32 __stack_pointer
; CHECK-NEXT: 0x6B R_WASM_SECTION_OFFSET_I32 .debug_str 118
; CHECK-NEXT: }
-; CHECK-NEXT: Section (11) .debug_pubnames {
+; CHECK-NEXT: Section (10) .debug_aranges {
+; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0
+; CHECK-NEXT: 0x10 R_WASM_MEMORY_ADDR_I32 foo 0
+; CHECK-NEXT: 0x18 R_WASM_MEMORY_ADDR_I32 ptr2 0
+; CHECK-NEXT: 0x20 R_WASM_FUNCTION_OFFSET_I32 f2 0
+; CHECK-NEXT: }
+; CHECK-NEXT: Section (12) .debug_pubnames {
; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0
; CHECK-NEXT: }
-; CHECK-NEXT: Section (12) .debug_pubtypes {
+; CHECK-NEXT: Section (13) .debug_pubtypes {
; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0
; CHECK-NEXT: }
-; CHECK-NEXT: Section (13) .debug_line {
+; CHECK-NEXT: Section (14) .debug_line {
; CHECK-NEXT: 0x2B R_WASM_FUNCTION_OFFSET_I32 f2 0
; CHECK-NEXT: }
; CHECK-NEXT:]
@@ -228,7 +246,7 @@
; CHECK-NEXT: Flags [ (0x2)
; CHECK-NEXT: BINDING_LOCAL (0x2)
; CHECK-NEXT: ]
-; CHECK-NEXT: ElementIndex: 0x9
+; CHECK-NEXT: ElementIndex: 0xA
; CHECK-NEXT: }
; CHECK-NEXT: Symbol {
; CHECK-NEXT: Name: .debug_line
@@ -236,7 +254,7 @@
; CHECK-NEXT: Flags [ (0x2)
; CHECK-NEXT: BINDING_LOCAL (0x2)
; CHECK-NEXT: ]
-; CHECK-NEXT: ElementIndex: 0xC
+; CHECK-NEXT: ElementIndex: 0xD
; CHECK-NEXT: }
; CHECK-NEXT:]
diff --git a/llvm/test/MC/WebAssembly/debug-info64.ll b/llvm/test/MC/WebAssembly/debug-info64.ll
index 60fa0cbfe987..47b33aac104c 100644
--- a/llvm/test/MC/WebAssembly/debug-info64.ll
+++ b/llvm/test/MC/WebAssembly/debug-info64.ll
@@ -1,4 +1,4 @@
-; RUN: llc -filetype=obj %s -o - | llvm-readobj -S -r --symbols - | FileCheck %s
+; RUN: llc -generate-arange-section -filetype=obj %s -o - | llvm-readobj -S -r --symbols - | FileCheck %s
; CHECK: Format: WASM
; CHECK-NEXT: Arch: wasm64
@@ -65,74 +65,86 @@
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
-; CHECK-NEXT: Size: 121
+; CHECK-NEXT: Size: 80
; CHECK-NEXT: Offset: 430
+; CHECK-NEXT: Name: .debug_aranges
+; CHECK-NEXT: }
+; CHECK-NEXT: Section {
+; CHECK-NEXT: Type: CUSTOM (0x0)
+; CHECK-NEXT: Size: 121
+; CHECK-NEXT: Offset: 531
; CHECK-NEXT: Name: .debug_str
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 42
-; CHECK-NEXT: Offset: 568
+; CHECK-NEXT: Offset: 669
; CHECK-NEXT: Name: .debug_pubnames
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 26
-; CHECK-NEXT: Offset: 632
+; CHECK-NEXT: Offset: 733
; CHECK-NEXT: Name: .debug_pubtypes
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 61
-; CHECK-NEXT: Offset: 680
+; CHECK-NEXT: Offset: 781
; CHECK-NEXT: Name: .debug_line
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 91
-; CHECK-NEXT: Offset: 759
+; CHECK-NEXT: Offset: 860
; CHECK-NEXT: Name: linking
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 9
-; CHECK-NEXT: Offset: 864
+; CHECK-NEXT: Offset: 965
; CHECK-NEXT: Name: reloc.DATA
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 61
-; CHECK-NEXT: Offset: 890
+; CHECK-NEXT: Offset: 991
; CHECK-NEXT: Name: reloc..debug_info
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
+; CHECK-NEXT: Size: 18
+; CHECK-NEXT: Offset: 1076
+; CHECK-NEXT: Name: reloc..debug_aranges
+; CHECK-NEXT: }
+; CHECK-NEXT: Section {
+; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 6
-; CHECK-NEXT: Offset: 975
+; CHECK-NEXT: Offset: 1121
; CHECK-NEXT: Name: reloc..debug_pubnames
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 6
-; CHECK-NEXT: Offset: 1009
+; CHECK-NEXT: Offset: 1155
; CHECK-NEXT: Name: reloc..debug_pubtypes
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 6
-; CHECK-NEXT: Offset: 1043
+; CHECK-NEXT: Offset: 1189
; CHECK-NEXT: Name: reloc..debug_line
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 77
-; CHECK-NEXT: Offset: 1073
+; CHECK-NEXT: Offset: 1219
; CHECK-NEXT: Name: producers
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 11
-; CHECK-NEXT: Offset: 1166
+; CHECK-NEXT: Offset: 1312
; CHECK-NEXT: Name: target_features
; CHECK-NEXT: }
; CHECK-NEXT: ]
@@ -157,13 +169,19 @@
; CHECK-NEXT: 0x76 R_WASM_GLOBAL_INDEX_I32 __stack_pointer
; CHECK-NEXT: 0x7B R_WASM_SECTION_OFFSET_I32 .debug_str 118
; CHECK-NEXT: }
-; CHECK-NEXT: Section (11) .debug_pubnames {
+; CHECK-NEXT: Section (10) .debug_aranges {
+; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0
+; CHECK-NEXT: 0x10 R_WASM_MEMORY_ADDR_I64 foo 0
+; CHECK-NEXT: 0x20 R_WASM_MEMORY_ADDR_I64 ptr2 0
+; CHECK-NEXT: 0x30 R_WASM_FUNCTION_OFFSET_I64 f2 0
+; CHECK-NEXT: }
+; CHECK-NEXT: Section (12) .debug_pubnames {
; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0
; CHECK-NEXT: }
-; CHECK-NEXT: Section (12) .debug_pubtypes {
+; CHECK-NEXT: Section (13) .debug_pubtypes {
; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0
; CHECK-NEXT: }
-; CHECK-NEXT: Section (13) .debug_line {
+; CHECK-NEXT: Section (14) .debug_line {
; CHECK-NEXT: 0x2B R_WASM_FUNCTION_OFFSET_I64 f2 0
; CHECK-NEXT: }
; CHECK-NEXT: ]
@@ -234,7 +252,7 @@
; CHECK-NEXT: Flags [ (0x2)
; CHECK-NEXT: BINDING_LOCAL (0x2)
; CHECK-NEXT: ]
-; CHECK-NEXT: ElementIndex: 0x9
+; CHECK-NEXT: ElementIndex: 0xA
; CHECK-NEXT: }
; CHECK-NEXT: Symbol {
; CHECK-NEXT: Name: .debug_line
@@ -242,7 +260,7 @@
; CHECK-NEXT: Flags [ (0x2)
; CHECK-NEXT: BINDING_LOCAL (0x2)
; CHECK-NEXT: ]
-; CHECK-NEXT: ElementIndex: 0xC
+; CHECK-NEXT: ElementIndex: 0xD
; CHECK-NEXT: }
; CHECK-NEXT: ]