Skip to content

Commit a2ab069

Browse files
committed
Auto merge of #151065 - nagisa:add-preserve-none-abi, r=petrochenkov
abi: add a rust-preserve-none calling convention This is the conceptual opposite of the rust-cold calling convention and is particularly useful in combination with the new `explicit_tail_calls` feature. For relatively tight loops implemented with tail calling (`become`) each of the function with the regular calling convention is still responsible for restoring the initial value of the preserved registers. So it is not unusual to end up with a situation where each step in the tail call loop is spilling and reloading registers, along the lines of: foo: push r12 ; do things pop r12 jmp next_step This adds up quickly, especially when most of the clobberable registers are already used to pass arguments or other uses. I was thinking of making the name of this ABI a little less LLVM-derived and more like a conceptual inverse of `rust-cold`, but could not come with a great name (`rust-cold` is itself not a great name: cold in what context? from which perspective? is it supposed to mean that the function is rarely called?)
2 parents e86e242 + 73b221a commit a2ab069

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

crates/hir-ty/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ pub enum FnAbi {
230230
Win64,
231231
Win64Unwind,
232232
X86Interrupt,
233+
RustPreserveNone,
233234
Unknown,
234235
}
235236

@@ -271,6 +272,7 @@ impl FnAbi {
271272
s if *s == sym::riscv_dash_interrupt_dash_s => FnAbi::RiscvInterruptS,
272273
s if *s == sym::rust_dash_call => FnAbi::RustCall,
273274
s if *s == sym::rust_dash_cold => FnAbi::RustCold,
275+
s if *s == sym::rust_dash_preserve_dash_none => FnAbi::RustPreserveNone,
274276
s if *s == sym::rust_dash_intrinsic => FnAbi::RustIntrinsic,
275277
s if *s == sym::Rust => FnAbi::Rust,
276278
s if *s == sym::stdcall_dash_unwind => FnAbi::StdcallUnwind,
@@ -314,6 +316,7 @@ impl FnAbi {
314316
FnAbi::Rust => "Rust",
315317
FnAbi::RustCall => "rust-call",
316318
FnAbi::RustCold => "rust-cold",
319+
FnAbi::RustPreserveNone => "rust-preserve-none",
317320
FnAbi::RustIntrinsic => "rust-intrinsic",
318321
FnAbi::Stdcall => "stdcall",
319322
FnAbi::StdcallUnwind => "stdcall-unwind",

crates/intern/src/symbol/symbols.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ define_symbols! {
109109
vectorcall_dash_unwind = "vectorcall-unwind",
110110
win64_dash_unwind = "win64-unwind",
111111
x86_dash_interrupt = "x86-interrupt",
112+
rust_dash_preserve_dash_none = "preserve-none",
112113

113114
@PLAIN:
114115
__ra_fixup,

0 commit comments

Comments
 (0)