Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
8 changes: 7 additions & 1 deletion src/ir/LocalStructuralDominance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ LocalStructuralDominance::LocalStructuralDominance(Function* func,
}

static void doLocalSet(Scanner* self, Expression** currp) {
auto index = (*currp)->cast<LocalSet>()->index;
auto* curr = *currp;
if (curr->type == Type::unreachable) {
// Unreachable sets are not emitted in the binary format, so we do not
// count them.
return;
}
auto index = curr->cast<LocalSet>()->index;
if (!self->localsSet[index]) {
// This local is now set until the end of this scope.
self->localsSet[index] = true;
Expand Down
30 changes: 30 additions & 0 deletions test/lit/passes/precompute-gc.wast
Original file line number Diff line number Diff line change
Expand Up @@ -1033,4 +1033,34 @@
)
)
)

;; CHECK: (func $unreachable-set (type $none_=>_none)
;; CHECK-NEXT: (local $x funcref)
;; CHECK-NEXT: (local.tee $x
;; CHECK-NEXT: (block
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (ref.as_non_null
;; CHECK-NEXT: (local.get $x)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $unreachable-set
;; An unreachable set is not helpful for validation of non-nullable locals
;; since we won't emit it in the binary format. We ignore the set in that
;; computation, and as a result we'll make the local nullable here after
;; this pass runs and the set becomes unreachable (due to calling refinalize
;; which propagates the unreachability).
(local $x (ref func))
(local.set $x
(block (result (ref func))
(unreachable)
)
)
(drop
(local.get $x)
)
)
)