diff options
| author | Michael Woerister <michaelwoerister@posteo.net> | 2016-05-06 17:00:59 -0400 |
|---|---|---|
| committer | Michael Woerister <michaelwoerister@posteo.net> | 2016-05-09 16:17:00 -0400 |
| commit | b89a5d1f7c8fb7fcfbbbf06544be9bfaf2c25bf8 (patch) | |
| tree | c14d97a4cf7bffce141567adcf53bff58d63a225 /src | |
| parent | 0142336a2a447e9883ae4dd6db98354154ba08e3 (diff) | |
| download | rust-b89a5d1f7c8fb7fcfbbbf06544be9bfaf2c25bf8.tar.gz rust-b89a5d1f7c8fb7fcfbbbf06544be9bfaf2c25bf8.zip | |
Make FixedCount partitioning handle case where codegen units have to be added.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_trans/partitioning.rs | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/src/librustc_trans/partitioning.rs b/src/librustc_trans/partitioning.rs index 6e50292a91a..7b21b612097 100644 --- a/src/librustc_trans/partitioning.rs +++ b/src/librustc_trans/partitioning.rs @@ -182,19 +182,7 @@ pub fn partition<'tcx, I>(tcx: &TyCtxt<'tcx>, // easily determine which declarations need to be placed within each one. let post_declarations = place_declarations(post_inlining, reference_map); - let mut final_partitioning = post_declarations.0; - - if final_partitioning.len() == 0 { - // Some crates don't contain anything that will result in a translation - // item. We still want to have at least one (empty) codegen unit in that - // case. - final_partitioning.push(CodegenUnit { - name: token::intern_and_get_ident(&format!("{}.0", tcx.crate_name)[..]), - items: FnvHashMap() - }); - } - - final_partitioning + post_declarations.0 } struct PreInliningPartitioning<'tcx> { @@ -268,10 +256,6 @@ fn place_root_translation_items<'tcx, I>(tcx: &TyCtxt<'tcx>, fn merge_codegen_units<'tcx>(initial_partitioning: &mut PreInliningPartitioning<'tcx>, target_cgu_count: usize, crate_name: &str) { - if target_cgu_count >= initial_partitioning.codegen_units.len() { - return; - } - assert!(target_cgu_count >= 1); let codegen_units = &mut initial_partitioning.codegen_units; @@ -290,7 +274,22 @@ fn merge_codegen_units<'tcx>(initial_partitioning: &mut PreInliningPartitioning< } for (index, cgu) in codegen_units.iter_mut().enumerate() { - cgu.name = token::intern_and_get_ident(&format!("{}.{}", crate_name, index)[..]); + cgu.name = numbered_codegen_unit_name(crate_name, index); + } + + // If the initial partitioning contained less than target_cgu_count to begin + // with, we won't have enough codegen units here, so add a empty units until + // we reach the target count + while codegen_units.len() < target_cgu_count { + let index = codegen_units.len(); + codegen_units.push(CodegenUnit { + name: numbered_codegen_unit_name(crate_name, index), + items: FnvHashMap() + }); + } + + fn numbered_codegen_unit_name(crate_name: &str, index: usize) -> InternedString { + token::intern_and_get_ident(&format!("{}.{}", crate_name, index)[..]) } } |
