Skip to content

Commit

Permalink
Rollup merge of rust-lang#133050 - tgross35:inline-f16-f128, r=saethlin
Browse files Browse the repository at this point in the history
Always inline functions signatures containing `f16` or `f128`

There are a handful of tier 2 and tier 3 targets that cause a LLVM crash or linker error when generating code that contains `f16` or `f128`. The cranelift backend also does not support these types. To work around this, every function in `std` or `core` that contains these types must be marked `#[inline]` in order to avoid sending any code to the backend unless specifically requested.

However, this is inconvenient and easy to forget. Introduce a check for these types in the frontend that automatically inlines any function signatures that take or return `f16` or `f128`.

Note that this is not a perfect fix because it does not account for the types being passed by reference or as members of aggregate types, but this is sufficient for what is currently needed in the standard library.

Fixes: rust-lang#133035
Closes: rust-lang#133037
  • Loading branch information
workingjubilee authored Nov 15, 2024
2 parents 2ee4159 + cdb5ff5 commit 4010980
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions core/src/num/f128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1258,9 +1258,8 @@ impl f128 {
min <= max,
"min > max, or either was NaN",
"min > max, or either was NaN. min = {min:?}, max = {max:?}",
// FIXME(f16_f128): Passed by-ref to avoid codegen crashes
min: &f128 = &min,
max: &f128 = &max,
min: f128,
max: f128,
);

if self < min {
Expand Down
5 changes: 2 additions & 3 deletions core/src/num/f16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1235,9 +1235,8 @@ impl f16 {
min <= max,
"min > max, or either was NaN",
"min > max, or either was NaN. min = {min:?}, max = {max:?}",
// FIXME(f16_f128): Passed by-ref to avoid codegen crashes
min: &f16 = &min,
max: &f16 = &max,
min: f16,
max: f16,
);

if self < min {
Expand Down

0 comments on commit 4010980

Please sign in to comment.