Skip to content

Commit 6837b82

Browse files
committed
Auto merge of rust-lang#121309 - Nilstrieb:inline-all-the-fallbacks, r=oli-obk
Make intrinsic fallback bodies cross-crate inlineable This change was prompted by the stage1 compiler spending 4% of its time when compiling the polymorphic-recursion MIR opt test in `unlikely`. Intrinsic fallback bodies like `unlikely` should always be inlined, it's very silly if they are not. To do this, we enable the fallback bodies to be cross-crate inlineable. Not that this matters for our workloads since the compiler never actually _uses_ the "fallback bodies", it just uses whatever was cfg(bootstrap)ped, so I've also added `#[inline]` to those. See the comments for more information. r? oli-obk
2 parents c79c270 + b70f8e9 commit 6837b82

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

core/src/intrinsics.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,7 @@ extern "rust-intrinsic" {
953953
#[rustc_nounwind]
954954
#[unstable(feature = "core_intrinsics", issue = "none")]
955955
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
956+
#[cfg_attr(bootstrap, inline)]
956957
pub const unsafe fn assume(b: bool) {
957958
if !b {
958959
// SAFETY: the caller must guarantee the argument is never `false`
@@ -975,6 +976,7 @@ pub const unsafe fn assume(b: bool) {
975976
#[unstable(feature = "core_intrinsics", issue = "none")]
976977
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
977978
#[rustc_nounwind]
979+
#[cfg_attr(bootstrap, inline)]
978980
pub const fn likely(b: bool) -> bool {
979981
b
980982
}
@@ -994,6 +996,7 @@ pub const fn likely(b: bool) -> bool {
994996
#[unstable(feature = "core_intrinsics", issue = "none")]
995997
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
996998
#[rustc_nounwind]
999+
#[cfg_attr(bootstrap, inline)]
9971000
pub const fn unlikely(b: bool) -> bool {
9981001
b
9991002
}
@@ -2596,6 +2599,7 @@ extern "rust-intrinsic" {
25962599
#[rustc_nounwind]
25972600
#[unstable(feature = "core_intrinsics", issue = "none")]
25982601
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
2602+
#[cfg_attr(bootstrap, inline)]
25992603
pub const fn is_val_statically_known<T: Copy>(_arg: T) -> bool {
26002604
false
26012605
}
@@ -2633,6 +2637,7 @@ pub(crate) const fn debug_assertions() -> bool {
26332637
#[unstable(feature = "core_intrinsics", issue = "none")]
26342638
#[rustc_nounwind]
26352639
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
2640+
#[cfg_attr(bootstrap, inline)]
26362641
pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 {
26372642
// const eval overrides this function, but runtime code should always just return null pointers.
26382643
crate::ptr::null_mut()
@@ -2652,6 +2657,7 @@ pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 {
26522657
#[unstable(feature = "core_intrinsics", issue = "none")]
26532658
#[rustc_nounwind]
26542659
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
2660+
#[cfg_attr(bootstrap, inline)]
26552661
pub const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {}
26562662

26572663
// Some functions are defined here because they accidentally got made

0 commit comments

Comments
 (0)