Skip to content

[CD] Fix TypeSSA on exact parameters in unreachable calls #7628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 29, 2025

Conversation

kripken
Copy link
Member

@kripken kripken commented May 28, 2025

TypeSSA ignored unreachable instructions, but we do validate parts of them,
like calls - a later unreachable param does not disable validation or other
params (see new testcase). Remove the ignoring of such code in TypeSSA and
add proper skipping of unreachable code, where necessary, in ChildTyper.

@kripken kripken requested a review from tlively May 28, 2025 16:54
Copy link
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, pretty annoying that we have to do this, but the only way I see around it would be to update validation so that expressions with an unreachable child do not impose any constraints on their other children. That would be an even more invasive change.

In addition to returning early in the cases where we don't know how the children should be constrained, can we call a user callback like noteUnknown so that specific users of ChildTyper other than TypeSSA can assert that this never happens?

@kripken
Copy link
Member Author

kripken commented May 28, 2025

can we call a user callback like noteUnknown so that specific users of ChildTyper other than TypeSSA can assert that this never happens?

I don't follow, why would other users need/want that?

@tlively
Copy link
Member

tlively commented May 28, 2025

The IRBuilder user would want to be able to assert that all the necessary type information has been provided. It would be a bad bug for any of the children to be silently skipped. We are also about to add another user to compute principal types for Outlining, and it would be similarly bad if that use case skipped any children (cc @ashleynh).

@kripken
Copy link
Member Author

kripken commented May 28, 2025

Makes sense, thanks. I added a hook so this is customizable.

Copy link
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -823,7 +832,9 @@ template<typename Subtype> struct ChildTyper : OverriddenVisitor<Subtype> {
void visitTupleExtract(TupleExtract* curr,
std::optional<size_t> arity = std::nullopt) {
if (!arity) {
assert(curr->tuple->type.isTuple());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep this assertion for the case when skipUnreachable() is false.

@kripken kripken merged commit 14d117f into WebAssembly:main May 29, 2025
16 checks passed
@kripken kripken deleted the tssa.exact.unreach branch May 29, 2025 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants