| ;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. | |
| ;; RUN: foreach %s %t wasm-opt --monomorphize -all -S -o - | filecheck %s | |
| (module | |
| (rec | |
| ;; CHECK: (rec | |
| ;; CHECK-NEXT: (type $A (descriptor $B) (struct)) | |
| (type $A (descriptor $B) (struct)) | |
| ;; CHECK: (type $B (describes $A) (struct)) | |
| (type $B (describes $A) (struct)) | |
| ) | |
| ;; CHECK: (type $2 (func (param i32))) | |
| ;; CHECK: (type $3 (func (result anyref))) | |
| ;; CHECK: (type $4 (func (param (ref none)))) | |
| ;; CHECK: (func $target (type $2) (param $0 i32) | |
| ;; CHECK-NEXT: (nop) | |
| ;; CHECK-NEXT: ) | |
| (func $target (param i32) | |
| ) | |
| ;; CHECK: (func $test (type $3) (result anyref) | |
| ;; CHECK-NEXT: (block $block (result (ref $A)) | |
| ;; CHECK-NEXT: (call $target_2 | |
| ;; CHECK-NEXT: (block ;; (replaces unreachable BrOn we can't emit) | |
| ;; CHECK-NEXT: (drop | |
| ;; CHECK-NEXT: (ref.null none) | |
| ;; CHECK-NEXT: ) | |
| ;; CHECK-NEXT: (drop | |
| ;; CHECK-NEXT: (ref.null none) | |
| ;; CHECK-NEXT: ) | |
| ;; CHECK-NEXT: (unreachable) | |
| ;; CHECK-NEXT: ) | |
| ;; CHECK-NEXT: ) | |
| ;; CHECK-NEXT: (unreachable) | |
| ;; CHECK-NEXT: ) | |
| ;; CHECK-NEXT: ) | |
| (func $test (result anyref) | |
| ;; We can monomorphize the call to $target, pushing the ref.is_null into | |
| ;; $target_2. The parameter we send there is now nullref, so everything there | |
| ;; gets optimized away. In this function, after refinalizing we end up with | |
| ;; an unprintable br_on (we don't have defined types for the null inputs, and | |
| ;; in fact the br_on is never taken). While doing so, we should not hit an | |
| ;; internal error. | |
| (block $block (result (ref $A)) | |
| (call $target | |
| (ref.is_null | |
| (br_on_cast_desc_eq $block anyref (ref $A) | |
| (ref.null none) | |
| (ref.null none) | |
| ) | |
| ) | |
| ) | |
| (unreachable) | |
| ) | |
| ) | |
| ) | |
| ;; CHECK: (func $target_2 (type $4) (param $0 (ref none)) | |
| ;; CHECK-NEXT: (nop) | |
| ;; CHECK-NEXT: ) |