Skip to content

Commit

Permalink
Fix an issue with terminator handling in InstrumentationVisitor
Browse files Browse the repository at this point in the history
  • Loading branch information
artemagvanian committed Jul 26, 2024
1 parent afb9df7 commit 08494ed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions kani-compiler/src/kani_middle/transform/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,12 @@ impl SourceInstruction {
SourceInstruction::Terminator { bb } => blocks[bb].terminator.span,
}
}

pub fn bb(&self) -> usize {
match self {
SourceInstruction::Statement { bb, .. } | SourceInstruction::Terminator { bb } => *bb,
}
}
}

fn find_instance(tcx: TyCtxt, diagnostic: &str) -> Option<Instance> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use rustc_hir::def_id::DefId as InternalDefId;
use rustc_middle::ty::TyCtxt;
use rustc_smir::rustc_internal;
use stable_mir::mir::visit::{Location, PlaceContext};
use stable_mir::mir::{BasicBlockIdx, MirVisitor, Operand, Place, Statement};
use stable_mir::mir::{BasicBlockIdx, MirVisitor, Operand, Place, Statement, Terminator};
use std::collections::HashSet;

pub struct InstrumentationVisitor<'a, 'tcx> {
Expand Down Expand Up @@ -92,6 +92,13 @@ impl<'a, 'tcx> MirVisitor for InstrumentationVisitor<'a, 'tcx> {
}
}

fn visit_terminator(&mut self, term: &Terminator, location: Location) {
if !(self.skip_next || self.target.is_some()) {
self.current = SourceInstruction::Terminator { bb: self.current.bb() };
self.super_terminator(term, location);
}
}

fn visit_place(&mut self, place: &Place, ptx: PlaceContext, location: Location) {
// Match the place by whatever it is pointing to and find an intersection with the targets.
if self
Expand Down

0 comments on commit 08494ed

Please sign in to comment.