From ab8a41c85ddb1ea783bc8a8832254f992262bed6 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 6 Nov 2024 19:11:39 -0800 Subject: [wasm64] Fix wasm-ctor-eval + utils on 64-bit indexes for memory64 (#7059) Some places assumed a 32-bit index. --- src/ir/memory-utils.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/ir/memory-utils.cpp') 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()->value = Literal(int32_t(0)); + dataSegments[0]->offset->cast()->value = + Literal::makeFromInt32(0, wasm.memories[0]->indexType); dataSegments[0]->data.swap(data); wasm.removeDataSegments( [&](DataSegment* curr) { return curr->name != dataSegments[0]->name; }); -- cgit v1.2.3