-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Implement immediate-abort by hooking #[rustc_panic_entrypoint] and lint for functions that look like a panic entrypoint #150497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
☔ The latest upstream changes (presumably #150386) made this pull request unmergeable. Please resolve the merge conflicts. |
Should be possible to check |
9907096 to
3dcb309
Compare
Yep. But it turns out |
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Implement immediate-abort by hooking #[rustc_panic_entrypoint] and lint for functions that look like a panic entrypoint
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (0de2b26): comparison URL. Overall result: ❌ regressions - no action neededBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (secondary 0.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 2.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary 0.0%, secondary -0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 480.336s -> 480.598s (0.05%) |
compiler/rustc_lint/src/builtin.rs
Outdated
| } | ||
| } | ||
|
|
||
| declare_lint! { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be an internal lint
b8ef8e7 to
848a6ad
Compare
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
I'm lost. How did trying to add an internal lint (which uses completely different macros from adding a builtin lint??) remove another lint? |
There are a handful of functions, mostly in
core, which have a mess of attributes on them which try to ensure that they compile down to justintrinsics::abort()whencfg(panic = "immediate-abort"), and otherwise are outlined. These functions now all get#[rustc_panic_entrypoint]which makes the functions#[cold],#[inline(never)], and#[optimize(size)]. But when immediate-abort is enabled, these functions are#[inline].And since these functions are now all known to the compiler, when immediate-abort is enabled, both their bodies and calls to them are directly replaced
intrinsics::abort(). Replacing both body and calls means that we rely much less on optimization to make immediate-abort do its job, but if for some godforsaken reason you are indirectly calling a panic entrypoint, that will still immediately abort.There is a fair bit of inconsistency in what attributes are on panic entrypoints, only some have
#[optimize(size)]and about half have#[inline(never)]. The single attribute makes sure they are all treated the same. (I am making an informed guess that the inconsistency was accidental, and mostly not impactful)This PR also adds an allow-by-default lint,
missing_panic_entrypointwhich looks for diverging functions that do not have one of#[rustc_panic_entrypoint]or#[inline]. Panic wrappers sometimes have#[inline]because they are theconst fnfor aconst_eval_select, so adding#[inline]ensures that monomorphization doesn't eagerly codegen a useless copy of them.TODO:
Make the way cg_ssa patches out diverging calls check for the entry point attr