Skip to content

Commit 31174e4

Browse files
committed
Avoid LocalCopy instantiation for #[inline] on -Copt-level=0
Because it is not really helpful to have downstream instantiations that we won't inline anyways (`*`) `*` This is not quite true when `#[inline]` is being used as effectively `#[likely_unused]`
1 parent 99ca0ae commit 31174e4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

compiler/rustc_mir_transform/src/cross_crate_inline.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
4646
// #[inline(never)] to force code generation.
4747
match codegen_fn_attrs.inline {
4848
InlineAttr::Never => return false,
49-
InlineAttr::Hint | InlineAttr::Always | InlineAttr::Force { .. } => return true,
49+
// For -Copt-level=0, we won't inline functions anyways, so there's no reason to codegen them as LocalCopy.
50+
InlineAttr::Hint if tcx.sess.opts.optimize != OptLevel::No => return true,
51+
InlineAttr::Always | InlineAttr::Force { .. } => return true,
5052
_ => {}
5153
}
5254

0 commit comments

Comments
 (0)