blob: b297cb7dfd08ce53ebfebba108ca88ea86d7af8c (
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
49
50
51
52
53
54
55
56
57
58
|
;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
;; RUN: wasm-opt %s --ignore-implicit-traps --optimize-instructions -all -S -o - \
;; RUN: | filecheck %s
(module
;; CHECK: (type $struct.A (struct (field i32)))
(type $struct.A (struct i32))
;; CHECK: (global $g-struct.A (rtt $struct.A) (rtt.canon $struct.A))
;; CHECK: (tag $e (param (ref null $struct.A)))
(tag $e (param (ref null $struct.A)))
(global $g-struct.A (rtt $struct.A) (rtt.canon $struct.A))
;; CHECK: (func $ref-cast-statically-removed
;; CHECK-NEXT: (local $0 (ref null $struct.A))
;; CHECK-NEXT: (local $1 (ref null $struct.A))
;; CHECK-NEXT: (try $try
;; CHECK-NEXT: (do
;; CHECK-NEXT: (nop)
;; CHECK-NEXT: )
;; CHECK-NEXT: (catch $e
;; CHECK-NEXT: (local.set $1
;; CHECK-NEXT: (pop (ref null $struct.A))
;; CHECK-NEXT: )
;; CHECK-NEXT: (throw $e
;; CHECK-NEXT: (block (result (ref null $struct.A))
;; CHECK-NEXT: (local.set $0
;; CHECK-NEXT: (local.get $1)
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (global.get $g-struct.A)
;; CHECK-NEXT: )
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $ref-cast-statically-removed
(try
(do)
(catch $e
(throw $e
;; Because --ignore-implicit-traps is given, this ref.cast is assumed
;; not to throw so this ref.cast can be statically removed. But that
;; creates a block around this, making 'pop' nested into it, which is
;; invalid. We fix this up at the end up OptimizeInstruction,
;; assigning the 'pop' to a local at the start of this 'catch' body
;; and later using 'local.get' to get it.
(ref.cast
(pop (ref null $struct.A))
(global.get $g-struct.A)
)
)
)
)
)
)
|