1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[WebAssembly] Add int32 DW_OP_WASM_location variant

This to allow us to add reloctable global indices as a symbol.
Also adds R_WASM_GLOBAL_INDEX_I32 relocation type to support it.

See discussion in https://github.com/WebAssembly/debugging/issues/12
This commit is contained in:
Wouter van Oortmerssen 2020-03-19 19:53:51 -07:00
parent 47f56f6e10
commit 2d2a0b49b2
23 changed files with 140 additions and 71 deletions

View File

@ -664,6 +664,7 @@ HANDLE_DW_OP(0xa9, reinterpret, 5, DWARF)
HANDLE_DW_OP(0xe0, GNU_push_tls_address, 0, GNU)
// Extensions for WebAssembly.
HANDLE_DW_OP(0xed, WASM_location, 0, WASM)
HANDLE_DW_OP(0xee, WASM_location_int, 0, WASM)
// The GNU entry value extension.
HANDLE_DW_OP(0xf3, GNU_entry_value, 0, GNU)
// Extensions for Fission proposal.

View File

@ -15,3 +15,4 @@ WASM_RELOC(R_WASM_SECTION_OFFSET_I32, 9)
WASM_RELOC(R_WASM_EVENT_INDEX_LEB, 10)
WASM_RELOC(R_WASM_MEMORY_ADDR_REL_SLEB, 11)
WASM_RELOC(R_WASM_TABLE_INDEX_REL_SLEB, 12)
WASM_RELOC(R_WASM_GLOBAL_INDEX_I32, 13)

View File

@ -42,6 +42,7 @@ public:
SizeRefAddr = 6,
SizeBlock = 7, ///< Preceding operand contains block size
BaseTypeRef = 8,
WasmLocationArg = 30,
SignBit = 0x80,
SignedSize1 = SignBit | Size1,
SignedSize2 = SignBit | Size2,

View File

@ -37,6 +37,7 @@
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCSymbolWasm.h"
#include "llvm/MC/MachineLocation.h"
#include "llvm/Support/Casting.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
@ -420,13 +421,37 @@ DIE &DwarfCompileUnit::updateSubprogramScopeDIE(const DISubprogram *SP) {
break;
}
case TargetFrameLowering::DwarfFrameBase::WasmFrameBase: {
DIELoc *Loc = new (DIEValueAllocator) DIELoc;
DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
DIExpressionCursor Cursor({});
DwarfExpr.addWasmLocation(FrameBase.Location.WasmLoc.Kind,
FrameBase.Location.WasmLoc.Index);
DwarfExpr.addExpression(std::move(Cursor));
addBlock(*SPDie, dwarf::DW_AT_frame_base, DwarfExpr.finalize());
// FIXME: duplicated from Target/WebAssembly/WebAssembly.h
// don't want to depend on target specific headers in this code?
const unsigned TI_GLOBAL_RELOC = 3;
if (FrameBase.Location.WasmLoc.Kind == TI_GLOBAL_RELOC) {
// These need to be relocatable.
assert(FrameBase.Location.WasmLoc.Index == 0); // Only SP so far.
auto SPSym = cast<MCSymbolWasm>(
Asm->GetExternalSymbolSymbol("__stack_pointer"));
// FIXME: this repeats what WebAssemblyMCInstLower::
// GetExternalSymbolSymbol does, since if there's no code that
// refers to this symbol, we have to set it here.
SPSym->setType(wasm::WASM_SYMBOL_TYPE_GLOBAL);
// FIXME: need to check subtarget to see if its wasm64, but we
// can't cast to WebAssemblySubtarget here.
SPSym->setGlobalType(wasm::WasmGlobalType{wasm::WASM_TYPE_I32, true});
DIELoc *Loc = new (DIEValueAllocator) DIELoc;
addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_WASM_location);
addSInt(*Loc, dwarf::DW_FORM_sdata, FrameBase.Location.WasmLoc.Kind);
addLabel(*Loc, dwarf::DW_FORM_udata, SPSym);
DD->addArangeLabel(SymbolCU(this, SPSym));
addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_stack_value);
addBlock(*SPDie, dwarf::DW_AT_frame_base, Loc);
} else {
DIELoc *Loc = new (DIEValueAllocator) DIELoc;
DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
DIExpressionCursor Cursor({});
DwarfExpr.addWasmLocation(FrameBase.Location.WasmLoc.Kind,
FrameBase.Location.WasmLoc.Index);
DwarfExpr.addExpression(std::move(Cursor));
addBlock(*SPDie, dwarf::DW_AT_frame_base, DwarfExpr.finalize());
}
break;
}
}

View File

@ -2400,7 +2400,7 @@ void DwarfDebug::emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT,
TargetIndexLocation Loc = Value.getTargetIndexLocation();
// TODO TargetIndexLocation is a target-independent. Currently only the WebAssembly-specific
// encoding is supported.
DwarfExpr.addWasmLocation(Loc.Index, Loc.Offset);
DwarfExpr.addWasmLocation(Loc.Index, static_cast<uint64_t>(Loc.Offset));
} else if (Value.isConstantFP()) {
APInt RawBytes = Value.getConstantFP()->getValueAPF().bitcastToAPInt();
DwarfExpr.addUnsignedConstant(RawBytes);

View File

@ -582,10 +582,10 @@ void DwarfExpression::emitLegacyZExt(unsigned FromBits) {
emitOp(dwarf::DW_OP_and);
}
void DwarfExpression::addWasmLocation(unsigned Index, int64_t Offset) {
void DwarfExpression::addWasmLocation(unsigned Index, uint64_t Offset) {
assert(LocationKind == Implicit || LocationKind == Unknown);
LocationKind = Implicit;
emitOp(dwarf::DW_OP_WASM_location);
emitUnsigned(Index);
emitSigned(Offset);
emitUnsigned(Offset);
}

View File

@ -342,7 +342,7 @@ public:
/// Emit location information expressed via WebAssembly location + offset
/// The Index is an identifier for locals, globals or operand stack.
void addWasmLocation(unsigned Index, int64_t Offset);
void addWasmLocation(unsigned Index, uint64_t Offset);
};
/// DwarfExpression implementation for .debug_loc entries.

View File

@ -94,7 +94,7 @@ static DescVector getDescriptions() {
Desc(Op::Dwarf3, Op::SizeLEB, Op::SizeBlock);
Descriptions[DW_OP_stack_value] = Desc(Op::Dwarf3);
Descriptions[DW_OP_WASM_location] =
Desc(Op::Dwarf4, Op::SizeLEB, Op::SignedSizeLEB);
Desc(Op::Dwarf4, Op::SizeLEB, Op::WasmLocationArg);
Descriptions[DW_OP_GNU_push_tls_address] = Desc(Op::Dwarf3);
Descriptions[DW_OP_addrx] = Desc(Op::Dwarf4, Op::SizeLEB);
Descriptions[DW_OP_GNU_addr_index] = Desc(Op::Dwarf4, Op::SizeLEB);
@ -170,6 +170,19 @@ bool DWARFExpression::Operation::extract(DataExtractor Data,
case Operation::BaseTypeRef:
Operands[Operand] = Data.getULEB128(&Offset);
break;
case Operation::WasmLocationArg:
assert(Operand == 1);
switch (Operands[0]) {
case 0: case 1: case 2:
Operands[Operand] = Data.getULEB128(&Offset);
break;
case 3: // global as uint32
Operands[Operand] = Data.getU32(&Offset);
break;
default:
return false; // Unknown Wasm location
}
break;
case Operation::SizeBlock:
// We need a size, so this cannot be the first operand
if (Operand == 0)
@ -273,6 +286,15 @@ bool DWARFExpression::Operation::print(raw_ostream &OS,
OS << " 0x0";
else
prettyPrintBaseTypeRef(U, OS, Operands, Operand);
} else if (Size == Operation::WasmLocationArg) {
assert(Operand == 1);
switch (Operands[0]) {
case 0: case 1: case 2:
case 3: // global as uint32
OS << format(" 0x%" PRIx64, Operands[Operand]);
break;
default: assert(false);
}
} else if (Size == Operation::SizeBlock) {
uint64_t Offset = Operands[Operand];
for (unsigned i = 0; i < Operands[Operand - 1]; ++i)

View File

@ -537,7 +537,9 @@ static const MCSymbolWasm *resolveSymbol(const MCSymbolWasm &Symbol) {
// useable.
uint32_t
WasmObjectWriter::getProvisionalValue(const WasmRelocationEntry &RelEntry) {
if (RelEntry.Type == wasm::R_WASM_GLOBAL_INDEX_LEB && !RelEntry.Symbol->isGlobal()) {
if ((RelEntry.Type == wasm::R_WASM_GLOBAL_INDEX_LEB ||
RelEntry.Type == wasm::R_WASM_GLOBAL_INDEX_I32) &&
!RelEntry.Symbol->isGlobal()) {
assert(GOTIndices.count(RelEntry.Symbol) > 0 && "symbol not found in GOT index space");
return GOTIndices[RelEntry.Symbol];
}
@ -556,6 +558,7 @@ WasmObjectWriter::getProvisionalValue(const WasmRelocationEntry &RelEntry) {
return getRelocationIndexValue(RelEntry);
case wasm::R_WASM_FUNCTION_INDEX_LEB:
case wasm::R_WASM_GLOBAL_INDEX_LEB:
case wasm::R_WASM_GLOBAL_INDEX_I32:
case wasm::R_WASM_EVENT_INDEX_LEB:
// Provisional value is function/global/event Wasm index
assert(WasmIndices.count(RelEntry.Symbol) > 0 && "symbol not found in wasm index space");
@ -660,6 +663,7 @@ void WasmObjectWriter::applyRelocations(
case wasm::R_WASM_MEMORY_ADDR_I32:
case wasm::R_WASM_FUNCTION_OFFSET_I32:
case wasm::R_WASM_SECTION_OFFSET_I32:
case wasm::R_WASM_GLOBAL_INDEX_I32:
writeI32(Stream, Value, Offset);
break;
case wasm::R_WASM_TABLE_INDEX_SLEB:

View File

@ -498,6 +498,7 @@ static bool supportsWasm32(uint64_t Type) {
case wasm::R_WASM_FUNCTION_OFFSET_I32:
case wasm::R_WASM_SECTION_OFFSET_I32:
case wasm::R_WASM_EVENT_INDEX_LEB:
case wasm::R_WASM_GLOBAL_INDEX_I32:
return true;
default:
return false;
@ -517,6 +518,7 @@ static uint64_t resolveWasm32(RelocationRef R, uint64_t S, uint64_t A) {
case wasm::R_WASM_FUNCTION_OFFSET_I32:
case wasm::R_WASM_SECTION_OFFSET_I32:
case wasm::R_WASM_EVENT_INDEX_LEB:
case wasm::R_WASM_GLOBAL_INDEX_I32:
// For wasm section, its offset at 0 -- ignoring Value
return A;
default:

View File

@ -798,6 +798,11 @@ Error WasmObjectFile::parseRelocSection(StringRef Name, ReadContext &Ctx) {
return make_error<GenericBinaryError>("Bad relocation global index",
object_error::parse_failed);
break;
case wasm::R_WASM_GLOBAL_INDEX_I32:
if (!isValidGlobalSymbol(Reloc.Index))
return make_error<GenericBinaryError>("Bad relocation global index",
object_error::parse_failed);
break;
case wasm::R_WASM_EVENT_INDEX_LEB:
if (!isValidEventSymbol(Reloc.Index))
return make_error<GenericBinaryError>("Bad relocation event index",
@ -837,7 +842,8 @@ Error WasmObjectFile::parseRelocSection(StringRef Name, ReadContext &Ctx) {
if (Reloc.Type == wasm::R_WASM_TABLE_INDEX_I32 ||
Reloc.Type == wasm::R_WASM_MEMORY_ADDR_I32 ||
Reloc.Type == wasm::R_WASM_SECTION_OFFSET_I32 ||
Reloc.Type == wasm::R_WASM_FUNCTION_OFFSET_I32)
Reloc.Type == wasm::R_WASM_FUNCTION_OFFSET_I32 ||
Reloc.Type == wasm::R_WASM_GLOBAL_INDEX_I32)
Size = 4;
if (Reloc.Offset + Size > EndOffset)
return make_error<GenericBinaryError>("Bad relocation offset",

View File

@ -530,12 +530,7 @@ void WasmWriter::writeRelocSection(raw_ostream &OS, WasmYAML::Section &Sec,
writeUint8(OS, Reloc.Type);
encodeULEB128(Reloc.Offset, OS);
encodeULEB128(Reloc.Index, OS);
switch (Reloc.Type) {
case wasm::R_WASM_MEMORY_ADDR_LEB:
case wasm::R_WASM_MEMORY_ADDR_SLEB:
case wasm::R_WASM_MEMORY_ADDR_I32:
case wasm::R_WASM_FUNCTION_OFFSET_I32:
case wasm::R_WASM_SECTION_OFFSET_I32:
if (wasm::relocTypeHasAddend(Reloc.Type)) {
encodeULEB128(Reloc.Addend, OS);
}
}

View File

@ -103,6 +103,8 @@ unsigned WebAssemblyWasmObjectWriter::getRelocType(const MCValue &Target,
case FK_Data_4:
if (SymA.isFunction())
return wasm::R_WASM_TABLE_INDEX_I32;
if (SymA.isGlobal())
return wasm::R_WASM_GLOBAL_INDEX_I32;
if (auto Section = static_cast<const MCSectionWasm *>(
getFixupSection(Fixup.getValue()))) {
if (Section->getKind().isText())

View File

@ -78,7 +78,16 @@ void initializeWebAssemblyRegNumberingPass(PassRegistry &);
void initializeWebAssemblyPeepholePass(PassRegistry &);
namespace WebAssembly {
enum TargetIndex { TI_LOCAL_START, TI_GLOBAL_START, TI_OPERAND_STACK_START };
enum TargetIndex {
// Followed by a local index (ULEB).
TI_LOCAL,
// Followed by an absolute global index (ULEB). DEPRECATED.
TI_GLOBAL_FIXED,
TI_OPERAND_STACK,
// Followed by a compilation unit relative global index (uint32_t)
// that will have an associated relocation.
TI_GLOBAL_RELOC
};
} // end namespace WebAssembly
} // end namespace llvm

View File

@ -48,6 +48,6 @@ void WebAssemblyDebugValueManager::clone(MachineInstr *Insert,
void WebAssemblyDebugValueManager::replaceWithLocal(unsigned LocalId) {
for (auto *DBI : DbgValues) {
MachineOperand &Op = DBI->getOperand(0);
Op.ChangeToTargetIndex(llvm::WebAssembly::TI_LOCAL_START, LocalId);
Op.ChangeToTargetIndex(llvm::WebAssembly::TI_LOCAL, LocalId);
}
}

View File

@ -266,12 +266,11 @@ WebAssemblyFrameLowering::getDwarfFrameBase(const MachineFunction &MF) const {
const WebAssemblyFunctionInfo &MFI = *MF.getInfo<WebAssemblyFunctionInfo>();
if (needsSP(MF) && MFI.isFrameBaseVirtual()) {
unsigned LocalNum = MFI.getFrameBaseLocal();
Loc.Location.WasmLoc = {WebAssembly::TI_LOCAL_START, LocalNum};
Loc.Location.WasmLoc = {WebAssembly::TI_LOCAL, LocalNum};
} else {
// TODO: This should work on a breakpoint at a function with no frame,
// but probably won't work for traversing up the stack.
// TODO: This needs a relocation for correct __stack_pointer
Loc.Location.WasmLoc = {WebAssembly::TI_GLOBAL_START, 0};
Loc.Location.WasmLoc = {WebAssembly::TI_GLOBAL_RELOC, 0};
}
return Loc;
}

View File

@ -235,8 +235,9 @@ bool WebAssemblyInstrInfo::reverseBranchCondition(
ArrayRef<std::pair<int, const char *>>
WebAssemblyInstrInfo::getSerializableTargetIndices() const {
static const std::pair<int, const char *> TargetIndices[] = {
{WebAssembly::TI_LOCAL_START, "wasm-local-start"},
{WebAssembly::TI_GLOBAL_START, "wasm-global-start"},
{WebAssembly::TI_OPERAND_STACK_START, "wasm-operator-stack-start"}};
{WebAssembly::TI_LOCAL, "wasm-local"},
{WebAssembly::TI_GLOBAL_FIXED, "wasm-global-fixed"},
{WebAssembly::TI_OPERAND_STACK, "wasm-operand-stack"},
{WebAssembly::TI_GLOBAL_RELOC, "wasm-global-reloc"}};
return makeArrayRef(TargetIndices);
}

View File

@ -11,7 +11,7 @@
; CHECK-NEXT: DW_AT_low_pc
; CHECK-NEXT: DW_AT_high_pc
;; Check that we fall back to the default frame base (the global)
; CHECK-NEXT: DW_AT_frame_base (DW_OP_WASM_location 0x1 +0, DW_OP_stack_value)
; CHECK-NEXT: DW_AT_frame_base (DW_OP_WASM_location_int 0x3 0x0, DW_OP_stack_value)
; TODO: Find a more-reduced test case for The fix in WebAssemblyRegColoring

View File

@ -21,11 +21,11 @@ for.body: ; preds = %entry, %for.body
%a.010 = phi i32 [ %b.011, %for.body ], [ 0, %entry ]
%i.09 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
; CHECK: DW_OP_WASM_location 0x0 +[[LOCAL_1:[0-9]+]]
; CHECK: DW_OP_WASM_location 0x0 0x[[LOCAL_1:[0-9]+]]
call void @llvm.dbg.value(metadata i32 %b.011, metadata !16, metadata !DIExpression()), !dbg !19
; CHECK-NOT: DW_OP_WASM_location 0x0 +[[LOCAL_1]]
; CHECK: DW_OP_WASM_location 0x0 +[[LOCAL_2:[0-9]+]]
; CHECK-NOT: DW_OP_WASM_location 0x0 0x[[LOCAL_1]]
; CHECK: DW_OP_WASM_location 0x0 0x[[LOCAL_2:[0-9]+]]
%add = add nsw i32 %b.011, %a.010, !dbg !26
%inc = add nuw nsw i32 %i.09, 1, !dbg !28
call void @llvm.dbg.value(metadata i32 %add, metadata !16, metadata !DIExpression()), !dbg !19

View File

@ -11,33 +11,33 @@
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: IMPORT (0x2)
; CHECK-NEXT: Size: 58
; 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: 82
; CHECK-NEXT: Offset: 105
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: ELEM (0x9)
; CHECK-NEXT: Size: 7
; CHECK-NEXT: Offset: 90
; CHECK-NEXT: Offset: 113
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: DATACOUNT (0xC)
; CHECK-NEXT: Size: 1
; CHECK-NEXT: Offset: 103
; CHECK-NEXT: Offset: 126
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CODE (0xA)
; CHECK-NEXT: Size: 4
; CHECK-NEXT: Offset: 110
; CHECK-NEXT: Offset: 133
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: DATA (0xB)
; CHECK-NEXT: Size: 19
; CHECK-NEXT: Offset: 120
; CHECK-NEXT: Offset: 143
; CHECK-NEXT: Segments [
; CHECK-NEXT: Segment {
; CHECK-NEXT: Name: .data.foo
@ -54,79 +54,79 @@
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 86
; CHECK-NEXT: Offset: 145
; CHECK-NEXT: Offset: 168
; CHECK-NEXT: Name: .debug_abbrev
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 111
; CHECK-NEXT: Offset: 251
; CHECK-NEXT: Size: 114
; CHECK-NEXT: Offset: 274
; CHECK-NEXT: Name: .debug_info
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 121
; CHECK-NEXT: Offset: 380
; CHECK-NEXT: Offset: 406
; CHECK-NEXT: Name: .debug_str
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 42
; CHECK-NEXT: Offset: 518
; CHECK-NEXT: Offset: 544
; CHECK-NEXT: Name: .debug_pubnames
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 26
; CHECK-NEXT: Offset: 582
; CHECK-NEXT: Offset: 608
; CHECK-NEXT: Name: .debug_pubtypes
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 57
; CHECK-NEXT: Offset: 630
; CHECK-NEXT: Offset: 656
; CHECK-NEXT: Name: .debug_line
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 88
; CHECK-NEXT: Offset: 705
; CHECK-NEXT: Size: 91
; CHECK-NEXT: Offset: 731
; CHECK-NEXT: Name: linking
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 9
; CHECK-NEXT: Offset: 807
; CHECK-NEXT: Offset: 836
; CHECK-NEXT: Name: reloc.DATA
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 58
; CHECK-NEXT: Offset: 833
; CHECK-NEXT: Size: 61
; CHECK-NEXT: Offset: 862
; CHECK-NEXT: Name: reloc..debug_info
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 6
; CHECK-NEXT: Offset: 915
; CHECK-NEXT: Offset: 947
; CHECK-NEXT: Name: reloc..debug_pubnames
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 6
; CHECK-NEXT: Offset: 949
; CHECK-NEXT: Offset: 981
; CHECK-NEXT: Name: reloc..debug_pubtypes
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 6
; CHECK-NEXT: Offset: 983
; CHECK-NEXT: Offset: 1015
; CHECK-NEXT: Name: reloc..debug_line
; CHECK-NEXT: }
; CHECK-NEXT: Section {
; CHECK-NEXT: Type: CUSTOM (0x0)
; CHECK-NEXT: Size: 77
; CHECK-NEXT: Offset: 1013
; CHECK-NEXT: Offset: 1045
; CHECK-NEXT: Name: producers
; CHECK-NEXT: }
; CHECK-NEXT:]
@ -148,7 +148,8 @@
; CHECK-NEXT: 0x44 R_WASM_SECTION_OFFSET_I32 .debug_str 113
; CHECK-NEXT: 0x50 R_WASM_MEMORY_ADDR_I32 ptr2 0
; CHECK-NEXT: 0x5B R_WASM_FUNCTION_OFFSET_I32 f2 0
; CHECK-NEXT: 0x68 R_WASM_SECTION_OFFSET_I32 .debug_str 118
; 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: 0x6 R_WASM_SECTION_OFFSET_I32 .debug_info 0
@ -213,6 +214,16 @@
; 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)

View File

@ -80,7 +80,7 @@ attributes #2 = { nounwind }
; CHECK-LABEL: DW_TAG_subprogram
; CHECK-NEXT: DW_AT_low_pc (0x0000000000000002)
; CHECK-NEXT: DW_AT_high_pc (0x0000000000000039)
; CHECK-NEXT: DW_AT_frame_base (DW_OP_WASM_location 0x0 +1, DW_OP_stack_value)
; CHECK-NEXT: DW_AT_frame_base (DW_OP_WASM_location 0x0 0x1, DW_OP_stack_value)
; CHECK-NEXT: DW_AT_name ("foo")
; CHECK-NEXT: DW_AT_decl_file ("/s/llvm-upstream{{(/|\\)}}debugtest.c")
; CHECK-NEXT: DW_AT_decl_line (1)

View File

@ -1,7 +1,7 @@
; RUN: llc -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s
; CHECK: .debug_info contents:
; CHECK-NEXT: 0x00000000: Compile Unit: length = 0x0000006b version = 0x0004 abbr_offset = 0x0000 addr_size = 0x04 (next unit at 0x0000006f)
; CHECK-NEXT: 0x00000000: Compile Unit: length = 0x0000006e version = 0x0004 abbr_offset = 0x0000 addr_size = 0x04 (next unit at 0x00000072)
; CHECK: 0x0000000b: DW_TAG_compile_unit
; CHECK-NEXT: DW_AT_producer ("clang version 6.0.0 (trunk 315924) (llvm/trunk 315960)")
@ -46,14 +46,14 @@
; CHECK: 0x0000005a: DW_TAG_subprogram
; CHECK-NEXT: DW_AT_low_pc (0x0000000000000002)
; CHECK-NEXT: DW_AT_high_pc (0x0000000000000004)
; CHECK-NEXT: DW_AT_frame_base (DW_OP_WASM_location 0x1 +0, DW_OP_stack_value)
; CHECK-NEXT: DW_AT_frame_base (DW_OP_WASM_location 0x3 0x0, DW_OP_stack_value)
; CHECK-NEXT: DW_AT_name ("f2")
; CHECK-NEXT: DW_AT_decl_file ("/usr/local/google/home/sbc/dev/wasm/simple{{[/\\]}}test.c")
; CHECK-NEXT: DW_AT_decl_line (2)
; CHECK-NEXT: DW_AT_prototyped (true)
; CHECK-NEXT: DW_AT_external (true)
; CHECK: 0x0000006e: NULL
; CHECK: 0x00000071: NULL
target triple = "wasm32-unknown-unknown"

View File

@ -93,18 +93,8 @@ void WasmDumper::printRelocation(const SectionRef &Section,
if (SI != Obj->symbol_end())
SymName = unwrapOrError(Obj->getFileName(), SI->getName());
bool HasAddend = false;
switch (RelocType) {
case wasm::R_WASM_MEMORY_ADDR_LEB:
case wasm::R_WASM_MEMORY_ADDR_SLEB:
case wasm::R_WASM_MEMORY_ADDR_I32:
case wasm::R_WASM_FUNCTION_OFFSET_I32:
case wasm::R_WASM_SECTION_OFFSET_I32:
HasAddend = true;
break;
default:
break;
}
bool HasAddend = wasm::relocTypeHasAddend(static_cast<uint32_t>(RelocType));
if (opts::ExpandRelocs) {
DictScope Group(W, "Relocation");
W.printNumber("Type", RelocTypeName, RelocType);