miri: add machine hook for Abort terminator

This commit is contained in:
Ralf Jung 2020-03-09 10:45:20 +01:00
parent 4897594656
commit 8a8870fbae
2 changed files with 12 additions and 2 deletions

View file

@ -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

View file

@ -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
@ -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(())