fuzzgen: Generate multiple functions per testcase (#5765)

* fuzzgen: Generate multiple functions per testcase

* fuzzgen: Fix typo

Co-authored-by: Jamey Sharp <jamey@minilop.net>

---------

Co-authored-by: Jamey Sharp <jamey@minilop.net>
This commit is contained in:
Afonso Bordado
2023-02-28 18:47:09 +00:00
committed by GitHub
parent aad8eaeb5a
commit 2dd6064005
5 changed files with 125 additions and 63 deletions

View File

@@ -114,16 +114,16 @@ impl TestFileCompiler {
Self::with_host_isa(flags)
}
/// Registers all functions in a [TestFile]. Additionally creates a trampoline for each one
/// of them.
pub fn add_testfile(&mut self, testfile: &TestFile) -> Result<()> {
/// Declares and compiles all functions in `functions`. Additionally creates a trampoline for
/// each one of them.
pub fn add_functions(&mut self, functions: &[Function]) -> Result<()> {
// Declare all functions in the file, so that they may refer to each other.
for (func, _) in &testfile.functions {
for func in functions {
self.declare_function(func)?;
}
// Define all functions and trampolines
for (func, _) in &testfile.functions {
for func in functions {
self.define_function(func.clone())?;
self.create_trampoline_for_function(func)?;
}
@@ -131,6 +131,20 @@ impl TestFileCompiler {
Ok(())
}
/// Registers all functions in a [TestFile]. Additionally creates a trampoline for each one
/// of them.
pub fn add_testfile(&mut self, testfile: &TestFile) -> Result<()> {
let functions = testfile
.functions
.iter()
.map(|(f, _)| f)
.cloned()
.collect::<Vec<_>>();
self.add_functions(&functions[..])?;
Ok(())
}
/// Declares a function an registers it as a linkable and callable target internally
pub fn declare_function(&mut self, func: &Function) -> Result<()> {
let next_id = self.defined_functions.len() as u32;