cranelift: Use cranelift-jit in runtests (#4453)

* cranelift: Use JIT in runtests

Using `cranelift-jit` in run tests allows us to preform relocations and
libcalls. This is important since some instruction lowerings fallback
to libcall's when an extension is missing, or when it's too complicated
to implement manually.

This is also a first step to being able to test `call`'s between functions
in the runtest suite. It should also make it easier to eventually test
TLS relocations, symbol resolution and ABI's.

Another benefit of this is that we also get to test the JIT more, since
it now runs the runtests, and gets some fuzzing via `fuzzgen` (which
uses the `SingleFunctionCompiler`).

This change causes regressions in terms of runtime for the filetests.
I haven't done any serious benchmarking but what I've been seeing is
that it now takes about ~3 seconds to run the testsuite while it
previously took around 2 seconds.

* Add FMA tests for X86
This commit is contained in:
Afonso Bordado
2022-08-09 22:54:25 +01:00
committed by GitHub
parent 97b2680f20
commit 4d2a2cfae6
13 changed files with 119 additions and 107 deletions

View File

@@ -36,10 +36,24 @@ fn build_host_isa(
let mut builder = cranelift_native::builder_with_options(infer_native_flags)
.expect("Unable to build a TargetIsa for the current host");
// Copy ISA Flags
for value in isa_flags {
builder.set(value.name, &value.value_string()).unwrap();
}
// We need to force disable stack probing, since we don't support it yet.
let flags = {
let mut flags_builder = settings::builder();
// Copy all flags
for flag in flags.iter() {
flags_builder.set(flag.name, &flag.value_string()).unwrap();
}
flags_builder.set("enable_probestack", "false").unwrap();
settings::Flags::new(flags_builder)
};
builder.finish(flags).unwrap()
}
@@ -118,20 +132,20 @@ impl SubTest for TestRun {
return Ok(());
}
// We can't use the requested ISA directly since it does not contain info
// about the operating system / calling convention / etc..
//
// Copy the requested ISA flags into the host ISA and use that.
let isa = build_host_isa(false, context.flags.clone(), requested_isa.isa_flags());
let test_env = RuntestEnvironment::parse(&context.details.comments[..])?;
let mut compiler = SingleFunctionCompiler::new(isa);
for comment in context.details.comments.iter() {
if let Some(command) = parse_run_command(comment.text, &func.signature)? {
trace!("Parsed run command: {}", command);
let compiled_fn = compiler.compile(func.clone().into_owned())?;
// We can't use the requested ISA directly since it does not contain info
// about the operating system / calling convention / etc..
//
// Copy the requested ISA flags into the host ISA and use that.
let isa = build_host_isa(false, context.flags.clone(), requested_isa.isa_flags());
let compiled_fn =
SingleFunctionCompiler::new(isa).compile(func.clone().into_owned())?;
command
.run(|_, run_args| {
test_env.validate_signature(&func)?;