From cfb335064d5cb153030849f4bf7df7d6194723a3 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 1 Apr 2026 10:01:36 -0700 Subject: [PATCH 1/2] fix --- src/ir/possible-contents.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ir/possible-contents.cpp b/src/ir/possible-contents.cpp index 905349f1c68..10b01f986dc 100644 --- a/src/ir/possible-contents.cpp +++ b/src/ir/possible-contents.cpp @@ -3136,24 +3136,20 @@ void Flower::filterPackedDataReads(PossibleContents& contents, Expression* ref; Index index; unsigned bytes = 0; - Type resultType = Type::none; if (auto* get = expr->dynCast()) { signed_ = get->signed_; ref = get->ref; index = get->index; - resultType = get->type; } else if (auto* get = expr->dynCast()) { 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()) { signed_ = load->signed_; ref = load->ref; index = 0; bytes = load->bytes; - resultType = load->type; } else { WASM_UNREACHABLE("bad packed read"); } @@ -3161,6 +3157,12 @@ void Flower::filterPackedDataReads(PossibleContents& contents, 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(); From 7a196c53ea93019535ff83c22143bfa9f9056ade Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 1 Apr 2026 10:03:26 -0700 Subject: [PATCH 2/2] test --- test/lit/passes/gufa-refs.wast | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/lit/passes/gufa-refs.wast b/test/lit/passes/gufa-refs.wast index 9907fd90c23..14f362f5e3d 100644 --- a/test/lit/passes/gufa-refs.wast +++ b/test/lit/passes/gufa-refs.wast @@ -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