[llvm] 16f0243 - [WebAssembly] Added R_WASM_FUNCTION_OFFSET_I64 for use with DWARF DW_AT_low_pc
Wouter van Oortmerssen via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 13 09:33:10 PST 2020
Author: Wouter van Oortmerssen
Date: 2020-11-13T09:32:31-08:00
New Revision: 16f02431dc53af2b8acbc60d7cc1aafdad59a9f9
URL: https://github.com/llvm/llvm-project/commit/16f02431dc53af2b8acbc60d7cc1aafdad59a9f9
DIFF: https://github.com/llvm/llvm-project/commit/16f02431dc53af2b8acbc60d7cc1aafdad59a9f9.diff
LOG: [WebAssembly] Added R_WASM_FUNCTION_OFFSET_I64 for use with DWARF DW_AT_low_pc
Needed for wasm64, see discussion in https://reviews.llvm.org/D91203
Differential Revision: https://reviews.llvm.org/D91395
Added:
llvm/test/MC/WebAssembly/debug-info64.ll
Modified:
lld/wasm/InputChunks.cpp
lld/wasm/InputFiles.cpp
llvm/include/llvm/BinaryFormat/WasmRelocs.def
llvm/lib/BinaryFormat/Wasm.cpp
llvm/lib/MC/WasmObjectWriter.cpp
llvm/lib/Object/RelocationResolver.cpp
llvm/lib/Object/WasmObjectFile.cpp
llvm/lib/ObjectYAML/WasmEmitter.cpp
llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp
llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
llvm/test/MC/WebAssembly/dwarfdump64.ll
Removed:
################################################################################
diff --git a/lld/wasm/InputChunks.cpp b/lld/wasm/InputChunks.cpp
index f33178f29b31..06a734b69a97 100644
--- a/lld/wasm/InputChunks.cpp
+++ b/lld/wasm/InputChunks.cpp
@@ -97,6 +97,7 @@ void InputChunk::verifyRelocTargets() const {
break;
case R_WASM_TABLE_INDEX_I64:
case R_WASM_MEMORY_ADDR_I64:
+ case R_WASM_FUNCTION_OFFSET_I64:
existingValue = read64le(loc);
break;
default:
@@ -176,6 +177,7 @@ void InputChunk::writeTo(uint8_t *buf) const {
break;
case R_WASM_TABLE_INDEX_I64:
case R_WASM_MEMORY_ADDR_I64:
+ case R_WASM_FUNCTION_OFFSET_I64:
write64le(loc, value);
break;
default:
diff --git a/lld/wasm/InputFiles.cpp b/lld/wasm/InputFiles.cpp
index 3cf177532d84..57db39dd76fd 100644
--- a/lld/wasm/InputFiles.cpp
+++ b/lld/wasm/InputFiles.cpp
@@ -124,6 +124,7 @@ uint64_t ObjFile::calcNewAddend(const WasmRelocation &reloc) const {
case R_WASM_MEMORY_ADDR_I32:
case R_WASM_MEMORY_ADDR_I64:
case R_WASM_FUNCTION_OFFSET_I32:
+ case R_WASM_FUNCTION_OFFSET_I64:
return reloc.Addend;
case R_WASM_SECTION_OFFSET_I32:
return getSectionSymbol(reloc.Index)->section->outputOffset + reloc.Addend;
@@ -171,7 +172,8 @@ uint64_t ObjFile::calcExpectedValue(const WasmRelocation &reloc) const {
else
llvm_unreachable("unknown init expr opcode");
}
- case R_WASM_FUNCTION_OFFSET_I32: {
+ case R_WASM_FUNCTION_OFFSET_I32:
+ case R_WASM_FUNCTION_OFFSET_I64: {
const WasmSymbol &sym = wasmObj->syms()[reloc.Index];
InputFunction *f =
functions[sym.Info.ElementIndex - wasmObj->getNumImportedFunctions()];
@@ -258,7 +260,8 @@ uint64_t ObjFile::calcNewValue(const WasmRelocation &reloc) const {
return sym->getGOTIndex();
case R_WASM_EVENT_INDEX_LEB:
return getEventSymbol(reloc.Index)->getEventIndex();
- case R_WASM_FUNCTION_OFFSET_I32: {
+ case R_WASM_FUNCTION_OFFSET_I32:
+ case R_WASM_FUNCTION_OFFSET_I64: {
auto *f = cast<DefinedFunction>(sym);
return f->function->outputOffset +
(f->function->getFunctionCodeOffset() + reloc.Addend);
diff --git a/llvm/include/llvm/BinaryFormat/WasmRelocs.def b/llvm/include/llvm/BinaryFormat/WasmRelocs.def
index 4eb12684eaa6..dca63eca9455 100644
--- a/llvm/include/llvm/BinaryFormat/WasmRelocs.def
+++ b/llvm/include/llvm/BinaryFormat/WasmRelocs.def
@@ -24,3 +24,4 @@ WASM_RELOC(R_WASM_TABLE_INDEX_SLEB64, 18)
WASM_RELOC(R_WASM_TABLE_INDEX_I64, 19)
WASM_RELOC(R_WASM_TABLE_NUMBER_LEB, 20)
WASM_RELOC(R_WASM_MEMORY_ADDR_TLS_SLEB, 21)
+WASM_RELOC(R_WASM_FUNCTION_OFFSET_I64, 22)
diff --git a/llvm/lib/BinaryFormat/Wasm.cpp b/llvm/lib/BinaryFormat/Wasm.cpp
index a22ab5890922..126680ac41c2 100644
--- a/llvm/lib/BinaryFormat/Wasm.cpp
+++ b/llvm/lib/BinaryFormat/Wasm.cpp
@@ -50,6 +50,7 @@ bool llvm::wasm::relocTypeHasAddend(uint32_t Type) {
case R_WASM_MEMORY_ADDR_I64:
case R_WASM_MEMORY_ADDR_TLS_SLEB:
case R_WASM_FUNCTION_OFFSET_I32:
+ case R_WASM_FUNCTION_OFFSET_I64:
case R_WASM_SECTION_OFFSET_I32:
return true;
default:
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index 6bcec5f4c37c..0cf6e310ae32 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -478,6 +478,7 @@ void WasmObjectWriter::recordRelocation(MCAssembler &Asm,
// Currently only supported for for metadata sections.
// See: test/MC/WebAssembly/blockaddress.ll
if (Type == wasm::R_WASM_FUNCTION_OFFSET_I32 ||
+ Type == wasm::R_WASM_FUNCTION_OFFSET_I64 ||
Type == wasm::R_WASM_SECTION_OFFSET_I32) {
if (!FixupSection.getKind().isMetadata())
report_fatal_error("relocations for function or section offsets are "
@@ -564,6 +565,7 @@ WasmObjectWriter::getProvisionalValue(const WasmRelocationEntry &RelEntry,
assert(WasmIndices.count(RelEntry.Symbol) > 0 && "symbol not found in wasm index space");
return WasmIndices[RelEntry.Symbol];
case wasm::R_WASM_FUNCTION_OFFSET_I32:
+ case wasm::R_WASM_FUNCTION_OFFSET_I64:
case wasm::R_WASM_SECTION_OFFSET_I32: {
const auto &Section =
static_cast<const MCSectionWasm &>(RelEntry.Symbol->getSection());
@@ -680,6 +682,7 @@ void WasmObjectWriter::applyRelocations(
break;
case wasm::R_WASM_TABLE_INDEX_I64:
case wasm::R_WASM_MEMORY_ADDR_I64:
+ case wasm::R_WASM_FUNCTION_OFFSET_I64:
patchI64(Stream, Value, Offset);
break;
case wasm::R_WASM_TABLE_INDEX_SLEB:
diff --git a/llvm/lib/Object/RelocationResolver.cpp b/llvm/lib/Object/RelocationResolver.cpp
index d56e7be7043c..f39262bc9061 100644
--- a/llvm/lib/Object/RelocationResolver.cpp
+++ b/llvm/lib/Object/RelocationResolver.cpp
@@ -566,6 +566,7 @@ static bool supportsWasm64(uint64_t Type) {
case wasm::R_WASM_MEMORY_ADDR_I64:
case wasm::R_WASM_TABLE_INDEX_SLEB64:
case wasm::R_WASM_TABLE_INDEX_I64:
+ case wasm::R_WASM_FUNCTION_OFFSET_I64:
return true;
default:
return supportsWasm32(Type);
@@ -601,6 +602,7 @@ static uint64_t resolveWasm64(RelocationRef R, uint64_t S, uint64_t A) {
case wasm::R_WASM_MEMORY_ADDR_I64:
case wasm::R_WASM_TABLE_INDEX_SLEB64:
case wasm::R_WASM_TABLE_INDEX_I64:
+ case wasm::R_WASM_FUNCTION_OFFSET_I64:
// For wasm section, its offset at 0 -- ignoring Value
return A;
default:
diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp
index 63f2742e9215..82aa1f527fb8 100644
--- a/llvm/lib/Object/WasmObjectFile.cpp
+++ b/llvm/lib/Object/WasmObjectFile.cpp
@@ -876,6 +876,12 @@ Error WasmObjectFile::parseRelocSection(StringRef Name, ReadContext &Ctx) {
object_error::parse_failed);
Reloc.Addend = readVarint32(Ctx);
break;
+ case wasm::R_WASM_FUNCTION_OFFSET_I64:
+ if (!isValidFunctionSymbol(Reloc.Index))
+ return make_error<GenericBinaryError>("Bad relocation function index",
+ object_error::parse_failed);
+ Reloc.Addend = readVarint64(Ctx);
+ break;
case wasm::R_WASM_SECTION_OFFSET_I32:
if (!isValidSectionSymbol(Reloc.Index))
return make_error<GenericBinaryError>("Bad relocation section index",
@@ -903,7 +909,8 @@ Error WasmObjectFile::parseRelocSection(StringRef Name, ReadContext &Ctx) {
Reloc.Type == wasm::R_WASM_GLOBAL_INDEX_I32)
Size = 4;
if (Reloc.Type == wasm::R_WASM_TABLE_INDEX_I64 ||
- Reloc.Type == wasm::R_WASM_MEMORY_ADDR_I64)
+ Reloc.Type == wasm::R_WASM_MEMORY_ADDR_I64 ||
+ Reloc.Type == wasm::R_WASM_FUNCTION_OFFSET_I64)
Size = 8;
if (Reloc.Offset + Size > EndOffset)
return make_error<GenericBinaryError>("Bad relocation offset",
diff --git a/llvm/lib/ObjectYAML/WasmEmitter.cpp b/llvm/lib/ObjectYAML/WasmEmitter.cpp
index 81e24bfdaf84..7b21d56be503 100644
--- a/llvm/lib/ObjectYAML/WasmEmitter.cpp
+++ b/llvm/lib/ObjectYAML/WasmEmitter.cpp
@@ -547,6 +547,7 @@ void WasmWriter::writeRelocSection(raw_ostream &OS, WasmYAML::Section &Sec,
case wasm::R_WASM_MEMORY_ADDR_I32:
case wasm::R_WASM_MEMORY_ADDR_I64:
case wasm::R_WASM_FUNCTION_OFFSET_I32:
+ case wasm::R_WASM_FUNCTION_OFFSET_I64:
case wasm::R_WASM_SECTION_OFFSET_I32:
encodeULEB128(Reloc.Addend, OS);
}
diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp
index 7cbe9e38fb47..c3d259e6ff20 100644
--- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp
+++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp
@@ -23,9 +23,7 @@ WebAssemblyMCAsmInfo::~WebAssemblyMCAsmInfo() = default; // anchor.
WebAssemblyMCAsmInfo::WebAssemblyMCAsmInfo(const Triple &T,
const MCTargetOptions &Options) {
- CalleeSaveStackSlotSize = T.isArch64Bit() ? 8 : 4;
- // So far this is used for DWARF DW_AT_low_pc which is always 32-bit in Wasm.
- CodePointerSize = 4;
+ CodePointerSize = CalleeSaveStackSlotSize = T.isArch64Bit() ? 8 : 4;
// TODO: What should MaxInstLength be?
diff --git a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
index f0f5d9834771..aa7e2311d240 100644
--- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
+++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
@@ -131,7 +131,7 @@ unsigned WebAssemblyWasmObjectWriter::getRelocType(const MCValue &Target,
if (auto Section = static_cast<const MCSectionWasm *>(
getFixupSection(Fixup.getValue()))) {
if (Section->getKind().isText())
- llvm_unreachable("unimplemented R_WASM_FUNCTION_OFFSET_I64");
+ return wasm::R_WASM_FUNCTION_OFFSET_I64;
else if (!Section->isWasmData())
llvm_unreachable("unimplemented R_WASM_SECTION_OFFSET_I64");
}
diff --git a/llvm/test/MC/WebAssembly/debug-info64.ll b/llvm/test/MC/WebAssembly/debug-info64.ll
new file mode 100644
index 000000000000..48f46ee10694
--- /dev/null
+++ b/llvm/test/MC/WebAssembly/debug-info64.ll
@@ -0,0 +1,289 @@
+; RUN: llc -filetype=obj %s -o - | llvm-readobj -r -S --symbols - | FileCheck %s
+
+; CHECK: Format: WASM
+; CHECK-NEXT: Arch: wasm64
+; CHECK-NEXT: AddressSize: 64bit
+; CHECK-NEXT: Sections [
+; CHECK-NEXT: Section {
+; CHECK-NEXT: Type: TYPE (0x1)
+; CHECK-NEXT: Size: 4
+; CHECK-NEXT: Offset: 8
+; CHECK-NEXT: }
+; CHECK-NEXT: Section {
+; CHECK-NEXT: Type: IMPORT (0x2)
+; CHECK-NEXT: Size: 81
+; CHECK-NEXT: Offset: 18
+; CHECK-NEXT: }
+; CHECK-NEXT: Section {
+; CHECK-NEXT: Type: FUNCTION (0x3)
+; CHECK-NEXT: Size: 2
+; CHECK-NEXT: Offset: 105
+; CHECK-NEXT: }
+; CHECK-NEXT: Section {
+; CHECK-NEXT: Type: ELEM (0x9)
+; CHECK-NEXT: Size: 7
+; CHECK-NEXT: Offset: 113
+; CHECK-NEXT: }
+; CHECK-NEXT: Section {
+; CHECK-NEXT: Type: DATACOUNT (0xC)
+; CHECK-NEXT: Size: 1
+; CHECK-NEXT: Offset: 126
+; CHECK-NEXT: }
+; CHECK-NEXT: Section {
+; CHECK-NEXT: Type: CODE (0xA)
+; CHECK-NEXT: Size: 4
+; CHECK-NEXT: Offset: 133
+; CHECK-NEXT: }
+; CHECK-NEXT: Section {
+; CHECK-NEXT: Type: DATA (0xB)
+; CHECK-NEXT: Size: 27
+; CHECK-NEXT: Offset: 143
+; CHECK-NEXT: Segments [
+; CHECK-NEXT: Segment {
+; CHECK-NEXT: Name: .data.foo
+; CHECK-NEXT: Size: 8
+; CHECK-NEXT: Offset: 0
+; CHECK-NEXT: }
+; CHECK-NEXT: Segment {
+; CHECK-NEXT: Name: .data.ptr2
+; CHECK-NEXT: Size: 8
+; CHECK-NEXT: Offset: 8
+; CHECK-NEXT: }
+; CHECK-NEXT: ]
+; CHECK-NEXT: }
+; CHECK-NEXT: Section {
+; CHECK-NEXT: Type: CUSTOM (0x0)
+; CHECK-NEXT: Size: 86
+; CHECK-NEXT: Offset: 176
+; CHECK-NEXT: Name: .debug_abbrev
+; CHECK-NEXT: }
+; CHECK-NEXT: Section {
+; CHECK-NEXT: Type: CUSTOM (0x0)
+; CHECK-NEXT: Size: 130
+; CHECK-NEXT: Offset: 282
+; CHECK-NEXT: Name: .debug_info
+; CHECK-NEXT: }
+; CHECK-NEXT: Section {
+; CHECK-NEXT: Type: CUSTOM (0x0)
+; CHECK-NEXT: Size: 121
+; CHECK-NEXT: Offset: 430
+; 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: Name: .debug_pubnames
+; CHECK-NEXT: }
+; CHECK-NEXT: Section {
+; CHECK-NEXT: Type: CUSTOM (0x0)
+; CHECK-NEXT: Size: 26
+; CHECK-NEXT: Offset: 632
+; 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: Name: .debug_line
+; CHECK-NEXT: }
+; CHECK-NEXT: Section {
+; CHECK-NEXT: Type: CUSTOM (0x0)
+; CHECK-NEXT: Size: 91
+; CHECK-NEXT: Offset: 759
+; CHECK-NEXT: Name: linking
+; CHECK-NEXT: }
+; CHECK-NEXT: Section {
+; CHECK-NEXT: Type: CUSTOM (0x0)
+; CHECK-NEXT: Size: 9
+; CHECK-NEXT: Offset: 864
+; 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: Name: reloc..debug_info
+; CHECK-NEXT: }
+; CHECK-NEXT: Section {
+; CHECK-NEXT: Type: CUSTOM (0x0)
+; CHECK-NEXT: Size: 6
+; CHECK-NEXT: Offset: 975
+; 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: Name: reloc..debug_pubtypes
+; CHECK-NEXT: }
+; CHECK-NEXT: Section {
+; CHECK-NEXT: Type: CUSTOM (0x0)
+; CHECK-NEXT: Size: 6
+; CHECK-NEXT: Offset: 1043
+; 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: Name: producers
+; CHECK-NEXT: }
+; CHECK-NEXT: ]
+; CHECK-NEXT: Relocations [
+; CHECK-NEXT: Section (7) DATA {
+; CHECK-NEXT: 0x6 R_WASM_MEMORY_ADDR_I64 myextern 0
+; CHECK-NEXT: 0x13 R_WASM_TABLE_INDEX_I64 f2
+; CHECK-NEXT: }
+; CHECK-NEXT: Section (9) .debug_info {
+; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_abbrev 0
+; CHECK-NEXT: 0xC R_WASM_SECTION_OFFSET_I32 .debug_str 0
+; CHECK-NEXT: 0x12 R_WASM_SECTION_OFFSET_I32 .debug_str 55
+; CHECK-NEXT: 0x16 R_WASM_SECTION_OFFSET_I32 .debug_line 0
+; CHECK-NEXT: 0x1A R_WASM_SECTION_OFFSET_I32 .debug_str 62
+; CHECK-NEXT: 0x1E R_WASM_FUNCTION_OFFSET_I64 f2 0
+; CHECK-NEXT: 0x2B R_WASM_SECTION_OFFSET_I32 .debug_str 105
+; CHECK-NEXT: 0x37 R_WASM_MEMORY_ADDR_I64 foo 0
+; CHECK-NEXT: 0x45 R_WASM_SECTION_OFFSET_I32 .debug_str 109
+; CHECK-NEXT: 0x4C R_WASM_SECTION_OFFSET_I32 .debug_str 113
+; CHECK-NEXT: 0x58 R_WASM_MEMORY_ADDR_I64 ptr2 0
+; CHECK-NEXT: 0x67 R_WASM_FUNCTION_OFFSET_I64 f2 0
+; 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: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0
+; CHECK-NEXT: }
+; CHECK-NEXT: Section (12) .debug_pubtypes {
+; CHECK-NEXT: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0
+; CHECK-NEXT: }
+; CHECK-NEXT: Section (13) .debug_line {
+; CHECK-NEXT: 0x2B R_WASM_FUNCTION_OFFSET_I64 f2 0
+; CHECK-NEXT: }
+; CHECK-NEXT: ]
+; CHECK-NEXT: Symbols [
+; CHECK-NEXT: Symbol {
+; CHECK-NEXT: Name: f2
+; CHECK-NEXT: Type: FUNCTION (0x0)
+; CHECK-NEXT: Flags [ (0x4)
+; CHECK-NEXT: VISIBILITY_HIDDEN (0x4)
+; CHECK-NEXT: ]
+; CHECK-NEXT: ElementIndex: 0x0
+; CHECK-NEXT: }
+; CHECK-NEXT: Symbol {
+; CHECK-NEXT: Name: foo
+; CHECK-NEXT: Type: DATA (0x1)
+; CHECK-NEXT: Flags [ (0x4)
+; CHECK-NEXT: VISIBILITY_HIDDEN (0x4)
+; CHECK-NEXT: ]
+; CHECK-NEXT: Offset: 0x0
+; CHECK-NEXT: Segment: 0x0
+; CHECK-NEXT: Size: 0x8
+; CHECK-NEXT: }
+; CHECK-NEXT: Symbol {
+; CHECK-NEXT: Name: myextern
+; CHECK-NEXT: Type: DATA (0x1)
+; CHECK-NEXT: Flags [ (0x10)
+; CHECK-NEXT: UNDEFINED (0x10)
+; CHECK-NEXT: ]
+; CHECK-NEXT: }
+; CHECK-NEXT: Symbol {
+; CHECK-NEXT: Name: ptr2
+; CHECK-NEXT: Type: DATA (0x1)
+; CHECK-NEXT: Flags [ (0x4)
+; CHECK-NEXT: VISIBILITY_HIDDEN (0x4)
+; CHECK-NEXT: ]
+; CHECK-NEXT: Offset: 0x0
+; CHECK-NEXT: Segment: 0x1
+; CHECK-NEXT: Size: 0x8
+; CHECK-NEXT: }
+; CHECK-NEXT: Symbol {
+; CHECK-NEXT: Name: .debug_abbrev
+; CHECK-NEXT: Type: SECTION (0x3)
+; CHECK-NEXT: Flags [ (0x2)
+; CHECK-NEXT: BINDING_LOCAL (0x2)
+; CHECK-NEXT: ]
+; CHECK-NEXT: ElementIndex: 0x7
+; CHECK-NEXT: }
+; CHECK-NEXT: Symbol {
+; CHECK-NEXT: Name: .debug_info
+; CHECK-NEXT: Type: SECTION (0x3)
+; CHECK-NEXT: Flags [ (0x2)
+; CHECK-NEXT: BINDING_LOCAL (0x2)
+; CHECK-NEXT: ]
+; CHECK-NEXT: ElementIndex: 0x8
+; CHECK-NEXT: }
+; CHECK-NEXT: Symbol {
+; CHECK-NEXT: Name: __stack_pointer
+; CHECK-NEXT: Type: GLOBAL (0x2)
+; CHECK-NEXT: Flags [ (0x10)
+; CHECK-NEXT: UNDEFINED (0x10)
+; CHECK-NEXT: ]
+; CHECK-NEXT: ImportName: __stack_pointer
+; CHECK-NEXT: ImportModule: env
+; CHECK-NEXT: ElementIndex: 0x0
+; CHECK-NEXT: }
+; CHECK-NEXT: Symbol {
+; CHECK-NEXT: Name: .debug_str
+; CHECK-NEXT: Type: SECTION (0x3)
+; CHECK-NEXT: Flags [ (0x2)
+; CHECK-NEXT: BINDING_LOCAL (0x2)
+; CHECK-NEXT: ]
+; CHECK-NEXT: ElementIndex: 0x9
+; CHECK-NEXT: }
+; CHECK-NEXT: Symbol {
+; CHECK-NEXT: Name: .debug_line
+; CHECK-NEXT: Type: SECTION (0x3)
+; CHECK-NEXT: Flags [ (0x2)
+; CHECK-NEXT: BINDING_LOCAL (0x2)
+; CHECK-NEXT: ]
+; CHECK-NEXT: ElementIndex: 0xC
+; CHECK-NEXT: }
+; CHECK-NEXT: ]
+
+; generated from the following C code using: clang --target=wasm64 -g -O0 -S -emit-llvm test.c
+; extern int myextern;
+; void f2(void) { return; }
+;
+; int* foo = &myextern;
+; void (*ptr2)(void) = f2;
+
+target triple = "wasm64-unknown-unknown"
+
+source_filename = "test.c"
+
+ at myextern = external global i32, align 4
+ at foo = hidden global i32* @myextern, align 4, !dbg !0
+ at ptr2 = hidden global void ()* @f2, align 4, !dbg !6
+
+; Function Attrs: noinline nounwind optnone
+define hidden void @f2() #0 !dbg !17 {
+entry:
+ ret void, !dbg !18
+}
+
+attributes #0 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="generic" "unsafe-fp-math"="false" "use-soft-float"="false" }
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!13, !14, !15}
+!llvm.ident = !{!16}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "foo", scope: !2, file: !3, line: 4, type: !11, isLocal: false, isDefinition: true)
+!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 7.0.0 (trunk 332303) (llvm/trunk 332406)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
+!3 = !DIFile(filename: "test.c", directory: "/usr/local/google/home/sbc/dev/wasm/simple")
+!4 = !{}
+!5 = !{!0, !6}
+!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
+!7 = distinct !DIGlobalVariable(name: "ptr2", scope: !2, file: !3, line: 5, type: !8, isLocal: false, isDefinition: true)
+!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 32)
+!9 = !DISubroutineType(types: !10)
+!10 = !{null}
+!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 32)
+!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!13 = !{i32 2, !"Dwarf Version", i32 4}
+!14 = !{i32 2, !"Debug Info Version", i32 3}
+!15 = !{i32 1, !"wchar_size", i32 4}
+!16 = !{!"clang version 7.0.0 (trunk 332303) (llvm/trunk 332406)"}
+!17 = distinct !DISubprogram(name: "f2", scope: !3, file: !3, line: 2, type: !9, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !2, retainedNodes: !4)
+!18 = !DILocation(line: 2, column: 17, scope: !17)
diff --git a/llvm/test/MC/WebAssembly/dwarfdump64.ll b/llvm/test/MC/WebAssembly/dwarfdump64.ll
index 0166858c9134..ff711ed53988 100644
--- a/llvm/test/MC/WebAssembly/dwarfdump64.ll
+++ b/llvm/test/MC/WebAssembly/dwarfdump64.ll
@@ -2,7 +2,7 @@
; RUN: llc -filetype=obj %s -o - | llvm-dwarfdump --show-form - | FileCheck %s
; CHECK: .debug_info contents:
-; CHECK-NEXT: 0x00000000: Compile Unit: length = 0x0000006e, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x04 (next unit at 0x00000072)
+; CHECK-NEXT: 0x00000000: Compile Unit: length = 0x0000007e, format = DWARF32, version = 0x0004, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x00000082)
; CHECK: 0x0000000b: DW_TAG_compile_unit
; CHECK-NEXT: DW_AT_producer [DW_FORM_strp] ("clang version 6.0.0 (trunk 315924) (llvm/trunk 315960)")
@@ -11,46 +11,41 @@
; CHECK-NEXT: DW_AT_stmt_list [DW_FORM_sec_offset] (0x00000000)
; CHECK-NEXT: DW_AT_comp_dir [DW_FORM_strp] ("/usr/local/google/home/sbc/dev/wasm/simple")
; CHECK-NEXT: DW_AT_GNU_pubnames [DW_FORM_flag_present] (true)
-; CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x00000002)
+; CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000002)
; CHECK-NEXT: DW_AT_high_pc [DW_FORM_data4] (0x00000002)
-; CHECK: 0x00000026: DW_TAG_variable
+; CHECK: 0x0000002a: DW_TAG_variable
; CHECK-NEXT: DW_AT_name [DW_FORM_strp] ("foo")
-; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (0x00000037 "int*")
+; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (0x0000003f "int*")
; CHECK-NEXT: DW_AT_external [DW_FORM_flag_present] (true)
; CHECK-NEXT: DW_AT_decl_file [DW_FORM_data1] ("/usr/local/google/home/sbc/dev/wasm/simple{{[/\\]}}test.c")
; CHECK-NEXT: DW_AT_decl_line [DW_FORM_data1] (4)
; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc] (DW_OP_addr 0x0)
-; CHECK: 0x00000037: DW_TAG_pointer_type
-; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (0x0000003c "int")
+; CHECK: 0x0000003f: DW_TAG_pointer_type
+; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (0x00000044 "int")
-; CHECK: 0x0000003c: DW_TAG_base_type
+; CHECK: 0x00000044: DW_TAG_base_type
; CHECK-NEXT: DW_AT_name [DW_FORM_strp] ("int")
; CHECK-NEXT: DW_AT_encoding [DW_FORM_data1] (DW_ATE_signed)
; CHECK-NEXT: DW_AT_byte_size [DW_FORM_data1] (0x04)
-; CHECK: 0x00000043: DW_TAG_variable
+; CHECK: 0x0000004b: DW_TAG_variable
; CHECK-NEXT: DW_AT_name [DW_FORM_strp] ("ptr2")
-; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (0x00000054 "void()*")
+; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (0x00000060 "void()*")
; CHECK-NEXT: DW_AT_external [DW_FORM_flag_present] (true)
; CHECK-NEXT: DW_AT_decl_file [DW_FORM_data1] ("/usr/local/google/home/sbc/dev/wasm/simple{{[/\\]}}test.c")
; CHECK-NEXT: DW_AT_decl_line [DW_FORM_data1] (5)
-
-
-
-; TODO: is this correct?
-
; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc] (DW_OP_addr 0x8)
-; CHECK: 0x00000054: DW_TAG_pointer_type
-; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (0x00000059 "void()")
+; CHECK: 0x00000060: DW_TAG_pointer_type
+; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (0x00000065 "void()")
-; CHECK: 0x00000059: DW_TAG_subroutine_type
-; CHECK-NEXT: DW_AT_prototyped [DW_FORM_flag_present] (true)
+; CHECK: 0x00000065: DW_TAG_subroutine_type
+; CHECK-NEXT: DW_AT_prototyped [DW_FORM_flag_present] (true)
-; CHECK: 0x0000005a: DW_TAG_subprogram
-; CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x00000002)
+; CHECK: 0x00000066: DW_TAG_subprogram
+; CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000002)
; CHECK-NEXT: DW_AT_high_pc [DW_FORM_data4] (0x00000002)
; CHECK-NEXT: DW_AT_frame_base [DW_FORM_exprloc] (DW_OP_WASM_location 0x3 0x0, DW_OP_stack_value)
; CHECK-NEXT: DW_AT_name [DW_FORM_strp] ("f2")
@@ -59,7 +54,7 @@
; CHECK-NEXT: DW_AT_prototyped [DW_FORM_flag_present] (true)
; CHECK-NEXT: DW_AT_external [DW_FORM_flag_present] (true)
-; CHECK: 0x00000071: NULL
+; CHECK: 0x00000081: NULL
target triple = "wasm64-unknown-unknown"
More information about the llvm-commits
mailing list