Skip to content

Commit c5e38b7

Browse files
committed
Pass Session to optimize_and_codegen_fat_lto
This is necessary to fix incremental LTO in cg_gcc as well as to do some LTO refactorings I want to do. The actual fix for cg_gcc will be done on the cg_gcc repo to test it in CI.
1 parent f53b654 commit c5e38b7

4 files changed

Lines changed: 11 additions & 11 deletions

File tree

compiler/rustc_codegen_gcc/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,16 +430,16 @@ impl WriteBackendMethods for GccCodegenBackend {
430430
}
431431

432432
fn optimize_and_codegen_fat_lto(
433+
sess: &Session,
433434
cgcx: &CodegenContext,
434-
prof: &SelfProfilerRef,
435435
shared_emitter: &SharedEmitter,
436436
_tm_factory: TargetMachineFactoryFn<Self>,
437437
// FIXME(bjorn3): Limit LTO exports to these symbols
438438
_exported_symbols_for_lto: &[String],
439439
each_linked_rlib_for_lto: &[PathBuf],
440440
modules: Vec<FatLtoInput<Self>>,
441441
) -> CompiledModule {
442-
back::lto::run_fat(cgcx, prof, shared_emitter, each_linked_rlib_for_lto, modules)
442+
back::lto::run_fat(cgcx, &sess.prof, shared_emitter, each_linked_rlib_for_lto, modules)
443443
}
444444

445445
fn run_thin_lto(

compiler/rustc_codegen_llvm/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ impl WriteBackendMethods for LlvmCodegenBackend {
133133
back::write::target_machine_factory(sess, optlvl, target_features)
134134
}
135135
fn optimize_and_codegen_fat_lto(
136+
sess: &Session,
136137
cgcx: &CodegenContext,
137-
prof: &SelfProfilerRef,
138138
shared_emitter: &SharedEmitter,
139139
tm_factory: TargetMachineFactoryFn<LlvmCodegenBackend>,
140140
exported_symbols_for_lto: &[String],
@@ -143,7 +143,7 @@ impl WriteBackendMethods for LlvmCodegenBackend {
143143
) -> CompiledModule {
144144
let mut module = back::lto::run_fat(
145145
cgcx,
146-
prof,
146+
&sess.prof,
147147
shared_emitter,
148148
tm_factory,
149149
exported_symbols_for_lto,
@@ -153,9 +153,9 @@ impl WriteBackendMethods for LlvmCodegenBackend {
153153

154154
let dcx = DiagCtxt::new(Box::new(shared_emitter.clone()));
155155
let dcx = dcx.handle();
156-
back::lto::run_pass_manager(cgcx, prof, dcx, &mut module, false);
156+
back::lto::run_pass_manager(cgcx, &sess.prof, dcx, &mut module, false);
157157

158-
back::write::codegen(cgcx, prof, shared_emitter, module, &cgcx.module_config)
158+
back::write::codegen(cgcx, &sess.prof, shared_emitter, module, &cgcx.module_config)
159159
}
160160
fn run_thin_lto(
161161
cgcx: &CodegenContext,

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -961,24 +961,24 @@ fn execute_copy_from_cache_work_item(
961961
}
962962

963963
fn do_fat_lto<B: WriteBackendMethods>(
964+
sess: &Session,
964965
cgcx: &CodegenContext,
965-
prof: &SelfProfilerRef,
966966
shared_emitter: SharedEmitter,
967967
tm_factory: TargetMachineFactoryFn<B>,
968968
exported_symbols_for_lto: &[String],
969969
each_linked_rlib_for_lto: &[PathBuf],
970970
needs_fat_lto: Vec<FatLtoInput<B>>,
971971
) -> CompiledModule {
972-
let _timer = prof.verbose_generic_activity("LLVM_fatlto");
972+
let _timer = sess.prof.verbose_generic_activity("LLVM_fatlto");
973973

974974
let dcx = DiagCtxt::new(Box::new(shared_emitter.clone()));
975975
let dcx = dcx.handle();
976976

977977
check_lto_allowed(&cgcx, dcx);
978978

979979
B::optimize_and_codegen_fat_lto(
980+
sess,
980981
cgcx,
981-
prof,
982982
&shared_emitter,
983983
tm_factory,
984984
exported_symbols_for_lto,
@@ -2177,8 +2177,8 @@ impl<B: WriteBackendMethods> OngoingCodegen<B> {
21772177

21782178
CompiledModules {
21792179
modules: vec![do_fat_lto(
2180+
sess,
21802181
&cgcx,
2181-
&sess.prof,
21822182
shared_emitter,
21832183
tm_factory,
21842184
&exported_symbols_for_lto,

compiler/rustc_codegen_ssa/src/traits/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ pub trait WriteBackendMethods: Clone + 'static {
3030
/// Performs fat LTO by merging all modules into a single one, running autodiff
3131
/// if necessary and running any further optimizations
3232
fn optimize_and_codegen_fat_lto(
33+
sess: &Session,
3334
cgcx: &CodegenContext,
34-
prof: &SelfProfilerRef,
3535
shared_emitter: &SharedEmitter,
3636
tm_factory: TargetMachineFactoryFn<Self>,
3737
exported_symbols_for_lto: &[String],

0 commit comments

Comments
 (0)