Skip to content

Commit 5c4c00a

Browse files
committed
Don't put related things together
1 parent 1ff5c5a commit 5c4c00a

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/librustc_middle/mir/mono.rs

+7
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ pub enum MonoItem<'tcx> {
4848
}
4949

5050
impl<'tcx> MonoItem<'tcx> {
51+
pub fn def_id(&self) -> Option<DefId> {
52+
match self {
53+
MonoItem::Fn(instance) => Some(instance.def_id()),
54+
MonoItem::Static(def_id) => Some(*def_id),
55+
MonoItem::GlobalAsm(..) => None,
56+
}
57+
}
5158
pub fn size_estimate(&self, tcx: TyCtxt<'tcx>) -> usize {
5259
match *self {
5360
MonoItem::Fn(instance) => {

src/librustc_mir/monomorphize/partitioning.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ where
210210
let mut roots = FxHashSet::default();
211211
let mut codegen_units = FxHashMap::default();
212212
let is_incremental_build = tcx.sess.opts.incremental.is_some();
213+
let is_debug_incremental = is_incremental_build && tcx.sess.opts.optimize == OptLevel::No;
213214
let mut internalization_candidates = FxHashSet::default();
214215

215216
// Determine if monomorphizations instantiated in this crate will be made
@@ -227,11 +228,11 @@ where
227228
InstantiationMode::LocalCopy => continue,
228229
}
229230

230-
let characteristic_def_id = characteristic_def_id_of_mono_item(tcx, mono_item);
231+
let characteristic_def_id = characteristic_def_id_of_mono_item(tcx, mono_item, is_debug_incremental);
231232
let is_volatile = is_incremental_build && mono_item.is_generic_fn();
232233

233234
let codegen_unit_name = match (characteristic_def_id, mono_item.is_local()) {
234-
(Some(def_id), false) if is_incremental_build && tcx.sess.opts.optimize == OptLevel::No => {
235+
(Some(def_id), false) if is_debug_incremental => {
235236
let crate_name = tcx.crate_name(def_id.krate);
236237
cgu_name_builder.build_cgu_name(LOCAL_CRATE, &[&*crate_name.as_str(), if mono_item.has_closure_generic_argument() { "has_closure" } else { "" }], Some("cgu"))
237238
},
@@ -720,7 +721,12 @@ fn internalize_symbols<'tcx>(
720721
fn characteristic_def_id_of_mono_item<'tcx>(
721722
tcx: TyCtxt<'tcx>,
722723
mono_item: MonoItem<'tcx>,
724+
is_debug_incremental: bool,
723725
) -> Option<DefId> {
726+
if is_debug_incremental {
727+
return mono_item.def_id();
728+
}
729+
724730
match mono_item {
725731
MonoItem::Fn(instance) => {
726732
let def_id = match instance.def {

0 commit comments

Comments
 (0)