Skip to content

Commit ef685a5

Browse files
committed
Use more CGUs in incremental compilation
1 parent 2f348cb commit ef685a5

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

compiler/rustc_middle/src/mir/mono.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::fmt;
22
use std::hash::Hash;
33

4-
use rustc_attr_parsing::InlineAttr;
54
use rustc_data_structures::base_n::{BaseNString, CASE_INSENSITIVE, ToBaseN};
65
use rustc_data_structures::fingerprint::Fingerprint;
76
use rustc_data_structures::fx::FxIndexMap;
@@ -127,16 +126,7 @@ impl<'tcx> MonoItem<'tcx> {
127126
return InstantiationMode::LocalCopy;
128127
}
129128

130-
// Finally, if this is `#[inline(always)]` we're sure to respect
131-
// that with an inline copy per CGU, but otherwise we'll be
132-
// creating one copy of this `#[inline]` function which may
133-
// conflict with upstream crates as it could be an exported
134-
// symbol.
135-
if tcx.codegen_fn_attrs(instance.def_id()).inline.always() {
136-
InstantiationMode::LocalCopy
137-
} else {
138-
InstantiationMode::GloballyShared { may_conflict: true }
139-
}
129+
InstantiationMode::GloballyShared { may_conflict: true }
140130
}
141131
MonoItem::Static(..) | MonoItem::GlobalAsm(..) => {
142132
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
@@ -690,6 +690,14 @@ fn compute_codegen_unit_name(
690690
let mut cgu_def_id = None;
691691
// Walk backwards from the item we want to find the module for.
692692
loop {
693+
if tcx.sess.opts.incremental.is_some()
694+
&& tcx.sess.opts.optimize == rustc_session::config::OptLevel::No
695+
&& def_id.is_local()
696+
{
697+
cgu_def_id = Some(current_def_id);
698+
break;
699+
}
700+
693701
if current_def_id.is_crate_root() {
694702
if cgu_def_id.is_none() {
695703
// If we have not found a module yet, take the crate root.
@@ -716,8 +724,7 @@ fn compute_codegen_unit_name(
716724
let def_path = tcx.def_path(cgu_def_id);
717725

718726
let components = def_path.data.iter().map(|part| match part.data.name() {
719-
DefPathDataName::Named(name) => name,
720-
DefPathDataName::Anon { .. } => unreachable!(),
727+
DefPathDataName::Named(name) | DefPathDataName::Anon { namespace: name } => name,
721728
});
722729

723730
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
@@ -788,7 +788,7 @@ impl Session {
788788
// codegen units in order to reduce the "collateral damage" small
789789
// changes cause.
790790
if self.opts.incremental.is_some() {
791-
return CodegenUnits::Default(256);
791+
return CodegenUnits::Default(4096);
792792
}
793793

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

0 commit comments

Comments
 (0)