Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/s2wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,11 @@ class S2WasmBuilder {
};
auto setOutput = [&](Expression* curr, Name assign) {
if (assign.isNull() || assign.str[0] == 'd') { // drop
addToBlock(builder.makeDrop(curr));
auto* add = curr;
if (isConcreteWasmType(curr->type)) {
add = builder.makeDrop(curr);
}
addToBlock(add);
} else if (assign.str[0] == 'p') { // push
push(curr);
} else { // set to a local
Expand Down
4 changes: 1 addition & 3 deletions test/dot_s/alias.wast
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
)
)
(func $__needs_exit (result i32)
(drop
(call $__exit)
)
(call $__exit)
(return
(i32.const 1)
)
Expand Down
6 changes: 2 additions & 4 deletions test/dot_s/asm_const.wast
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
(export "memory" (memory $0))
(export "main" (func $main))
(func $main (result i32)
(drop
(call $emscripten_asm_const_vi
(i32.const 0)
)
(call $emscripten_asm_const_vi
(i32.const 0)
)
(return
(i32.const 0)
Expand Down
6 changes: 2 additions & 4 deletions test/dot_s/basics.wast
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
(table 2 2 anyfunc)
(elem (i32.const 0) $__wasm_nullptr $main)
(func $main (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32)
(drop
(call $puts
(i32.const 16)
)
(call $puts
(i32.const 16)
)
(block $label$0
(block $label$1
Expand Down
26 changes: 7 additions & 19 deletions test/dot_s/bcp-1.wast
Original file line number Diff line number Diff line change
Expand Up @@ -287,36 +287,24 @@
(i32.const 0)
)
)
(drop
(call $exit
(get_local $0)
)
(call $exit
(get_local $0)
)
(unreachable)
)
(drop
(call $abort)
)
(unreachable)
)
(drop
(call $abort)
(unreachable)
)
(unreachable)
)
(drop
(call $abort)
(unreachable)
)
(unreachable)
)
(drop
(call $abort)
(unreachable)
)
(unreachable)
)
(drop
(call $abort)
(unreachable)
)
(call $abort)
(unreachable)
)
(func $__wasm_nullptr (type $FUNCSIG$v)
Expand Down
6 changes: 2 additions & 4 deletions test/dot_s/exit.wast
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
(export "main" (func $main))
(func $main (result i32)
(local $0 i32)
(drop
(call $exit
(i32.const 0)
)
(call $exit
(i32.const 0)
)
(unreachable)
)
Expand Down
14 changes: 5 additions & 9 deletions test/dot_s/fix_em_ehsjlj_names.wast
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@
(local $1 i32)
(local $2 i32)
(local $3 i32)
(drop
(call $invoke_v
(i32.const 1)
)
(call $invoke_v
(i32.const 1)
)
(drop
(call $invoke_iiii
Expand Down Expand Up @@ -70,11 +68,9 @@
)
)
)
(drop
(call $emscripten_longjmp
(i32.const 5)
(i32.const 6)
)
(call $emscripten_longjmp
(i32.const 5)
(i32.const 6)
)
(i32.const 0)
)
Expand Down
86 changes: 33 additions & 53 deletions test/dot_s/indirect-import.wast
Original file line number Diff line number Diff line change
Expand Up @@ -22,50 +22,36 @@
(func $bar (result i32)
(local $0 i32)
(local $1 i32)
(drop
(i32.store offset=4
(i32.const 0)
(tee_local $1
(i32.sub
(i32.load offset=4
(i32.const 0)
)
(i32.const 32)
(i32.store offset=4
(i32.const 0)
(tee_local $1
(i32.sub
(i32.load offset=4
(i32.const 0)
)
(i32.const 32)
)
)
)
(drop
(i32.store offset=28
(get_local $1)
(i32.const 1)
)
)
(drop
(i32.store offset=24
(get_local $1)
(i32.const 2)
)
(i32.store offset=28
(get_local $1)
(i32.const 1)
)
(drop
(call $extern_vj
(i64.const 1)
)
(i32.store offset=24
(get_local $1)
(i32.const 2)
)
(drop
(i32.store offset=20
(get_local $1)
(i32.const 3)
)
(call $extern_vj
(i64.const 1)
)
(drop
(call $extern_v)
(i32.store offset=20
(get_local $1)
(i32.const 3)
)
(drop
(i32.store offset=16
(get_local $1)
(i32.const 4)
)
(call $extern_v)
(i32.store offset=16
(get_local $1)
(i32.const 4)
)
(drop
(call $extern_ijidf
Expand All @@ -75,30 +61,24 @@
(f32.const 4)
)
)
(drop
(i32.store offset=12
(get_local $1)
(i32.const 5)
)
(i32.store offset=12
(get_local $1)
(i32.const 5)
)
(drop
(i32.store offset=8
(get_local $1)
(i32.const 6)
)
(i32.store offset=8
(get_local $1)
(i32.const 6)
)
(set_local $0
(i32.load offset=28
(get_local $1)
)
)
(drop
(i32.store offset=4
(i32.const 0)
(i32.add
(get_local $1)
(i32.const 32)
)
(i32.store offset=4
(i32.const 0)
(i32.add
(get_local $1)
(i32.const 32)
)
)
(get_local $0)
Expand Down
6 changes: 2 additions & 4 deletions test/dot_s/local_align.wast
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
(func $foo (param $0 i32)
)
(func $main (result i32)
(drop
(call $foo
(i32.const 16)
)
(call $foo
(i32.const 16)
)
(i32.const 0)
)
Expand Down
54 changes: 21 additions & 33 deletions test/dot_s/memops.wast
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@
(export "memory" (memory $0))
(export "main" (func $main))
(func $_Z6reporti (param $0 i32)
(drop
(i32.store
(i32.const 8)
(get_local $0)
)
(i32.store
(i32.const 8)
(get_local $0)
)
(drop
(call $emscripten_asm_const_vi
(i32.const 0)
)
(call $emscripten_asm_const_vi
(i32.const 0)
)
(return)
)
Expand Down Expand Up @@ -53,11 +49,9 @@
(set_local $8
(i32.const 0)
)
(drop
(i32.store
(get_local $8)
(get_local $12)
)
(i32.store
(get_local $8)
(get_local $12)
)
(set_local $1
(i32.const 0)
Expand All @@ -84,16 +78,14 @@
(get_local $10)
)
)
(drop
(i32.store8
(i32.add
(get_local $10)
(get_local $4)
)
(i32.add
(get_local $6)
(get_local $4)
)
(i32.store8
(i32.add
(get_local $10)
(get_local $4)
)
(i32.add
(get_local $6)
(get_local $4)
)
)
(set_local $2
Expand Down Expand Up @@ -190,10 +182,8 @@
)
)
)
(drop
(call $_Z6reporti
(get_local $6)
)
(call $_Z6reporti
(get_local $6)
)
(set_local $9
(i32.const 1048576)
Expand All @@ -207,11 +197,9 @@
(set_local $9
(i32.const 0)
)
(drop
(i32.store
(get_local $9)
(get_local $12)
)
(i32.store
(get_local $9)
(get_local $12)
)
(return
(i32.const 0)
Expand Down
8 changes: 3 additions & 5 deletions test/dot_s/symbolic-offset.wast
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
(export "memory" (memory $0))
(export "f" (func $f))
(func $f (param $0 i32) (param $1 i32)
(drop
(i32.store offset=16
(get_local $0)
(get_local $1)
)
(i32.store offset=16
(get_local $0)
(get_local $1)
)
(return)
)
Expand Down
4 changes: 1 addition & 3 deletions test/dot_s/text_before_type.wast
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
(export "memory" (memory $0))
(export "main" (func $main))
(func $main (result i32)
(drop
(call $foo)
)
(call $foo)
(i32.const 0)
)
(func $foo
Expand Down
Loading