summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ir/gc-type-utils.h4
-rw-r--r--test/lit/passes/optimize-instructions-gc.wast21
2 files changed, 24 insertions, 1 deletions
diff --git a/src/ir/gc-type-utils.h b/src/ir/gc-type-utils.h
index 8832d4d0f..1646e47c3 100644
--- a/src/ir/gc-type-utils.h
+++ b/src/ir/gc-type-utils.h
@@ -123,7 +123,9 @@ inline EvaluationResult evaluateKindCheck(Expression* curr) {
Kind actual;
- if (childType.isFunction()) {
+ if (childType == Type::unreachable) {
+ return Unknown;
+ } else if (childType.isFunction()) {
actual = Func;
} else if (childType.isData()) {
actual = Data;
diff --git a/test/lit/passes/optimize-instructions-gc.wast b/test/lit/passes/optimize-instructions-gc.wast
index abf3da432..c5100434d 100644
--- a/test/lit/passes/optimize-instructions-gc.wast
+++ b/test/lit/passes/optimize-instructions-gc.wast
@@ -3230,4 +3230,25 @@
)
)
)
+
+ ;; CHECK: (func $as_of_unreachable (type $none_=>_ref|data|) (result (ref data))
+ ;; CHECK-NEXT: (ref.as_data
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; NOMNL: (func $as_of_unreachable (type $none_=>_ref|data|) (result (ref data))
+ ;; NOMNL-NEXT: (ref.as_data
+ ;; NOMNL-NEXT: (unreachable)
+ ;; NOMNL-NEXT: )
+ ;; NOMNL-NEXT: )
+ (func $as_of_unreachable (result (ref data))
+ ;; The cast will definitely fail, so we can turn it into an unreachable. The
+ ;; ref.as must then ignore the unreachable input and not error on trying to
+ ;; infer anything about it.
+ (ref.as_data
+ (ref.cast $A
+ (ref.null none)
+ )
+ )
+ )
)