blob: 165036f4d5e09a71a4ec6f26f20f0108179acae0 (
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
|
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; RUN: wasm-opt %s --inlining --vacuum --optimize-instructions -all -S -o - | filecheck %s
;; Check for a specific bug involving inlining first turning a struct.get's
;; input into a null, then vacuum gets rid of intervening blocks, and then
;; optimize-instructions runs into the following situation: first it turns the
;; struct.get of a null into an unreachable, then it makes a note to itself to
;; refinalize at the end, but before the end it tries to optimize the ref.cast.
;; The ref.cast's type has not been updated to unreachable yet, but its ref has,
;; which is temporarily inconsistent. We must be careful to avoid confusion
;; there.
(module
;; CHECK: (type $B (sub (struct)))
(type $B (sub (struct )))
;; CHECK: (type $A (sub (struct (field (ref null $B)))))
(type $A (sub (struct (field (ref null $B)))))
;; CHECK: (type $2 (func (param (ref null $A))))
;; CHECK: (func $target (type $2) (param $0 (ref null $A))
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (block ;; (replaces unreachable RefCast we can't emit)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
(func $target (param $0 (ref null $A))
(drop
(ref.cast (ref null $B)
(struct.get $A 0
(call $get-null)
)
)
)
(unreachable)
)
(func $get-null (result (ref null $A))
(ref.null none)
)
)
|