Skip to content

Commit d490d39

Browse files
committed
Only put inline functions in one CGU
1 parent 7b73d14 commit d490d39

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

src/librustc/mir/mono.rs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ use crate::dep_graph::{DepConstructor, DepNode, WorkProduct, WorkProductId};
22
use crate::ich::{NodeIdHashingMode, StableHashingContext};
33
use crate::ty::print::obsolete::DefPathBasedNames;
44
use crate::ty::{subst::InternalSubsts, Instance, InstanceDef, SymbolName, TyCtxt};
5-
use rustc_attr::InlineAttr;
65
use rustc_data_structures::base_n;
76
use rustc_data_structures::fingerprint::Fingerprint;
87
use rustc_data_structures::fx::FxHashMap;
98
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
109
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
1110
use rustc_hir::HirId;
12-
use rustc_session::config::OptLevel;
1311
use rustc_span::source_map::Span;
1412
use rustc_span::symbol::Symbol;
1513
use std::fmt;
@@ -80,13 +78,9 @@ impl<'tcx> MonoItem<'tcx> {
8078
}
8179

8280
pub fn instantiation_mode(&self, tcx: TyCtxt<'tcx>) -> InstantiationMode {
83-
let generate_cgu_internal_copies = tcx
84-
.sess
85-
.opts
86-
.debugging_opts
87-
.inline_in_all_cgus
88-
.unwrap_or_else(|| tcx.sess.opts.optimize != OptLevel::No)
89-
&& !tcx.sess.opts.cg.link_dead_code;
81+
let generate_cgu_internal_copies =
82+
tcx.sess.opts.debugging_opts.inline_in_all_cgus.unwrap_or(false)
83+
&& !tcx.sess.opts.cg.link_dead_code;
9084

9185
match *self {
9286
MonoItem::Fn(ref instance) => {
@@ -107,15 +101,7 @@ impl<'tcx> MonoItem<'tcx> {
107101
return InstantiationMode::LocalCopy;
108102
}
109103

110-
// Finally, if this is `#[inline(always)]` we're sure to respect
111-
// that with an inline copy per CGU, but otherwise we'll be
112-
// creating one copy of this `#[inline]` function which may
113-
// conflict with upstream crates as it could be an exported
114-
// symbol.
115-
match tcx.codegen_fn_attrs(instance.def_id()).inline {
116-
InlineAttr::Always => InstantiationMode::LocalCopy,
117-
_ => InstantiationMode::GloballyShared { may_conflict: true },
118-
}
104+
return InstantiationMode::GloballyShared { may_conflict: true };
119105
}
120106
MonoItem::Static(..) | MonoItem::GlobalAsm(..) => {
121107
InstantiationMode::GloballyShared { may_conflict: false }

0 commit comments

Comments
 (0)