Skip to content

Commit b06c83c

Browse files
committed
Add miri trampoline, fix handling of intrinsic return
1 parent 5553476 commit b06c83c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/libpanic_unwind/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,6 @@ pub unsafe extern "C" fn __rust_start_panic(payload: usize) -> u32 {
9797
let payload = payload as *mut &mut dyn BoxMeUp;
9898
imp::panic(Box::from_raw((*payload).box_me_up()))
9999
}
100+
101+
#[cfg(miri)]
102+
pub fn miri_panic_trampoline() {}

src/librustc_mir/interpret/terminator.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,19 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
264264

265265
match instance.def {
266266
ty::InstanceDef::Intrinsic(..) => {
267+
let old_stack = self.cur_frame();
267268
M::call_intrinsic(self, span, instance, args, dest)?;
268269
// No stack frame gets pushed, the main loop will just act as if the
269270
// call completed.
270-
self.goto_block(ret)?;
271+
if ret.is_some() {
272+
self.goto_block(ret)?;
273+
} else {
274+
// If this intrinsic call doesn't have a ret block,
275+
// then the intrinsic implementation should have
276+
// changed the stack frame (otherwise, we'll end
277+
// up trying to execute this intrinsic call again)
278+
assert!(self.cur_frame() != old_stack);
279+
}
271280
if let Some(dest) = dest {
272281
self.dump_place(*dest)
273282
}

0 commit comments

Comments
 (0)