Improve comment and move code up
This commit is contained in:
parent
aeb3061c40
commit
07a59822aa
1 changed files with 11 additions and 10 deletions
|
@ -78,14 +78,6 @@ impl<'tcx> MonoItem<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn instantiation_mode(&self, tcx: TyCtxt<'tcx>) -> InstantiationMode {
|
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 {
|
match *self {
|
||||||
MonoItem::Fn(ref instance) => {
|
MonoItem::Fn(ref instance) => {
|
||||||
let entry_def_id = tcx.entry_fn(LOCAL_CRATE).map(|(id, _)| id);
|
let entry_def_id = tcx.entry_fn(LOCAL_CRATE).map(|(id, _)| id);
|
||||||
|
@ -98,9 +90,18 @@ impl<'tcx> MonoItem<'tcx> {
|
||||||
return InstantiationMode::GloballyShared { may_conflict: false };
|
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
|
// 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
|
// inlined function. If we should generate local copies for each CGU,
|
||||||
// be creating a local copy per 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 {
|
if generate_cgu_internal_copies {
|
||||||
InstantiationMode::LocalCopy
|
InstantiationMode::LocalCopy
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue