Skip to content

Commit 07a5982

Browse files
committed
Improve comment and move code up
1 parent aeb3061 commit 07a5982

File tree

1 file changed

+11
-10
lines changed
  • compiler/rustc_middle/src/mir

1 file changed

+11
-10
lines changed

compiler/rustc_middle/src/mir/mono.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,6 @@ impl<'tcx> MonoItem<'tcx> {
7878
}
7979

8080
pub fn instantiation_mode(&self, tcx: TyCtxt<'tcx>) -> InstantiationMode {
81-
let generate_cgu_internal_copies = tcx
82-
.sess
83-
.opts
84-
.debugging_opts
85-
.inline_in_all_cgus
86-
.unwrap_or_else(|| tcx.sess.opts.optimize != OptLevel::No)
87-
&& !tcx.sess.link_dead_code();
88-
8981
match *self {
9082
MonoItem::Fn(ref instance) => {
9183
let entry_def_id = tcx.entry_fn(LOCAL_CRATE).map(|(id, _)| id);
@@ -98,9 +90,18 @@ impl<'tcx> MonoItem<'tcx> {
9890
return InstantiationMode::GloballyShared { may_conflict: false };
9991
}
10092

93+
let generate_cgu_internal_copies = tcx
94+
.sess
95+
.opts
96+
.debugging_opts
97+
.inline_in_all_cgus
98+
.unwrap_or_else(|| tcx.sess.opts.optimize != OptLevel::No)
99+
&& !tcx.sess.link_dead_code();
100+
101101
// At this point we don't have explicit linkage and we're an
102-
// inlined function. If we're inlining into all CGUs then we'll
103-
// be creating a local copy per CGU.
102+
// inlined function. If we should generate local copies for each CGU,
103+
// then return `LocalCopy`, otherwise we'll just generate one copy
104+
// and share it with all CGUs in this crate.
104105
if generate_cgu_internal_copies {
105106
InstantiationMode::LocalCopy
106107
} else {

0 commit comments

Comments
 (0)