MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / run

Function run

cranelift/src/bugpoint.rs:39–81  ·  view source on GitHub ↗
(options: &Options)

Source from the content-addressed store, hash-verified

37}
38
39pub fn run(options: &Options) -> Result<()> {
40 let parsed = parse_sets_and_triple(&options.settings, &options.target)?;
41 let fisa = parsed.as_fisa();
42
43 let buffer = read_to_string(&options.file)?;
44 let test_file = parse_test(&buffer, ParseOptions::default())
45 .with_context(|| format!("failed to parse {}", options.file.display()))?;
46
47 // If we have an isa from the command-line, use that. Otherwise if the
48 // file contains a unique isa, use that.
49 let isa = if let Some(isa) = fisa.isa {
50 isa
51 } else if let Some(isa) = test_file.isa_spec.unique_isa() {
52 isa
53 } else {
54 anyhow::bail!("compilation requires a target isa");
55 };
56
57 unsafe {
58 std::env::set_var("RUST_BACKTRACE", "0"); // Disable backtraces to reduce verbosity
59 }
60
61 for (func, _) in test_file.functions {
62 let (orig_block_count, orig_inst_count) = (block_count(&func), inst_count(&func));
63
64 match reduce(isa, func, options.verbose) {
65 Ok((func, crash_msg)) => {
66 println!("Crash message: {crash_msg}");
67 println!("\n{func}");
68 println!(
69 "{} blocks {} insts -> {} blocks {} insts",
70 orig_block_count,
71 orig_inst_count,
72 block_count(&func),
73 inst_count(&func)
74 );
75 }
76 Err(err) => println!("Warning: {err}"),
77 }
78 }
79
80 Ok(())
81}
82
83enum ProgressStatus {
84 /// The mutation raised or reduced the amount of instructions or blocks.

Callers

nothing calls this directly

Calls 10

parse_sets_and_tripleFunction · 0.85
read_to_stringFunction · 0.85
parse_testFunction · 0.85
block_countFunction · 0.85
inst_countFunction · 0.85
reduceFunction · 0.85
OkFunction · 0.85
as_fisaMethod · 0.80
with_contextMethod · 0.80
unique_isaMethod · 0.80

Tested by

no test coverage detected