Skip to content

Commit fc82914

Browse files
committed
Crater: closure size profile build
1 parent 32c447e commit fc82914

File tree

1 file changed

+7
-19
lines changed
  • compiler/rustc_mir/src/monomorphize

1 file changed

+7
-19
lines changed

compiler/rustc_mir/src/monomorphize/util.rs

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,17 @@
1+
use rustc_hir::def_id::LOCAL_CRATE;
12
use rustc_middle::ty::{self, ClosureSizeProfileData, Instance, TyCtxt};
2-
use std::fs::OpenOptions;
3-
use std::io::prelude::*;
43

54
/// For a given closure, writes out the data for the profiling the impact of RFC 2229 on
65
/// closure size into a CSV.
76
///
87
/// During the same compile all closures dump the information in the same file
98
/// "closure_profile_XXXXX.csv", which is created in the directory where the compiler is invoked.
109
crate fn dump_closure_profile(tcx: TyCtxt<'tcx>, closure_instance: Instance<'tcx>) {
11-
let mut file = if let Ok(file) = OpenOptions::new()
12-
.create(true)
13-
.append(true)
14-
.open(&format!("closure_profile_{}.csv", std::process::id()))
15-
{
16-
file
17-
} else {
18-
eprintln!("Cound't open file for writing closure profile");
19-
return;
20-
};
21-
2210
let closure_def_id = closure_instance.def_id();
2311
let typeck_results = tcx.typeck(closure_def_id.expect_local());
2412

13+
let crate_name = tcx.crate_name(LOCAL_CRATE);
14+
2515
if typeck_results.closure_size_eval.contains_key(&closure_def_id) {
2616
let param_env = ty::ParamEnv::reveal_all();
2717

@@ -59,15 +49,13 @@ crate fn dump_closure_profile(tcx: TyCtxt<'tcx>, closure_instance: Instance<'tcx
5949
.map(|l| format!("{:?} {:?}", l.lines.first(), l.lines.last()))
6050
.unwrap_or_else(|e| format!("{:?}", e));
6151

62-
if let Err(e) = writeln!(
63-
file,
64-
"{}, {}, {}, {:?}",
52+
eprintln!(
53+
"SG_CRATER_E239478slkdjf: {}, {}, {}, {}, {:?}",
54+
crate_name,
6555
old_size,
6656
new_size,
6757
src_file.prefer_local(),
6858
line_nos
69-
) {
70-
eprintln!("Error writting to file {}", e.to_string())
71-
}
59+
);
7260
}
7361
}

0 commit comments

Comments
 (0)