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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fuzzgen: Add support for stack slot alignment #8650

Merged
merged 1 commit into from
May 22, 2024

Conversation

afonso360
Copy link
Contributor

馃憢 Hey,

This PR is a follow up to #8635. It adds the bare minimum possible for the Cranelift Fuzzgen to start fuzzing with different stack slot alignments.

Now that we can specify alignments, we should be able to start fuzzing load sinking with stack addresses 馃帀 . That isn't done yet, but this is the first step.

@afonso360 afonso360 requested a review from a team as a code owner May 17, 2024 20:43
@afonso360 afonso360 requested review from elliottt and removed request for a team May 17, 2024 20:43
@github-actions github-actions bot added the cranelift Issues related to the Cranelift code generator label May 17, 2024
@@ -86,6 +88,7 @@ impl Default for Config {
switch_max_range_size: 2..=32,
static_stack_slots_per_function: 0..=8,
static_stack_slot_size: 0..=128,
stack_slot_alignment_log2: 0..=10,
Copy link
Contributor

Choose a reason for hiding this comment

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

Currently the max working alignment is 2^4 (16 bytes): #8635 (comment)

Copy link
Contributor Author

@afonso360 afonso360 May 18, 2024

Choose a reason for hiding this comment

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

馃憤 I've been following that thread. We currently don't depend on any alignment. And at most we'll need 16bytes (for sinking SIMD loads).

But I think it's still a good idea to test with larger values, even if we end up not having any guarantee past 16 bytes.

Copy link
Contributor

Choose a reason for hiding this comment

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

I missed that you are not actually checking that the stack slot is correctly aligned at runtime.

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.

This looks good to me! Do you have a plan for verifying alignment in the future?

@afonso360
Copy link
Contributor Author

Yes, but hopefully we shouldn't need to.

The plan is to rely on the ABI alignment and generate loads/stores with the aligned flag if both the slot and the ABI support that alignment. That should allow us to start testing load sinking.

Now, I do plan on validating if these memory accesses are actually aligned with the interpreter. The interpreter already checks if stack accesses are aligned, when they contain the aligned memflag, but it currently doesn't support aligning the stack slots. Or align the stack at the call boundary. So those are the two missing items.

This hopefully shouldn't be needed since, if we're failing fuzz runs in the interpreter its not great for fuzzing efficiency.

@afonso360 afonso360 added this pull request to the merge queue May 22, 2024
Merged via the queue into bytecodealliance:main with commit c0fda8c May 22, 2024
35 checks passed
@afonso360 afonso360 deleted the fuzz-stackslot-alignment branch May 22, 2024 23:38
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.

None yet

3 participants