about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorWesley Wiser <wwiser@gmail.com>2020-12-18 07:43:55 -0500
committerWesley Wiser <wwiser@gmail.com>2020-12-18 07:43:55 -0500
commit07a59822aacaf53ef2396b6e43fa3e8ad3a3e983 (patch)
tree78194cad51d449b207c046515bcba3d5aa933832 /compiler
parentaeb3061c40593e9cfbb52a1d5c8dafb1bd3e6a18 (diff)
downloadrust-07a59822aacaf53ef2396b6e43fa3e8ad3a3e983.tar.gz
rust-07a59822aacaf53ef2396b6e43fa3e8ad3a3e983.zip
Improve comment and move code up
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_middle/src/mir/mono.rs21
1 files changed, 11 insertions, 10 deletions
diff --git a/compiler/rustc_middle/src/mir/mono.rs b/compiler/rustc_middle/src/mir/mono.rs
index b79c1a19a90..18ef5d42084 100644
--- a/compiler/rustc_middle/src/mir/mono.rs
+++ b/compiler/rustc_middle/src/mir/mono.rs
@@ -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);
@@ -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 {