Skip to content

Commit a329615

Browse files
committed
Use more CGUs in incremental compilation
1 parent a475551 commit a329615

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

compiler/rustc_middle/src/mir/mono.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,7 @@ impl<'tcx> MonoItem<'tcx> {
118118
return InstantiationMode::LocalCopy;
119119
}
120120

121-
// Finally, if this is `#[inline(always)]` we're sure to respect
122-
// that with an inline copy per CGU, but otherwise we'll be
123-
// creating one copy of this `#[inline]` function which may
124-
// conflict with upstream crates as it could be an exported
125-
// symbol.
126-
match tcx.codegen_fn_attrs(instance.def_id()).inline {
127-
InlineAttr::Always => InstantiationMode::LocalCopy,
128-
_ => InstantiationMode::GloballyShared { may_conflict: true },
129-
}
121+
InstantiationMode::GloballyShared { may_conflict: true }
130122
}
131123
MonoItem::Static(..) | MonoItem::GlobalAsm(..) => {
132124
InstantiationMode::GloballyShared { may_conflict: false }

compiler/rustc_monomorphize/src/partitioning.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,14 @@ fn compute_codegen_unit_name(
694694
let mut cgu_def_id = None;
695695
// Walk backwards from the item we want to find the module for.
696696
loop {
697+
if tcx.sess.opts.incremental.is_some()
698+
&& tcx.sess.opts.optimize == rustc_session::config::OptLevel::No
699+
&& def_id.is_local()
700+
{
701+
cgu_def_id = Some(current_def_id);
702+
break;
703+
}
704+
697705
if current_def_id.is_crate_root() {
698706
if cgu_def_id.is_none() {
699707
// If we have not found a module yet, take the crate root.
@@ -720,8 +728,7 @@ fn compute_codegen_unit_name(
720728
let def_path = tcx.def_path(cgu_def_id);
721729

722730
let components = def_path.data.iter().map(|part| match part.data.name() {
723-
DefPathDataName::Named(name) => name,
724-
DefPathDataName::Anon { .. } => unreachable!(),
731+
DefPathDataName::Named(name) | DefPathDataName::Anon { namespace: name } => name,
725732
});
726733

727734
let volatile_suffix = volatile.then_some("volatile");

compiler/rustc_session/src/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ impl Session {
841841
// codegen units in order to reduce the "collateral damage" small
842842
// changes cause.
843843
if self.opts.incremental.is_some() {
844-
return CodegenUnits::Default(256);
844+
return CodegenUnits::Default(4096);
845845
}
846846

847847
// Why is 16 codegen units the default all the time?

0 commit comments

Comments
 (0)