forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
4 changed files
with
43 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//@ revisions: default nopt | ||
//@[nopt] compile-flags: -Copt-level=0 -Zcross-crate-inline-threshold=never -Zmir-opt-level=0 -Cno-prepopulate-passes | ||
|
||
// Ensure that functions using `f16` and `f128` are always inlined to avoid crashes | ||
// when the backend does not support these types. | ||
|
||
#![crate_type = "lib"] | ||
#![feature(f128)] | ||
#![feature(f16)] | ||
|
||
pub fn f16_arg(_a: f16) { | ||
// CHECK-NOT: f16_arg | ||
todo!() | ||
} | ||
|
||
pub fn f16_ret() -> f16 { | ||
// CHECK-NOT: f16_ret | ||
todo!() | ||
} | ||
|
||
pub fn f128_arg(_a: f128) { | ||
// CHECK-NOT: f128_arg | ||
todo!() | ||
} | ||
|
||
pub fn f128_ret() -> f128 { | ||
// CHECK-NOT: f128_ret | ||
todo!() | ||
} |