Auto merge of #147351 - Noratrieb:avoid-localcopy-for-inline-on-o0, r… · rust-lang/rust@85bd5e8 (original) (raw)

File tree

1 file changed

lines changed

1 file changed

lines changed

Original file line number Diff line number Diff line change
@@ -46,7 +46,9 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
46 46 // #[inline(never)] to force code generation.
47 47 match codegen_fn_attrs.inline {
48 48 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,
50 52 _ => {}
51 53 }
52 54