Skip to content

Commit 85bd5e8

Browse files
Auto merge of #147351 - Noratrieb:avoid-localcopy-for-inline-on-o0, r=<try>
Avoid `LocalCopy` instantiation for `#[inline]` on `-Copt-level=0`
2 parents 99ca0ae + 31174e4 commit 85bd5e8

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)