Skip to content

Commit 4010980

Browse files
Rollup merge of rust-lang#133050 - tgross35:inline-f16-f128, r=saethlin
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
2 parents 2ee4159 + cdb5ff5 commit 4010980

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

core/src/num/f128.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1258,9 +1258,8 @@ impl f128 {
12581258
min <= max,
12591259
"min > max, or either was NaN",
12601260
"min > max, or either was NaN. min = {min:?}, max = {max:?}",
1261-
// FIXME(f16_f128): Passed by-ref to avoid codegen crashes
1262-
min: &f128 = &min,
1263-
max: &f128 = &max,
1261+
min: f128,
1262+
max: f128,
12641263
);
12651264

12661265
if self < min {

core/src/num/f16.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1235,9 +1235,8 @@ impl f16 {
12351235
min <= max,
12361236
"min > max, or either was NaN",
12371237
"min > max, or either was NaN. min = {min:?}, max = {max:?}",
1238-
// FIXME(f16_f128): Passed by-ref to avoid codegen crashes
1239-
min: &f16 = &min,
1240-
max: &f16 = &max,
1238+
min: f16,
1239+
max: f16,
12411240
);
12421241

12431242
if self < min {

0 commit comments

Comments
 (0)