diff options
Diffstat (limited to 'test/passes')
-rw-r--r-- | test/passes/dae_enable-tail-call.txt (renamed from test/passes/dae.txt) | 38 | ||||
-rw-r--r-- | test/passes/dae_enable-tail-call.wast (renamed from test/passes/dae.wast) | 32 | ||||
-rw-r--r-- | test/passes/directize_enable-tail-call.txt (renamed from test/passes/directize.txt) | 14 | ||||
-rw-r--r-- | test/passes/directize_enable-tail-call.wast (renamed from test/passes/directize.wast) | 15 | ||||
-rw-r--r-- | test/passes/inlining_enable-tail-call.txt (renamed from test/passes/inlining.txt) | 164 | ||||
-rw-r--r-- | test/passes/inlining_enable-tail-call.wast (renamed from test/passes/inlining.wast) | 113 |
6 files changed, 374 insertions, 2 deletions
diff --git a/test/passes/dae.txt b/test/passes/dae_enable-tail-call.txt index 2789d5206..1854f8a33 100644 --- a/test/passes/dae.txt +++ b/test/passes/dae_enable-tail-call.txt @@ -243,3 +243,41 @@ ) ) ) +(module + (type $FUNCSIG$ii (func (param i32) (result i32))) + (func $foo (; 0 ;) (type $FUNCSIG$ii) (param $x i32) (result i32) + (drop + (return_call $bar) + ) + (i32.const 42) + ) + (func $bar (; 1 ;) (result i32) + (local $0 i32) + (local.set $0 + (i32.const 0) + ) + (i32.const 7) + ) +) +(module + (type $T (func (result i32))) + (type $FUNCSIG$ii (func (param i32) (result i32))) + (type $FUNCSIG$v (func)) + (table $0 1 1 funcref) + (func $foo (; 0 ;) (result i32) + (local $0 i32) + (local.set $0 + (i32.const 42) + ) + (drop + (return_call_indirect (type $T) + (i32.const 0) + ) + ) + ) + (func $bar (; 1 ;) (type $FUNCSIG$v) + (drop + (call $foo) + ) + ) +) diff --git a/test/passes/dae.wast b/test/passes/dae_enable-tail-call.wast index 2fdf6958d..e70cde1bb 100644 --- a/test/passes/dae.wast +++ b/test/passes/dae_enable-tail-call.wast @@ -130,4 +130,34 @@ (local.get $x) ) ) - +(module ;; tail calls inhibit dropped result removal + (func $foo (param $x i32) (result i32) + (drop + (return_call $bar + (i32.const 0) + ) + ) + (i32.const 42) + ) + (func $bar (param $x i32) (result i32) + (i32.const 7) + ) +) +(module ;; indirect tail calls inhibit dropped result removal + (type $T (func (result i32))) + (table 1 1 funcref) + (func $foo (param $x i32) (result i32) + (drop + (return_call_indirect (type $T) + (i32.const 0) + ) + ) + ) + (func $bar + (drop + (call $foo + (i32.const 42) + ) + ) + ) +) diff --git a/test/passes/directize.txt b/test/passes/directize_enable-tail-call.txt index 109140a8f..2a74aff68 100644 --- a/test/passes/directize.txt +++ b/test/passes/directize_enable-tail-call.txt @@ -195,3 +195,17 @@ ) ) ) +(module + (type $ii (func (param i32 i32))) + (table $0 5 5 funcref) + (elem (i32.const 1) $foo) + (func $foo (; 0 ;) (type $ii) (param $0 i32) (param $1 i32) + (unreachable) + ) + (func $bar (; 1 ;) (type $ii) (param $x i32) (param $y i32) + (return_call $foo + (local.get $x) + (local.get $y) + ) + ) +) diff --git a/test/passes/directize.wast b/test/passes/directize_enable-tail-call.wast index 4385aa18a..e111cf615 100644 --- a/test/passes/directize.wast +++ b/test/passes/directize_enable-tail-call.wast @@ -191,3 +191,18 @@ ) ) ) +(module ;; indirect tail call + (type $ii (func (param i32 i32))) + (table $0 5 5 funcref) + (elem (i32.const 1) $foo) + (func $foo (param i32) (param i32) + (unreachable) + ) + (func $bar (param $x i32) (param $y i32) + (return_call_indirect (type $ii) + (local.get $x) + (local.get $y) + (i32.const 1) + ) + ) +) diff --git a/test/passes/inlining.txt b/test/passes/inlining_enable-tail-call.txt index 738b580de..3119de526 100644 --- a/test/passes/inlining.txt +++ b/test/passes/inlining_enable-tail-call.txt @@ -261,3 +261,167 @@ ) ) ) +(module + (type $FUNCSIG$i (func (result i32))) + (func $0 (; 0 ;) (type $FUNCSIG$i) (result i32) + (return + (block $__inlined_func$1 (result i32) + (i32.const 42) + ) + ) + ) +) +(module + (type $FUNCSIG$v (func)) + (type $FUNCSIG$vi (func (param i32))) + (func $0 (; 0 ;) (type $FUNCSIG$v) + (local $0 i32) + (block + (block $__inlined_func$1 + (local.set $0 + (i32.const 42) + ) + (drop + (local.get $0) + ) + ) + (return) + ) + ) +) +(module + (type $FUNCSIG$i (func (result i32))) + (type $FUNCSIG$ii (func (param i32) (result i32))) + (func $0 (; 0 ;) (type $FUNCSIG$i) (result i32) + (local $0 i32) + (return + (block $__inlined_func$1 (result i32) + (local.set $0 + (i32.const 42) + ) + (local.get $0) + ) + ) + ) +) +(module + (type $FUNCSIG$v (func)) + (type $FUNCSIG$i (func (result i32))) + (func $0 (; 0 ;) (type $FUNCSIG$v) + (drop + (block (result i32) + (block $__inlined_func$1 (result i32) + (block + (br $__inlined_func$1 + (block (result i32) + (block $__inlined_func$2 (result i32) + (i32.const 42) + ) + ) + ) + ) + ) + ) + ) + ) +) +(module + (type $FUNCSIG$v (func)) + (type $FUNCSIG$vi (func (param i32))) + (func $0 (; 0 ;) (type $FUNCSIG$v) + (local $0 i32) + (block $__inlined_func$1 + (block + (block + (block + (block $__inlined_func$2 + (local.set $0 + (i32.const 42) + ) + (drop + (local.get $0) + ) + ) + ) + (br $__inlined_func$1) + ) + ) + (br $__inlined_func$1) + ) + ) +) +(module + (type $T (func (param i32) (result i32))) + (type $FUNCSIG$v (func)) + (type $FUNCSIG$i (func (result i32))) + (table $0 10 funcref) + (func $0 (; 0 ;) (type $FUNCSIG$v) + (drop + (block (result i32) + (block $__inlined_func$1 (result i32) + (br $__inlined_func$1 + (call_indirect (type $T) + (i32.const 42) + (i32.const 0) + ) + ) + ) + ) + ) + ) +) +(module + (type $T (func (param i32))) + (type $FUNCSIG$v (func)) + (table $0 10 funcref) + (func $0 (; 0 ;) (type $FUNCSIG$v) + (block $__inlined_func$1 + (block + (call_indirect (type $T) + (i32.const 42) + (i32.const 0) + ) + (br $__inlined_func$1) + ) + (br $__inlined_func$1) + ) + ) +) +(module + (type $6 (func)) + (memory $0 1 1) + (global $global$0 (mut i32) (i32.const 10)) + (export "func_102_invoker" (func $19)) + (func $19 (; 0 ;) (type $6) + (block + (block + (block $__inlined_func$13 + (block + (if + (global.get $global$0) + (unreachable) + ) + (block + (block + (block $__inlined_func$2 + (block + (if + (global.get $global$0) + (br $__inlined_func$2) + ) + (global.set $global$0 + (i32.const 1) + ) + ) + ) + (br $__inlined_func$13) + ) + ) + ) + (br $__inlined_func$13) + ) + ) + ) + (unreachable) + ) +) diff --git a/test/passes/inlining.wast b/test/passes/inlining_enable-tail-call.wast index 050ee9bc2..0ca64267a 100644 --- a/test/passes/inlining.wast +++ b/test/passes/inlining_enable-tail-call.wast @@ -174,4 +174,115 @@ (call $0) ) ) - +(module + (func $0 (result i32) + (return_call $1) + ) + (func $1 (result i32) + (i32.const 42) + ) +) +(module + (func $0 + (return_call $1 + (i32.const 42) + ) + ) + (func $1 (param i32) + (drop + (local.get 0) + ) + ) +) +(module + (func $0 (result i32) + (return_call $1 + (i32.const 42) + ) + ) + (func $1 (param i32) (result i32) + (local.get 0) + ) +) +(module + (func $0 + (drop + (call $1) + ) + ) + (func $1 (result i32) + (return_call $2) + ) + (func $2 (result i32) + (i32.const 42) + ) +) +(module + (func $0 + (call $1) + ) + (func $1 + (return_call $2 + (i32.const 42) + ) + ) + (func $2 (param i32) + (drop + (local.get 0) + ) + ) +) +(module + (type $T (func (param i32) (result i32))) + (table 10 funcref) + (func $0 + (drop + (call $1) + ) + ) + (func $1 (result i32) + (return_call_indirect (type $T) + (i32.const 42) + (i32.const 0) + ) + ) +) +(module + (type $T (func (param i32))) + (table 10 funcref) + (func $0 + (call $1) + ) + (func $1 + (return_call_indirect (type $T) + (i32.const 42) + (i32.const 0) + ) + ) +) +(module + (type $6 (func)) + (memory $0 1 1) + (global $global$0 (mut i32) (i32.const 10)) + (export "func_102_invoker" (func $19)) + (func $2 (; 2 ;) (type $6) + (if + (global.get $global$0) + (return) + ) + (global.set $global$0 + (i32.const 1) + ) + ) + (func $13 (; 13 ;) (type $6) + (if + (global.get $global$0) + (unreachable) + ) + (return_call $2) + ) + (func $19 (; 19 ;) (type $6) + (call $13) + (unreachable) + ) +) |