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

cranelift: Fuzz Argument Extensions in clif-fuzzer #4589

Merged
merged 1 commit into from
Aug 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions cranelift/fuzzgen/src/function_generator.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::codegen::ir::ValueList;
use crate::codegen::ir::{ArgumentExtension, ArgumentPurpose, ValueList};
use crate::config::Config;
use anyhow::Result;
use arbitrary::{Arbitrary, Unstructured};
Expand Down Expand Up @@ -288,9 +288,21 @@ where
}

fn generate_abi_param(&mut self) -> Result<AbiParam> {
// TODO: Generate more advanced abi params (structs/purposes/extensions/etc...)
let ty = self.generate_type()?;
Ok(AbiParam::new(ty))
let value_type = self.generate_type()?;
// TODO: There are more argument purposes to be explored...
let purpose = ArgumentPurpose::Normal;
let extension = match self.u.int_in_range(0..=2)? {
2 => ArgumentExtension::Sext,
1 => ArgumentExtension::Uext,
_ => ArgumentExtension::None,
};

Ok(AbiParam {
value_type,
purpose,
extension,
legalized_to_pointer: false,
})
}

fn generate_signature(&mut self) -> Result<Signature> {
Expand Down