Skip to content

Commit 3224cbd

Browse files
authored
Fix MIR dump to emit one MIR per-harness (rust-lang#2556)
This was a regression introduced by rust-lang#2439. We were still writing the result of the reachability algorithm to the same file for every harness. Thus, we could only see the MIR for the last harness that was processed. Use the file name that is specific for the harness instead and generate one MIR file per harness like we do with other files generated by kani-compiler.
1 parent 43bc890 commit 3224cbd

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

kani-compiler/src/codegen_cprover_gotoc/compiler_interface.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl GotocCodegenBackend {
8686
|| collect_reachable_items(tcx, starting_items),
8787
"codegen reachability analysis",
8888
);
89-
dump_mir_items(tcx, &items);
89+
dump_mir_items(tcx, &items, &symtab_goto.with_extension("kani.mir"));
9090

9191
// Follow rustc naming convention (cx is abbrev for context).
9292
// https://rustc-dev-guide.rust-lang.org/conventions.html#naming-conventions

kani-compiler/src/kani_middle/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//! and transformations.
55
66
use std::collections::HashSet;
7+
use std::path::Path;
78

89
use crate::kani_queries::QueryDb;
910
use rustc_hir::{def::DefKind, def_id::DefId, def_id::LOCAL_CRATE};
@@ -79,7 +80,7 @@ pub fn check_reachable_items(tcx: TyCtxt, queries: &QueryDb, items: &[MonoItem])
7980
}
8081

8182
/// Print MIR for the reachable items if the `--emit mir` option was provided to rustc.
82-
pub fn dump_mir_items(tcx: TyCtxt, items: &[MonoItem]) {
83+
pub fn dump_mir_items(tcx: TyCtxt, items: &[MonoItem], output: &Path) {
8384
/// Convert MonoItem into a DefId.
8485
/// Skip stuff that we cannot generate the MIR items.
8586
fn visible_item<'tcx>(item: &MonoItem<'tcx>) -> Option<(MonoItem<'tcx>, DefId)> {
@@ -96,9 +97,7 @@ pub fn dump_mir_items(tcx: TyCtxt, items: &[MonoItem]) {
9697

9798
if tcx.sess.opts.output_types.contains_key(&OutputType::Mir) {
9899
// Create output buffer.
99-
let outputs = tcx.output_filenames(());
100-
let path = outputs.output_path(OutputType::Mir).with_extension("kani.mir");
101-
let out_file = File::create(&path).unwrap();
100+
let out_file = File::create(output).unwrap();
102101
let mut writer = BufWriter::new(out_file);
103102

104103
// For each def_id, dump their MIR

0 commit comments

Comments
 (0)