[PATCH] D91203: [WebAssembly] Fixed wasm64 DWARF using 64-bit code pointer sizes
Wouter van Oortmerssen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 10 13:25:34 PST 2020
aardappel created this revision.
aardappel added reviewers: dschuff, sbc100, yurydelendik, dblaikie.
Herald added subscribers: llvm-commits, ecnelises, sunfish, hiraditya, jgravelle-google.
Herald added a project: LLVM.
aardappel requested review of this revision.
Herald added a subscriber: aheejin.
As per https://reviews.llvm.org/D90503, a "code pointer" is always 32-bit in Wasm.
The emitter for DW_FORM_addr used AsmPrinter::getPointerSize (which calls TargetMachine::getPointerSize and then DataLayout::getPointerSize) which is 64-bit. Since those last calls are non-virtual, there is no easy way to fix this path for Wasm.
Thus I added a AsmPrinter::getCodePointerSize which uses MCAsmInfo::getCodePointerSize instead, which hopefully should be correct for other platforms as well.
https://reviews.llvm.org/D91203
Files:
llvm/include/llvm/CodeGen/AsmPrinter.h
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/CodeGen/AsmPrinter/DIE.cpp
Index: llvm/lib/CodeGen/AsmPrinter/DIE.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DIE.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DIE.cpp
@@ -430,7 +430,7 @@
unsigned DIEInteger::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
assert(AP && "AsmPrinter is required to set FormParams");
dwarf::FormParams Params = {AP->getDwarfVersion(),
- uint8_t(AP->getPointerSize()),
+ uint8_t(AP->getCodePointerSize()),
AP->OutStreamer->getContext().getDwarfFormat()};
if (Optional<uint8_t> FixedSize = dwarf::getFixedFormByteSize(Form, Params))
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -221,6 +221,10 @@
return TM.getPointerSize(0); // FIXME: Default address space
}
+unsigned AsmPrinter::getCodePointerSize() const {
+ return MAI->getCodePointerSize();
+}
+
const MCSubtargetInfo &AsmPrinter::getSubtargetInfo() const {
assert(MF && "getSubtargetInfo requires a valid MachineFunction!");
return MF->getSubtarget<MCSubtargetInfo>();
Index: llvm/include/llvm/CodeGen/AsmPrinter.h
===================================================================
--- llvm/include/llvm/CodeGen/AsmPrinter.h
+++ llvm/include/llvm/CodeGen/AsmPrinter.h
@@ -256,6 +256,9 @@
/// Return the pointer size from the TargetMachine
unsigned getPointerSize() const;
+ /// Return the code pointer size from the TargetMachine
+ unsigned getCodePointerSize() const;
+
/// Return information about subtarget.
const MCSubtargetInfo &getSubtargetInfo() const;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91203.304316.patch
Type: text/x-patch
Size: 1779 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201110/06e4b92e/attachment.bin>
More information about the llvm-commits
mailing list