1 #![feature(custom_attribute, test)]
2 #![feature(rustc_private)]
3 #![allow(unused_attributes)]
8 extern crate rustc_driver;
10 use miri::interpreter;
11 use rustc::session::Session;
12 use rustc_driver::{driver, CompilerCalls};
13 use std::cell::RefCell;
22 fn noop(bencher: &mut Bencher) {
31 fn noop_miri_full(bencher: &mut Bencher) {
32 let path = std::env::var("RUST_SYSROOT").expect("env variable `RUST_SYSROOT` not set");
34 let mut process = std::process::Command::new("target/release/miri");
35 process.arg("benches/smoke_helper.rs")
36 .arg("--sysroot").arg(&path);
37 let output = process.output().unwrap();
38 if !output.status.success() {
39 println!("{}", String::from_utf8(output.stdout).unwrap());
40 println!("{}", String::from_utf8(output.stderr).unwrap());
41 panic!("failed to run miri");
48 fn noop_miri_interpreter(bencher: &mut Bencher) {
49 let path = std::env::var("RUST_SYSROOT").expect("env variable `RUST_SYSROOT` not set");
50 rustc_driver::run_compiler(&[
51 "miri".to_string(), "benches/smoke_helper.rs".to_string(), "--sysroot".to_string(), path.to_string(),
52 ], &mut MiriCompilerCalls(Rc::new(RefCell::new(bencher))));
55 struct MiriCompilerCalls<'a>(Rc<RefCell<&'a mut Bencher>>);
57 impl<'a> CompilerCalls<'a> for MiriCompilerCalls<'a> {
62 ) -> driver::CompileController<'a> {
63 let mut control: driver::CompileController<'a> = driver::CompileController::basic();
65 let bencher = self.0.clone();
67 control.after_analysis.callback = Box::new(move |state| {
68 state.session.abort_if_errors();
69 bencher.borrow_mut().iter(|| {
70 interpreter::interpret_start_points(state.tcx.unwrap(), state.mir_map.unwrap());