Fix up intrinsic implementation
This commit is contained in:
parent
caf3cc1fc8
commit
fe88fc03c5
@ -1352,7 +1352,7 @@ pub fn volatile_copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T,
|
||||
/// Internal hook used by Miri to implement unwinding.
|
||||
/// Perma-unstable: do not use
|
||||
#[cfg(not(bootstrap))]
|
||||
pub fn miri_start_panic(data: *mut (dyn crate::any::Any + Send)) -> !;
|
||||
pub fn miri_start_panic(data: u128) -> !;
|
||||
}
|
||||
|
||||
// Some functions are defined here because they accidentally got made
|
||||
|
@ -1,9 +1,13 @@
|
||||
use core::any::Any;
|
||||
use alloc::boxed::Box;
|
||||
|
||||
pub fn payload() -> *mut u8 {
|
||||
core::ptr::null_mut()
|
||||
}
|
||||
|
||||
pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
|
||||
core::intrinsics::miri_start_panic(Box::into_raw(data))
|
||||
pub unsafe fn panic(data: Box<dyn Any + Send>) -> ! {
|
||||
let raw_val = core::mem::transmute::<_, u128>(Box::into_raw(data));
|
||||
core::intrinsics::miri_start_panic(raw_val)
|
||||
}
|
||||
|
||||
pub unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> {
|
||||
|
@ -528,6 +528,16 @@ fn codegen_call_terminator<'b>(
|
||||
_ => FnAbi::new(&bx, sig, &extra_args)
|
||||
};
|
||||
|
||||
// This should never be reachable at runtime:
|
||||
// We should only emit a call to this intrinsic in #[cfg(miri)] mode,
|
||||
// which means that we will never actually use the generate object files
|
||||
// (we will just be interpreting the MIR)
|
||||
if intrinsic == Some("miri_start_panic") {
|
||||
bx.abort();
|
||||
bx.unreachable();
|
||||
return;
|
||||
}
|
||||
|
||||
// Emit a panic or a no-op for `panic_if_uninhabited`.
|
||||
if intrinsic == Some("panic_if_uninhabited") {
|
||||
let ty = instance.unwrap().substs.type_at(0);
|
||||
|
@ -384,6 +384,10 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem) {
|
||||
(1, vec![ tcx.mk_mut_ptr(param(0)), param(0) ], tcx.mk_unit())
|
||||
}
|
||||
|
||||
"miri_start_panic" => {
|
||||
(0, vec![tcx.types.u128], tcx.types.never)
|
||||
}
|
||||
|
||||
ref other => {
|
||||
struct_span_err!(tcx.sess, it.span, E0093,
|
||||
"unrecognized intrinsic function: `{}`",
|
||||
|
Loading…
Reference in New Issue
Block a user