File tree Expand file tree Collapse file tree 3 files changed +60
-0
lines changed Expand file tree Collapse file tree 3 files changed +60
-0
lines changed Original file line number Diff line number Diff line change 122
122
'coalesce-locals-exact.wast' ,
123
123
'remove-unused-brs-exact.wast' ,
124
124
'signature-refining-exact.wast' ,
125
+ 'gufa-cast-all-exact.wast' ,
125
126
# TODO: fuzzer support for custom descriptors
126
127
'custom-descriptors.wast' ,
127
128
]
Original file line number Diff line number Diff line change @@ -374,6 +374,11 @@ struct GUFAOptimizer
374
374
}
375
375
376
376
auto oracleType = parent.getContents (curr).getType ();
377
+ // Exact casts are only allowed when custom descriptors is enabled.
378
+ if (oracleType.isExact () &&
379
+ !getModule ()->features .hasCustomDescriptors ()) {
380
+ oracleType = oracleType.with (Inexact);
381
+ }
377
382
if (oracleType.isRef () && oracleType != curr->type &&
378
383
Type::isSubType (oracleType, curr->type )) {
379
384
replaceCurrent (Builder (*getModule ()).makeRefCast (curr, oracleType));
Original file line number Diff line number Diff line change
1
+ ;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
2
+
3
+ ;; Check that exact casts are only added when custom descriptors are enabled.
4
+
5
+ ;; RUN: wasm-opt %s -all --gufa-cast-all -S -o - | filecheck %s
6
+ ;; RUN: wasm-opt %s -all --disable-custom-descriptors --gufa-cast-all -S -o - | filecheck %s --check-prefix=NO_CD
7
+
8
+ (module
9
+ ;; CHECK: (type $foo (struct))
10
+ ;; NO_CD: (type $foo (struct))
11
+ (type $foo (struct ))
12
+
13
+ ;; CHECK: (import "" "" (global $g (ref (exact $foo))))
14
+ ;; NO_CD: (import "" "" (global $g (ref (exact $foo))))
15
+ (import " " " " (global $g (ref (exact $foo ))))
16
+
17
+ ;; CHECK: (func $callee (type $1) (result (ref $foo))
18
+ ;; CHECK-NEXT: (global.get $g)
19
+ ;; CHECK-NEXT: )
20
+ ;; NO_CD: (func $callee (type $1) (result (ref $foo))
21
+ ;; NO_CD-NEXT: (global.get $g)
22
+ ;; NO_CD-NEXT: )
23
+ (func $callee (result (ref $foo ))
24
+ (global.get $g )
25
+ )
26
+
27
+ ;; CHECK: (func $caller (type $2)
28
+ ;; CHECK-NEXT: (drop
29
+ ;; CHECK-NEXT: (block (result (ref (exact $foo)))
30
+ ;; CHECK-NEXT: (drop
31
+ ;; CHECK-NEXT: (ref.cast (ref (exact $foo))
32
+ ;; CHECK-NEXT: (call $callee)
33
+ ;; CHECK-NEXT: )
34
+ ;; CHECK-NEXT: )
35
+ ;; CHECK-NEXT: (global.get $g)
36
+ ;; CHECK-NEXT: )
37
+ ;; CHECK-NEXT: )
38
+ ;; CHECK-NEXT: )
39
+ ;; NO_CD: (func $caller (type $2)
40
+ ;; NO_CD-NEXT: (drop
41
+ ;; NO_CD-NEXT: (block (result (ref (exact $foo)))
42
+ ;; NO_CD-NEXT: (drop
43
+ ;; NO_CD-NEXT: (call $callee)
44
+ ;; NO_CD-NEXT: )
45
+ ;; NO_CD-NEXT: (global.get $g)
46
+ ;; NO_CD-NEXT: )
47
+ ;; NO_CD-NEXT: )
48
+ ;; NO_CD-NEXT: )
49
+ (func $caller
50
+ (drop
51
+ (call $callee )
52
+ )
53
+ )
54
+ )
You can’t perform that action at this time.
0 commit comments