| ;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. | |
| ;; RUN: wasm-opt %s -all --disable-custom-descriptors --roundtrip -S -o - | filecheck %s | |
| (module | |
| ;; CHECK: (type $foo (struct)) | |
| (type $foo (struct)) | |
| ;; CHECK: (func $trivial-exact-cast (type $1) (param $x i32) | |
| ;; CHECK-NEXT: (drop | |
| ;; CHECK-NEXT: (ref.cast (ref $foo) | |
| ;; CHECK-NEXT: (if (result (ref $foo)) | |
| ;; CHECK-NEXT: (local.get $x) | |
| ;; CHECK-NEXT: (then | |
| ;; CHECK-NEXT: (struct.new_default $foo) | |
| ;; CHECK-NEXT: ) | |
| ;; CHECK-NEXT: (else | |
| ;; CHECK-NEXT: (struct.new_default $foo) | |
| ;; CHECK-NEXT: ) | |
| ;; CHECK-NEXT: ) | |
| ;; CHECK-NEXT: ) | |
| ;; CHECK-NEXT: ) | |
| ;; CHECK-NEXT: ) | |
| (func $trivial-exact-cast (param $x i32) | |
| (drop | |
| ;; We allow trivial exact casts even without custom descriptors enabled, | |
| ;; so this is valid. However, when we round trip, the exactness in the if | |
| ;; result will be erased. If we fail to erase the exactness in the cast, | |
| ;; we will be emitting a binary that uses a disabled feature, and also we | |
| ;; will fail validation when we read the module back in because the cast | |
| ;; will no longer be trivial. | |
| (ref.cast (ref (exact $foo)) | |
| (if (result (ref (exact $foo))) | |
| (local.get $x) | |
| (then (struct.new $foo)) | |
| (else (struct.new $foo)) | |
| ) | |
| ) | |
| ) | |
| ) | |
| ) |