Skip to content

Commit

Permalink
Fix MIR dump to emit one MIR per-harness
Browse files Browse the repository at this point in the history
  • Loading branch information
celinval committed Jun 22, 2023
1 parent 43bc890 commit 22777ad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl GotocCodegenBackend {
|| collect_reachable_items(tcx, starting_items),
"codegen reachability analysis",
);
dump_mir_items(tcx, &items);
dump_mir_items(tcx, &items, &symtab_goto.with_extension("kani.mir"));

// Follow rustc naming convention (cx is abbrev for context).
// https://rustc-dev-guide.rust-lang.org/conventions.html#naming-conventions
Expand Down
7 changes: 3 additions & 4 deletions kani-compiler/src/kani_middle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//! and transformations.

use std::collections::HashSet;
use std::path::Path;

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

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

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

// For each def_id, dump their MIR
Expand Down

0 comments on commit 22777ad

Please sign in to comment.