summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/passes/dce.txt32
-rw-r--r--test/passes/dce.wast36
-rw-r--r--test/passes/dce_vacuum.txt12
-rw-r--r--test/passes/dce_vacuum.wast14
4 files changed, 94 insertions, 0 deletions
diff --git a/test/passes/dce.txt b/test/passes/dce.txt
index 443417744..96bc6b3b2 100644
--- a/test/passes/dce.txt
+++ b/test/passes/dce.txt
@@ -2,6 +2,8 @@
(memory $0 10)
(type $ii (func (param i32 i32)))
(type $1 (func))
+ (type $2 (func (result i32)))
+ (type $3 (func (param i32) (result i32)))
(table 1 1 anyfunc)
(elem (i32.const 0) $call-me)
(func $call-me (type $ii) (param $0 i32) (param $1 i32)
@@ -296,4 +298,34 @@
(i32.const 2000)
)
)
+ (func $typed-block-none-then-unreachable (type $2) (result i32)
+ (block $top-typed i32
+ (block $switch$0
+ (return
+ (i32.const 0)
+ )
+ )
+ (unreachable)
+ )
+ )
+ (func $typed-block-remove-br-changes-type (type $3) (param $$$0 i32) (result i32)
+ (block $switch$7
+ (block $switch-default$10
+ (block $switch-case$9
+ (block $switch-case$8
+ (br_table $switch-case$9 $switch-case$8 $switch-default$10
+ (i32.const -1)
+ )
+ )
+ )
+ (return
+ (get_local $$$0)
+ )
+ )
+ (return
+ (get_local $$$0)
+ )
+ )
+ (unreachable)
+ )
)
diff --git a/test/passes/dce.wast b/test/passes/dce.wast
index af85945b4..fe8cb73f9 100644
--- a/test/passes/dce.wast
+++ b/test/passes/dce.wast
@@ -393,4 +393,40 @@
(i32.const 2000)
)
)
+ (func $typed-block-none-then-unreachable (result i32)
+ (block $top-typed i32
+ (block $switch$0 ;; this looks like it can be broken to, so it gets type 'none'
+ (return
+ (i32.const 0)
+ )
+ (br $switch$0) ;; this is not reachable, so dce cleans it up, changing $switch$0's type
+ )
+ (return ;; and this is cleaned up as well, leaving $top-typed in need of a type change
+ (i32.const 1)
+ )
+ )
+ )
+ (func $typed-block-remove-br-changes-type (param $$$0 i32) (result i32)
+ (block $switch$7
+ (block $switch-default$10
+ (block $switch-case$9
+ (block $switch-case$8
+ (br_table $switch-case$9 $switch-case$8 $switch-default$10
+ (i32.const -1)
+ )
+ )
+ )
+ (return
+ (get_local $$$0)
+ )
+ (br $switch$7)
+ )
+ (return
+ (get_local $$$0)
+ )
+ )
+ (return
+ (i32.const 0)
+ )
+ )
)
diff --git a/test/passes/dce_vacuum.txt b/test/passes/dce_vacuum.txt
new file mode 100644
index 000000000..876eb3c34
--- /dev/null
+++ b/test/passes/dce_vacuum.txt
@@ -0,0 +1,12 @@
+(module
+ (memory $0 0)
+ (type $0 (func (result i32)))
+ (func $__Z12serveroptionPc (type $0) (result i32)
+ (block $switch$0
+ (return
+ (i32.const 0)
+ )
+ )
+ (unreachable)
+ )
+)
diff --git a/test/passes/dce_vacuum.wast b/test/passes/dce_vacuum.wast
new file mode 100644
index 000000000..a7e43db23
--- /dev/null
+++ b/test/passes/dce_vacuum.wast
@@ -0,0 +1,14 @@
+(module
+ (func $__Z12serveroptionPc (result i32)
+ (block $switch$0
+ (return
+ (i32.const 0)
+ )
+ (br $switch$0)
+ )
+ (return
+ (i32.const 0)
+ )
+ )
+)
+