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
10 changes: 6 additions & 4 deletions src/ir/possible-contents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3136,31 +3136,33 @@ void Flower::filterPackedDataReads(PossibleContents& contents,
Expression* ref;
Index index;
unsigned bytes = 0;
Type resultType = Type::none;
if (auto* get = expr->dynCast<StructGet>()) {
signed_ = get->signed_;
ref = get->ref;
index = get->index;
resultType = get->type;
} else if (auto* get = expr->dynCast<ArrayGet>()) {
signed_ = get->signed_;
ref = get->ref;
// Arrays are treated as having a single field.
index = 0;
resultType = get->type;
} else if (auto* load = expr->dynCast<ArrayLoad>()) {
signed_ = load->signed_;
ref = load->ref;
index = 0;
bytes = load->bytes;
resultType = load->type;
} else {
WASM_UNREACHABLE("bad packed read");
}
if (!signed_) {
return;
}

Type resultType = expr->type;
if (resultType == Type::unreachable) {
// This read never executes.
return;
}

// If there is no struct or array to read, no value will ever be returned.
if (ref->type.isNull()) {
contents = PossibleContents::none();
Expand Down
19 changes: 19 additions & 0 deletions test/lit/passes/gufa-refs.wast
Original file line number Diff line number Diff line change
Expand Up @@ -6141,6 +6141,25 @@
)
)
)

;; CHECK: (func $unreachable (type $1)
;; CHECK-NEXT: (array.get_s $array
;; CHECK-NEXT: (array.new_default $array
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: (unreachable)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $unreachable
;; This array.get is unreachable, and when handling packing we should not
;; error.
(array.get_s $array
(array.new_default $array
(i32.const 0)
)
(unreachable)
)
)
)

;; Atomic accesses require special handling
Expand Down
Loading