Skip to content

Make hint::cold_path #[cold] so that it works even if the MIR inliner can't inline it#156863

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
saethlin:silly-cold-path
May 30, 2026
Merged

Make hint::cold_path #[cold] so that it works even if the MIR inliner can't inline it#156863
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
saethlin:silly-cold-path

Conversation

@saethlin
Copy link
Copy Markdown
Member

This fixes #156859 because the branch weight metadata is actually keyed off seeing a #[cold] function call in an arm. We don't need the intrinsic, any #[cold] function will do. So if the hint wrapper itself is made #[cold], we will still get the desired effect, and LLVM will clean up the call to an empty function when optimizations are enabled.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 23, 2026
@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 23, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 23, 2026

r? @jackh726

rustbot has assigned @jackh726.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 18 candidates

Comment thread tests/codegen-llvm/hint/cold_path.rs Outdated
@rust-log-analyzer

This comment has been minimized.

@jackh726
Copy link
Copy Markdown
Member

@bors r+

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 30, 2026

📌 Commit 54569c6 has been approved by jackh726

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 30, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request May 30, 2026
Make hint::cold_path #[cold] so that it works even if the MIR inliner can't inline it

This fixes rust-lang#156859 because the branch weight metadata is actually keyed off seeing a `#[cold]` function call in an arm. We don't need the intrinsic, any `#[cold]` function will do. So if the hint wrapper itself is made `#[cold]`, we will still get the desired effect, and LLVM will clean up the call to an empty function when optimizations are enabled.
rust-bors Bot pushed a commit that referenced this pull request May 30, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #156863 (Make hint::cold_path #[cold] so that it works even if the MIR inliner can't inline it)
 - #156875 (Correct and document semantics of `yield` terminator)
 - #157115 ([rustdoc] Fix foreign items macro expansion)
 - #157150 (Revert "drop derive helpers during ast lowering" )
 - #156887 (Rename `-Zdebuginfo-for-profiling` switch)
 - #157039 (rustdoc: correctly propagate cfgs for glob reexports)
 - #157125 (Rewrite the `#[repr]` attribute parser)
 - #157154 (Revert workaround used to select the gcc codegen in the coretests CI)
@rust-bors rust-bors Bot merged commit 213551d into rust-lang:main May 30, 2026
11 checks passed
@rustbot rustbot added this to the 1.98.0 milestone May 30, 2026
rust-timer added a commit that referenced this pull request May 30, 2026
Rollup merge of #156863 - saethlin:silly-cold-path, r=jackh726

Make hint::cold_path #[cold] so that it works even if the MIR inliner can't inline it

This fixes #156859 because the branch weight metadata is actually keyed off seeing a `#[cold]` function call in an arm. We don't need the intrinsic, any `#[cold]` function will do. So if the hint wrapper itself is made `#[cold]`, we will still get the desired effect, and LLVM will clean up the call to an empty function when optimizations are enabled.
@Kobzol
Copy link
Copy Markdown
Member

Kobzol commented May 30, 2026

@rust-timer build 95a8ac2

Testing for #157161.

@rust-timer
Copy link
Copy Markdown
Collaborator

Missing artifact for sha 95a8ac295f6b33e8acd96e8ccbc30e5776a78649 (https://ci-artifacts.rust-lang.org/rustc-builds/95a8ac295f6b33e8acd96e8ccbc30e5776a78649/rustc-nightly-x86_64-unknown-linux-gnu.tar.xz); not built yet, try again later.

@JonathanBrouwer
Copy link
Copy Markdown
Contributor

@rust-timer build 95a8ac2

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (95a8ac2): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

This perf run didn't have relevant results for this metric.

Cycles

This perf run didn't have relevant results for this metric.

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 515.367s -> 511.239s (-0.80%)
Artifact size: 400.82 MiB -> 400.80 MiB (-0.00%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

target_feature(enable = ...) interferes with core::hint::cold_path

8 participants