diff options
author | Alon Zakai <azakai@google.com> | 2024-11-06 19:11:39 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-06 19:11:39 -0800 |
commit | ab8a41c85ddb1ea783bc8a8832254f992262bed6 (patch) | |
tree | 13a3a209c1c4f7f3e1dc42da3dee908ef50abf64 /src/ir/memory-utils.cpp | |
parent | de680182bcd1d64d597538cfa4ad6857ce298bc3 (diff) | |
download | binaryen-ab8a41c85ddb1ea783bc8a8832254f992262bed6.tar.gz binaryen-ab8a41c85ddb1ea783bc8a8832254f992262bed6.tar.bz2 binaryen-ab8a41c85ddb1ea783bc8a8832254f992262bed6.zip |
[wasm64] Fix wasm-ctor-eval + utils on 64-bit indexes for memory64 (#7059)
Some places assumed a 32-bit index.
Diffstat (limited to 'src/ir/memory-utils.cpp')
-rw-r--r-- | src/ir/memory-utils.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/ir/memory-utils.cpp b/src/ir/memory-utils.cpp index 0f6b77602..552e4ff9a 100644 --- a/src/ir/memory-utils.cpp +++ b/src/ir/memory-utils.cpp @@ -21,8 +21,12 @@ namespace wasm::MemoryUtils { bool flatten(Module& wasm) { + // If there are no memories then they are already flat, in the empty sense. + if (wasm.memories.empty()) { + return true; + } // Flatten does not currently have support for multimemory - if (wasm.memories.size() > 1) { + if (wasm.memories.size() != 1) { return false; } // The presence of any instruction that cares about segment identity is a @@ -105,7 +109,8 @@ bool flatten(Module& wasm) { } std::copy(segment->data.begin(), segment->data.end(), data.begin() + start); } - dataSegments[0]->offset->cast<Const>()->value = Literal(int32_t(0)); + dataSegments[0]->offset->cast<Const>()->value = + Literal::makeFromInt32(0, wasm.memories[0]->indexType); dataSegments[0]->data.swap(data); wasm.removeDataSegments( [&](DataSegment* curr) { return curr->name != dataSegments[0]->name; }); |