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
1 change: 1 addition & 0 deletions src/wasm-builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ class Builder {
ret->ptr = ptr;
ret->type = type;
ret->memory = memory;
ret->finalize();
return ret;
}
Load* makeAtomicLoad(
Expand Down
3 changes: 3 additions & 0 deletions src/wasm/wasm-ir-builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,9 @@ Result<Expression*> IRBuilder::finishScope(Block* block) {
} else {
auto hoisted = hoistLastValue();
CHECK_ERR(hoisted);
if (!hoisted) {
return Err{"popping from empty stack"};
}
auto hoistedType = scope.exprStack.back()->type;
if (hoistedType.size() != type.size()) {
// We cannot propagate the hoisted value directly because it does not
Expand Down
2 changes: 1 addition & 1 deletion test/ctor-eval/bad-indirect-call2.wast
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(module
(import "env" "_abort" (func $_abort))
(type $v (func))
(memory 256 256)
(data (i32.const 10) "waka waka waka waka waka")
(import "env" "_abort" (func $_abort))
(table 2 2 funcref)
(elem (i32.const 0) $_abort $call-indirect)
(export "test1" (func $test1))
Expand Down
4 changes: 2 additions & 2 deletions test/ctor-eval/imported-global-2.wast
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(module
(memory 256 256)

;; imports must not be used
(import "env" "imported" (global $imported i32))

(memory 256 256)

(func $test1 (export "test1") (result i32)
(local $temp i32)

Expand Down
2 changes: 1 addition & 1 deletion test/ctor-eval/imported-global.wast
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(module
(import "env" "tempDoublePtr" (global $tempDoublePtr i32))
(memory 256 256)
(data (i32.const 10) "waka waka waka waka waka")
;; imports must not be used
(import "env" "tempDoublePtr" (global $tempDoublePtr i32))
(export "test1" (func $test1))
(global $mine (mut i32) (global.get $tempDoublePtr)) ;; BAD, if used
(func $test1
Expand Down
2 changes: 1 addition & 1 deletion test/ctor-eval/indirect-call3.wast
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(module
(import "env" "_abort" (func $_abort))
(type $v (func))
(memory 256 256)
(data (i32.const 10) "waka waka waka waka waka")
(import "env" "_abort" (func $_abort))
(table 2 2 funcref)
(elem (i32.const 0) $_abort $call-indirect)
(export "test1" (func $test1))
Expand Down
5 changes: 4 additions & 1 deletion test/lit/passes/vacuum_all-features.wast
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
;; RUN: foreach %s %t wasm-opt --vacuum --all-features -S -o - | filecheck %s

(module
(memory 256 256)
;; CHECK: (type $0 (func))
(type $0 (func))
;; CHECK: (type $3 (func (result i32)))
Expand All @@ -16,14 +15,18 @@
(type $3 (func (result i32)))
;; CHECK: (type $4 (func (param i32 f64 i32 i32)))
(type $4 (func (param i32 f64 i32 i32)))

;; CHECK: (type $5 (func (param i32) (result i32)))

;; CHECK: (type $6 (func (result f64)))

;; CHECK: (import "env" "int" (func $int (type $3) (result i32)))
(import "env" "int" (func $int (result i32)))

;; CHECK: (global $Int i32 (i32.const 0))
(global $Int i32 (i32.const 0))

(memory 256 256)
;; CHECK: (memory $0 256 256)

;; CHECK: (func $b (type $0)
Expand Down
14 changes: 7 additions & 7 deletions test/lit/validation/closed-world-interface.wast
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,29 @@

(type $private (func (param v128)))

(func $1 (export "test1") (type $void)
;; Ok even though it is an import instead of an export.
(func $1 (import "env" "test5") (type $exported-pair-1))

(func $2 (export "test1") (type $void)
(unreachable)
)

;; Ok because it only refers to basic heap types
(func $2 (export "test2") (type $abstract)
(func $3 (export "test2") (type $abstract)
(unreachable)
)

;; Not ok because it refers to $struct.
(func $3 (export "test3") (type $concrete)
(func $4 (export "test3") (type $concrete)
(unreachable)
)

;; Ok even though it is in a rec group because the rest of the group and the
;; types this refers to are on the boundary as well.
(func $4 (export "test4") (type $exported-pair-0)
(func $5 (export "test4") (type $exported-pair-0)
(unreachable)
)

;; Ok even though it is an import instead of an export.
(func $5 (import "env" "test5") (type $exported-pair-1))

;; Ok, and we also allow the other type in the group.
(func $6 (export "test6") (type $partial-pair-0)
(unreachable)
Expand Down
4 changes: 2 additions & 2 deletions test/lit/validation/extended-const.wast
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
;; EXTENDED: ) "hello world")

(module
(memory 1 1)
(import "env" "global" (global i32))
(memory 1 1)
(global i32 (i32.add (global.get 0) (i32.const 42)))
(data (i32.sub (global.get 0) (i32.const 10)) "hello world")
(data (offset (i32.sub (global.get 0) (i32.const 10))) "hello world")
)
4 changes: 2 additions & 2 deletions test/lit/wasm-split/export-name-already-exists.wast
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
;; CHECK: error: Export foo already exists.

(module
(memory 0 0)
(export "foo" (memory 0 0))
(memory $m 0 0)
(export "foo" (memory $m))
)
4 changes: 2 additions & 2 deletions test/lit/wasm-split/merge-profiles.wast
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
;; SPLIT-NEXT: Splitting out functions: qux{{$}}

(module
(memory 0 0)
(export "memory" (memory 0 0))
(memory $m 0 0)
(export "memory" (memory $m))
(export "foo" (func $foo))
(export "bar" (func $bar))
(export "baz" (func $baz))
Expand Down
4 changes: 2 additions & 2 deletions test/lit/wasm-split/mismatched-hashes.wast
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
;; RUN: wasm-split %s --profile=%t.prof -o1 %t.1.wasm -o2 %t.2.wasm

(module
(memory 0 0)
(export "memory" (memory 0 0))
(memory $m 0 0)
(export "memory" (memory $m))
)
4 changes: 2 additions & 2 deletions test/lit/wasm-split/print-profile.wast
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
;; UNESCAPED: - bar(double[3])

(module
(memory 0 0)
(export "memory" (memory 0 0))
(memory $m 0 0)
(export "memory" (memory $m))
(export "foo" (func $foo))
(export "bar" (func $bar\28double\5b3\5d\29))
(func $foo
Expand Down
8 changes: 4 additions & 4 deletions test/metadce/corners.wast
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
(module
(import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32))
(global $STACKTOP (mut i32) (global.get $STACKTOP$asm2wasm$import))

(import "env" "UNUSEDTOP" (global $UNUSEDTOP$asm2wasm$import i32))
(global $UNUSEDTOP (mut i32) (global.get $UNUSEDTOP$asm2wasm$import))

(import "env" "imported_twice" (func $imported_twice_a)) ;; and used just once,
(import "env" "imported_twice" (func $imported_twice_b)) ;; but the other should not kill the import for both!

(import "env" "an-imported-table-func" (func $imported_table_func))

(import "env" "table" (table 10 10 funcref))

(global $STACKTOP (mut i32) (global.get $STACKTOP$asm2wasm$import))
(global $UNUSEDTOP (mut i32) (global.get $UNUSEDTOP$asm2wasm$import))

(elem (i32.const 0) $imported_table_func)

(export "stackAlloc" (func $stackAlloc))
Expand All @@ -20,4 +21,3 @@
(call $imported_twice_a)
)
)

7 changes: 4 additions & 3 deletions test/metadce/outside.wast
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
(import "env" "memory" (memory $0 256 256))
(import "env" "table" (table 10 10 funcref))

(global $from_segment (import "env" "g1") i32)
(global $from_segment_2 (import "env" "g2") i32)
(global $from_segment_never_used (import "env" "g3") i32)

(export "wasm_func" (func $a_wasm_func))
(export "wasm_func_unused" (func $an_unused_wasm_func))

(global $__THREW__ (mut i32) (i32.const 0))
(global $__THREW__unused (mut i32) (i32.const 0))
(global $from_segment (import "env" "g1") i32)
(global $from_segment_2 (import "env" "g2") i32)
(global $from_segment_never_used (import "env" "g3") i32)

(data (i32.const 1024) "abcd")
(data (global.get $from_segment) "abcd")
Expand Down
5 changes: 3 additions & 2 deletions test/metadce/spanning_cycle.wast
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
(module
(import "env" "js_func" (func $a_js_func))

(memory 1 1)
(data "Hello, datacount section!")

(import "env" "js_func" (func $a_js_func))
(data "Hello, datacount section!")

(export "wasm_func_a" (func $a_wasm_func))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,10 @@
)
)
(module
(memory 0)
(type $FUNCSIG$v (func))
(import "env" "i" (func $i))
(import "env" "j" (func $j))
(memory 0)
(type $FUNCSIG$v (func))
(func $erase (type $FUNCSIG$v)
(call $i)
)
Expand All @@ -447,10 +447,10 @@
)
)
(module
(memory 0)
(type $FUNCSIG$v (func))
(import "env" "i" (func $i))
(import "env" "j" (func $j))
(memory 0)
(type $FUNCSIG$v (func))
(func $keep2 (type $FUNCSIG$v)
(call $i)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,10 @@
)
)
(module
(memory 0)
(type $FUNCSIG$v (func))
(import "env" "i" (func $i))
(import "env" "j" (func $j))
(memory 0)
(type $FUNCSIG$v (func))
(func $erase (type $FUNCSIG$v)
(call $i)
)
Expand All @@ -447,10 +447,10 @@
)
)
(module
(memory 0)
(type $FUNCSIG$v (func))
(import "env" "i" (func $i))
(import "env" "j" (func $j))
(memory 0)
(type $FUNCSIG$v (func))
(func $keep2 (type $FUNCSIG$v)
(call $i)
)
Expand Down
2 changes: 1 addition & 1 deletion test/passes/remove-imports.wast
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(module
(memory 1024 1024)
(type $FUNCSIG$v (func))
(type $FUNCSIG$i (func (result i32)))
(type $FUNCSIG$d (func (result f64)))
Expand All @@ -9,6 +8,7 @@
(import "somewhere" "waka-sneaky" (func $waka-sneaky))
(import "env" "memBase" (global i32))
(import "env" "table" (table $table 1 1 funcref))
(memory 1024 1024)
(elem (i32.const 0) $waka-sneaky)
(func $nada (type $FUNCSIG$v)
(call $waka)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@
)
(module ;; non-exported tags can be removed
(type $0 (func (param i32)))
(import "env" "e" (tag $e2 (param i32)))
(tag $e0 (type $0))
(tag $e1 (param i64))
(export "e1" (tag $e1))
(import "env" "e" (tag $e2 (param i32)))
(func $f (; 0 ;) (type $0))
)
2 changes: 1 addition & 1 deletion test/passes/safe-heap_disable-simd.wast
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
(memory 1 1)
)
(module
(memory 1 1)
(import "env" "emscripten_get_sbrk_ptr" (func $foo (result i32)))
(memory 1 1)
)
(module
(memory 1 1)
Expand Down
4 changes: 2 additions & 2 deletions test/passes/simplify-locals_all-features.wast
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(module
(memory 256 256)
(type $FUNCSIG$v (func))
(type $FUNCSIG$i (func (result i32)))
(type $FUNCSIG$iiiii (func (param i32 i32 i32 i32) (result i32)))
Expand All @@ -13,6 +12,7 @@
(import "env" "moddi" (func $___udivmoddi4 (param i32 i32 i32 i32 i32) (result i32)))
(import "env" "lp" (func $lp (param i32 i32) (result i32)))
(import "fuzzing-support" "log-f32" (func $fimport$0 (param f32)))
(memory 256 256)
(global $global$0 (mut i32) (i32.const 10))
(func $contrast ;; check for tee and structure sinking
(local $x i32)
Expand Down Expand Up @@ -1187,7 +1187,6 @@
)
)
(module
(memory 256 256 shared)
(type $FUNCSIG$v (func))
(type $FUNCSIG$i (func (result i32)))
(type $FUNCSIG$iiiii (func (param i32 i32 i32 i32) (result i32)))
Expand All @@ -1198,6 +1197,7 @@
(import "fuzzing-support" "log1" (func $fimport$0 (result i32)))
(import "fuzzing-support" "log2" (func $fimport$1 (param i32)))
(import "fuzzing-support" "log3" (func $fimport$2 (param f32)))
(memory 256 256 shared)
(global $global$0 (mut i32) (i32.const 10))
(func $nonatomics (result i32) ;; loads are reordered
(local $x i32)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(module
(memory 256 256)
(type $FUNCSIG$v (func))
(type $FUNCSIG$i (func (result i32)))
(type $FUNCSIG$iiiii (func (param i32 i32 i32 i32) (result i32)))
Expand All @@ -13,6 +12,7 @@
(import "env" "moddi" (func $___udivmoddi4 (param i32 i32 i32 i32 i32) (result i32)))
(import "env" "lp" (func $lp (param i32 i32) (result i32)))
(import "fuzzing-support" "log-f32" (func $fimport$0 (param f32)))
(memory 256 256)
(global $global$0 (mut i32) (i32.const 10))
(func $contrast ;; check for tee and structure sinking
(local $x i32)
Expand Down Expand Up @@ -1187,7 +1187,6 @@
)
)
(module
(memory 256 256 shared)
(type $FUNCSIG$v (func))
(type $FUNCSIG$i (func (result i32)))
(type $FUNCSIG$iiiii (func (param i32 i32 i32 i32) (result i32)))
Expand All @@ -1198,6 +1197,7 @@
(import "fuzzing-support" "log1" (func $fimport$0 (result i32)))
(import "fuzzing-support" "log2" (func $fimport$1 (param i32)))
(import "fuzzing-support" "log3" (func $fimport$2 (param f32)))
(memory 256 256 shared)
(global $global$0 (mut i32) (i32.const 10))
(func $nonatomics (result i32) ;; loads are reordered
(local $x i32)
Expand Down
Loading