Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit fae4bb9

Browse files
committed
Auto merge of rust-lang#129222 - saethlin:more-incr-cgus, r=<try>
Use more CGUs in incremental compilation Just wondering how this looks in perf... r? `@ghost`
2 parents 826b673 + 1ce8857 commit fae4bb9

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

compiler/rustc_middle/src/mir/mono.rs

Lines changed: 1 addition & 10 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::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;
@@ -118,15 +117,7 @@ impl<'tcx> MonoItem<'tcx> {
118117
return InstantiationMode::LocalCopy;
119118
}
120119

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-
}
120+
InstantiationMode::GloballyShared { may_conflict: true }
130121
}
131122
MonoItem::Static(..) | MonoItem::GlobalAsm(..) => {
132123
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)