about summary refs log tree commit diff
path: root/library/std
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-12-15 04:54:14 +0000
committerbors <bors@rust-lang.org>2023-12-15 04:54:14 +0000
commit1559dd2dbfd42e72ac05b1d23b85ce5ed63f900b (patch)
tree1b774224078ee022c8e5197e47cee27ba6c787cd /library/std
parent604f185fae9a4b0edf7e28f616a0f53880f8f074 (diff)
parente559172249af514ab2c3be6340d557dcbb6347eb (diff)
downloadrust-1559dd2dbfd42e72ac05b1d23b85ce5ed63f900b.tar.gz
rust-1559dd2dbfd42e72ac05b1d23b85ce5ed63f900b.zip
Auto merge of #118770 - saethlin:fix-inline-never-uses, r=nnethercote
Fix cases where std accidentally relied on inline(never)

This PR increases the power of `-Zcross-crate-inline-threshold=always` so that it applies through `#[inline(never)]`. Note that though this is called "cross-crate-inlining" in this case especially it is _just_ lazy per-CGU codegen. The MIR inliner and LLVM still respect the attribute as much as they ever have.

Trying to bootstrap with the new `-Zcross-crate-inline-threshold=always` change revealed two bugs:

We have special intrinsics `assert_inhabited`, `assert_zero_valid`, and `assert_mem_uniniitalized_valid` which codegen backends will lower to nothing or a call to `panic_nounwind`.  Since we may not have any call to `panic_nounwind` in MIR but emit one anyway, we need to specially tell `MirUsedCollector` about this situation.

`#[lang = "start"]` is special-cased already so that `MirUsedCollector` will collect it, but then when we make it cross-crate-inlinable it is only assigned to a CGU based on whether `MirUsedCollector` saw a call to it, which of course we didn't.

---

I started looking into this because https://github.com/rust-lang/rust/pull/118683 revealed a case where we were accidentally relying on a function being `#[inline(never)]`, and cranking up cross-crate-inlinability seems like a way to find other situations like that.

r? `@nnethercote` because I don't like what I'm doing to the CGU partitioning code here but I can't come up with something much better
Diffstat (limited to 'library/std')
-rw-r--r--library/std/src/rt.rs1
1 files changed, 0 insertions, 1 deletions
diff --git a/library/std/src/rt.rs b/library/std/src/rt.rs
index 5c83f72f3c1..f1eeb75be7c 100644
--- a/library/std/src/rt.rs
+++ b/library/std/src/rt.rs
@@ -155,7 +155,6 @@ fn lang_start_internal(
 }
 
 #[cfg(not(test))]
-#[inline(never)]
 #[lang = "start"]
 fn lang_start<T: crate::process::Termination + 'static>(
     main: fn() -> T,