Path: blob/main/cranelift/filetests/src/test_safepoint.rs
1692 views
use crate::subtest::{Context, SubTest, run_filecheck};1use cranelift_codegen::ir::Function;2use cranelift_reader::TestCommand;3use std::borrow::Cow;45struct TestSafepoint;67pub fn subtest(parsed: &TestCommand) -> anyhow::Result<Box<dyn SubTest>> {8assert_eq!(parsed.command, "safepoint");9if !parsed.options.is_empty() {10anyhow::bail!("No options allowed on {}", parsed);11}12Ok(Box::new(TestSafepoint))13}1415impl SubTest for TestSafepoint {16fn name(&self) -> &'static str {17"safepoint"18}1920fn run(&self, func: Cow<Function>, context: &Context) -> anyhow::Result<()> {21let mut comp_ctx = cranelift_codegen::Context::for_function(func.into_owned());2223let isa = context.isa.expect("register allocator needs an ISA");24comp_ctx.compute_cfg();25comp_ctx26.legalize(isa)27.map_err(|e| crate::pretty_anyhow_error(&comp_ctx.func, e))?;28comp_ctx.compute_domtree();2930let text = comp_ctx.func.display().to_string();31run_filecheck(&text, context)32}33}343536