Skip to content

Commit

Permalink
Improve comment and move code up
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleywiser committed Dec 18, 2020
1 parent aeb3061 commit 07a5982
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions compiler/rustc_middle/src/mir/mono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,6 @@ impl<'tcx> MonoItem<'tcx> {
}

pub fn instantiation_mode(&self, tcx: TyCtxt<'tcx>) -> InstantiationMode {
let generate_cgu_internal_copies = tcx
.sess
.opts
.debugging_opts
.inline_in_all_cgus
.unwrap_or_else(|| tcx.sess.opts.optimize != OptLevel::No)
&& !tcx.sess.link_dead_code();

match *self {
MonoItem::Fn(ref instance) => {
let entry_def_id = tcx.entry_fn(LOCAL_CRATE).map(|(id, _)| id);
Expand All @@ -98,9 +90,18 @@ impl<'tcx> MonoItem<'tcx> {
return InstantiationMode::GloballyShared { may_conflict: false };
}

let generate_cgu_internal_copies = tcx
.sess
.opts
.debugging_opts
.inline_in_all_cgus
.unwrap_or_else(|| tcx.sess.opts.optimize != OptLevel::No)
&& !tcx.sess.link_dead_code();

// At this point we don't have explicit linkage and we're an
// inlined function. If we're inlining into all CGUs then we'll
// be creating a local copy per CGU.
// inlined function. If we should generate local copies for each CGU,
// then return `LocalCopy`, otherwise we'll just generate one copy
// and share it with all CGUs in this crate.
if generate_cgu_internal_copies {
InstantiationMode::LocalCopy
} else {
Expand Down

0 comments on commit 07a5982

Please sign in to comment.