Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f2bf9e6

Browse files
committedNov 8, 2024
remove support for rustc_safe_intrinsic attribute; use rustc_intrinsic functions instead
1 parent dffc5e7 commit f2bf9e6

File tree

1 file changed

+102
-78
lines changed

1 file changed

+102
-78
lines changed
 

‎core/src/intrinsics/mod.rs

+102-78
Original file line numberDiff line numberDiff line change
@@ -904,45 +904,51 @@ extern "rust-intrinsic" {
904904
#[rustc_nounwind]
905905
pub fn prefetch_write_instruction<T>(data: *const T, locality: i32);
906906

907-
/// Magic intrinsic that derives its meaning from attributes
908-
/// attached to the function.
909-
///
910-
/// For example, dataflow uses this to inject static assertions so
911-
/// that `rustc_peek(potentially_uninitialized)` would actually
912-
/// double-check that dataflow did indeed compute that it is
913-
/// uninitialized at that point in the control flow.
914-
///
915-
/// This intrinsic should not be used outside of the compiler.
916-
#[rustc_safe_intrinsic]
917-
#[rustc_nounwind]
918-
pub fn rustc_peek<T>(_: T) -> T;
919-
920-
/// Aborts the execution of the process.
921-
///
922-
/// Note that, unlike most intrinsics, this is safe to call;
923-
/// it does not require an `unsafe` block.
924-
/// Therefore, implementations must not require the user to uphold
925-
/// any safety invariants.
926-
///
927-
/// [`std::process::abort`](../../std/process/fn.abort.html) is to be preferred if possible,
928-
/// as its behavior is more user-friendly and more stable.
929-
///
930-
/// The current implementation of `intrinsics::abort` is to invoke an invalid instruction,
931-
/// on most platforms.
932-
/// On Unix, the
933-
/// process will probably terminate with a signal like `SIGABRT`, `SIGILL`, `SIGTRAP`, `SIGSEGV` or
934-
/// `SIGBUS`. The precise behavior is not guaranteed and not stable.
935-
#[rustc_safe_intrinsic]
936-
#[rustc_nounwind]
937-
pub fn abort() -> !;
938-
939907
/// Executes a breakpoint trap, for inspection by a debugger.
940908
///
941909
/// This intrinsic does not have a stable counterpart.
942910
#[rustc_nounwind]
943911
pub fn breakpoint();
944912
}
945913

914+
/// Magic intrinsic that derives its meaning from attributes
915+
/// attached to the function.
916+
///
917+
/// For example, dataflow uses this to inject static assertions so
918+
/// that `rustc_peek(potentially_uninitialized)` would actually
919+
/// double-check that dataflow did indeed compute that it is
920+
/// uninitialized at that point in the control flow.
921+
///
922+
/// This intrinsic should not be used outside of the compiler.
923+
#[rustc_nounwind]
924+
#[rustc_intrinsic]
925+
#[rustc_intrinsic_must_be_overridden]
926+
pub fn rustc_peek<T>(_: T) -> T {
927+
unreachable!()
928+
}
929+
930+
/// Aborts the execution of the process.
931+
///
932+
/// Note that, unlike most intrinsics, this is safe to call;
933+
/// it does not require an `unsafe` block.
934+
/// Therefore, implementations must not require the user to uphold
935+
/// any safety invariants.
936+
///
937+
/// [`std::process::abort`](../../std/process/fn.abort.html) is to be preferred if possible,
938+
/// as its behavior is more user-friendly and more stable.
939+
///
940+
/// The current implementation of `intrinsics::abort` is to invoke an invalid instruction,
941+
/// on most platforms.
942+
/// On Unix, the
943+
/// process will probably terminate with a signal like `SIGABRT`, `SIGILL`, `SIGTRAP`, `SIGSEGV` or
944+
/// `SIGBUS`. The precise behavior is not guaranteed and not stable.
945+
#[rustc_nounwind]
946+
#[rustc_intrinsic]
947+
#[rustc_intrinsic_must_be_overridden]
948+
pub fn abort() -> ! {
949+
unreachable!()
950+
}
951+
946952
/// Informs the optimizer that this point in the code is not reachable,
947953
/// enabling further optimizations.
948954
///
@@ -1512,19 +1518,22 @@ pub const unsafe fn arith_offset<T>(_dst: *const T, _offset: isize) -> *const T
15121518
unreachable!()
15131519
}
15141520

1515-
extern "rust-intrinsic" {
1516-
/// Masks out bits of the pointer according to a mask.
1517-
///
1518-
/// Note that, unlike most intrinsics, this is safe to call;
1519-
/// it does not require an `unsafe` block.
1520-
/// Therefore, implementations must not require the user to uphold
1521-
/// any safety invariants.
1522-
///
1523-
/// Consider using [`pointer::mask`] instead.
1524-
#[rustc_safe_intrinsic]
1525-
#[rustc_nounwind]
1526-
pub fn ptr_mask<T>(ptr: *const T, mask: usize) -> *const T;
1521+
/// Masks out bits of the pointer according to a mask.
1522+
///
1523+
/// Note that, unlike most intrinsics, this is safe to call;
1524+
/// it does not require an `unsafe` block.
1525+
/// Therefore, implementations must not require the user to uphold
1526+
/// any safety invariants.
1527+
///
1528+
/// Consider using [`pointer::mask`] instead.
1529+
#[rustc_nounwind]
1530+
#[rustc_intrinsic]
1531+
#[rustc_intrinsic_must_be_overridden]
1532+
pub fn ptr_mask<T>(_ptr: *const T, _mask: usize) -> *const T {
1533+
unreachable!()
1534+
}
15271535

1536+
extern "rust-intrinsic" {
15281537
/// Equivalent to the appropriate `llvm.memcpy.p0i8.0i8.*` intrinsic, with
15291538
/// a size of `count` * `size_of::<T>()` and an alignment of
15301539
/// `min_align_of::<T>()`
@@ -2140,47 +2149,62 @@ extern "rust-intrinsic" {
21402149
#[rustc_nounwind]
21412150
pub fn frem_fast<T: Copy>(a: T, b: T) -> T;
21422151

2143-
/// Float addition that allows optimizations based on algebraic rules.
2152+
/// Converts with LLVM’s fptoui/fptosi, which may return undef for values out of range
2153+
/// (<https://github.com/rust-lang/rust/issues/10184>)
21442154
///
2145-
/// This intrinsic does not have a stable counterpart.
2155+
/// Stabilized as [`f32::to_int_unchecked`] and [`f64::to_int_unchecked`].
21462156
#[rustc_nounwind]
2147-
#[rustc_safe_intrinsic]
2148-
pub fn fadd_algebraic<T: Copy>(a: T, b: T) -> T;
2157+
pub fn float_to_int_unchecked<Float: Copy, Int: Copy>(value: Float) -> Int;
2158+
}
21492159

2150-
/// Float subtraction that allows optimizations based on algebraic rules.
2151-
///
2152-
/// This intrinsic does not have a stable counterpart.
2153-
#[rustc_nounwind]
2154-
#[rustc_safe_intrinsic]
2155-
pub fn fsub_algebraic<T: Copy>(a: T, b: T) -> T;
2160+
/// Float addition that allows optimizations based on algebraic rules.
2161+
///
2162+
/// This intrinsic does not have a stable counterpart.
2163+
#[rustc_nounwind]
2164+
#[rustc_intrinsic]
2165+
#[rustc_intrinsic_must_be_overridden]
2166+
pub fn fadd_algebraic<T: Copy>(_a: T, _b: T) -> T {
2167+
unimplemented!()
2168+
}
21562169

2157-
/// Float multiplication that allows optimizations based on algebraic rules.
2158-
///
2159-
/// This intrinsic does not have a stable counterpart.
2160-
#[rustc_nounwind]
2161-
#[rustc_safe_intrinsic]
2162-
pub fn fmul_algebraic<T: Copy>(a: T, b: T) -> T;
2170+
/// Float subtraction that allows optimizations based on algebraic rules.
2171+
///
2172+
/// This intrinsic does not have a stable counterpart.
2173+
#[rustc_nounwind]
2174+
#[rustc_intrinsic]
2175+
#[rustc_intrinsic_must_be_overridden]
2176+
pub fn fsub_algebraic<T: Copy>(_a: T, _b: T) -> T {
2177+
unimplemented!()
2178+
}
21632179

2164-
/// Float division that allows optimizations based on algebraic rules.
2165-
///
2166-
/// This intrinsic does not have a stable counterpart.
2167-
#[rustc_nounwind]
2168-
#[rustc_safe_intrinsic]
2169-
pub fn fdiv_algebraic<T: Copy>(a: T, b: T) -> T;
2180+
/// Float multiplication that allows optimizations based on algebraic rules.
2181+
///
2182+
/// This intrinsic does not have a stable counterpart.
2183+
#[rustc_nounwind]
2184+
#[rustc_intrinsic]
2185+
#[rustc_intrinsic_must_be_overridden]
2186+
pub fn fmul_algebraic<T: Copy>(_a: T, _b: T) -> T {
2187+
unimplemented!()
2188+
}
21702189

2171-
/// Float remainder that allows optimizations based on algebraic rules.
2172-
///
2173-
/// This intrinsic does not have a stable counterpart.
2174-
#[rustc_nounwind]
2175-
#[rustc_safe_intrinsic]
2176-
pub fn frem_algebraic<T: Copy>(a: T, b: T) -> T;
2190+
/// Float division that allows optimizations based on algebraic rules.
2191+
///
2192+
/// This intrinsic does not have a stable counterpart.
2193+
#[rustc_nounwind]
2194+
#[rustc_intrinsic]
2195+
#[rustc_intrinsic_must_be_overridden]
2196+
pub fn fdiv_algebraic<T: Copy>(_a: T, _b: T) -> T {
2197+
unimplemented!()
2198+
}
21772199

2178-
/// Converts with LLVM’s fptoui/fptosi, which may return undef for values out of range
2179-
/// (<https://github.com/rust-lang/rust/issues/10184>)
2180-
///
2181-
/// Stabilized as [`f32::to_int_unchecked`] and [`f64::to_int_unchecked`].
2182-
#[rustc_nounwind]
2183-
pub fn float_to_int_unchecked<Float: Copy, Int: Copy>(value: Float) -> Int;
2200+
/// Float remainder that allows optimizations based on algebraic rules.
2201+
///
2202+
/// This intrinsic does not have a stable counterpart.
2203+
#[rustc_nounwind]
2204+
#[rustc_intrinsic]
2205+
#[rustc_intrinsic_must_be_overridden]
2206+
pub fn frem_algebraic<T: Copy>(_a: T, _b: T) -> T {
2207+
unimplemented!()
21842208
}
21852209

21862210
/// Returns the number of bits set in an integer type `T`

0 commit comments

Comments
 (0)
Failed to load comments.