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

Tracking Issue for extern "rust-cold" ABI (feature rust_cold_cc) #97544

Open
4 of 8 tasks
scottmcm opened this issue May 30, 2022 · 1 comment
Open
4 of 8 tasks

Tracking Issue for extern "rust-cold" ABI (feature rust_cold_cc) #97544

scottmcm opened this issue May 30, 2022 · 1 comment
Labels
A-ABI Area: Concerning the application binary interface (ABI) C-tracking-issue Category: A tracking issue for an RFC or an unstable feature.

Comments

@scottmcm
Copy link
Member

scottmcm commented May 30, 2022

This is a tracking issue for the experimental extern "rust-cold" ABI.
The feature gate for the issue is #![feature(rust_cold_cc)].

This allows emitting functions with coldcc in LLVM and CallConv::Cold in cranelift. These are more aggressive than the stable #[cold], as they can use a different calling convention (and thus have incompatible fns), not just affect branch weights -- for example, they might require more/slower code in the callee in exchange for smaller call sites.

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.

Steps

Unresolved Questions

Implementation history

@scottmcm scottmcm added the C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. label May 30, 2022
@workingjubilee workingjubilee added the A-ABI Area: Concerning the application binary interface (ABI) label Jul 1, 2022
@reinerp
Copy link

reinerp commented Feb 23, 2023

I'm very excited about this, thank you for your work on this!

Couple comments:

  • this seems to be broken for 16-byte returns on x86-64. Example: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=e484bf958a2e5b421de9e5a52f736723. Looking at the code for foo in this example, it seems to be trying to return the result in rax and rdx, but then it calls pop rdx which clobbers the return value.
  • coldcc is suitable for "never runs" things like panics. For "runs rarely (amortized)" things, LLVM's preserve_mostcc seems like it is often a better fit. (A primary difference is that coldcc saves all XMM registers, whereas preserve_mostcc does not.) It has the added advantage of being exposed to C++ in Clang, and seems to be used in some popular codebases (V8, Folly), so it might be better exercised/tested than the coldcc convention. Would it be possible to have a "rust-cool" variant too, which uses preserve_mostcc?

bors added a commit to rust-lang-ci/rust that referenced this issue Aug 29, 2023
…Lapkin

Use `preserve_mostcc` for `extern "rust-cold"`

As experimentation in rust-lang#115242 has shown looks better than `coldcc`.  Notably, clang exposes `preserve_most` (https://clang.llvm.org/docs/AttributeReference.html#preserve-most) but not `cold`, so this change should put us on a better-supported path.

And *don't* use a different convention for cold on Windows, because that actually ends up making things worse. (See comment in the code.)

cc tracking issue rust-lang#97544
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ABI Area: Concerning the application binary interface (ABI) C-tracking-issue Category: A tracking issue for an RFC or an unstable feature.
Projects
None yet
Development

No branches or pull requests

3 participants