diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/passes/spill-pointers.txt | 644 | ||||
-rw-r--r-- | test/passes/spill-pointers.wast | 168 |
2 files changed, 812 insertions, 0 deletions
diff --git a/test/passes/spill-pointers.txt b/test/passes/spill-pointers.txt new file mode 100644 index 000000000..30febbec6 --- /dev/null +++ b/test/passes/spill-pointers.txt @@ -0,0 +1,644 @@ +(module + (type $ii (func (param i32 i32))) + (type $FUNCSIG$vi (func (param i32))) + (type $2 (func)) + (type $3 (func (result i32))) + (type $4 (func (param i32) (result i32))) + (type $5 (func (param f64))) + (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32)) + (import "env" "segfault" (func $segfault (param i32))) + (global $stack_ptr (mut i32) (get_global $STACKTOP$asm2wasm$import)) + (table 1 1 anyfunc) + (memory $0 10) + (func $nothing (; 1 ;) (type $2) + (nop) + ) + (func $not-alive (; 2 ;) (type $2) + (local $x i32) + (set_local $x + (i32.const 1) + ) + (call $nothing) + ) + (func $spill (; 3 ;) (type $2) + (local $x i32) + (local $1 i32) + (set_local $1 + (get_global $stack_ptr) + ) + (set_global $stack_ptr + (i32.add + (get_local $1) + (i32.const 16) + ) + ) + (block + (block + (i32.store + (get_local $1) + (get_local $x) + ) + (call $nothing) + ) + (drop + (get_local $x) + ) + ) + (set_global $stack_ptr + (get_local $1) + ) + ) + (func $ignore-non-pointers (; 4 ;) (type $2) + (local $x i32) + (local $y i64) + (local $z f32) + (local $w f64) + (local $4 i32) + (set_local $4 + (get_global $stack_ptr) + ) + (set_global $stack_ptr + (i32.add + (get_local $4) + (i32.const 16) + ) + ) + (block + (set_local $x + (i32.const 1) + ) + (set_local $y + (i64.const 1) + ) + (set_local $z + (f32.const 1) + ) + (set_local $w + (f64.const 1) + ) + (block + (i32.store + (get_local $4) + (get_local $x) + ) + (call $nothing) + ) + (drop + (get_local $x) + ) + (drop + (get_local $y) + ) + (drop + (get_local $z) + ) + (drop + (get_local $w) + ) + ) + (set_global $stack_ptr + (get_local $4) + ) + ) + (func $spill4 (; 5 ;) (type $2) + (local $x i32) + (local $y i32) + (local $z i32) + (local $w i32) + (local $4 i32) + (set_local $4 + (get_global $stack_ptr) + ) + (set_global $stack_ptr + (i32.add + (get_local $4) + (i32.const 16) + ) + ) + (block + (set_local $x + (i32.const 1) + ) + (set_local $y + (i32.const 1) + ) + (set_local $z + (i32.const 1) + ) + (set_local $w + (i32.const 1) + ) + (block + (i32.store + (get_local $4) + (get_local $x) + ) + (i32.store offset=4 + (get_local $4) + (get_local $y) + ) + (i32.store offset=8 + (get_local $4) + (get_local $z) + ) + (i32.store offset=12 + (get_local $4) + (get_local $w) + ) + (call $nothing) + ) + (drop + (get_local $x) + ) + (drop + (get_local $y) + ) + (drop + (get_local $z) + ) + (drop + (get_local $w) + ) + ) + (set_global $stack_ptr + (get_local $4) + ) + ) + (func $spill5 (; 6 ;) (type $2) + (local $x i32) + (local $y i32) + (local $z i32) + (local $w i32) + (local $a i32) + (local $5 i32) + (set_local $5 + (get_global $stack_ptr) + ) + (set_global $stack_ptr + (i32.add + (get_local $5) + (i32.const 32) + ) + ) + (block + (set_local $x + (i32.const 1) + ) + (set_local $y + (i32.const 1) + ) + (set_local $z + (i32.const 1) + ) + (set_local $w + (i32.const 1) + ) + (set_local $a + (i32.const 1) + ) + (block + (i32.store + (get_local $5) + (get_local $x) + ) + (i32.store offset=4 + (get_local $5) + (get_local $y) + ) + (i32.store offset=8 + (get_local $5) + (get_local $z) + ) + (i32.store offset=12 + (get_local $5) + (get_local $w) + ) + (i32.store offset=16 + (get_local $5) + (get_local $a) + ) + (call $nothing) + ) + (drop + (get_local $x) + ) + (drop + (get_local $y) + ) + (drop + (get_local $z) + ) + (drop + (get_local $w) + ) + (drop + (get_local $a) + ) + ) + (set_global $stack_ptr + (get_local $5) + ) + ) + (func $some-alive (; 7 ;) (type $2) + (local $x i32) + (local $y i32) + (local $2 i32) + (set_local $2 + (get_global $stack_ptr) + ) + (set_global $stack_ptr + (i32.add + (get_local $2) + (i32.const 16) + ) + ) + (block + (block + (i32.store + (get_local $2) + (get_local $x) + ) + (call $nothing) + ) + (drop + (get_local $x) + ) + ) + (set_global $stack_ptr + (get_local $2) + ) + ) + (func $spill-args (; 8 ;) (type $ii) (param $p i32) (param $q i32) + (local $x i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (set_local $3 + (get_global $stack_ptr) + ) + (set_global $stack_ptr + (i32.add + (get_local $3) + (i32.const 16) + ) + ) + (block + (block + (set_local $4 + (i32.const 1) + ) + (set_local $5 + (i32.const 2) + ) + (i32.store offset=8 + (get_local $3) + (get_local $x) + ) + (call $spill-args + (get_local $4) + (get_local $5) + ) + ) + (drop + (get_local $x) + ) + ) + (set_global $stack_ptr + (get_local $3) + ) + ) + (func $spill-ret (; 9 ;) (type $3) (result i32) + (local $x i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (set_local $1 + (get_global $stack_ptr) + ) + (set_global $stack_ptr + (i32.add + (get_local $1) + (i32.const 16) + ) + ) + (set_local $4 + (block (result i32) + (block + (i32.store + (get_local $1) + (get_local $x) + ) + (call $nothing) + ) + (drop + (get_local $x) + ) + (if + (i32.const 1) + (block + (set_local $2 + (i32.const 2) + ) + (set_global $stack_ptr + (get_local $1) + ) + (return + (get_local $2) + ) + ) + (block + (set_local $3 + (i32.const 3) + ) + (set_global $stack_ptr + (get_local $1) + ) + (return + (get_local $3) + ) + ) + ) + (i32.const 4) + ) + ) + (set_global $stack_ptr + (get_local $1) + ) + (get_local $4) + ) + (func $spill-unreachable (; 10 ;) (type $3) (result i32) + (local $x i32) + (local $1 i32) + (local $2 i32) + (set_local $1 + (get_global $stack_ptr) + ) + (set_global $stack_ptr + (i32.add + (get_local $1) + (i32.const 16) + ) + ) + (set_local $2 + (block (result i32) + (block + (i32.store + (get_local $1) + (get_local $x) + ) + (call $nothing) + ) + (drop + (get_local $x) + ) + (unreachable) + ) + ) + (set_global $stack_ptr + (get_local $1) + ) + (get_local $2) + ) + (func $spill-call-call0 (; 11 ;) (type $4) (param $p i32) (result i32) + (unreachable) + ) + (func $spill-call-call1 (; 12 ;) (type $4) (param $p i32) (result i32) + (local $x i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (set_local $2 + (get_global $stack_ptr) + ) + (set_global $stack_ptr + (i32.add + (get_local $2) + (i32.const 16) + ) + ) + (set_local $5 + (block (result i32) + (drop + (block (result i32) + (set_local $3 + (block (result i32) + (set_local $4 + (i32.const 1) + ) + (i32.store offset=4 + (get_local $2) + (get_local $x) + ) + (call $spill-call-call1 + (get_local $4) + ) + ) + ) + (i32.store offset=4 + (get_local $2) + (get_local $x) + ) + (call $spill-call-call0 + (get_local $3) + ) + ) + ) + (get_local $x) + ) + ) + (set_global $stack_ptr + (get_local $2) + ) + (get_local $5) + ) + (func $spill-call-ret (; 13 ;) (type $4) (param $p i32) (result i32) + (local $x i32) + (drop + (call $spill-call-call0 + (return + (i32.const 1) + ) + ) + ) + (i32.const 0) + ) + (func $spill-ret-call (; 14 ;) (type $4) (param $p i32) (result i32) + (local $x i32) + (drop + (return + (call $spill-call-call0 + (i32.const 1) + ) + ) + ) + (i32.const 0) + ) + (func $spill-ret-ret (; 15 ;) (type $3) (result i32) + (local $x i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (set_local $1 + (get_global $stack_ptr) + ) + (set_global $stack_ptr + (i32.add + (get_local $1) + (i32.const 16) + ) + ) + (set_local $3 + (block (result i32) + (block + (i32.store + (get_local $1) + (get_local $x) + ) + (call $nothing) + ) + (drop + (get_local $x) + ) + (drop + (block + (set_global $stack_ptr + (get_local $1) + ) + (return + (block + (set_local $2 + (i32.const 1) + ) + (set_global $stack_ptr + (get_local $1) + ) + (return + (get_local $2) + ) + ) + ) + ) + ) + (i32.const 0) + ) + ) + (set_global $stack_ptr + (get_local $1) + ) + (get_local $3) + ) + (func $spill-call-othertype (; 16 ;) (type $5) (param $y f64) + (local $x i32) + (local $2 i32) + (local $3 f64) + (set_local $2 + (get_global $stack_ptr) + ) + (set_global $stack_ptr + (i32.add + (get_local $2) + (i32.const 16) + ) + ) + (block + (block + (set_local $3 + (f64.const 1) + ) + (i32.store + (get_local $2) + (get_local $x) + ) + (call $spill-call-othertype + (get_local $3) + ) + ) + (drop + (get_local $x) + ) + ) + (set_global $stack_ptr + (get_local $2) + ) + ) + (func $spill-call_indirect (; 17 ;) (type $2) + (local $x i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (set_local $1 + (get_global $stack_ptr) + ) + (set_global $stack_ptr + (i32.add + (get_local $1) + (i32.const 16) + ) + ) + (block + (block + (set_local $2 + (i32.const 123) + ) + (set_local $3 + (i32.const 456) + ) + (set_local $4 + (i32.const 789) + ) + (i32.store + (get_local $1) + (get_local $x) + ) + (call_indirect (type $ii) + (get_local $2) + (get_local $3) + (get_local $4) + ) + ) + (drop + (get_local $x) + ) + ) + (set_global $stack_ptr + (get_local $1) + ) + ) + (func $spill-call_import (; 18 ;) (type $2) + (local $x i32) + (local $1 i32) + (local $2 i32) + (set_local $1 + (get_global $stack_ptr) + ) + (set_global $stack_ptr + (i32.add + (get_local $1) + (i32.const 16) + ) + ) + (block + (block + (set_local $2 + (i32.const 200) + ) + (i32.store + (get_local $1) + (get_local $x) + ) + (call $segfault + (get_local $2) + ) + ) + (drop + (get_local $x) + ) + ) + (set_global $stack_ptr + (get_local $1) + ) + ) +) diff --git a/test/passes/spill-pointers.wast b/test/passes/spill-pointers.wast new file mode 100644 index 000000000..c9bccd3b5 --- /dev/null +++ b/test/passes/spill-pointers.wast @@ -0,0 +1,168 @@ +(module + (memory 10) + (type $ii (func (param i32 i32))) + (table 1 1 anyfunc) + (elem (i32.const 0)) + (import "env" "STACKTOP" (global $STACKTOP$asm2wasm$import i32)) + (import "env" "segfault" (func $segfault (param i32))) + (global $stack_ptr (mut i32) (get_global $STACKTOP$asm2wasm$import)) + + (func $nothing + ) + (func $not-alive + (local $x i32) + (set_local $x (i32.const 1)) + (call $nothing) + ) + (func $spill + (local $x i32) + (call $nothing) + (drop (get_local $x)) + ) + (func $ignore-non-pointers + (local $x i32) + (local $y i64) + (local $z f32) + (local $w f64) + (set_local $x (i32.const 1)) + (set_local $y (i64.const 1)) + (set_local $z (f32.const 1)) + (set_local $w (f64.const 1)) + (call $nothing) + (drop (get_local $x)) + (drop (get_local $y)) + (drop (get_local $z)) + (drop (get_local $w)) + ) + (func $spill4 + (local $x i32) + (local $y i32) + (local $z i32) + (local $w i32) + (set_local $x (i32.const 1)) + (set_local $y (i32.const 1)) + (set_local $z (i32.const 1)) + (set_local $w (i32.const 1)) + (call $nothing) + (drop (get_local $x)) + (drop (get_local $y)) + (drop (get_local $z)) + (drop (get_local $w)) + ) + (func $spill5 + (local $x i32) + (local $y i32) + (local $z i32) + (local $w i32) + (local $a i32) + (set_local $x (i32.const 1)) + (set_local $y (i32.const 1)) + (set_local $z (i32.const 1)) + (set_local $w (i32.const 1)) + (set_local $a (i32.const 1)) + (call $nothing) + (drop (get_local $x)) + (drop (get_local $y)) + (drop (get_local $z)) + (drop (get_local $w)) + (drop (get_local $a)) + ) + (func $some-alive + (local $x i32) + (local $y i32) + (call $nothing) + (drop (get_local $x)) + ) + (func $spill-args (param $p i32) (param $q i32) + (local $x i32) + (call $spill-args (i32.const 1) (i32.const 2)) + (drop (get_local $x)) + ) + (func $spill-ret (result i32) + (local $x i32) + (call $nothing) + (drop (get_local $x)) + (if (i32.const 1) + (return (i32.const 2)) + (return (i32.const 3)) + ) + (i32.const 4) + ) + (func $spill-unreachable (result i32) + (local $x i32) + (call $nothing) + (drop (get_local $x)) + (unreachable) + ) + (func $spill-call-call0 (param $p i32) (result i32) + (unreachable) + ) + (func $spill-call-call1 (param $p i32) (result i32) + (local $x i32) + (drop + (call $spill-call-call0 + (call $spill-call-call1 + (i32.const 1) + ) + ) + ) + (get_local $x) + ) + (func $spill-call-ret (param $p i32) (result i32) + (local $x i32) + (drop + (call $spill-call-call0 + (return + (i32.const 1) + ) + ) + ) + (get_local $x) + ) + (func $spill-ret-call (param $p i32) (result i32) + (local $x i32) + (drop + (return + (call $spill-call-call0 + (i32.const 1) + ) + ) + ) + (get_local $x) + ) + (func $spill-ret-ret (result i32) + (local $x i32) + (call $nothing) + (drop (get_local $x)) + (drop + (return + (return + (i32.const 1) + ) + ) + ) + (get_local $x) + ) + (func $spill-call-othertype (param $y f64) + (local $x i32) + (call $spill-call-othertype (f64.const 1)) + (drop (get_local $x)) + ) + (func $spill-call_indirect + (local $x i32) + (call_indirect (type $ii) + (i32.const 123) + (i32.const 456) + (i32.const 789) + ) + (drop (get_local $x)) + ) + (func $spill-call_import + (local $x i32) + (call_import $segfault + (i32.const 200) + ) + (drop (get_local $x)) + ) +) + |