From df1044fec09db03bb2e00f5ffb4652f7ee5caaad Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Fri, 8 Mar 2024 13:12:15 -0800 Subject: Check for unreachable in `Select::finalize(Type)` (#6389) Previously selects finalized with explicit types would never be marked unreachable, even when they should have been. --- src/wasm/wasm.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index 374a97e19..7147f2c3d 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -760,7 +760,15 @@ void Binary::finalize() { } } -void Select::finalize(Type type_) { type = type_; } +void Select::finalize(Type type_) { + assert(ifTrue && ifFalse); + if (ifTrue->type == Type::unreachable || ifFalse->type == Type::unreachable || + condition->type == Type::unreachable) { + type = Type::unreachable; + } else { + type = type_; + } +} void Select::finalize() { assert(ifTrue && ifFalse); -- cgit v1.2.3