Skip to content

Commit 4e75f25

Browse files
Don't partition generic and non-generic code into different CGUs during incr. comp.
1 parent 35a5541 commit 4e75f25

File tree

5 files changed

+16
-26
lines changed

5 files changed

+16
-26
lines changed

src/librustc_mir/monomorphize/partitioning.rs

+4-14
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ fn place_root_mono_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
303303
{
304304
let mut roots = FxHashSet();
305305
let mut codegen_units = FxHashMap();
306-
let is_incremental_build = tcx.sess.opts.incremental.is_some();
307306
let mut internalization_candidates = FxHashSet();
308307

309308
// Determine if monomorphizations instantiated in this crate will be made
@@ -323,14 +322,11 @@ fn place_root_mono_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
323322
}
324323

325324
let characteristic_def_id = characteristic_def_id_of_mono_item(tcx, mono_item);
326-
let is_volatile = is_incremental_build &&
327-
mono_item.is_generic_fn();
328325

329326
let codegen_unit_name = match characteristic_def_id {
330327
Some(def_id) => compute_codegen_unit_name(tcx,
331328
cgu_name_builder,
332329
def_id,
333-
is_volatile,
334330
cgu_name_cache),
335331
None => fallback_cgu_name(cgu_name_builder),
336332
};
@@ -794,12 +790,11 @@ fn characteristic_def_id_of_mono_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
794790
}
795791
}
796792

797-
type CguNameCache = FxHashMap<(DefId, bool), InternedString>;
793+
type CguNameCache = FxHashMap<DefId, InternedString>;
798794

799795
fn compute_codegen_unit_name(tcx: TyCtxt,
800796
name_builder: &mut CodegenUnitNameBuilder,
801797
def_id: DefId,
802-
volatile: bool,
803798
cache: &mut CguNameCache)
804799
-> InternedString {
805800
// Find the innermost module that is not nested within a function
@@ -838,21 +833,16 @@ fn compute_codegen_unit_name(tcx: TyCtxt,
838833

839834
let cgu_def_id = cgu_def_id.unwrap();
840835

841-
cache.entry((cgu_def_id, volatile)).or_insert_with(|| {
836+
cache.entry(cgu_def_id).or_insert_with(|| {
842837
let def_path = tcx.def_path(cgu_def_id);
843838

844839
let components = def_path
845840
.data
846841
.iter()
847842
.map(|part| part.data.as_interned_str());
848843

849-
let volatile_suffix = if volatile {
850-
Some("volatile")
851-
} else {
852-
None
853-
};
854-
855-
name_builder.build_cgu_name(def_path.krate, components, volatile_suffix)
844+
let suffix: Option<&str> = None;
845+
name_builder.build_cgu_name(def_path.krate, components, suffix)
856846
}).clone()
857847
}
858848

src/test/codegen-units/partitioning/extern-generic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@ mod mod3 {
5858

5959
// Make sure the two generic functions from the extern crate get instantiated
6060
// once for the current crate
61-
//~ MONO_ITEM fn cgu_generic_function::foo[0]<&str> @@ cgu_generic_function.volatile[External]
62-
//~ MONO_ITEM fn cgu_generic_function::bar[0]<&str> @@ cgu_generic_function.volatile[External]
61+
//~ MONO_ITEM fn cgu_generic_function::foo[0]<&str> @@ cgu_generic_function[External]
62+
//~ MONO_ITEM fn cgu_generic_function::bar[0]<&str> @@ cgu_generic_function[External]

src/test/codegen-units/partitioning/local-generic.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
#![allow(dead_code)]
1717
#![crate_type="lib"]
1818

19-
//~ MONO_ITEM fn local_generic::generic[0]<u32> @@ local_generic.volatile[External]
20-
//~ MONO_ITEM fn local_generic::generic[0]<u64> @@ local_generic.volatile[External]
21-
//~ MONO_ITEM fn local_generic::generic[0]<char> @@ local_generic.volatile[External]
22-
//~ MONO_ITEM fn local_generic::generic[0]<&str> @@ local_generic.volatile[External]
19+
//~ MONO_ITEM fn local_generic::generic[0]<u32> @@ local_generic[External]
20+
//~ MONO_ITEM fn local_generic::generic[0]<u64> @@ local_generic[External]
21+
//~ MONO_ITEM fn local_generic::generic[0]<char> @@ local_generic[External]
22+
//~ MONO_ITEM fn local_generic::generic[0]<&str> @@ local_generic[External]
2323
pub fn generic<T>(x: T) -> T { x }
2424

2525
//~ MONO_ITEM fn local_generic::user[0] @@ local_generic[Internal]

src/test/codegen-units/partitioning/shared-generics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ extern crate shared_generics_aux;
1919
//~ MONO_ITEM fn shared_generics::foo[0]
2020
pub fn foo() {
2121

22-
//~ MONO_ITEM fn shared_generics_aux::generic_fn[0]<u16> @@ shared_generics_aux.volatile[External]
22+
//~ MONO_ITEM fn shared_generics_aux::generic_fn[0]<u16> @@ shared_generics_aux[External]
2323
let _ = shared_generics_aux::generic_fn(0u16, 1u16);
2424

2525
// This should not generate a monomorphization because it's already

src/test/codegen-units/partitioning/vtable-through-const.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,20 @@ fn start(_: isize, _: *const *const u8) -> isize {
7878
// Since Trait1::do_something() is instantiated via its default implementation,
7979
// it is considered a generic and is instantiated here only because it is
8080
// referenced in this module.
81-
//~ MONO_ITEM fn vtable_through_const::mod1[0]::Trait1[0]::do_something_else[0]<u32> @@ vtable_through_const-mod1.volatile[External]
81+
//~ MONO_ITEM fn vtable_through_const::mod1[0]::Trait1[0]::do_something_else[0]<u32> @@ vtable_through_const-mod1[External]
8282

8383
// Although it is never used, Trait1::do_something_else() has to be
8484
// instantiated locally here too, otherwise the <&u32 as &Trait1> vtable
8585
// could not be fully constructed.
86-
//~ MONO_ITEM fn vtable_through_const::mod1[0]::Trait1[0]::do_something[0]<u32> @@ vtable_through_const-mod1.volatile[External]
86+
//~ MONO_ITEM fn vtable_through_const::mod1[0]::Trait1[0]::do_something[0]<u32> @@ vtable_through_const-mod1[External]
8787
mod1::TRAIT1_REF.do_something();
8888

8989
// Same as above
90-
//~ MONO_ITEM fn vtable_through_const::mod1[0]::{{impl}}[1]::do_something[0]<u8> @@ vtable_through_const-mod1.volatile[External]
91-
//~ MONO_ITEM fn vtable_through_const::mod1[0]::{{impl}}[1]::do_something_else[0]<u8> @@ vtable_through_const-mod1.volatile[External]
90+
//~ MONO_ITEM fn vtable_through_const::mod1[0]::{{impl}}[1]::do_something[0]<u8> @@ vtable_through_const-mod1[External]
91+
//~ MONO_ITEM fn vtable_through_const::mod1[0]::{{impl}}[1]::do_something_else[0]<u8> @@ vtable_through_const-mod1[External]
9292
mod1::TRAIT1_GEN_REF.do_something(0u8);
9393

94-
//~ MONO_ITEM fn vtable_through_const::mod1[0]::id[0]<char> @@ vtable_through_const-mod1.volatile[External]
94+
//~ MONO_ITEM fn vtable_through_const::mod1[0]::id[0]<char> @@ vtable_through_const-mod1[External]
9595
mod1::ID_CHAR('x');
9696

9797
0

0 commit comments

Comments
 (0)