File tree 2 files changed +53
-1
lines changed
test/codegen-units/partitioning
2 files changed +53
-1
lines changed Original file line number Diff line number Diff line change
1
+ // ignore-tidy-linelength
2
+ // We specify -C incremental here because we want to test the partitioning for
3
+ // incremental compilation
4
+ // compile-flags:-Zprint-mono-items=lazy -Cincremental=tmp/partitioning-tests/incremental-merging
5
+ // compile-flags:-Ccodegen-units=3
6
+
7
+ #![ crate_type = "rlib" ]
8
+
9
+ // This test makes sure that merging of CGUs works together with incremental
10
+ // compilation but at the same time does not modify names of CGUs that were not
11
+ // affected by merging.
12
+ //
13
+ // We expect CGUs `aaa` and `bbb` to be merged (because they are the smallest),
14
+ // while `ccc` and `ddd` are supposed to stay untouched.
15
+
16
+ pub mod aaa {
17
+ //~ MONO_ITEM fn incremental_merging::aaa[0]::foo[0] @@ incremental_merging-aaa--incremental_merging-bbb[External]
18
+ pub fn foo ( a : u64 ) -> u64 {
19
+ a + 1
20
+ }
21
+ }
22
+
23
+ pub mod bbb {
24
+ //~ MONO_ITEM fn incremental_merging::bbb[0]::foo[0] @@ incremental_merging-aaa--incremental_merging-bbb[External]
25
+ pub fn foo ( a : u64 , b : u64 ) -> u64 {
26
+ a + b + 1
27
+ }
28
+ }
29
+
30
+ pub mod ccc {
31
+ //~ MONO_ITEM fn incremental_merging::ccc[0]::foo[0] @@ incremental_merging-ccc[External]
32
+ pub fn foo ( a : u64 , b : u64 , c : u64 ) -> u64 {
33
+ a + b + c + 1
34
+ }
35
+ }
36
+
37
+ pub mod ddd {
38
+ //~ MONO_ITEM fn incremental_merging::ddd[0]::foo[0] @@ incremental_merging-ddd[External]
39
+ pub fn foo ( a : u64 , b : u64 , c : u64 , d : u64 ) -> u64 {
40
+ a + b + c + d + 1
41
+ }
42
+ }
Original file line number Diff line number Diff line change @@ -2517,7 +2517,7 @@ impl<'test> TestCx<'test> {
2517
2517
. filter ( |s| !s. is_empty ( ) )
2518
2518
. map ( |s| {
2519
2519
if cgu_has_crate_disambiguator {
2520
- remove_crate_disambiguator_from_cgu ( s)
2520
+ remove_crate_disambiguators_from_set_of_cgu_names ( s)
2521
2521
} else {
2522
2522
s. to_string ( )
2523
2523
}
@@ -2567,6 +2567,16 @@ impl<'test> TestCx<'test> {
2567
2567
2568
2568
new_name
2569
2569
}
2570
+
2571
+ // The name of merged CGUs is constructed as the names of the original
2572
+ // CGUs joined with "--". This function splits such composite CGU names
2573
+ // and handles each component individually.
2574
+ fn remove_crate_disambiguators_from_set_of_cgu_names ( cgus : & str ) -> String {
2575
+ cgus. split ( "--" )
2576
+ . map ( |cgu| remove_crate_disambiguator_from_cgu ( cgu) )
2577
+ . collect :: < Vec < _ > > ( )
2578
+ . join ( "--" )
2579
+ }
2570
2580
}
2571
2581
2572
2582
fn init_incremental_test ( & self ) {
You can’t perform that action at this time.
0 commit comments