My general policy for by-value vs by-ref arguments in Rust is to take anything bigger than one register on 64-bit by reference. It might not always be 100% optimal on every architecture, but LLVM usually optimizes it, and it’s an easy and consistent rule to remember.
Yeah, almost the same for me except I use 64 bit as the cutoff for things that fit in GPRs and 128 bit only for things that will be passed in SIMD registers.
-
-
Slices and things like structs with 2 usizes with repr(Rust) are compiled to pairs of scalars which are usually passed as two separate arguments and which are easily optimised by LLVM. It’s past midnight so I probably got some details wrong. Cc
@eddyb_r -
Oh yeah, I guess I always pass slices and trait objects by value as well.
- 1 more reply
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.