@@ -11,7 +11,7 @@ use object::{Object, ObjectSection};
11
11
use rustc_codegen_ssa:: back:: lto:: { SerializedModule , ThinModule , ThinShared } ;
12
12
use rustc_codegen_ssa:: back:: write:: { CodegenContext , FatLtoInput } ;
13
13
use 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} ;
15
15
use rustc_data_structures:: fx:: FxHashMap ;
16
16
use rustc_data_structures:: memmap:: Mmap ;
17
17
use rustc_errors:: DiagCtxtHandle ;
@@ -43,9 +43,7 @@ fn prepare_lto(
43
43
. map ( |symbol| CString :: new ( symbol. to_owned ( ) ) . unwrap ( ) )
44
44
. collect :: < Vec < CString > > ( ) ;
45
45
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 ( ) {
49
47
// These are weak symbols that point to the profile version and the
50
48
// profile name, which need to be treated as exported so LTO doesn't nix
51
49
// them.
@@ -55,15 +53,15 @@ fn prepare_lto(
55
53
symbols_below_threshold. extend ( PROFILER_WEAK_SYMBOLS . iter ( ) . map ( |& sym| sym. to_owned ( ) ) ) ;
56
54
}
57
55
58
- if cgcx. regular_module_config . sanitizer . contains ( SanitizerSet :: MEMORY ) {
56
+ if cgcx. module_config . sanitizer . contains ( SanitizerSet :: MEMORY ) {
59
57
let mut msan_weak_symbols = Vec :: new ( ) ;
60
58
61
59
// 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 ) {
63
61
msan_weak_symbols. push ( c"__msan_keep_going" ) ;
64
62
}
65
63
66
- if cgcx. regular_module_config . sanitizer_memory_track_origins != 0 {
64
+ if cgcx. module_config . sanitizer_memory_track_origins != 0 {
67
65
msan_weak_symbols. push ( c"__msan_track_origins" ) ;
68
66
}
69
67
@@ -227,15 +225,9 @@ fn fat_lto(
227
225
// All the other modules will be serialized and reparsed into the new
228
226
// context, so this hopefully avoids serializing and parsing the largest
229
227
// 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.
235
228
let costliest_module = in_memory
236
229
. iter ( )
237
230
. enumerate ( )
238
- . filter ( |& ( _, module) | module. kind == ModuleKind :: Regular )
239
231
. map ( |( i, module) | {
240
232
let cost = unsafe { llvm:: LLVMRustModuleCost ( module. module_llvm . llmod ( ) ) } ;
241
233
( cost, i)
@@ -583,7 +575,7 @@ pub(crate) fn run_pass_manager(
583
575
thin : bool ,
584
576
) {
585
577
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 ;
587
579
588
580
// Now we have one massive module inside of llmod. Time to run the
589
581
// LTO-specific optimization passes that LLVM provides.
@@ -745,7 +737,7 @@ pub(crate) fn optimize_thin_module(
745
737
let module_llvm = ModuleLlvm :: parse ( cgcx, module_name, thin_module. data ( ) , dcx) ;
746
738
let mut module = ModuleCodegen :: new_regular ( thin_module. name ( ) , module_llvm) ;
747
739
// 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 ( ) {
749
741
module. thin_lto_buffer = Some ( thin_module. data ( ) . to_vec ( ) ) ;
750
742
}
751
743
{
0 commit comments