diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-03-12 16:32:23 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-12 16:32:23 +0100 |
| commit | fac7122682664ae1a4325e05b43ba5b0817645b6 (patch) | |
| tree | d703045814615a1496b785ee140a459aeeddcb08 | |
| parent | d21320cbd910cabb5b3da93a35f9e42c65fbebf8 (diff) | |
| parent | 911c75ff5f11c28c9f355857a47c5cd2d73767e7 (diff) | |
| download | rust-fac7122682664ae1a4325e05b43ba5b0817645b6.tar.gz rust-fac7122682664ae1a4325e05b43ba5b0817645b6.zip | |
Rollup merge of #69830 - RalfJung:miri-invalid-terminator, r=oli-obk
miri: ICE on invalid terminators We've run a lot of MIR in Miri (including some generators) and never seen these. @tmandry is it correct that `Yield` and `GeneratorDrop` get lowered away? @eddyb @oli-obk what's with this `Abort` that does not seem to ever actually exist? Codegen *does* seem to handle it, so I wonder why Miri can get away without that. In fact, codegen handles it twice: https://github.com/rust-lang/rust/blob/1d5241c96208ca7d925442b1a5fa45ad18717a6f/src/librustc_codegen_ssa/mir/block.rs#L796 https://github.com/rust-lang/rust/blob/1d5241c96208ca7d925442b1a5fa45ad18717a6f/src/librustc_codegen_ssa/mir/mod.rs#L296
| -rw-r--r-- | src/librustc_mir/interpret/intrinsics.rs | 4 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/machine.rs | 5 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/terminator.rs | 16 | ||||
| -rw-r--r-- | src/librustc_span/symbol.rs | 1 |
4 files changed, 19 insertions, 7 deletions
diff --git a/src/librustc_mir/interpret/intrinsics.rs b/src/librustc_mir/interpret/intrinsics.rs index 1e5ed76c467..869eb1227f2 100644 --- a/src/librustc_mir/interpret/intrinsics.rs +++ b/src/librustc_mir/interpret/intrinsics.rs @@ -103,6 +103,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { self.write_scalar(location.ptr, dest)?; } + sym::abort => { + M::abort(self)?; + } + sym::min_align_of | sym::pref_align_of | sym::needs_drop diff --git a/src/librustc_mir/interpret/machine.rs b/src/librustc_mir/interpret/machine.rs index 087517ff4e3..366de6e5561 100644 --- a/src/librustc_mir/interpret/machine.rs +++ b/src/librustc_mir/interpret/machine.rs @@ -169,6 +169,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 diff --git a/src/librustc_mir/interpret/terminator.rs b/src/librustc_mir/interpret/terminator.rs index b5c34daf8a3..473ed9d13ec 100644 --- a/src/librustc_mir/interpret/terminator.rs +++ b/src/librustc_mir/interpret/terminator.rs @@ -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 @@ -114,15 +118,13 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { Unreachable => throw_ub!(Unreachable), // These should never occur for MIR we actually run. - DropAndReplace { .. } | FalseEdges { .. } | FalseUnwind { .. } => { + DropAndReplace { .. } + | FalseEdges { .. } + | FalseUnwind { .. } + | Yield { .. } + | GeneratorDrop => { bug!("{:#?} should have been eliminated by MIR pass", terminator.kind) } - - // These are not (yet) supported. It is unclear if they even can occur in - // MIR that we actually run. - Yield { .. } | GeneratorDrop | Abort => { - throw_unsup_format!("Unsupported terminator kind: {:#?}", terminator.kind) - } } Ok(()) diff --git a/src/librustc_span/symbol.rs b/src/librustc_span/symbol.rs index d8ce9bbdfb3..6cb7cbf14fd 100644 --- a/src/librustc_span/symbol.rs +++ b/src/librustc_span/symbol.rs @@ -120,6 +120,7 @@ symbols! { abi_unadjusted, abi_vectorcall, abi_x86_interrupt, + abort, aborts, address, add_with_overflow, |
