summaryrefslogtreecommitdiff
path: root/test/lit/passes/simplify-locals-gc-validation.wast
blob: 70d3dec2308e0fc3d12e6ce46c3b117891d0d9ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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 (type $0) (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 none)
  ;; 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)
    )
  )
)