Clean up generate_lto_work.

This function has some shared code for the thin LTO and fat LTO cases,
but those cases have so little in common that it's actually clearer to
treat them fully separately.
This commit is contained in:
Nicholas Nethercote 2023-07-24 17:43:53 +10:00
parent d404699fb1
commit 5673f47042

View File

@ -380,16 +380,16 @@ fn generate_lto_work<B: ExtraBackendMethods>(
) -> Vec<(WorkItem<B>, u64)> {
let _prof_timer = cgcx.prof.generic_activity("codegen_generate_lto_work");
let (lto_modules, copy_jobs) = if !needs_fat_lto.is_empty() {
if !needs_fat_lto.is_empty() {
assert!(needs_thin_lto.is_empty());
let lto_module =
let module =
B::run_fat_lto(cgcx, needs_fat_lto, import_only_modules).unwrap_or_else(|e| e.raise());
(vec![lto_module], vec![])
// We are adding a single work item, so the cost doesn't matter.
vec![(WorkItem::LTO(module), 0)]
} else {
assert!(needs_fat_lto.is_empty());
B::run_thin_lto(cgcx, needs_thin_lto, import_only_modules).unwrap_or_else(|e| e.raise())
};
let (lto_modules, copy_jobs) = B::run_thin_lto(cgcx, needs_thin_lto, import_only_modules)
.unwrap_or_else(|e| e.raise());
lto_modules
.into_iter()
.map(|module| {
@ -402,11 +402,12 @@ fn generate_lto_work<B: ExtraBackendMethods>(
name: wp.cgu_name.clone(),
source: wp,
}),
0,
0, // copying is very cheap
)
}))
.collect()
}
}
pub struct CompiledModules {
pub modules: Vec<CompiledModule>,