diff options
Diffstat (limited to 'test/lit/passes/simplify-locals-gc-validation.wast')
-rw-r--r-- | test/lit/passes/simplify-locals-gc-validation.wast | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/lit/passes/simplify-locals-gc-validation.wast b/test/lit/passes/simplify-locals-gc-validation.wast new file mode 100644 index 000000000..bda59882b --- /dev/null +++ b/test/lit/passes/simplify-locals-gc-validation.wast @@ -0,0 +1,48 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. +;; RUN: wasm-opt %s --simplify-locals -all -S -o - | filecheck %s + +;; Tests for validation of non-nullable locals. In this form a local.set allows +;; a local.get until the end of the current block. + +(module + ;; CHECK: (func $test-nn (param $x (ref any)) + ;; CHECK-NEXT: (local $nn anyref) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (block $inner + ;; CHECK-NEXT: (call $test-nn + ;; CHECK-NEXT: (ref.as_non_null + ;; CHECK-NEXT: (local.tee $nn + ;; CHECK-NEXT: (ref.as_non_null + ;; CHECK-NEXT: (ref.null any) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $test-nn + ;; CHECK-NEXT: (ref.as_non_null + ;; CHECK-NEXT: (local.get $nn) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $test-nn (param $x (ref any)) + (local $nn (ref any)) + ;; We can sink this set into the block, but we should then update things so + ;; that we still validate, as then the final local.get is not structurally + ;; dominated. (Note that we end up with several ref.as_non_nulls here, but + ;; later passes could remove them.) + (local.set $nn + (ref.as_non_null + (ref.null any) + ) + ) + (block $inner + (call $test-nn + (local.get $nn) + ) + ) + (call $test-nn + (local.get $nn) + ) + ) +) |