From e5b5f83aa6b1859a214a0eae0ee92efab8ce329a Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 15 Sep 2021 17:47:58 -0700 Subject: Fix regression from #4130 (#4158) That PR reused the same node twice in the output, which fails on the assertion in BINARYEN_PASS_DEBUG=1 mode. No new test is needed because the existing test suite fails already in that mode. That the PR managed to land seems to say that we are not testing pass-debug mode on our lit tests, which we need to investigate. --- src/passes/OptimizeInstructions.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp index e48eecb72..c9e4d7ff5 100644 --- a/src/passes/OptimizeInstructions.cpp +++ b/src/passes/OptimizeInstructions.cpp @@ -2934,6 +2934,10 @@ private: } Expression* optimizeMemoryFill(MemoryFill* memFill) { + if (memFill->type == Type::unreachable) { + return nullptr; + } + if (!memFill->size->is()) { return nullptr; } @@ -3015,19 +3019,21 @@ private: Type::v128); } else { // { i64.store(d, C', 0), i64.store(d, C', 8) } + auto destType = memFill->dest->type; + Index tempLocal = builder.addVar(getFunction(), destType); return builder.makeBlock({ builder.makeStore( 8, offset, align, - memFill->dest, + builder.makeLocalTee(tempLocal, memFill->dest, destType), builder.makeConst(value * 0x0101010101010101ULL), Type::i64), builder.makeStore( 8, offset + 8, align, - memFill->dest, + builder.makeLocalGet(tempLocal, destType), builder.makeConst(value * 0x0101010101010101ULL), Type::i64), }); -- cgit v1.2.3