Conversation
When no value can flow out of a function (its body is unreachable, it
has no return with a value, and it does not tail-call a function with a
possible result), `LUB::getResultsLUB` notes nothing and DAE left the
result type alone. Such functions are common in compiled code (e.g.
wrappers that just throw an exception), and since `getResultsLUB` notes
the declared result type of `return_call` targets, every function that
tail-calls them also kept its imprecise result type.
For example, with `--dae`:
(func $fail (param $0 (ref eq)) (result (ref eq))
(throw $exn (local.get $0)))
(func $f (param $0 i32) (result (ref eq))
(if (local.get $0)
(then (return (ref.i31 (i32.const 0)))))
(return_call $fail (global.get $msg)))
`$f` stayed at `(ref eq)` although it can only return an i31.
When the result is a single reference type and no value is noted,
refine it to the non-nullable bottom type of its hierarchy (e.g. `(ref
none)`), under the same conditions as other result refinements (all
calls are known). `$fail` now returns `(ref none)` and `$f` `(ref i31)`
(chains of tail calls are refined over the DAE iterations). The callers
see an uninhabitable call result, so with dae-optimizing the code after
the call becomes unreachable, and a call whose result is dropped gets
an `unreachable` after it when the result is later removed.
Multivalue results are left alone.
Some existing tests relied on never-returning helper functions keeping
their declared result types; export those helpers to preserve what the
tests check.
vouillon
force-pushed
the
dea-refine
branch
from
September 28, 2026 23:01
c2861e5 to
d620428
Compare
tlively
approved these changes
Sep 28, 2026
tlively
left a comment
Member
There was a problem hiding this comment.
Looks good to me! Can you run the fuzzer for a few thousand iterations to see if it finds any issues? (scripts/fuzz_opt.py or scripts/monitor_fuzz.py -j --max-iters=5000)
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When no value can flow out of a function, DAE leaves the result type alone. Such functions are common in compiled code (e.g. functions that just throw an exception).
For example, with
--dae:$fstayed at(ref eq)although it can only return an i31.When the result is a single reference type and no value is noted, we refine it to the non-nullable bottom type of its hierarchy (e.g.
(ref none)), under the same conditions as other result refinements (all calls are known).$failnow returns(ref none)and$f(ref i31).