Skip to content
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

Use inline(never) instead of cold #76262

Merged
merged 1 commit into from
Sep 16, 2020
Merged

Use inline(never) instead of cold #76262

merged 1 commit into from
Sep 16, 2020

Conversation

howard0su
Copy link
Contributor

inline(never) is better way to avoid optimizer to inline the function instead of cold.

inline(never) is better way to avoid optimizer to inline the function instead of cold.
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @cramertj (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 2, 2020
@jhpratt
Copy link
Member

jhpratt commented Sep 6, 2020

I presume you've checked to make sure this actually makes a difference in the final binary?

@cramertj
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Sep 16, 2020

📌 Commit a80d390 has been approved by cramertj

@bors bors 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 Sep 16, 2020
@cramertj
Copy link
Member

This seems safe enough of a change, though I'd prefer it if profiling data or examples of binary changes were available here. The docs on the function do specify that it is trying to avoid inlining, and this is the correct way to do that.

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Sep 16, 2020
Use inline(never) instead of cold

inline(never) is better way to avoid optimizer to inline the function instead of cold.
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 16, 2020
Rollup of 10 pull requests

Successful merges:

 - rust-lang#76056 (Add more info for Vec Drain doc)
 - rust-lang#76062 (Vec slice example fix style and show type elision)
 - rust-lang#76262 (Use inline(never) instead of cold)
 - rust-lang#76335 (Make all methods of `Duration` unstably const)
 - rust-lang#76366 (Add Arith Tests in Library)
 - rust-lang#76369 (Move Various str tests in library)
 - rust-lang#76534 (Add doc comments for From impls)
 - rust-lang#76622 (Update bootstrap readme)
 - rust-lang#76641 (Some cleanup changes and commenting)
 - rust-lang#76662 (Fix liballoc test suite for Miri)

Failed merges:

r? `@ghost`
@bjorn3
Copy link
Member

bjorn3 commented Sep 16, 2020

#[cold] has the additional effect that it makes the call site cold, which means that LLVM will optimize for the case where it is not called.

@bors bors merged commit 19a62db into rust-lang:master Sep 16, 2020
@rustbot rustbot added this to the 1.48.0 milestone Sep 16, 2020
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants