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
13 changes: 8 additions & 5 deletions src/wasm/wasm-ir-builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,15 +414,18 @@ Result<Expression*> IRBuilder::getBranchValue(Name labelName,
}
auto scope = getScope(*label);
CHECK_ERR(scope);
std::vector<Expression*> values((*scope)->getResultType().size());
for (size_t i = 0, size = values.size(); i < size; ++i) {
// Loops would receive their input type rather than their output type, if we
// supported that.
size_t numValues = (*scope)->getLoop() ? 0 : (*scope)->getResultType().size();
std::vector<Expression*> values(numValues);
for (size_t i = 0; i < numValues; ++i) {
auto val = pop();
CHECK_ERR(val);
values[size - 1 - i] = *val;
values[numValues - 1 - i] = *val;
}
if (values.size() == 0) {
if (numValues == 0) {
return nullptr;
} else if (values.size() == 1) {
} else if (numValues == 1) {
return values[0];
} else {
return builder.makeTupleMake(values);
Expand Down
2 changes: 1 addition & 1 deletion test/ctor-eval/bad-indirect-call.wast
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
(data (i32.const 10) "waka waka waka waka waka")
(table 1 1 funcref)
(elem (i32.const 0) $call-indirect)
(export "test1" $test1)
(export "test1" (func $test1))
(func $test1
(call_indirect (type $v) (i32.const 1)) ;; unsafe to call, out of range
(i32.store8 (i32.const 20) (i32.const 120))
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
Expand Up @@ -5,7 +5,7 @@
(import "env" "_abort" (func $_abort))
(table 2 2 funcref)
(elem (i32.const 0) $_abort $call-indirect)
(export "test1" $test1)
(export "test1" (func $test1))
(func $test1
(call_indirect (type $v) (i32.const 0)) ;; unsafe to call, imported
(i32.store8 (i32.const 20) (i32.const 120))
Expand Down
6 changes: 3 additions & 3 deletions test/ctor-eval/basics-flatten.wast
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
(data (i32.const 20) "waka waka waka")
(table 1 1 funcref)
(elem (i32.const 0) $call-indirect)
(export "test1" $test1)
(export "test2" $test2)
(export "test3" $test3)
(export "test1" (func $test1))
(export "test2" (func $test2))
(export "test3" (func $test3))
(func $test1
(drop (i32.const 0)) ;; no work at all, really
(call $safe-to-call) ;; safe to call
Expand Down
6 changes: 3 additions & 3 deletions test/ctor-eval/basics.wast
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
(data (i32.const 10) "waka waka waka waka waka")
(table 1 1 funcref)
(elem (i32.const 0) $call-indirect)
(export "test1" $test1)
(export "test2" $test2)
(export "test3" $test3)
(export "test1" (func $test1))
(export "test2" (func $test2))
(export "test3" (func $test3))
(func $test1
(drop (i32.const 0)) ;; no work at all, really
(call $safe-to-call) ;; safe to call
Expand Down
2 changes: 1 addition & 1 deletion test/ctor-eval/imported-global.wast
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
(data (i32.const 10) "waka waka waka waka waka")
;; imports must not be used
(import "env" "tempDoublePtr" (global $tempDoublePtr i32))
(export "test1" $test1)
(export "test1" (func $test1))
(global $mine (mut i32) (global.get $tempDoublePtr)) ;; BAD, if used
(func $test1
(i32.store8 (i32.const 13) (i32.const 115)) ;; we never get here.
Expand Down
2 changes: 1 addition & 1 deletion test/ctor-eval/indirect-call3.wast
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(import "env" "_abort" (func $_abort))
(table 2 2 funcref)
(elem (i32.const 0) $_abort $call-indirect)
(export "test1" $test1)
(export "test1" (func $test1))
(func $test1
(call_indirect (type $v) (i32.const 1)) ;; safe to call
(i32.store8 (i32.const 20) (i32.const 120))
Expand Down
6 changes: 3 additions & 3 deletions test/ctor-eval/just_some.wast
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(module
(memory 256 256)
(data (i32.const 10) "waka waka waka waka waka")
(export "test1" $test1)
(export "test2" $test2)
(export "test3" $test3)
(export "test1" (func $test1))
(export "test2" (func $test2))
(export "test3" (func $test3))
(func $test1
(i32.store8 (i32.const 12) (i32.const 115)) ;; a safe store, should alter memory
)
Expand Down
2 changes: 1 addition & 1 deletion test/ctor-eval/partial-locals-tee.wast
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
(memory 256 256)
(data (i32.const 10) "_________________")

(export "test1" $test1)
(export "test1" (func $test1))

(func $test1
(local $temp i32)
Expand Down
2 changes: 1 addition & 1 deletion test/ctor-eval/partial-locals.wast
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
(memory 256 256)
(data (i32.const 10) "_________________")

(export "test1" $test1)
(export "test1" (func $test1))

(global $sp (mut i32) (i32.const 100))

Expand Down
2 changes: 1 addition & 1 deletion test/ctor-eval/partial-return.wast
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
(memory 256 256)
(data (i32.const 10) "_________________")

(export "test1" $test1)
(export "test1" (func $test1))
(export "memory" (memory $0))

(func $test1
Expand Down
4 changes: 2 additions & 2 deletions test/ctor-eval/partial.wast
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
(memory 256 256)
(data (i32.const 10) "_________________")

(export "test1" $test1)
(export "test1" (func $test1))

;; Use the function in an additional export. We should still get the same
;; results if we call this one, so it should point to identical contents as
;; earlier
(export "keepalive" $test1)
(export "keepalive" (func $test1))

(func $test1
;; A safe store, should alter memory
Expand Down
2 changes: 1 addition & 1 deletion test/ctor-eval/unsafe_call.wast
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(module
(memory 256 256)
(data (i32.const 10) "waka waka waka waka waka")
(export "test1" $test1)
(export "test1" (func $test1))
(func $test1
(call $unsafe-to-call) ;; unsafe to call
(i32.store (i32.const 12) (i32.const 115)) ;; a safe store, should alter memory
Expand Down
2 changes: 1 addition & 1 deletion test/ctor-eval/unsafe_store.wast
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(module
(memory 256 256)
(data (i32.const 10) "waka waka waka waka waka")
(export "test1" $test1)
(export "test1" (func $test1))
(func $test1
(i32.store8 (i32.const 9) (i32.const 109)) ;; before first segment
)
Expand Down
2 changes: 1 addition & 1 deletion test/ctor-eval/unsafe_store2.wast
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(module
(memory 256 256)
(data (i32.const 10) "waka waka waka waka waka")
(export "test1" $test1)
(export "test1" (func $test1))
(func $test1
(i32.store8 (i32.const 34) (i32.const 109)) ;; after last segment
)
Expand Down
2 changes: 1 addition & 1 deletion test/ctor-eval/unsafe_store3.wast
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(module
(memory 256 256)
(data (i32.const 10) "waka waka waka waka waka")
(export "test1" $test1)
(export "test1" (func $test1))
(func $test1
(i32.store16 (i32.const 33) (i32.const 109)) ;; after last segment due to size of type
)
Expand Down
2 changes: 1 addition & 1 deletion test/lit/basic/atomics.wast
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@
)
)
(drop
(memory.atomic.wait64 align=8 offset=16
(memory.atomic.wait64 offset=16 align=8
(local.get $0)
(local.get $1)
(local.get $1)
Expand Down
2 changes: 1 addition & 1 deletion test/lit/basic/atomics64.wast
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@
)
)
(drop
(memory.atomic.wait64 align=8 offset=16
(memory.atomic.wait64 offset=16 align=8
(local.get $0)
(local.get $1)
(local.get $1)
Expand Down
2 changes: 1 addition & 1 deletion test/lit/basic/multi-table.wast
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
;; table.
;; CHECK-TEXT: (elem $especial (table $tspecial) (i32.const 0) (ref null $none_=>_none) (ref.func $f) (ref.func $h))
;; CHECK-BIN: (elem $especial (table $tspecial) (i32.const 0) (ref null $none_=>_none) (ref.func $f) (ref.func $h))
(elem $especial (table $tspecial) (i32.const 0) (ref null $none_=>_none) $f $h)
(elem $especial (table $tspecial) (i32.const 0) (ref null $none_=>_none) (ref.func $f) (ref.func $h))

;; CHECK-TEXT: (func $f (type $none_=>_none)
;; CHECK-TEXT-NEXT: (drop
Expand Down
2 changes: 1 addition & 1 deletion test/lit/basic/reference-types.wast
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@

(import "env" "import_func" (func $import_func (param eqref) (result funcref)))
(import "env" "import_global" (global $import_global eqref))
(export "export_func" (func $import_func (param eqref) (result funcref)))
(export "export_func" (func $import_func))
(export "export_global" (global $import_global))

;; Test global initializer expressions
Expand Down
4 changes: 2 additions & 2 deletions test/lit/basic/simd.wast
Original file line number Diff line number Diff line change
Expand Up @@ -1738,7 +1738,7 @@
;; CHECK-BIN-NEXT: )
;; CHECK-BIN-NEXT: )
(func $v128.load64_lane_align_offset (param $0 i32) (param $1 v128) (result v128)
(v128.load64_lane align=1 offset=32 0
(v128.load64_lane offset=32 align=1 0
(local.get $0)
(local.get $1)
)
Expand Down Expand Up @@ -1871,7 +1871,7 @@
;; CHECK-BIN-NEXT: )
;; CHECK-BIN-NEXT: )
(func $v128.store64_lane_align_offset (param $0 i32) (param $1 v128)
(v128.store64_lane align=1 offset=32 0
(v128.store64_lane offset=32 align=1 0
(local.get $0)
(local.get $1)
)
Expand Down
4 changes: 2 additions & 2 deletions test/lit/if-then-else.wast
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
;; CHECK-NEXT: )
(func $test (param i32) (result i32)
(if
(local.get $0)
(local.get 0)
(then)
(else
(return (i32.const 0))
)
)
(if
(local.get $0)
(local.get 0)
(then
(return
(i32.const 1)
Expand Down
4 changes: 2 additions & 2 deletions test/lit/merge/renamings.wat
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@
;; CHECK: (table $other 70 80 funcref)

;; CHECK: (elem $foo func $foo $bar)
(elem $foo (ref null func) $foo $bar)
(elem $foo func $foo $bar)

;; This elem has a conflict in second.wat, and so second.wat's $bar
;; will be renamed.
;; CHECK: (elem $bar func $bar $foo)
(elem $bar (ref null func) $bar $foo)
(elem $bar func $bar $foo)

;; CHECK: (elem $other func $foo_3 $other)

Expand Down
4 changes: 2 additions & 2 deletions test/lit/merge/renamings.wat.second
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

(table $other 70 80 funcref)

(elem $other (ref null func) $foo $other)
(elem $other func $foo $other)

(elem $bar (ref null func) $other $foo)
(elem $bar func $other $foo)

(global $other i32 (i32.const 3))

Expand Down
2 changes: 1 addition & 1 deletion test/lit/passes/Oz.wast
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $basics (export "localcse") (param $x i32) ($param $y i32) (result i32) ;; -O3 does localcse
(func $basics (export "localcse") (param $x i32) (param $y i32) (result i32) ;; -O3 does localcse
(local $x2 i32)
(local $y2 i32)
(local.set $x2
Expand Down
12 changes: 6 additions & 6 deletions test/lit/passes/alignment-lowering.wast
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@
(drop (i64.load align=1 (i32.const 12)))
(drop (i64.load align=2 (i32.const 16)))
(drop (i64.load align=4 (i32.const 20)))
(drop (i64.load align=1 offset=3 (i32.const 20)))
(drop (i64.load offset=3 align=1 (i32.const 20)))
(drop (i64.load16_s align=1 (i32.const 28)))
(drop (i64.load32_s align=1 (i32.const 32)))
(drop (i64.load16_u align=1 (i32.const 40)))
Expand Down Expand Up @@ -1088,7 +1088,7 @@
(func $f32-load
(drop (f32.load align=1 (i32.const 12)))
(drop (f32.load align=2 (i32.const 16)))
(drop (f32.load align=1 offset=3 (i32.const 20)))
(drop (f32.load offset=3 align=1 (i32.const 20)))
)
;; CHECK: (func $f64-load
;; CHECK-NEXT: (local $0 i32)
Expand Down Expand Up @@ -1344,7 +1344,7 @@
(drop (f64.load align=1 (i32.const 12)))
(drop (f64.load align=2 (i32.const 16)))
(drop (f64.load align=4 (i32.const 20)))
(drop (f64.load align=1 offset=3 (i32.const 20)))
(drop (f64.load offset=3 align=1 (i32.const 20)))
)
;; CHECK: (func $i64-store
;; CHECK-NEXT: (local $0 i32)
Expand Down Expand Up @@ -1670,7 +1670,7 @@
(i64.store align=1 (i32.const 12) (i64.const 100))
(i64.store align=2 (i32.const 16) (i64.const 200))
(i64.store align=4 (i32.const 20) (i64.const 300))
(i64.store align=1 offset=3 (i32.const 24) (i64.const 400))
(i64.store offset=3 align=1 (i32.const 24) (i64.const 400))
(i64.store16 align=1 (i32.const 20) (i64.const 600))
(i64.store32 align=1 (i32.const 20) (i64.const 700))
)
Expand Down Expand Up @@ -1776,7 +1776,7 @@
(func $f32-store
(f32.store align=1 (i32.const 12) (f32.const 100))
(f32.store align=2 (i32.const 16) (f32.const 200))
(f32.store align=1 offset=3 (i32.const 24) (f32.const 400))
(f32.store offset=3 align=1 (i32.const 24) (f32.const 400))
)
;; CHECK: (func $f64-store
;; CHECK-NEXT: (local $0 i32)
Expand Down Expand Up @@ -2050,6 +2050,6 @@
(f64.store align=1 (i32.const 12) (f64.const 100))
(f64.store align=2 (i32.const 16) (f64.const 200))
(f64.store align=4 (i32.const 20) (f64.const 300))
(f64.store align=1 offset=3 (i32.const 24) (f64.const 400))
(f64.store offset=3 align=1 (i32.const 24) (f64.const 400))
)
)
12 changes: 6 additions & 6 deletions test/lit/passes/alignment-lowering64.wast
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@
(drop (i64.load align=1 (i64.const 12)))
(drop (i64.load align=2 (i64.const 16)))
(drop (i64.load align=4 (i64.const 20)))
(drop (i64.load align=1 offset=3 (i64.const 20)))
(drop (i64.load offset=3 align=1 (i64.const 20)))
(drop (i64.load16_s align=1 (i64.const 28)))
(drop (i64.load32_s align=1 (i64.const 32)))
(drop (i64.load16_u align=1 (i64.const 40)))
Expand Down Expand Up @@ -1088,7 +1088,7 @@
(func $f32-load
(drop (f32.load align=1 (i64.const 12)))
(drop (f32.load align=2 (i64.const 16)))
(drop (f32.load align=1 offset=3 (i64.const 20)))
(drop (f32.load offset=3 align=1 (i64.const 20)))
)
;; CHECK: (func $f64-load
;; CHECK-NEXT: (local $0 i64)
Expand Down Expand Up @@ -1344,7 +1344,7 @@
(drop (f64.load align=1 (i64.const 12)))
(drop (f64.load align=2 (i64.const 16)))
(drop (f64.load align=4 (i64.const 20)))
(drop (f64.load align=1 offset=3 (i64.const 20)))
(drop (f64.load offset=3 align=1 (i64.const 20)))
)
;; CHECK: (func $i64-store
;; CHECK-NEXT: (local $0 i64)
Expand Down Expand Up @@ -1670,7 +1670,7 @@
(i64.store align=1 (i64.const 12) (i64.const 100))
(i64.store align=2 (i64.const 16) (i64.const 200))
(i64.store align=4 (i64.const 20) (i64.const 300))
(i64.store align=1 offset=3 (i64.const 24) (i64.const 400))
(i64.store offset=3 align=1 (i64.const 24) (i64.const 400))
(i64.store16 align=1 (i64.const 20) (i64.const 600))
(i64.store32 align=1 (i64.const 20) (i64.const 700))
)
Expand Down Expand Up @@ -1776,7 +1776,7 @@
(func $f32-store
(f32.store align=1 (i64.const 12) (f32.const 100))
(f32.store align=2 (i64.const 16) (f32.const 200))
(f32.store align=1 offset=3 (i64.const 24) (f32.const 400))
(f32.store offset=3 align=1 (i64.const 24) (f32.const 400))
)
;; CHECK: (func $f64-store
;; CHECK-NEXT: (local $0 i64)
Expand Down Expand Up @@ -2050,6 +2050,6 @@
(f64.store align=1 (i64.const 12) (f64.const 100))
(f64.store align=2 (i64.const 16) (f64.const 200))
(f64.store align=4 (i64.const 20) (f64.const 300))
(f64.store align=1 offset=3 (i64.const 24) (f64.const 400))
(f64.store offset=3 align=1 (i64.const 24) (f64.const 400))
)
)
Loading