Remove unnecessary parts of run_fat_lto signature

Fat LTO merges into one module, so only return one module.
This commit is contained in:
Nikita Popov 2018-12-03 20:50:39 +01:00
parent bdbee6311b
commit bc2db43b9e
4 changed files with 12 additions and 19 deletions

View File

@ -144,22 +144,15 @@ fn prepare_lto(cgcx: &CodegenContext<LlvmCodegenBackend>,
/// for further optimization.
pub(crate) fn run_fat(cgcx: &CodegenContext<LlvmCodegenBackend>,
modules: Vec<ModuleCodegen<ModuleLlvm>>,
_cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
timeline: &mut Timeline)
-> Result<(Vec<LtoModuleCodegen<LlvmCodegenBackend>>, Vec<WorkProduct>), FatalError>
-> Result<LtoModuleCodegen<LlvmCodegenBackend>, FatalError>
{
let diag_handler = cgcx.create_diag_handler();
let (symbol_white_list, upstream_modules) = prepare_lto(cgcx, timeline, &diag_handler)?;
let symbol_white_list = symbol_white_list.iter()
.map(|c| c.as_ptr())
.collect::<Vec<_>>();
let opt_jobs = fat_lto(cgcx,
&diag_handler,
modules,
upstream_modules,
&symbol_white_list,
timeline);
opt_jobs.map(|opt_jobs| (opt_jobs, vec![]))
fat_lto(cgcx, &diag_handler, modules, upstream_modules, &symbol_white_list, timeline)
}
/// Performs thin LTO by performing necessary global analysis and returning two
@ -195,7 +188,7 @@ fn fat_lto(cgcx: &CodegenContext<LlvmCodegenBackend>,
mut serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>,
symbol_white_list: &[*const libc::c_char],
timeline: &mut Timeline)
-> Result<Vec<LtoModuleCodegen<LlvmCodegenBackend>>, FatalError>
-> Result<LtoModuleCodegen<LlvmCodegenBackend>, FatalError>
{
info!("going for a fat lto");
@ -284,10 +277,10 @@ fn fat_lto(cgcx: &CodegenContext<LlvmCodegenBackend>,
timeline.record("passes");
}
Ok(vec![LtoModuleCodegen::Fat {
Ok(LtoModuleCodegen::Fat {
module: Some(module),
_serialized_bitcode: serialized_bitcode,
}])
})
}
struct Linker<'a>(&'a mut llvm::Linker<'a>);

View File

@ -179,10 +179,9 @@ impl WriteBackendMethods for LlvmCodegenBackend {
fn run_fat_lto(
cgcx: &CodegenContext<Self>,
modules: Vec<ModuleCodegen<Self::Module>>,
cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>,
timeline: &mut Timeline
) -> Result<(Vec<LtoModuleCodegen<Self>>, Vec<WorkProduct>), FatalError> {
back::lto::run_fat(cgcx, modules, cached_modules, timeline)
) -> Result<LtoModuleCodegen<Self>, FatalError> {
back::lto::run_fat(cgcx, modules, timeline)
}
fn run_thin_lto(
cgcx: &CodegenContext<Self>,

View File

@ -264,8 +264,10 @@ fn generate_lto_work<B: ExtraBackendMethods>(
let (lto_modules, copy_jobs) = if !needs_fat_lto.is_empty() {
assert!(needs_thin_lto.is_empty());
B::run_fat_lto(cgcx, needs_fat_lto, import_only_modules, &mut timeline)
.unwrap_or_else(|e| e.raise())
assert!(import_only_modules.is_empty());
let lto_module = B::run_fat_lto(cgcx, needs_fat_lto, &mut timeline)
.unwrap_or_else(|e| e.raise());
(vec![lto_module], vec![])
} else {
assert!(needs_fat_lto.is_empty());
B::run_thin_lto(cgcx, needs_thin_lto, import_only_modules, &mut timeline)

View File

@ -29,9 +29,8 @@ pub trait WriteBackendMethods: 'static + Sized + Clone {
fn run_fat_lto(
cgcx: &CodegenContext<Self>,
modules: Vec<ModuleCodegen<Self::Module>>,
cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>,
timeline: &mut Timeline,
) -> Result<(Vec<LtoModuleCodegen<Self>>, Vec<WorkProduct>), FatalError>;
) -> Result<LtoModuleCodegen<Self>, FatalError>;
/// Performs thin LTO by performing necessary global analysis and returning two
/// lists, one of the modules that need optimization and another for modules that
/// can simply be copied over from the incr. comp. cache.