Skip to content

Stack switching: fix some optimization passes #7271

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 13 commits into from
Apr 2, 2025

Conversation

vouillon
Copy link
Contributor

@vouillon vouillon commented Feb 3, 2025

This continues #7041 by adapting the optimizations passes to work with the stack switching instructions.

@vouillon vouillon force-pushed the stack-switching-fixes branch from c067464 to 19e57a7 Compare February 7, 2025 16:38
@vouillon vouillon force-pushed the stack-switching-fixes branch from 19e57a7 to 50d6418 Compare February 7, 2025 16:47
@vouillon vouillon requested a review from tlively March 25, 2025 09:32
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.

Thanks for your patience on this and sorry for the delay. Looks good, with just a couple minor comments.

@@ -503,6 +504,14 @@ class TypeMapper : public GlobalTypeRewriter {
return getTempType(type);
}

HeapType getNewHeapType(HeapType type) {
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 reimplement getNewType using type.with(getNewHeapType(type.getHeapType()).

Comment on lines 2492 to 2495
if (!params[nparams - 1].isContinuation()) {
return Err{"the last argument of the continuation argument should be "
"itself a continuation"};
}
Copy link
Member

Choose a reason for hiding this comment

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

Can we leave this to the validator? It doesn't look like ChildTyper::visitStackSwitch depends on the last parameter correctly being a continuation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your time!
I have just removed this for now since validation is not implemented.

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.

Thank you!

@tlively tlively merged commit df26f96 into WebAssembly:main Apr 2, 2025
14 checks passed
@vouillon vouillon deleted the stack-switching-fixes branch April 2, 2025 18:28
@kripken
Copy link
Member

kripken commented Apr 2, 2025

Fuzzing on the main branch after this landed, I see

/home/azakai/Dev/binaryen/bin/wasm-opt /home/azakai/Dev/binaryen/out/test/input.dat -ttf -o /home/azakai/Dev/binaryen/out/test/a.wasm --dce --all-features --disable-fp16 --disable-shared-everything --disable-custom-descriptors --disable-strings --disable-multivalue --initial-fuzz=/home/azakai/Dev/binaryen/test/./lit/passes/vacuum-stack-switching.wast
TODO: cont
UNREACHABLE executed at /home/azakai/Dev/binaryen/src/tools/fuzzing/fuzzing.cpp:518!

Hopefully that information (note the --initial-fuzz file, and the line the unreachable is on) is enough to figure out the underlying problem? If not I can upload the input.dat

@tlively
Copy link
Member

tlively commented Apr 2, 2025

Hmm, vacuum-stack-switching.wast is listed in fuzzing.py as disallowed initial contents. Did your fuzzer somehow not pick up the new list?

@kripken
Copy link
Member

kripken commented Apr 2, 2025

Not just mine, but all of them 😉 #7430

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants