1
Fork 0

Don't attempt to do incr comp for the allocator shim

The allocator shim doesn't get reused and the allocator shim is just
under 2kb, so reusing it is likely more expensive than regenerating it.
This commit is contained in:
bjorn3 2022-08-12 13:15:51 +00:00
parent db7d8a811d
commit d3512b1d8e

View file

@ -38,12 +38,11 @@ pub(crate) struct OngoingCodegen {
metadata_module: Option<CompiledModule>, metadata_module: Option<CompiledModule>,
metadata: EncodedMetadata, metadata: EncodedMetadata,
crate_info: CrateInfo, crate_info: CrateInfo,
work_products: FxHashMap<WorkProductId, WorkProduct>,
} }
impl OngoingCodegen { impl OngoingCodegen {
pub(crate) fn join(self) -> (CodegenResults, FxHashMap<WorkProductId, WorkProduct>) { pub(crate) fn join(self) -> (CodegenResults, FxHashMap<WorkProductId, WorkProduct>) {
let mut work_products = self.work_products; let mut work_products = FxHashMap::default();
let mut modules = vec![]; let mut modules = vec![];
for module_codegen_result in self.modules { for module_codegen_result in self.modules {
@ -331,8 +330,6 @@ pub(crate) fn run_aot(
tcx.sess.abort_if_errors(); tcx.sess.abort_if_errors();
let mut work_products = FxHashMap::default();
let isa = crate::build_isa(tcx.sess, &backend_config); let isa = crate::build_isa(tcx.sess, &backend_config);
let mut allocator_module = make_module(tcx.sess, isa, "allocator_shim".to_string()); let mut allocator_module = make_module(tcx.sess, isa, "allocator_shim".to_string());
assert_eq!(pointer_ty(tcx), allocator_module.target_config().pointer_type()); assert_eq!(pointer_ty(tcx), allocator_module.target_config().pointer_type());
@ -341,21 +338,27 @@ pub(crate) fn run_aot(
crate::allocator::codegen(tcx, &mut allocator_module, &mut allocator_unwind_context); crate::allocator::codegen(tcx, &mut allocator_module, &mut allocator_unwind_context);
let allocator_module = if created_alloc_shim { let allocator_module = if created_alloc_shim {
let ModuleCodegenResult { module_regular, module_global_asm, work_product } = emit_module( let name = "allocator_shim".to_owned();
tcx,
&backend_config, let mut product = allocator_module.finish();
"allocator_shim".to_string(), allocator_unwind_context.emit(&mut product);
ModuleKind::Allocator,
allocator_module, let tmp_file = tcx.output_filenames(()).temp_path(OutputType::Object, Some(&name));
None, let obj = product.object.write().unwrap();
allocator_unwind_context,
None, tcx.sess.prof.artifact_size("object_file", &*name, obj.len().try_into().unwrap());
);
assert!(module_global_asm.is_none()); if let Err(err) = std::fs::write(&tmp_file, obj) {
if let Some((id, product)) = work_product { tcx.sess.fatal(&format!("error writing object file: {}", err));
work_products.insert(id, product);
} }
Some(module_regular)
Some(CompiledModule {
name,
kind: ModuleKind::Allocator,
object: Some(tmp_file),
dwarf_object: None,
bytecode: None,
})
} else { } else {
None None
}; };
@ -408,7 +411,6 @@ pub(crate) fn run_aot(
metadata_module, metadata_module,
metadata, metadata,
crate_info: CrateInfo::new(tcx, target_cpu), crate_info: CrateInfo::new(tcx, target_cpu),
work_products,
}) })
} }