@@ -11,7 +11,7 @@ use object::{Object, ObjectSection};
1111use  rustc_codegen_ssa:: back:: lto:: { SerializedModule ,  ThinModule ,  ThinShared } ; 
1212use  rustc_codegen_ssa:: back:: write:: { CodegenContext ,  FatLtoInput } ; 
1313use  rustc_codegen_ssa:: traits:: * ; 
14- use  rustc_codegen_ssa:: { ModuleCodegen ,  ModuleKind ,   looks_like_rust_object_file} ; 
14+ use  rustc_codegen_ssa:: { ModuleCodegen ,  looks_like_rust_object_file} ; 
1515use  rustc_data_structures:: fx:: FxHashMap ; 
1616use  rustc_data_structures:: memmap:: Mmap ; 
1717use  rustc_errors:: DiagCtxtHandle ; 
@@ -43,9 +43,7 @@ fn prepare_lto(
4343        . map ( |symbol| CString :: new ( symbol. to_owned ( ) ) . unwrap ( ) ) 
4444        . collect :: < Vec < CString > > ( ) ; 
4545
46-     if  cgcx. regular_module_config . instrument_coverage 
47-         || cgcx. regular_module_config . pgo_gen . enabled ( ) 
48-     { 
46+     if  cgcx. module_config . instrument_coverage  || cgcx. module_config . pgo_gen . enabled ( )  { 
4947        // These are weak symbols that point to the profile version and the 
5048        // profile name, which need to be treated as exported so LTO doesn't nix 
5149        // them. 
@@ -55,15 +53,15 @@ fn prepare_lto(
5553        symbols_below_threshold. extend ( PROFILER_WEAK_SYMBOLS . iter ( ) . map ( |& sym| sym. to_owned ( ) ) ) ; 
5654    } 
5755
58-     if  cgcx. regular_module_config . sanitizer . contains ( SanitizerSet :: MEMORY )  { 
56+     if  cgcx. module_config . sanitizer . contains ( SanitizerSet :: MEMORY )  { 
5957        let  mut  msan_weak_symbols = Vec :: new ( ) ; 
6058
6159        // Similar to profiling, preserve weak msan symbol during LTO. 
62-         if  cgcx. regular_module_config . sanitizer_recover . contains ( SanitizerSet :: MEMORY )  { 
60+         if  cgcx. module_config . sanitizer_recover . contains ( SanitizerSet :: MEMORY )  { 
6361            msan_weak_symbols. push ( c"__msan_keep_going" ) ; 
6462        } 
6563
66-         if  cgcx. regular_module_config . sanitizer_memory_track_origins  != 0  { 
64+         if  cgcx. module_config . sanitizer_memory_track_origins  != 0  { 
6765            msan_weak_symbols. push ( c"__msan_track_origins" ) ; 
6866        } 
6967
@@ -227,15 +225,9 @@ fn fat_lto(
227225    // All the other modules will be serialized and reparsed into the new 
228226    // context, so this hopefully avoids serializing and parsing the largest 
229227    // codegen unit. 
230-     // 
231-     // Additionally use a regular module as the base here to ensure that various 
232-     // file copy operations in the backend work correctly. The only other kind 
233-     // of module here should be an allocator one, and if your crate is smaller 
234-     // than the allocator module then the size doesn't really matter anyway. 
235228    let  costliest_module = in_memory
236229        . iter ( ) 
237230        . enumerate ( ) 
238-         . filter ( |& ( _,  module) | module. kind  == ModuleKind :: Regular ) 
239231        . map ( |( i,  module) | { 
240232            let  cost = unsafe  {  llvm:: LLVMRustModuleCost ( module. module_llvm . llmod ( ) )  } ; 
241233            ( cost,  i) 
@@ -583,7 +575,7 @@ pub(crate) fn run_pass_manager(
583575    thin :  bool , 
584576)  { 
585577    let  _timer = cgcx. prof . generic_activity_with_arg ( "LLVM_lto_optimize" ,  & * module. name ) ; 
586-     let  config = cgcx. config ( module . kind ) ; 
578+     let  config = & cgcx. module_config ; 
587579
588580    // Now we have one massive module inside of llmod. Time to run the 
589581    // LTO-specific optimization passes that LLVM provides. 
@@ -745,7 +737,7 @@ pub(crate) fn optimize_thin_module(
745737    let  module_llvm = ModuleLlvm :: parse ( cgcx,  module_name,  thin_module. data ( ) ,  dcx) ; 
746738    let  mut  module = ModuleCodegen :: new_regular ( thin_module. name ( ) ,  module_llvm) ; 
747739    // Given that the newly created module lacks a thinlto buffer for embedding, we need to re-add it here. 
748-     if  cgcx. config ( ModuleKind :: Regular ) . embed_bitcode ( )  { 
740+     if  cgcx. module_config . embed_bitcode ( )  { 
749741        module. thin_lto_buffer  = Some ( thin_module. data ( ) . to_vec ( ) ) ; 
750742    } 
751743    { 
0 commit comments