Skip to content
Open
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
1 change: 1 addition & 0 deletions src/ir/linear-execution.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ struct LinearExecutionWalker : public PostWalker<SubType, VisitorType> {
if (!self->connectAdjacentBlocks) {
self->pushTask(SubType::doNoteNonLinear, currp);
}
self->maybePushTask(SubType::scan, &curr->cast<BrOn>()->desc);
self->pushTask(SubType::scan, &curr->cast<BrOn>()->ref);
break;
}
Expand Down
77 changes: 76 additions & 1 deletion test/lit/passes/simplify-locals-desc.wast
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
(type $desc (describes $struct) (struct))
)

;; CHECK: (func $test (type $2) (param $ref (ref null $struct)) (result (ref $struct))
;; CHECK: (type $none (func))
(type $none (func))

;; CHECK: (tag $tag (type $none))
(tag $tag (type $none))

;; CHECK: (func $test (type $3) (param $ref (ref null $struct)) (result (ref $struct))
;; CHECK-NEXT: (local $temp (ref $desc))
;; CHECK-NEXT: (block $block (result (ref none))
;; CHECK-NEXT: (drop
Expand Down Expand Up @@ -49,5 +55,74 @@
(unreachable)
)
)

;; CHECK: (func $br_on_cast_desc_eq_in_block (type $4) (result (ref $struct))
;; CHECK-NEXT: (local $0 (ref null $desc))
;; CHECK-NEXT: (local $1 i32)
;; CHECK-NEXT: (block $out (result (ref $struct))
;; CHECK-NEXT: (if
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: (then
;; CHECK-NEXT: (block $block
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (block (result i32)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (br_on_cast_desc_eq_fail $out (ref (exact $struct)) (ref $struct)
;; CHECK-NEXT: (struct.new_default_desc $struct
;; CHECK-NEXT: (ref.null none)
;; CHECK-NEXT: )
;; CHECK-NEXT: (try_table (result (ref $desc)) (catch $tag $block)
;; CHECK-NEXT: (ref.as_non_null
;; CHECK-NEXT: (local.get $0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $br_on_cast_desc_eq_in_block (result (ref $struct))
(local $0 (ref null $desc))
(local $1 i32)
;; While simplifying locals here, we must be aware that the br_on
;; instruction has a descriptor, and must visit it. If we do not, then we'd
;; see no branches to $block, and move the tee out of it, breaking
;; validation.
(block $out (result (ref $struct))
(if

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the outer if important to the test? I also wonder if we can use a simpler branch than try_table.

(i32.const 0)
(then
(block $block
(drop
(local.tee $1
(block (result i32)
(drop
(br_on_cast_desc_eq_fail $out (ref (exact $struct)) (ref $struct)
(struct.new_default_desc $struct
(ref.null none)
)
(try_table (result (ref $desc)) (catch $tag $block)
(ref.as_non_null
(local.get $0)
)
)
)
)
(i32.const 0)
)
)
)
)
)
)
(unreachable)
)
)
)

Loading