Skip to content

Commit

Permalink
miri: add machine hook for Abort terminator
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Mar 9, 2020
1 parent 4897594 commit 8a8870f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/librustc_mir/interpret/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ pub trait Machine<'mir, 'tcx>: Sized {
unwind: Option<mir::BasicBlock>,
) -> InterpResult<'tcx>;

/// Called to evaluate `Abort` MIR terminator.
fn abort(_ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpResult<'tcx> {
throw_unsup_format!("aborting execution is not supported");
}

/// Called for all binary operations where the LHS has pointer type.
///
/// Returns a (value, overflowed) pair if the operation succeeded
Expand Down
9 changes: 7 additions & 2 deletions src/librustc_mir/interpret/terminator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
}
}

Abort => {
M::abort(self)?;
}

// When we encounter Resume, we've finished unwinding
// cleanup for the current stack frame. We pop it in order
// to continue unwinding the next frame
Expand All @@ -118,8 +122,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
| FalseEdges { .. }
| FalseUnwind { .. }
| Yield { .. }
| GeneratorDrop
| Abort => bug!("{:#?} should have been eliminated by MIR pass", terminator.kind),
| GeneratorDrop => {
bug!("{:#?} should have been eliminated by MIR pass", terminator.kind)
}
}

Ok(())
Expand Down

0 comments on commit 8a8870f

Please sign in to comment.