diff options
Diffstat (limited to 'test/lit')
-rw-r--r-- | test/lit/passes/simplify-locals-gc.wast | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/test/lit/passes/simplify-locals-gc.wast b/test/lit/passes/simplify-locals-gc.wast index 912c3a688..97891aca4 100644 --- a/test/lit/passes/simplify-locals-gc.wast +++ b/test/lit/passes/simplify-locals-gc.wast @@ -8,6 +8,9 @@ ;; CHECK: (type $struct (struct (field (mut i32)))) (type $struct (struct (field (mut i32)))) + ;; CHECK: (type $struct-immutable (struct (field i32))) + (type $struct-immutable (struct (field i32))) + ;; Writes to heap objects cannot be reordered with reads. ;; CHECK: (func $no-reorder-past-write (param $x (ref $struct)) (result i32) ;; CHECK-NEXT: (local $temp i32) @@ -36,6 +39,64 @@ (local.get $temp) ) + ;; CHECK: (func $reorder-past-write-if-immutable (param $x (ref $struct)) (param $y (ref $struct-immutable)) (result i32) + ;; CHECK-NEXT: (local $temp i32) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (struct.set $struct 0 + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: (i32.const 42) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (struct.get $struct-immutable 0 + ;; CHECK-NEXT: (local.get $y) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $reorder-past-write-if-immutable (param $x (ref $struct)) (param $y (ref $struct-immutable)) (result i32) + (local $temp i32) + (local.set $temp + (struct.get $struct-immutable 0 + (local.get $y) + ) + ) + (struct.set $struct 0 + (local.get $x) + (i32.const 42) + ) + (local.get $temp) + ) + + ;; CHECK: (func $unreachable-struct.get (param $x (ref $struct)) (param $y (ref $struct-immutable)) (result i32) + ;; CHECK-NEXT: (local $temp i32) + ;; CHECK-NEXT: (local.tee $temp + ;; CHECK-NEXT: (block ;; (replaces something unreachable we can't emit) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (struct.set $struct 0 + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: (i32.const 42) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.get $temp) + ;; CHECK-NEXT: ) + (func $unreachable-struct.get (param $x (ref $struct)) (param $y (ref $struct-immutable)) (result i32) + (local $temp i32) + ;; As above, but the get's ref is unreachable. This tests we do not hit an + ;; assertion on the get's type not having a heap type (as we depend on + ;; finding the heap type there in the reachable case). + ;; We simply do not handle this case, leaving it for DCE. + (local.set $temp + (struct.get $struct-immutable 0 + (unreachable) + ) + ) + (struct.set $struct 0 + (local.get $x) + (i32.const 42) + ) + (local.get $temp) + ) + ;; CHECK: (func $no-block-values-if-br_on ;; CHECK-NEXT: (local $temp anyref) ;; CHECK-NEXT: (block $block |