summaryrefslogtreecommitdiff
path: root/src/ir/memory-utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ir/memory-utils.cpp')
-rw-r--r--src/ir/memory-utils.cpp9
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; });