Skip to content

Commit 8365f66

Browse files
committed
Always inline f16 and f128
1 parent c82e0df commit 8365f66

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

compiler/rustc_mir_transform/src/cross_crate_inline.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
5050
_ => {}
5151
}
5252

53+
let sig = tcx.fn_sig(def_id).instantiate_identity();
54+
for ty in sig.inputs().skip_binder().iter().chain(std::iter::once(&sig.output().skip_binder()))
55+
{
56+
// FIXME(f16_f128): in order to avoid crashes building `core`, always inline to skip
57+
// codegen if the function is not used.
58+
if ty == &tcx.types.f16 || ty == &tcx.types.f128 {
59+
return true;
60+
}
61+
}
62+
5363
// Don't do any inference when incremental compilation is enabled; the additional inlining that
5464
// inference permits also creates more work for small edits.
5565
if tcx.sess.opts.incremental.is_some() {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//! Ensure that functions using `f16` and `f128` are always inlined
2+
3+
#![crate_type = "lib"]
4+
#![feature(f128)]
5+
#![feature(f16)]
6+
7+
#[no_mangle]
8+
pub fn f16_arg(a: f16) {
9+
// CHECK-NOT: f16_arg
10+
todo!()
11+
}
12+
13+
#[no_mangle]
14+
pub fn f16_ret() -> f16 {
15+
// CHECK-NOT: f16_ret
16+
todo!()
17+
}
18+
19+
#[no_mangle]
20+
pub fn f128_arg(a: f128) {
21+
// CHECK-NOT: f128_arg
22+
todo!()
23+
}
24+
25+
#[no_mangle]
26+
pub fn f128_ret() -> f128 {
27+
// CHECK-NOT: f128_ret
28+
todo!()
29+
}

0 commit comments

Comments
 (0)