summaryrefslogtreecommitdiff
path: root/src/passes/I64ToI32Lowering.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/I64ToI32Lowering.cpp')
-rw-r--r--src/passes/I64ToI32Lowering.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/passes/I64ToI32Lowering.cpp b/src/passes/I64ToI32Lowering.cpp
index 4575dd2f8..ae69ec19d 100644
--- a/src/passes/I64ToI32Lowering.cpp
+++ b/src/passes/I64ToI32Lowering.cpp
@@ -27,6 +27,7 @@
#include "emscripten-optimizer/istring.h"
#include "support/name.h"
#include "wasm-builder.h"
+#include "ir/memory-utils.h"
#include "ir/module-utils.h"
#include "ir/names.h"
#include "asmjs/shared-constants.h"
@@ -608,6 +609,7 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> {
);
setOutParam(result, std::move(highBits));
replaceCurrent(result);
+ ensureMinimalMemory();
}
void lowerReinterpretInt64(Unary* curr) {
@@ -620,6 +622,13 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> {
builder->makeLoad(8, true, 0, 8, builder->makeConst(Literal(int32_t(0))), f64)
);
replaceCurrent(result);
+ ensureMinimalMemory();
+ }
+
+ // Ensure memory exists with a minimal size, enough for round-tripping operations on
+ // address 0, which we need for reinterpret operations.
+ void ensureMinimalMemory() {
+ MemoryUtils::ensureExists(getModule()->memory);
}
void lowerTruncFloatToInt(Unary *curr) {