Give fields of ModuleCodegenResult names

This commit is contained in:
bjorn3 2022-08-12 13:03:18 +00:00
parent f76ca22479
commit db7d8a811d

View File

@ -20,11 +20,11 @@
use crate::global_asm::GlobalAsmConfig; use crate::global_asm::GlobalAsmConfig;
use crate::{prelude::*, BackendConfig}; use crate::{prelude::*, BackendConfig};
struct ModuleCodegenResult( struct ModuleCodegenResult {
CompiledModule, module_regular: CompiledModule,
Option<CompiledModule>, module_global_asm: Option<CompiledModule>,
Option<(WorkProductId, WorkProduct)>, work_product: Option<(WorkProductId, WorkProduct)>,
); }
impl<HCX> HashStable<HCX> for ModuleCodegenResult { impl<HCX> HashStable<HCX> for ModuleCodegenResult {
fn hash_stable(&self, _: &mut HCX, _: &mut StableHasher) { fn hash_stable(&self, _: &mut HCX, _: &mut StableHasher) {
@ -47,7 +47,7 @@ pub(crate) fn join(self) -> (CodegenResults, FxHashMap<WorkProductId, WorkProduc
let mut modules = vec![]; let mut modules = vec![];
for module_codegen_result in self.modules { for module_codegen_result in self.modules {
let ModuleCodegenResult(module_regular, module_global_asm, work_product) = let ModuleCodegenResult { module_regular, module_global_asm, work_product } =
module_codegen_result; module_codegen_result;
if let Some((work_product_id, work_product)) = work_product { if let Some((work_product_id, work_product)) = work_product {
work_products.insert(work_product_id, work_product); work_products.insert(work_product_id, work_product);
@ -124,15 +124,15 @@ fn emit_module(
) )
}; };
ModuleCodegenResult( ModuleCodegenResult {
CompiledModule { module_regular: CompiledModule {
name: name.clone(), name: name.clone(),
kind, kind,
object: Some(tmp_file), object: Some(tmp_file),
dwarf_object: None, dwarf_object: None,
bytecode: None, bytecode: None,
}, },
global_asm_object_file.map(|global_asm_object_file| CompiledModule { module_global_asm: global_asm_object_file.map(|global_asm_object_file| CompiledModule {
name: format!("{name}.asm"), name: format!("{name}.asm"),
kind, kind,
object: Some(global_asm_object_file), object: Some(global_asm_object_file),
@ -140,7 +140,7 @@ fn emit_module(
bytecode: None, bytecode: None,
}), }),
work_product, work_product,
) }
} }
fn reuse_workproduct_for_cgu(tcx: TyCtxt<'_>, cgu: &CodegenUnit<'_>) -> ModuleCodegenResult { fn reuse_workproduct_for_cgu(tcx: TyCtxt<'_>, cgu: &CodegenUnit<'_>) -> ModuleCodegenResult {
@ -178,15 +178,15 @@ fn reuse_workproduct_for_cgu(tcx: TyCtxt<'_>, cgu: &CodegenUnit<'_>) -> ModuleCo
false false
}; };
ModuleCodegenResult( ModuleCodegenResult {
CompiledModule { module_regular: CompiledModule {
name: cgu.name().to_string(), name: cgu.name().to_string(),
kind: ModuleKind::Regular, kind: ModuleKind::Regular,
object: Some(obj_out_regular), object: Some(obj_out_regular),
dwarf_object: None, dwarf_object: None,
bytecode: None, bytecode: None,
}, },
if has_global_asm { module_global_asm: if has_global_asm {
Some(CompiledModule { Some(CompiledModule {
name: cgu.name().to_string(), name: cgu.name().to_string(),
kind: ModuleKind::Regular, kind: ModuleKind::Regular,
@ -197,8 +197,8 @@ fn reuse_workproduct_for_cgu(tcx: TyCtxt<'_>, cgu: &CodegenUnit<'_>) -> ModuleCo
} else { } else {
None None
}, },
Some((cgu.work_product_id(), work_product)), work_product: Some((cgu.work_product_id(), work_product)),
) }
} }
fn module_codegen( fn module_codegen(
@ -341,7 +341,7 @@ 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, module_global_asm, work_product) = emit_module( let ModuleCodegenResult { module_regular, module_global_asm, work_product } = emit_module(
tcx, tcx,
&backend_config, &backend_config,
"allocator_shim".to_string(), "allocator_shim".to_string(),
@ -355,7 +355,7 @@ pub(crate) fn run_aot(
if let Some((id, product)) = work_product { if let Some((id, product)) = work_product {
work_products.insert(id, product); work_products.insert(id, product);
} }
Some(module) Some(module_regular)
} else { } else {
None None
}; };