We weren't previously keeping track of quite the right information for whether an `if .. else .. end`'s following block was reachable or not. It should be reachable if the head is reachable and either the consequent or alternative end reachable (and therefore fall through to the following block) or do an early `br_if` to it. This commit rejiggers `ControlStackFrame::If` to keep track of reachability at the end of the consequent (we don't need to keep track of it at the end of the alternative, since that is simply `state.reachable`) and adds Wasm tests for every reachability situation we can encounter with `if .. else .. end`. Fixes #1132
13 lines
257 B
Plaintext
13 lines
257 B
Plaintext
;; Reachable `if` head and unreachable consequent and reachable alternative
|
|
;; means that the following block is also reachable.
|
|
|
|
(module
|
|
(func (param i32) (result i32)
|
|
local.get 0
|
|
if
|
|
unreachable
|
|
else
|
|
nop
|
|
end
|
|
i32.const 0))
|