miri: rename intrinsic_fallback_checks_ub to intrinsic_fallback_is_spec

This commit is contained in:
Ralf Jung 2024-05-08 17:22:35 +02:00
parent 1fef1524f2
commit 75f57670b0
5 changed files with 23 additions and 23 deletions

View File

@ -987,7 +987,7 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
#[unstable(feature = "core_intrinsics", issue = "none")]
#[rustc_intrinsic]
#[rustc_nounwind]
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_checks_ub)]
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_is_spec)]
pub const fn likely(b: bool) -> bool {
b
}
@ -1007,7 +1007,7 @@ pub const fn likely(b: bool) -> bool {
#[unstable(feature = "core_intrinsics", issue = "none")]
#[rustc_intrinsic]
#[rustc_nounwind]
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_checks_ub)]
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_is_spec)]
pub const fn unlikely(b: bool) -> bool {
b
}
@ -2471,7 +2471,7 @@ pub const fn unlikely(b: bool) -> bool {
#[rustc_nounwind]
#[rustc_do_not_const_check]
#[inline]
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_checks_ub)]
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_is_spec)]
pub const fn ptr_guaranteed_cmp<T>(ptr: *const T, other: *const T) -> u8 {
(ptr == other) as u8
}
@ -2736,7 +2736,7 @@ pub const fn ub_checks() -> bool {
#[unstable(feature = "core_intrinsics", issue = "none")]
#[rustc_nounwind]
#[rustc_intrinsic]
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_checks_ub)]
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_is_spec)]
pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 {
// const eval overrides this function, but runtime code for now just returns null pointers.
// See <https://github.com/rust-lang/rust/issues/93935>.
@ -2757,7 +2757,7 @@ pub const fn ub_checks() -> bool {
#[unstable(feature = "core_intrinsics", issue = "none")]
#[rustc_nounwind]
#[rustc_intrinsic]
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_checks_ub)]
#[cfg_attr(not(bootstrap), miri::intrinsic_fallback_is_spec)]
pub const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {
// Runtime NOP
}

View File

@ -43,18 +43,18 @@ fn call_intrinsic(
if this.tcx.intrinsic(instance.def_id()).unwrap().must_be_overridden {
throw_unsup_format!("unimplemented intrinsic: `{intrinsic_name}`")
}
let intrinsic_fallback_checks_ub = Symbol::intern("intrinsic_fallback_checks_ub");
let intrinsic_fallback_is_spec = Symbol::intern("intrinsic_fallback_is_spec");
if this
.tcx
.get_attrs_by_path(
instance.def_id(),
&[sym::miri, intrinsic_fallback_checks_ub],
&[sym::miri, intrinsic_fallback_is_spec],
)
.next()
.is_none()
{
throw_unsup_format!(
"miri can only use intrinsic fallback bodies that check UB. After verifying that `{intrinsic_name}` does so, add the `#[miri::intrinsic_fallback_checks_ub]` attribute to it; also ping @rust-lang/miri when you do that"
"Miri can only use intrinsic fallback bodies that exactly reflect the specification: they fully check for UB and are as non-deterministic as possible. After verifying that `{intrinsic_name}` does so, add the `#[miri::intrinsic_fallback_is_spec]` attribute to it; also ping @rust-lang/miri when you do that"
);
}
Ok(Some(ty::Instance {

View File

@ -1,14 +0,0 @@
error: unsupported operation: miri can only use intrinsic fallback bodies that check UB. After verifying that `ptr_guaranteed_cmp` does so, add the `#[miri::intrinsic_fallback_checks_ub]` attribute to it; also ping @rust-lang/miri when you do that
--> $DIR/intrinsic_fallback_checks_ub.rs:LL:CC
|
LL | ptr_guaranteed_cmp::<()>(std::ptr::null(), std::ptr::null());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ miri can only use intrinsic fallback bodies that check UB. After verifying that `ptr_guaranteed_cmp` does so, add the `#[miri::intrinsic_fallback_checks_ub]` attribute to it; also ping @rust-lang/miri when you do that
|
= help: this is likely not a bug in the program; it indicates that the program performed an operation that Miri does not support
= note: BACKTRACE:
= note: inside `main` at $DIR/intrinsic_fallback_checks_ub.rs:LL:CC
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
error: aborting due to 1 previous error

View File

@ -10,5 +10,5 @@ pub const fn ptr_guaranteed_cmp<T>(ptr: *const T, other: *const T) -> u8 {
fn main() {
ptr_guaranteed_cmp::<()>(std::ptr::null(), std::ptr::null());
//~^ ERROR: can only use intrinsic fallback bodies that check UB.
//~^ ERROR: can only use intrinsic fallback bodies that exactly reflect the specification
}

View File

@ -0,0 +1,14 @@
error: unsupported operation: Miri can only use intrinsic fallback bodies that exactly reflect the specification: they fully check for UB and are as non-deterministic as possible. After verifying that `ptr_guaranteed_cmp` does so, add the `#[miri::intrinsic_fallback_is_spec]` attribute to it; also ping @rust-lang/miri when you do that
--> $DIR/intrinsic_fallback_is_spec.rs:LL:CC
|
LL | ptr_guaranteed_cmp::<()>(std::ptr::null(), std::ptr::null());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Miri can only use intrinsic fallback bodies that exactly reflect the specification: they fully check for UB and are as non-deterministic as possible. After verifying that `ptr_guaranteed_cmp` does so, add the `#[miri::intrinsic_fallback_is_spec]` attribute to it; also ping @rust-lang/miri when you do that
|
= help: this is likely not a bug in the program; it indicates that the program performed an operation that Miri does not support
= note: BACKTRACE:
= note: inside `main` at $DIR/intrinsic_fallback_is_spec.rs:LL:CC
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
error: aborting due to 1 previous error