Skip to content
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

fuzzgen: Use the correct ISA when running NaN Canonicalization pass #8360

Merged

Conversation

afonso360
Copy link
Contributor

👋 Hey,

cranelift-fuzzgen unconditionally runs the NaN Canonicalization pass on all functions that it generates. This is so that we can ensure that when running in the interpreter vs natively we get the same bitpattern for all NaN's.

Until now we just picked a random ISA (the host ISA), disabled the verifier and ran the pass with that. This was because the ISA didn't really matter for the passes that we wanted to run.

In #8313 the ISA now drives some codegen decisions for the NaN Canonicalization pass. Namely, if the ISA supports Vectors, it tries to use that.

In #8359 a fuzz bug was reported where fuzzgen generated vector code for RISC-V without the has_v flag, something that should never happen, because we simply cannot compile that code.

It turns out that fuzzgen did not generate vector code itself. But since we were passing the host ISA to the NaN canonicalization pass, it assumed that it could use vectors and did so. But the actual target ISA did not support vectors.

To fix this, we now correctly pass the target ISA that we are building a function for.

Fixes #8359

cranelift-fuzzgen unconditionally runs the NaN Canonicalization pass on all functions that it generates. This is so that we can ensure that when running in the interpreter vs natively we get the same bitpattern for all NaN's.

Until now we just picked a random ISA (the host ISA), disabled the verifier and ran the pass with that. This was because the ISA didn't really matter for the passes that we wanted to run.

In bytecodealliance#8313 the ISA now drives some codgen decisions for the NaN Canonicalization pass. Namely, if the ISA supports Vectors, it tries to use that.

In bytecodealliance#8359 there was a fuzz bug reported where fuzzgen generated vector code for RISC-V without the `has_v` flag, something that should *never* happen, because we simply cannot compile that code.

It turns out that fuzzgen did not generate vector code itself. But since we were passing the host ISA to the nan canonicalization pass, it assumed that it could use vectors and did so. But the actual target isa did not support vectors.

To fix this, we now correctly pass the target isa that we are building a function for.
@afonso360 afonso360 requested a review from a team as a code owner April 13, 2024 12:33
@afonso360 afonso360 requested review from elliottt and removed request for a team April 13, 2024 12:33
@github-actions github-actions bot added the cranelift Issues related to the Cranelift code generator label Apr 13, 2024
Copy link
Member

@elliottt elliottt left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@alexcrichton alexcrichton added this pull request to the merge queue Apr 13, 2024
Merged via the queue into bytecodealliance:main with commit 4d17d4f Apr 13, 2024
21 checks passed
@afonso360 afonso360 deleted the fuzzgen-use-correct-target-isa branch April 13, 2024 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift Issues related to the Cranelift code generator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

riscv64: Panic on partial gen_extractlane rule
3 participants