summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ast_utils.h7
-rw-r--r--src/wasm-validator.h3
-rw-r--r--test/emcc_O2_hello_world.fromasm28
-rw-r--r--test/emcc_O2_hello_world.fromasm.imprecise28
-rw-r--r--test/emcc_O2_hello_world.fromasm.imprecise.no-opts32
-rw-r--r--test/emcc_O2_hello_world.fromasm.no-opts32
-rw-r--r--test/emcc_hello_world.fromasm100
-rw-r--r--test/emcc_hello_world.fromasm.imprecise100
-rw-r--r--test/emcc_hello_world.fromasm.imprecise.no-opts100
-rw-r--r--test/emcc_hello_world.fromasm.no-opts100
-rw-r--r--test/example/c-api-kitchen-sink.txt8
-rw-r--r--test/example/c-api-kitchen-sink.txt.txt4
-rw-r--r--test/memorygrowth.fromasm28
-rw-r--r--test/memorygrowth.fromasm.imprecise28
-rw-r--r--test/memorygrowth.fromasm.imprecise.no-opts32
-rw-r--r--test/memorygrowth.fromasm.no-opts32
-rw-r--r--test/unit.asm.js5
-rw-r--r--test/unit.fromasm16
-rw-r--r--test/unit.fromasm.imprecise16
-rw-r--r--test/unit.fromasm.imprecise.no-opts16
-rw-r--r--test/unit.fromasm.no-opts16
21 files changed, 448 insertions, 283 deletions
diff --git a/src/ast_utils.h b/src/ast_utils.h
index f7a486332..5deaa6a2c 100644
--- a/src/ast_utils.h
+++ b/src/ast_utils.h
@@ -832,6 +832,13 @@ struct AutoDrop : public WalkerPass<ExpressionStackWalker<AutoDrop, Visitor<Auto
curr->finalize(); // we may have changed our type
}
+ void visitIf(If* curr) {
+ // if without else does not return a value, so the body must be dropped if it is concrete
+ if (!curr->ifFalse && isConcreteWasmType(curr->ifTrue->type)) {
+ curr->ifTrue = Builder(*getModule()).makeDrop(curr->ifTrue);
+ }
+ }
+
void visitFunction(Function* curr) {
if (curr->result == none && isConcreteWasmType(curr->body->type)) {
curr->body = Builder(*getModule()).makeDrop(curr->body);
diff --git a/src/wasm-validator.h b/src/wasm-validator.h
index 58a30f9a3..e23221337 100644
--- a/src/wasm-validator.h
+++ b/src/wasm-validator.h
@@ -104,6 +104,9 @@ public:
void visitIf(If *curr) {
shouldBeTrue(curr->condition->type == unreachable || curr->condition->type == i32 || curr->condition->type == i64, curr, "if condition must be valid");
+ if (!curr->ifFalse) {
+ shouldBeFalse(isConcreteWasmType(curr->ifTrue->type), curr, "if without else must not return a value in body");
+ }
}
// override scan to add a pre and a post check task to all nodes
diff --git a/test/emcc_O2_hello_world.fromasm b/test/emcc_O2_hello_world.fromasm
index f7fa57f61..18f533f4f 100644
--- a/test/emcc_O2_hello_world.fromasm
+++ b/test/emcc_O2_hello_world.fromasm
@@ -8980,21 +8980,23 @@
)
)
)
- (call_indirect $FUNCSIG$iiii
- (get_local $0)
- (i32.sub
- (get_local $4)
- (get_local $6)
- )
- (i32.const 1)
- (i32.add
- (i32.and
- (i32.load offset=40
- (get_local $0)
+ (drop
+ (call_indirect $FUNCSIG$iiii
+ (get_local $0)
+ (i32.sub
+ (get_local $4)
+ (get_local $6)
+ )
+ (i32.const 1)
+ (i32.add
+ (i32.and
+ (i32.load offset=40
+ (get_local $0)
+ )
+ (i32.const 7)
)
- (i32.const 7)
+ (i32.const 2)
)
- (i32.const 2)
)
)
)
diff --git a/test/emcc_O2_hello_world.fromasm.imprecise b/test/emcc_O2_hello_world.fromasm.imprecise
index 925aa4813..d4e40feb4 100644
--- a/test/emcc_O2_hello_world.fromasm.imprecise
+++ b/test/emcc_O2_hello_world.fromasm.imprecise
@@ -8978,21 +8978,23 @@
)
)
)
- (call_indirect $FUNCSIG$iiii
- (get_local $0)
- (i32.sub
- (get_local $4)
- (get_local $6)
- )
- (i32.const 1)
- (i32.add
- (i32.and
- (i32.load offset=40
- (get_local $0)
+ (drop
+ (call_indirect $FUNCSIG$iiii
+ (get_local $0)
+ (i32.sub
+ (get_local $4)
+ (get_local $6)
+ )
+ (i32.const 1)
+ (i32.add
+ (i32.and
+ (i32.load offset=40
+ (get_local $0)
+ )
+ (i32.const 7)
)
- (i32.const 7)
+ (i32.const 2)
)
- (i32.const 2)
)
)
)
diff --git a/test/emcc_O2_hello_world.fromasm.imprecise.no-opts b/test/emcc_O2_hello_world.fromasm.imprecise.no-opts
index b125481a7..d158d27bf 100644
--- a/test/emcc_O2_hello_world.fromasm.imprecise.no-opts
+++ b/test/emcc_O2_hello_world.fromasm.imprecise.no-opts
@@ -10632,24 +10632,26 @@
(get_local $i6)
(get_local $i8)
)
- (call_indirect $FUNCSIG$iiii
- (get_local $i1)
- (i32.sub
- (get_local $i6)
- (get_local $i8)
- )
- (i32.const 1)
- (i32.add
- (i32.and
- (i32.load
- (i32.add
- (get_local $i1)
- (i32.const 40)
+ (drop
+ (call_indirect $FUNCSIG$iiii
+ (get_local $i1)
+ (i32.sub
+ (get_local $i6)
+ (get_local $i8)
+ )
+ (i32.const 1)
+ (i32.add
+ (i32.and
+ (i32.load
+ (i32.add
+ (get_local $i1)
+ (i32.const 40)
+ )
)
+ (i32.const 7)
)
- (i32.const 7)
+ (i32.const 2)
)
- (i32.const 2)
)
)
)
diff --git a/test/emcc_O2_hello_world.fromasm.no-opts b/test/emcc_O2_hello_world.fromasm.no-opts
index 4acb5bc87..618b0f593 100644
--- a/test/emcc_O2_hello_world.fromasm.no-opts
+++ b/test/emcc_O2_hello_world.fromasm.no-opts
@@ -10633,24 +10633,26 @@
(get_local $i6)
(get_local $i8)
)
- (call_indirect $FUNCSIG$iiii
- (get_local $i1)
- (i32.sub
- (get_local $i6)
- (get_local $i8)
- )
- (i32.const 1)
- (i32.add
- (i32.and
- (i32.load
- (i32.add
- (get_local $i1)
- (i32.const 40)
+ (drop
+ (call_indirect $FUNCSIG$iiii
+ (get_local $i1)
+ (i32.sub
+ (get_local $i6)
+ (get_local $i8)
+ )
+ (i32.const 1)
+ (i32.add
+ (i32.and
+ (i32.load
+ (i32.add
+ (get_local $i1)
+ (i32.const 40)
+ )
)
+ (i32.const 7)
)
- (i32.const 7)
+ (i32.const 2)
)
- (i32.const 2)
)
)
)
diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm
index 3b93c26fd..0a40314a8 100644
--- a/test/emcc_hello_world.fromasm
+++ b/test/emcc_hello_world.fromasm
@@ -3081,10 +3081,12 @@
(i32.const 32)
)
)
- (call $___fwritex
- (get_local $20)
- (get_local $12)
- (get_local $0)
+ (drop
+ (call $___fwritex
+ (get_local $20)
+ (get_local $12)
+ (get_local $0)
+ )
)
)
)
@@ -5105,10 +5107,12 @@
(i32.const 32)
)
)
- (call $___fwritex
- (get_local $10)
- (get_local $7)
- (get_local $0)
+ (drop
+ (call $___fwritex
+ (get_local $10)
+ (get_local $7)
+ (get_local $0)
+ )
)
)
(call $_pad
@@ -5136,10 +5140,12 @@
(i32.const 32)
)
)
- (call $___fwritex
- (get_local $27)
- (get_local $1)
- (get_local $0)
+ (drop
+ (call $___fwritex
+ (get_local $27)
+ (get_local $1)
+ (get_local $0)
+ )
)
)
(call $_pad
@@ -5169,10 +5175,12 @@
(i32.const 32)
)
)
- (call $___fwritex
- (get_local $8)
- (get_local $1)
- (get_local $0)
+ (drop
+ (call $___fwritex
+ (get_local $8)
+ (get_local $1)
+ (get_local $0)
+ )
)
)
(call $_pad
@@ -6633,10 +6641,12 @@
(i32.const 32)
)
)
- (call $___fwritex
- (get_local $50)
- (get_local $37)
- (get_local $0)
+ (drop
+ (call $___fwritex
+ (get_local $50)
+ (get_local $37)
+ (get_local $0)
+ )
)
)
(call $_pad
@@ -6984,10 +6994,12 @@
(i32.const 32)
)
)
- (call $___fwritex
- (get_local $8)
- (i32.const 1)
- (get_local $0)
+ (drop
+ (call $___fwritex
+ (get_local $8)
+ (i32.const 1)
+ (get_local $0)
+ )
)
)
(br_if $do-once$122
@@ -7247,10 +7259,12 @@
(i32.const 32)
)
)
- (call $___fwritex
- (get_local $8)
- (i32.const 3)
- (get_local $0)
+ (drop
+ (call $___fwritex
+ (get_local $8)
+ (i32.const 3)
+ (get_local $0)
+ )
)
)
(call $_pad
@@ -7725,10 +7739,12 @@
(i32.const 32)
)
)
- (call $___fwritex
- (get_local $62)
- (get_local $5)
- (get_local $0)
+ (drop
+ (call $___fwritex
+ (get_local $62)
+ (get_local $5)
+ (get_local $0)
+ )
)
)
(if
@@ -7959,10 +7975,12 @@
(i32.const 32)
)
)
- (call $___fwritex
- (get_local $47)
- (get_local $41)
- (get_local $0)
+ (drop
+ (call $___fwritex
+ (get_local $47)
+ (get_local $41)
+ (get_local $0)
+ )
)
)
(call $_pad
@@ -7991,10 +8009,12 @@
(i32.const 32)
)
)
- (call $___fwritex
- (get_local $46)
- (get_local $5)
- (get_local $0)
+ (drop
+ (call $___fwritex
+ (get_local $46)
+ (get_local $5)
+ (get_local $0)
+ )
)
)
(call $_pad
diff --git a/test/emcc_hello_world.fromasm.imprecise b/test/emcc_hello_world.fromasm.imprecise
index 0d1653a62..c13902e50 100644
--- a/test/emcc_hello_world.fromasm.imprecise
+++ b/test/emcc_hello_world.fromasm.imprecise
@@ -3074,10 +3074,12 @@
(i32.const 32)
)
)
- (call $___fwritex
- (get_local $20)
- (get_local $12)
- (get_local $0)
+ (drop
+ (call $___fwritex
+ (get_local $20)
+ (get_local $12)
+ (get_local $0)
+ )
)
)
)
@@ -5098,10 +5100,12 @@
(i32.const 32)
)
)
- (call $___fwritex
- (get_local $10)
- (get_local $7)
- (get_local $0)
+ (drop
+ (call $___fwritex
+ (get_local $10)
+ (get_local $7)
+ (get_local $0)
+ )
)
)
(call $_pad
@@ -5129,10 +5133,12 @@
(i32.const 32)
)
)
- (call $___fwritex
- (get_local $27)
- (get_local $1)
- (get_local $0)
+ (drop
+ (call $___fwritex
+ (get_local $27)
+ (get_local $1)
+ (get_local $0)
+ )
)
)
(call $_pad
@@ -5162,10 +5168,12 @@
(i32.const 32)
)
)
- (call $___fwritex
- (get_local $8)
- (get_local $1)
- (get_local $0)
+ (drop
+ (call $___fwritex
+ (get_local $8)
+ (get_local $1)
+ (get_local $0)
+ )
)
)
(call $_pad
@@ -6626,10 +6634,12 @@
(i32.const 32)
)
)
- (call $___fwritex
- (get_local $50)
- (get_local $37)
- (get_local $0)
+ (drop
+ (call $___fwritex
+ (get_local $50)
+ (get_local $37)
+ (get_local $0)
+ )
)
)
(call $_pad
@@ -6977,10 +6987,12 @@
(i32.const 32)
)
)
- (call $___fwritex
- (get_local $8)
- (i32.const 1)
- (get_local $0)
+ (drop
+ (call $___fwritex
+ (get_local $8)
+ (i32.const 1)
+ (get_local $0)
+ )
)
)
(br_if $do-once$122
@@ -7240,10 +7252,12 @@
(i32.const 32)
)
)
- (call $___fwritex
- (get_local $8)
- (i32.const 3)
- (get_local $0)
+ (drop
+ (call $___fwritex
+ (get_local $8)
+ (i32.const 3)
+ (get_local $0)
+ )
)
)
(call $_pad
@@ -7718,10 +7732,12 @@
(i32.const 32)
)
)
- (call $___fwritex
- (get_local $62)
- (get_local $5)
- (get_local $0)
+ (drop
+ (call $___fwritex
+ (get_local $62)
+ (get_local $5)
+ (get_local $0)
+ )
)
)
(if
@@ -7952,10 +7968,12 @@
(i32.const 32)
)
)
- (call $___fwritex
- (get_local $47)
- (get_local $41)
- (get_local $0)
+ (drop
+ (call $___fwritex
+ (get_local $47)
+ (get_local $41)
+ (get_local $0)
+ )
)
)
(call $_pad
@@ -7984,10 +8002,12 @@
(i32.const 32)
)
)
- (call $___fwritex
- (get_local $46)
- (get_local $5)
- (get_local $0)
+ (drop
+ (call $___fwritex
+ (get_local $46)
+ (get_local $5)
+ (get_local $0)
+ )
)
)
(call $_pad
diff --git a/test/emcc_hello_world.fromasm.imprecise.no-opts b/test/emcc_hello_world.fromasm.imprecise.no-opts
index 45f19f21c..486697a52 100644
--- a/test/emcc_hello_world.fromasm.imprecise.no-opts
+++ b/test/emcc_hello_world.fromasm.imprecise.no-opts
@@ -6156,10 +6156,12 @@
)
(if
(get_local $$tobool$i)
- (call $___fwritex
- (get_local $$incdec$ptr169275)
- (get_local $$sub$ptr$sub)
- (get_local $$f)
+ (drop
+ (call $___fwritex
+ (get_local $$incdec$ptr169275)
+ (get_local $$sub$ptr$sub)
+ (get_local $$f)
+ )
)
)
)
@@ -9623,10 +9625,12 @@
)
(if
(get_local $$tobool$i$419$i)
- (call $___fwritex
- (get_local $$prefix$0$add$ptr65$i)
- (get_local $$add67$i)
- (get_local $$f)
+ (drop
+ (call $___fwritex
+ (get_local $$prefix$0$add$ptr65$i)
+ (get_local $$add67$i)
+ (get_local $$f)
+ )
)
)
(set_local $$xor167$i
@@ -9667,10 +9671,12 @@
)
(if
(get_local $$tobool$i$425$i)
- (call $___fwritex
- (get_local $$buf$i)
- (get_local $$sub$ptr$sub172$i)
- (get_local $$f)
+ (drop
+ (call $___fwritex
+ (get_local $$buf$i)
+ (get_local $$sub$ptr$sub172$i)
+ (get_local $$f)
+ )
)
)
(set_local $$sub$ptr$rhs$cast174$i
@@ -9720,10 +9726,12 @@
)
(if
(get_local $$tobool$i$431$i)
- (call $___fwritex
- (get_local $$incdec$ptr115$i)
- (get_local $$sub$ptr$sub175$i)
- (get_local $$f)
+ (drop
+ (call $___fwritex
+ (get_local $$incdec$ptr115$i)
+ (get_local $$sub$ptr$sub175$i)
+ (get_local $$f)
+ )
)
)
(set_local $$xor186$i
@@ -12090,10 +12098,12 @@
)
(if
(get_local $$tobool$i$437$i)
- (call $___fwritex
- (get_local $$prefix$0$i)
- (get_local $$pl$0$i)
- (get_local $$f)
+ (drop
+ (call $___fwritex
+ (get_local $$prefix$0$i)
+ (get_local $$pl$0$i)
+ (get_local $$f)
+ )
)
)
(set_local $$xor655$i
@@ -12650,10 +12660,12 @@
)
(if
(get_local $$tobool$i$461$i)
- (call $___fwritex
- (get_local $$s753$0$i)
- (i32.const 1)
- (get_local $$f)
+ (drop
+ (call $___fwritex
+ (get_local $$s753$0$i)
+ (i32.const 1)
+ (get_local $$f)
+ )
)
)
(set_local $$cmp777$i
@@ -13082,10 +13094,12 @@
)
(if
(get_local $$tobool$i$413$i)
- (call $___fwritex
- (get_local $$s35$0$i)
- (i32.const 3)
- (get_local $$f)
+ (drop
+ (call $___fwritex
+ (get_local $$s35$0$i)
+ (i32.const 3)
+ (get_local $$f)
+ )
)
)
(set_local $$xor$i
@@ -13839,10 +13853,12 @@
)
(if
(get_local $$tobool$i$232)
- (call $___fwritex
- (get_local $$mb)
- (get_local $$call411)
- (get_local $$f)
+ (drop
+ (call $___fwritex
+ (get_local $$mb)
+ (get_local $$call411)
+ (get_local $$f)
+ )
)
)
(set_local $$cmp404
@@ -14170,10 +14186,12 @@
)
(if
(get_local $$tobool$i$245)
- (call $___fwritex
- (get_local $$prefix$2)
- (get_local $$pl$2)
- (get_local $$f)
+ (drop
+ (call $___fwritex
+ (get_local $$prefix$2)
+ (get_local $$pl$2)
+ (get_local $$f)
+ )
)
)
(set_local $$xor449
@@ -14215,10 +14233,12 @@
)
(if
(get_local $$tobool$i$217)
- (call $___fwritex
- (get_local $$a$2)
- (get_local $$sub$ptr$sub433)
- (get_local $$f)
+ (drop
+ (call $___fwritex
+ (get_local $$a$2)
+ (get_local $$sub$ptr$sub433)
+ (get_local $$f)
+ )
)
)
(set_local $$xor457
diff --git a/test/emcc_hello_world.fromasm.no-opts b/test/emcc_hello_world.fromasm.no-opts
index ea2bb8801..93f1a73cd 100644
--- a/test/emcc_hello_world.fromasm.no-opts
+++ b/test/emcc_hello_world.fromasm.no-opts
@@ -6162,10 +6162,12 @@
)
(if
(get_local $$tobool$i)
- (call $___fwritex
- (get_local $$incdec$ptr169275)
- (get_local $$sub$ptr$sub)
- (get_local $$f)
+ (drop
+ (call $___fwritex
+ (get_local $$incdec$ptr169275)
+ (get_local $$sub$ptr$sub)
+ (get_local $$f)
+ )
)
)
)
@@ -9629,10 +9631,12 @@
)
(if
(get_local $$tobool$i$419$i)
- (call $___fwritex
- (get_local $$prefix$0$add$ptr65$i)
- (get_local $$add67$i)
- (get_local $$f)
+ (drop
+ (call $___fwritex
+ (get_local $$prefix$0$add$ptr65$i)
+ (get_local $$add67$i)
+ (get_local $$f)
+ )
)
)
(set_local $$xor167$i
@@ -9673,10 +9677,12 @@
)
(if
(get_local $$tobool$i$425$i)
- (call $___fwritex
- (get_local $$buf$i)
- (get_local $$sub$ptr$sub172$i)
- (get_local $$f)
+ (drop
+ (call $___fwritex
+ (get_local $$buf$i)
+ (get_local $$sub$ptr$sub172$i)
+ (get_local $$f)
+ )
)
)
(set_local $$sub$ptr$rhs$cast174$i
@@ -9726,10 +9732,12 @@
)
(if
(get_local $$tobool$i$431$i)
- (call $___fwritex
- (get_local $$incdec$ptr115$i)
- (get_local $$sub$ptr$sub175$i)
- (get_local $$f)
+ (drop
+ (call $___fwritex
+ (get_local $$incdec$ptr115$i)
+ (get_local $$sub$ptr$sub175$i)
+ (get_local $$f)
+ )
)
)
(set_local $$xor186$i
@@ -12096,10 +12104,12 @@
)
(if
(get_local $$tobool$i$437$i)
- (call $___fwritex
- (get_local $$prefix$0$i)
- (get_local $$pl$0$i)
- (get_local $$f)
+ (drop
+ (call $___fwritex
+ (get_local $$prefix$0$i)
+ (get_local $$pl$0$i)
+ (get_local $$f)
+ )
)
)
(set_local $$xor655$i
@@ -12656,10 +12666,12 @@
)
(if
(get_local $$tobool$i$461$i)
- (call $___fwritex
- (get_local $$s753$0$i)
- (i32.const 1)
- (get_local $$f)
+ (drop
+ (call $___fwritex
+ (get_local $$s753$0$i)
+ (i32.const 1)
+ (get_local $$f)
+ )
)
)
(set_local $$cmp777$i
@@ -13088,10 +13100,12 @@
)
(if
(get_local $$tobool$i$413$i)
- (call $___fwritex
- (get_local $$s35$0$i)
- (i32.const 3)
- (get_local $$f)
+ (drop
+ (call $___fwritex
+ (get_local $$s35$0$i)
+ (i32.const 3)
+ (get_local $$f)
+ )
)
)
(set_local $$xor$i
@@ -13845,10 +13859,12 @@
)
(if
(get_local $$tobool$i$232)
- (call $___fwritex
- (get_local $$mb)
- (get_local $$call411)
- (get_local $$f)
+ (drop
+ (call $___fwritex
+ (get_local $$mb)
+ (get_local $$call411)
+ (get_local $$f)
+ )
)
)
(set_local $$cmp404
@@ -14176,10 +14192,12 @@
)
(if
(get_local $$tobool$i$245)
- (call $___fwritex
- (get_local $$prefix$2)
- (get_local $$pl$2)
- (get_local $$f)
+ (drop
+ (call $___fwritex
+ (get_local $$prefix$2)
+ (get_local $$pl$2)
+ (get_local $$f)
+ )
)
)
(set_local $$xor449
@@ -14221,10 +14239,12 @@
)
(if
(get_local $$tobool$i$217)
- (call $___fwritex
- (get_local $$a$2)
- (get_local $$sub$ptr$sub433)
- (get_local $$f)
+ (drop
+ (call $___fwritex
+ (get_local $$a$2)
+ (get_local $$sub$ptr$sub433)
+ (get_local $$f)
+ )
)
)
(set_local $$xor457
diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt
index 6544f9f33..574be4965 100644
--- a/test/example/c-api-kitchen-sink.txt
+++ b/test/example/c-api-kitchen-sink.txt
@@ -408,7 +408,9 @@ BinaryenFloat64: 4
)
(if
(i32.const 4)
- (i32.const 5)
+ (drop
+ (i32.const 5)
+ )
)
(drop
(loop $in
@@ -1999,7 +2001,9 @@ int main() {
)
(if
(i32.const 4)
- (i32.const 5)
+ (drop
+ (i32.const 5)
+ )
)
(drop
(loop $in
diff --git a/test/example/c-api-kitchen-sink.txt.txt b/test/example/c-api-kitchen-sink.txt.txt
index b37814f89..991c8738c 100644
--- a/test/example/c-api-kitchen-sink.txt.txt
+++ b/test/example/c-api-kitchen-sink.txt.txt
@@ -403,7 +403,9 @@
)
(if
(i32.const 4)
- (i32.const 5)
+ (drop
+ (i32.const 5)
+ )
)
(drop
(loop $in
diff --git a/test/memorygrowth.fromasm b/test/memorygrowth.fromasm
index d0d1f9214..85105c556 100644
--- a/test/memorygrowth.fromasm
+++ b/test/memorygrowth.fromasm
@@ -9056,21 +9056,23 @@
)
)
)
- (call_indirect $FUNCSIG$iiii
- (get_local $0)
- (i32.sub
- (get_local $2)
- (get_local $6)
- )
- (i32.const 1)
- (i32.add
- (i32.and
- (i32.load offset=40
- (get_local $0)
+ (drop
+ (call_indirect $FUNCSIG$iiii
+ (get_local $0)
+ (i32.sub
+ (get_local $2)
+ (get_local $6)
+ )
+ (i32.const 1)
+ (i32.add
+ (i32.and
+ (i32.load offset=40
+ (get_local $0)
+ )
+ (i32.const 3)
)
- (i32.const 3)
+ (i32.const 2)
)
- (i32.const 2)
)
)
)
diff --git a/test/memorygrowth.fromasm.imprecise b/test/memorygrowth.fromasm.imprecise
index ce121503e..6e3124830 100644
--- a/test/memorygrowth.fromasm.imprecise
+++ b/test/memorygrowth.fromasm.imprecise
@@ -9054,21 +9054,23 @@
)
)
)
- (call_indirect $FUNCSIG$iiii
- (get_local $0)
- (i32.sub
- (get_local $2)
- (get_local $6)
- )
- (i32.const 1)
- (i32.add
- (i32.and
- (i32.load offset=40
- (get_local $0)
+ (drop
+ (call_indirect $FUNCSIG$iiii
+ (get_local $0)
+ (i32.sub
+ (get_local $2)
+ (get_local $6)
+ )
+ (i32.const 1)
+ (i32.add
+ (i32.and
+ (i32.load offset=40
+ (get_local $0)
+ )
+ (i32.const 3)
)
- (i32.const 3)
+ (i32.const 2)
)
- (i32.const 2)
)
)
)
diff --git a/test/memorygrowth.fromasm.imprecise.no-opts b/test/memorygrowth.fromasm.imprecise.no-opts
index 347eb4392..064c1d821 100644
--- a/test/memorygrowth.fromasm.imprecise.no-opts
+++ b/test/memorygrowth.fromasm.imprecise.no-opts
@@ -10686,24 +10686,26 @@
(get_local $f)
(get_local $h)
)
- (call_indirect $FUNCSIG$iiii
- (get_local $a)
- (i32.sub
- (get_local $f)
- (get_local $h)
- )
- (i32.const 1)
- (i32.add
- (i32.and
- (i32.load
- (i32.add
- (get_local $a)
- (i32.const 40)
+ (drop
+ (call_indirect $FUNCSIG$iiii
+ (get_local $a)
+ (i32.sub
+ (get_local $f)
+ (get_local $h)
+ )
+ (i32.const 1)
+ (i32.add
+ (i32.and
+ (i32.load
+ (i32.add
+ (get_local $a)
+ (i32.const 40)
+ )
)
+ (i32.const 3)
)
- (i32.const 3)
+ (i32.const 2)
)
- (i32.const 2)
)
)
)
diff --git a/test/memorygrowth.fromasm.no-opts b/test/memorygrowth.fromasm.no-opts
index 9415b19e5..0639416ea 100644
--- a/test/memorygrowth.fromasm.no-opts
+++ b/test/memorygrowth.fromasm.no-opts
@@ -10687,24 +10687,26 @@
(get_local $f)
(get_local $h)
)
- (call_indirect $FUNCSIG$iiii
- (get_local $a)
- (i32.sub
- (get_local $f)
- (get_local $h)
- )
- (i32.const 1)
- (i32.add
- (i32.and
- (i32.load
- (i32.add
- (get_local $a)
- (i32.const 40)
+ (drop
+ (call_indirect $FUNCSIG$iiii
+ (get_local $a)
+ (i32.sub
+ (get_local $f)
+ (get_local $h)
+ )
+ (i32.const 1)
+ (i32.add
+ (i32.and
+ (i32.load
+ (i32.add
+ (get_local $a)
+ (i32.const 40)
+ )
)
+ (i32.const 3)
)
- (i32.const 3)
+ (i32.const 2)
)
- (i32.const 2)
)
)
)
diff --git a/test/unit.asm.js b/test/unit.asm.js
index 893d29a99..721e9e8cc 100644
--- a/test/unit.asm.js
+++ b/test/unit.asm.js
@@ -14,6 +14,7 @@ function asm(global, env, buffer) {
var abort = env.abort;
var print = env.print;
var h = env.h;
+ var return_int = env.return_int;
var HEAP8 = new global.Int8Array(buffer);
var HEAP16 = new global.Int16Array(buffer);
@@ -364,6 +365,10 @@ function asm(global, env, buffer) {
Int = x;
}
+ function dropCallImport() {
+ if (1) return_int() | 0;
+ }
+
var FUNCTION_TABLE_a = [ z, big_negative, z, z ];
var FUNCTION_TABLE_b = [ w, w, importedDoubles, w ];
var FUNCTION_TABLE_c = [ z, cneg ];
diff --git a/test/unit.fromasm b/test/unit.fromasm
index a1103f064..e1956de79 100644
--- a/test/unit.fromasm
+++ b/test/unit.fromasm
@@ -8,6 +8,7 @@
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$dd (func (param f64) (result f64)))
+ (type $FUNCSIG$i (func (result i32)))
(import "global" "NaN" (global $t f64))
(import "global" "Infinity" (global $u f64))
(import "env" "tempDoublePtr" (global $tempDoublePtr i32))
@@ -16,6 +17,7 @@
(import "env" "abort" (func $abort (param f64) (result f64)))
(import "env" "print" (func $print (param i32)))
(import "env" "h" (func $h (param i32)))
+ (import "env" "return_int" (func $return_int (result i32)))
(import "asm2wasm" "f64-to-int" (func $f64-to-int (param f64) (result i32)))
(import "asm2wasm" "f64-rem" (func $f64-rem (param f64 f64) (result f64)))
(import "asm2wasm" "i32u-div" (func $i32u-div (param i32 i32) (result i32)))
@@ -484,8 +486,10 @@
(get_local $1)
(i32.const 3)
)
- (call $lb
- (i32.const 2)
+ (drop
+ (call $lb
+ (i32.const 2)
+ )
)
)
)
@@ -708,4 +712,12 @@
(get_local $0)
)
)
+ (func $dropCallImport
+ (if
+ (i32.const 1)
+ (drop
+ (call_import $return_int)
+ )
+ )
+ )
)
diff --git a/test/unit.fromasm.imprecise b/test/unit.fromasm.imprecise
index db854cac0..017284aae 100644
--- a/test/unit.fromasm.imprecise
+++ b/test/unit.fromasm.imprecise
@@ -5,6 +5,7 @@
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$dd (func (param f64) (result f64)))
+ (type $FUNCSIG$i (func (result i32)))
(import "global" "NaN" (global $t f64))
(import "global" "Infinity" (global $u f64))
(import "env" "tempDoublePtr" (global $tempDoublePtr i32))
@@ -13,6 +14,7 @@
(import "env" "abort" (func $abort (param f64) (result f64)))
(import "env" "print" (func $print (param i32)))
(import "env" "h" (func $h (param i32)))
+ (import "env" "return_int" (func $return_int (result i32)))
(import "asm2wasm" "f64-rem" (func $f64-rem (param f64 f64) (result f64)))
(import "env" "memory" (memory $memory))
(import "env" "table" (table $table))
@@ -465,8 +467,10 @@
(get_local $1)
(i32.const 3)
)
- (call $lb
- (i32.const 2)
+ (drop
+ (call $lb
+ (i32.const 2)
+ )
)
)
)
@@ -689,4 +693,12 @@
(get_local $0)
)
)
+ (func $dropCallImport
+ (if
+ (i32.const 1)
+ (drop
+ (call_import $return_int)
+ )
+ )
+ )
)
diff --git a/test/unit.fromasm.imprecise.no-opts b/test/unit.fromasm.imprecise.no-opts
index 6c51812e4..814bc52d7 100644
--- a/test/unit.fromasm.imprecise.no-opts
+++ b/test/unit.fromasm.imprecise.no-opts
@@ -5,6 +5,7 @@
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$dd (func (param f64) (result f64)))
+ (type $FUNCSIG$i (func (result i32)))
(import "global" "NaN" (global $t f64))
(import "global" "Infinity" (global $u f64))
(import "env" "tempDoublePtr" (global $tempDoublePtr i32))
@@ -13,6 +14,7 @@
(import "env" "abort" (func $abort (param f64) (result f64)))
(import "env" "print" (func $print (param i32)))
(import "env" "h" (func $h (param i32)))
+ (import "env" "return_int" (func $return_int (result i32)))
(import "asm2wasm" "f64-rem" (func $f64-rem (param f64 f64) (result f64)))
(import "env" "memory" (memory $memory))
(import "env" "table" (table $table))
@@ -817,8 +819,10 @@
(get_local $y)
(i32.const 3)
)
- (call $lb
- (i32.const 2)
+ (drop
+ (call $lb
+ (i32.const 2)
+ )
)
)
)
@@ -1140,4 +1144,12 @@
(get_local $x)
)
)
+ (func $dropCallImport
+ (if
+ (i32.const 1)
+ (drop
+ (call_import $return_int)
+ )
+ )
+ )
)
diff --git a/test/unit.fromasm.no-opts b/test/unit.fromasm.no-opts
index 747c742dd..4205ff1f1 100644
--- a/test/unit.fromasm.no-opts
+++ b/test/unit.fromasm.no-opts
@@ -7,6 +7,7 @@
(type $FUNCSIG$vi (func (param i32)))
(type $FUNCSIG$ii (func (param i32) (result i32)))
(type $FUNCSIG$dd (func (param f64) (result f64)))
+ (type $FUNCSIG$i (func (result i32)))
(import "global" "NaN" (global $t f64))
(import "global" "Infinity" (global $u f64))
(import "env" "tempDoublePtr" (global $tempDoublePtr i32))
@@ -15,6 +16,7 @@
(import "env" "abort" (func $abort (param f64) (result f64)))
(import "env" "print" (func $print (param i32)))
(import "env" "h" (func $h (param i32)))
+ (import "env" "return_int" (func $return_int (result i32)))
(import "asm2wasm" "f64-to-int" (func $f64-to-int (param f64) (result i32)))
(import "asm2wasm" "f64-rem" (func $f64-rem (param f64 f64) (result f64)))
(import "asm2wasm" "i32u-div" (func $i32u-div (param i32 i32) (result i32)))
@@ -823,8 +825,10 @@
(get_local $y)
(i32.const 3)
)
- (call $lb
- (i32.const 2)
+ (drop
+ (call $lb
+ (i32.const 2)
+ )
)
)
)
@@ -1146,4 +1150,12 @@
(get_local $x)
)
)
+ (func $dropCallImport
+ (if
+ (i32.const 1)
+ (drop
+ (call_import $return_int)
+ )
+ )
+ )
)