summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/port_passes_tests_to_lit.py2
-rw-r--r--test/lit/passes/remove-unused-brs_all-features.wast225
-rw-r--r--test/passes/remove-unused-brs_all-features.txt116
-rw-r--r--test/passes/remove-unused-brs_all-features.wast99
4 files changed, 226 insertions, 216 deletions
diff --git a/scripts/port_passes_tests_to_lit.py b/scripts/port_passes_tests_to_lit.py
index 1ac5ac838..659cc20d2 100755
--- a/scripts/port_passes_tests_to_lit.py
+++ b/scripts/port_passes_tests_to_lit.py
@@ -91,7 +91,7 @@ def port_test(args, test):
continue
os.remove(f)
if args.git_add:
- subprocess.rcheck_call(['git', 'add', f])
+ subprocess.check_call(['git', 'add', f])
if args.git_add:
subprocess.check_call(['git', 'add', dest])
diff --git a/test/lit/passes/remove-unused-brs_all-features.wast b/test/lit/passes/remove-unused-brs_all-features.wast
new file mode 100644
index 000000000..8ca632040
--- /dev/null
+++ b/test/lit/passes/remove-unused-brs_all-features.wast
@@ -0,0 +1,225 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
+;; NOTE: This test was ported using port_passes_tests_to_lit.py and could be cleaned up.
+
+;; RUN: foreach %s %t wasm-opt --remove-unused-brs --all-features -S -o - | filecheck %s
+
+(module
+ ;; CHECK: (type $vector (array (mut i32)))
+ (type $vector (array (mut i32)))
+ ;; CHECK: (type $struct (struct (field (ref null $vector))))
+ (type $struct (struct (field (ref null $vector))))
+ ;; CHECK: (type $ref|func|_=>_none (func (param (ref func))))
+
+ ;; CHECK: (type $i32_=>_none (func (param i32)))
+
+ ;; CHECK: (type $none_=>_ref?|$struct| (func (result (ref null $struct))))
+
+ ;; CHECK: (type $none_=>_f64 (func (result f64)))
+
+ ;; CHECK: (type $none_=>_i32 (func (result i32)))
+
+ ;; CHECK: (type $i32_=>_funcref (func (param i32) (result funcref)))
+
+ ;; CHECK: (import "out" "log" (func $log (type $i32_=>_none) (param i32)))
+ (import "out" "log" (func $log (param i32)))
+ ;; CHECK: (elem declare func $br_on-to-br $i32_=>_none $none_=>_i32)
+
+ ;; CHECK: (func $foo (type $none_=>_ref?|$struct|) (result (ref null $struct))
+ ;; CHECK-NEXT: (if (result (ref null $struct))
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: (struct.new $struct
+ ;; CHECK-NEXT: (array.new_default $vector
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (ref.null none)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $foo (result (ref null $struct))
+ (if (result (ref null $struct))
+ (i32.const 1)
+ (struct.new $struct
+ ;; regression test for computing the cost of an array.new_default, which
+ ;; lacks the optional field "init"
+ (array.new_default $vector
+ (i32.const 1)
+ )
+ )
+ (ref.null $struct)
+ )
+ )
+
+ ;; CHECK: (func $test-prefinalize (type $none_=>_f64) (result f64)
+ ;; CHECK-NEXT: (loop $loop (result f64)
+ ;; CHECK-NEXT: (if (result f64)
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: (f64.const 0)
+ ;; CHECK-NEXT: (block $block (result f64)
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: (br_if $loop
+ ;; CHECK-NEXT: (i32.eqz
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $test-prefinalize (result f64)
+ (loop $loop (result f64)
+ (block $block (result f64)
+ (drop
+ (br_if $block
+ (f64.const 0)
+ (i32.const 1)
+ )
+ )
+ (if
+ (i32.const 0)
+ (unreachable)
+ )
+ ;; this will be moved from $block into the if right before it. we must be
+ ;; careful to properly finalize() things, as if we finalize the block too
+ ;; early - before the if - then the block ends in a none type, which is
+ ;; invalid.
+ (br $loop)
+ )
+ )
+ )
+
+ ;; CHECK: (func $none_=>_i32 (type $none_=>_i32) (result i32)
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: )
+ (func $none_=>_i32 (result i32)
+ (unreachable)
+ )
+ ;; CHECK: (func $i32_=>_none (type $i32_=>_none) (param $0 i32)
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: )
+ (func $i32_=>_none (param i32)
+ )
+ ;; CHECK: (func $selectify (type $i32_=>_funcref) (param $x i32) (result funcref)
+ ;; CHECK-NEXT: (select (result funcref)
+ ;; CHECK-NEXT: (ref.func $none_=>_i32)
+ ;; CHECK-NEXT: (ref.func $i32_=>_none)
+ ;; CHECK-NEXT: (local.get $x)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $selectify (param $x i32) (result funcref)
+ ;; this if has arms with different function types, for which funcref is the
+ ;; LUB
+ (if (result funcref)
+ (local.get $x)
+ (ref.func $none_=>_i32)
+ (ref.func $i32_=>_none)
+ )
+ )
+
+ ;; CHECK: (func $br_on-to-br (type $ref|func|_=>_none) (param $func (ref func))
+ ;; CHECK-NEXT: (call $log
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (block $null
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (ref.func $br_on-to-br)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $log
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $log
+ ;; CHECK-NEXT: (i32.const 2)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (block $func (result (ref $ref|func|_=>_none))
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (br $func
+ ;; CHECK-NEXT: (ref.func $br_on-to-br)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $log
+ ;; CHECK-NEXT: (i32.const 3)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (ref.func $br_on-to-br)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $log
+ ;; CHECK-NEXT: (i32.const 4)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (block $i31 (result (ref i31))
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (br $i31
+ ;; CHECK-NEXT: (i31.new
+ ;; CHECK-NEXT: (i32.const 42)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $log
+ ;; CHECK-NEXT: (i32.const 5)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i31.new
+ ;; CHECK-NEXT: (i32.const 1337)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $log
+ ;; CHECK-NEXT: (i32.const 6)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (block $non-null (result (ref $ref|func|_=>_none))
+ ;; CHECK-NEXT: (br $non-null
+ ;; CHECK-NEXT: (ref.func $br_on-to-br)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $log
+ ;; CHECK-NEXT: (i32.const 7)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (ref.func $br_on-to-br)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $br_on-to-br (param $func (ref func))
+ (call $log (i32.const 0))
+ (block $null
+ ;; a non-null reference is not null, and the br is never taken
+ (drop
+ (br_on_null $null (ref.func $br_on-to-br))
+ )
+ (call $log (i32.const 1))
+ )
+ (call $log (i32.const 2))
+ (drop
+ (block $func (result funcref)
+ ;; a non-null function reference means we always take the br
+ (drop
+ (br_on_func $func (ref.func $br_on-to-br))
+ )
+ (call $log (i32.const 3))
+ (ref.func $br_on-to-br)
+ )
+ )
+ (call $log (i32.const 4))
+ (drop
+ (block $i31 (result i31ref)
+ ;; a non-null i31 reference means we always take the br
+ (drop
+ (br_on_i31 $i31
+ (i31.new (i32.const 42))
+ )
+ )
+ (call $log (i32.const 5))
+ (i31.new (i32.const 1337))
+ )
+ )
+ (call $log (i32.const 6))
+ (drop
+ (block $non-null (result (ref func))
+ ;; a non-null reference is not null, and the br is always taken
+ (br_on_non_null $non-null (ref.func $br_on-to-br))
+ (call $log (i32.const 7))
+ (ref.func $br_on-to-br)
+ )
+ )
+ )
+)
diff --git a/test/passes/remove-unused-brs_all-features.txt b/test/passes/remove-unused-brs_all-features.txt
deleted file mode 100644
index cd2630f75..000000000
--- a/test/passes/remove-unused-brs_all-features.txt
+++ /dev/null
@@ -1,116 +0,0 @@
-(module
- (type $vector (array (mut i32)))
- (type $struct (struct (field (ref null $vector))))
- (type $ref|func|_=>_none (func (param (ref func))))
- (type $i32_=>_none (func (param i32)))
- (type $none_=>_ref?|$struct| (func (result (ref null $struct))))
- (type $none_=>_f64 (func (result f64)))
- (type $none_=>_i32 (func (result i32)))
- (type $i32_=>_funcref (func (param i32) (result funcref)))
- (import "out" "log" (func $log (type $i32_=>_none) (param i32)))
- (elem declare func $br_on-to-br $i32_=>_none $none_=>_i32)
- (func $foo (type $none_=>_ref?|$struct|) (result (ref null $struct))
- (if (result (ref null $struct))
- (i32.const 1)
- (struct.new $struct
- (array.new_default $vector
- (i32.const 1)
- )
- )
- (ref.null none)
- )
- )
- (func $test-prefinalize (type $none_=>_f64) (result f64)
- (loop $loop (result f64)
- (if (result f64)
- (i32.const 1)
- (f64.const 0)
- (block $block (result f64)
- (nop)
- (br_if $loop
- (i32.eqz
- (i32.const 0)
- )
- )
- (unreachable)
- )
- )
- )
- )
- (func $none_=>_i32 (type $none_=>_i32) (result i32)
- (unreachable)
- )
- (func $i32_=>_none (type $i32_=>_none) (param $0 i32)
- (nop)
- )
- (func $selectify (type $i32_=>_funcref) (param $x i32) (result funcref)
- (select (result funcref)
- (ref.func $none_=>_i32)
- (ref.func $i32_=>_none)
- (local.get $x)
- )
- )
- (func $br_on-to-br (type $ref|func|_=>_none) (param $func (ref func))
- (call $log
- (i32.const 0)
- )
- (block $null
- (drop
- (ref.func $br_on-to-br)
- )
- (call $log
- (i32.const 1)
- )
- )
- (call $log
- (i32.const 2)
- )
- (drop
- (block $func (result (ref $ref|func|_=>_none))
- (drop
- (br $func
- (ref.func $br_on-to-br)
- )
- )
- (call $log
- (i32.const 3)
- )
- (ref.func $br_on-to-br)
- )
- )
- (call $log
- (i32.const 4)
- )
- (drop
- (block $i31 (result (ref i31))
- (drop
- (br $i31
- (i31.new
- (i32.const 42)
- )
- )
- )
- (call $log
- (i32.const 5)
- )
- (i31.new
- (i32.const 1337)
- )
- )
- )
- (call $log
- (i32.const 6)
- )
- (drop
- (block $non-null (result (ref $ref|func|_=>_none))
- (br $non-null
- (ref.func $br_on-to-br)
- )
- (call $log
- (i32.const 7)
- )
- (ref.func $br_on-to-br)
- )
- )
- )
-)
diff --git a/test/passes/remove-unused-brs_all-features.wast b/test/passes/remove-unused-brs_all-features.wast
deleted file mode 100644
index 5960e1029..000000000
--- a/test/passes/remove-unused-brs_all-features.wast
+++ /dev/null
@@ -1,99 +0,0 @@
-(module
- (type $vector (array (mut i32)))
- (type $struct (struct (field (ref null $vector))))
- (import "out" "log" (func $log (param i32)))
- (func $foo (result (ref null $struct))
- (if (result (ref null $struct))
- (i32.const 1)
- (struct.new $struct
- ;; regression test for computing the cost of an array.new_default, which
- ;; lacks the optional field "init"
- (array.new_default $vector
- (i32.const 1)
- )
- )
- (ref.null $struct)
- )
- )
-
- (func $test-prefinalize (result f64)
- (loop $loop (result f64)
- (block $block (result f64)
- (drop
- (br_if $block
- (f64.const 0)
- (i32.const 1)
- )
- )
- (if
- (i32.const 0)
- (unreachable)
- )
- ;; this will be moved from $block into the if right before it. we must be
- ;; careful to properly finalize() things, as if we finalize the block too
- ;; early - before the if - then the block ends in a none type, which is
- ;; invalid.
- (br $loop)
- )
- )
- )
-
- (func $none_=>_i32 (result i32)
- (unreachable)
- )
- (func $i32_=>_none (param i32)
- )
- (func $selectify (param $x i32) (result funcref)
- ;; this if has arms with different function types, for which funcref is the
- ;; LUB
- (if (result funcref)
- (local.get $x)
- (ref.func $none_=>_i32)
- (ref.func $i32_=>_none)
- )
- )
-
- (func $br_on-to-br (param $func (ref func))
- (call $log (i32.const 0))
- (block $null
- ;; a non-null reference is not null, and the br is never taken
- (drop
- (br_on_null $null (ref.func $br_on-to-br))
- )
- (call $log (i32.const 1))
- )
- (call $log (i32.const 2))
- (drop
- (block $func (result funcref)
- ;; a non-null function reference means we always take the br
- (drop
- (br_on_func $func (ref.func $br_on-to-br))
- )
- (call $log (i32.const 3))
- (ref.func $br_on-to-br)
- )
- )
- (call $log (i32.const 4))
- (drop
- (block $i31 (result i31ref)
- ;; a non-null i31 reference means we always take the br
- (drop
- (br_on_i31 $i31
- (i31.new (i32.const 42))
- )
- )
- (call $log (i32.const 5))
- (i31.new (i32.const 1337))
- )
- )
- (call $log (i32.const 6))
- (drop
- (block $non-null (result (ref func))
- ;; a non-null reference is not null, and the br is always taken
- (br_on_non_null $non-null (ref.func $br_on-to-br))
- (call $log (i32.const 7))
- (ref.func $br_on-to-br)
- )
- )
- )
-) \ No newline at end of file