Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/cranelift/filetests/src/test_safepoint.rs
1692 views
1
use crate::subtest::{Context, SubTest, run_filecheck};
2
use cranelift_codegen::ir::Function;
3
use cranelift_reader::TestCommand;
4
use std::borrow::Cow;
5
6
struct TestSafepoint;
7
8
pub fn subtest(parsed: &TestCommand) -> anyhow::Result<Box<dyn SubTest>> {
9
assert_eq!(parsed.command, "safepoint");
10
if !parsed.options.is_empty() {
11
anyhow::bail!("No options allowed on {}", parsed);
12
}
13
Ok(Box::new(TestSafepoint))
14
}
15
16
impl SubTest for TestSafepoint {
17
fn name(&self) -> &'static str {
18
"safepoint"
19
}
20
21
fn run(&self, func: Cow<Function>, context: &Context) -> anyhow::Result<()> {
22
let mut comp_ctx = cranelift_codegen::Context::for_function(func.into_owned());
23
24
let isa = context.isa.expect("register allocator needs an ISA");
25
comp_ctx.compute_cfg();
26
comp_ctx
27
.legalize(isa)
28
.map_err(|e| crate::pretty_anyhow_error(&comp_ctx.func, e))?;
29
comp_ctx.compute_domtree();
30
31
let text = comp_ctx.func.display().to_string();
32
run_filecheck(&text, context)
33
}
34
}
35
36