[PATCH] D97564: [WebAssembly] Fix split-dwarf not emitting DW_OP_WASM_location correctly
Wouter van Oortmerssen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 26 09:56:09 PST 2021
aardappel created this revision.
aardappel added a reviewer: dschuff.
Herald added subscribers: ecnelises, sunfish, hiraditya, jgravelle-google, sbc100.
aardappel requested review of this revision.
Herald added subscribers: llvm-commits, aheejin.
Herald added a project: LLVM.
It was using the regular path for target indices that uses uleb, but TI_GLOBAL_RELOC needs to be uint32_t.
Introduced here: https://reviews.llvm.org/D85685
Fixes: https://github.com/emscripten-core/emscripten/issues/13240
https://reviews.llvm.org/D97564
Files:
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
Index: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -447,10 +447,7 @@
// 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;
- // FIXME: when writing dwo, we need to avoid relocations. Probably
- // the "right" solution is to treat globals the way func and data symbols
- // are (with entries in .debug_addr).
- if (FrameBase.Location.WasmLoc.Kind == TI_GLOBAL_RELOC && !isDwoUnit()) {
+ 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>(
@@ -468,8 +465,17 @@
DIELoc *Loc = new (DIEValueAllocator) DIELoc;
addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_WASM_location);
addSInt(*Loc, dwarf::DW_FORM_sdata, TI_GLOBAL_RELOC);
- addLabel(*Loc, dwarf::DW_FORM_data4, SPSym);
- DD->addArangeLabel(SymbolCU(this, SPSym));
+ 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
+ // symbols are (with entries in .debug_addr).
+ // For now, since we only ever use index 0, this should work as-is.
+ addUInt(*Loc, dwarf::DW_FORM_data4,
+ FrameBase.Location.WasmLoc.Index);
+ }
addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_stack_value);
addBlock(*SPDie, dwarf::DW_AT_frame_base, Loc);
} else {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97564.326726.patch
Type: text/x-patch
Size: 1970 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210226/657991b6/attachment.bin>
More information about the llvm-commits
mailing list