Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/ir/effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -1044,10 +1044,8 @@ class EffectAnalyzer {
}
void visitRefGetDesc(RefGetDesc* curr) { trapOnNull(curr->ref); }
void visitBrOn(BrOn* curr) {
if (trapOnNull(curr->desc)) {
return;
}
parent.breakTargets.insert(curr->name);
trapOnNull(curr->desc);
}
void visitStructNew(StructNew* curr) { trapOnNull(curr->desc); }
void visitStructGet(StructGet* curr) {
Expand Down
65 changes: 65 additions & 0 deletions test/lit/passes/monomorphize-desc.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
;; 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 nullref)))

;; 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 nullref)
;; CHECK-NEXT: (nop)
;; CHECK-NEXT: )
Loading