summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/wasm/wasm-debug.cpp12
-rw-r--r--third_party/llvm-project/DWARFEmitter.cpp4
-rw-r--r--third_party/llvm-project/include/llvm/ObjectYAML/DWARFYAML.h1
3 files changed, 14 insertions, 3 deletions
diff --git a/src/wasm/wasm-debug.cpp b/src/wasm/wasm-debug.cpp
index 448bcaaa9..2e7a10071 100644
--- a/src/wasm/wasm-debug.cpp
+++ b/src/wasm/wasm-debug.cpp
@@ -853,7 +853,8 @@ static void updateDIE(const llvm::DWARFDebugInfoEntry& DIE,
static void updateCompileUnits(const BinaryenDWARFInfo& info,
llvm::DWARFYAML::Data& yaml,
- LocationUpdater& locationUpdater) {
+ LocationUpdater& locationUpdater,
+ bool is64) {
// The context has the high-level information we need, and the YAML is where
// we write changes. First, iterate over the compile units.
size_t compileUnitIndex = 0;
@@ -862,6 +863,13 @@ static void updateCompileUnits(const BinaryenDWARFInfo& info,
yaml.CompileUnits,
[&](const std::unique_ptr<llvm::DWARFUnit>& CU,
llvm::DWARFYAML::Unit& yamlUnit) {
+ // Our Memory64Lowering pass may change the "architecture" of the DWARF
+ // data. AddrSize will cause all DW_AT_low_pc to be written as 32/64-bit.
+ auto NewAddrSize = is64 ? 8 : 4;
+ if (NewAddrSize != yamlUnit.AddrSize) {
+ yamlUnit.AddrSize = NewAddrSize;
+ yamlUnit.AddrSizeChanged = true;
+ }
// Process the DIEs in each compile unit.
iterContextAndYAML(
CU->dies(),
@@ -1039,7 +1047,7 @@ void writeDWARFSections(Module& wasm, const BinaryLocations& newLocations) {
updateDebugLines(data, locationUpdater);
- updateCompileUnits(info, data, locationUpdater);
+ updateCompileUnits(info, data, locationUpdater, wasm.memory.is64());
updateRanges(data, locationUpdater);
diff --git a/third_party/llvm-project/DWARFEmitter.cpp b/third_party/llvm-project/DWARFEmitter.cpp
index 6e4ee6119..aa0465d9b 100644
--- a/third_party/llvm-project/DWARFEmitter.cpp
+++ b/third_party/llvm-project/DWARFEmitter.cpp
@@ -190,9 +190,11 @@ protected:
// XXX BINARYEN Make sure we emit the right size. We should not change the
// size as we only modify relocatable fields like addresses, and such fields
// have a fixed size, so any change is a bug.
+ // We make an exception for AddrSizeChanged, which happens when we have run
+ // the Memory64Lowering pass to turn wasm64 into wasm32.
void onEndCompileUnit(const DWARFYAML::Unit &CU) {
size_t EndPos = OS.tell();
- if (EndPos - StartPos != CU.Length.getLength()) {
+ if (EndPos - StartPos != CU.Length.getLength() && !CU.AddrSizeChanged) {
llvm_unreachable("compile unit size was incorrect");
}
}
diff --git a/third_party/llvm-project/include/llvm/ObjectYAML/DWARFYAML.h b/third_party/llvm-project/include/llvm/ObjectYAML/DWARFYAML.h
index 818bddede..510610123 100644
--- a/third_party/llvm-project/include/llvm/ObjectYAML/DWARFYAML.h
+++ b/third_party/llvm-project/include/llvm/ObjectYAML/DWARFYAML.h
@@ -128,6 +128,7 @@ struct Unit {
llvm::dwarf::UnitType Type; // Added in DWARF 5
uint32_t AbbrOffset;
uint8_t AddrSize;
+ bool AddrSizeChanged = false; // XXX BINARYEN
std::vector<Entry> Entries;
};