Skip to content

Commit a75ff82

Browse files
committed
Remove tm_factory field from CodegenContext
This is necessary to support serializing the CodegenContext to a .rlink file in the future for moving LTO to the -Zlink-only step.
1 parent 14527b2 commit a75ff82

3 files changed

Lines changed: 16 additions & 16 deletions

File tree

src/back/lto.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct LtoData {
5050
}
5151

5252
fn prepare_lto(
53-
cgcx: &CodegenContext<GccCodegenBackend>,
53+
cgcx: &CodegenContext,
5454
each_linked_rlib_for_lto: &[PathBuf],
5555
dcx: DiagCtxtHandle<'_>,
5656
) -> LtoData {
@@ -111,7 +111,7 @@ fn save_as_file(obj: &[u8], path: &Path) -> Result<(), LtoBitcodeFromRlib> {
111111
/// Performs fat LTO by merging all modules into a single one and returning it
112112
/// for further optimization.
113113
pub(crate) fn run_fat(
114-
cgcx: &CodegenContext<GccCodegenBackend>,
114+
cgcx: &CodegenContext,
115115
shared_emitter: &SharedEmitter,
116116
each_linked_rlib_for_lto: &[PathBuf],
117117
modules: Vec<FatLtoInput<GccCodegenBackend>>,
@@ -132,7 +132,7 @@ pub(crate) fn run_fat(
132132
}
133133

134134
fn fat_lto(
135-
cgcx: &CodegenContext<GccCodegenBackend>,
135+
cgcx: &CodegenContext,
136136
_dcx: DiagCtxtHandle<'_>,
137137
modules: Vec<FatLtoInput<GccCodegenBackend>>,
138138
mut serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>,
@@ -283,7 +283,7 @@ impl ModuleBufferMethods for ModuleBuffer {
283283
/// lists, one of the modules that need optimization and another for modules that
284284
/// can simply be copied over from the incr. comp. cache.
285285
pub(crate) fn run_thin(
286-
cgcx: &CodegenContext<GccCodegenBackend>,
286+
cgcx: &CodegenContext,
287287
dcx: DiagCtxtHandle<'_>,
288288
each_linked_rlib_for_lto: &[PathBuf],
289289
modules: Vec<(String, ThinBuffer)>,
@@ -345,7 +345,7 @@ pub(crate) fn prepare_thin(module: ModuleCodegen<GccContext>) -> (String, ThinBu
345345
/// all of the `LtoModuleCodegen` units returned below and destroyed once
346346
/// they all go out of scope.
347347
fn thin_lto(
348-
cgcx: &CodegenContext<GccCodegenBackend>,
348+
cgcx: &CodegenContext,
349349
_dcx: DiagCtxtHandle<'_>,
350350
modules: Vec<(String, ThinBuffer)>,
351351
serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>,
@@ -520,11 +520,9 @@ fn thin_lto(
520520

521521
pub fn optimize_thin_module(
522522
thin_module: ThinModule<GccCodegenBackend>,
523-
_cgcx: &CodegenContext<GccCodegenBackend>,
523+
_cgcx: &CodegenContext,
524524
) -> ModuleCodegen<GccContext> {
525525
//let module_name = &thin_module.shared.module_names[thin_module.idx];
526-
/*let tm_factory_config = TargetMachineFactoryConfig::new(cgcx, module_name.to_str().unwrap());
527-
let tm = (cgcx.tm_factory)(tm_factory_config).map_err(|e| write::llvm_err(&dcx, e))?;*/
528526

529527
// Right now the implementation we've got only works over serialized
530528
// modules, so we create a fresh new LLVM context and parse the module

src/back/write.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ use rustc_target::spec::SplitDebuginfo;
1414

1515
use crate::base::add_pic_option;
1616
use crate::errors::CopyBitcode;
17-
use crate::{GccCodegenBackend, GccContext, LtoMode};
17+
use crate::{GccContext, LtoMode};
1818

1919
pub(crate) fn codegen(
20-
cgcx: &CodegenContext<GccCodegenBackend>,
20+
cgcx: &CodegenContext,
2121
shared_emitter: &SharedEmitter,
2222
module: ModuleCodegen<GccContext>,
2323
config: &ModuleConfig,
@@ -227,7 +227,7 @@ pub(crate) fn codegen(
227227
}
228228

229229
pub(crate) fn save_temp_bitcode(
230-
cgcx: &CodegenContext<GccCodegenBackend>,
230+
cgcx: &CodegenContext,
231231
_module: &ModuleCodegen<GccContext>,
232232
_name: &str,
233233
) {

src/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,9 @@ impl WriteBackendMethods for GccCodegenBackend {
426426
type ThinBuffer = ThinBuffer;
427427

428428
fn run_and_optimize_fat_lto(
429-
cgcx: &CodegenContext<Self>,
429+
cgcx: &CodegenContext,
430430
shared_emitter: &SharedEmitter,
431+
_tm_factory: TargetMachineFactoryFn<Self>,
431432
// FIXME(bjorn3): Limit LTO exports to these symbols
432433
_exported_symbols_for_lto: &[String],
433434
each_linked_rlib_for_lto: &[PathBuf],
@@ -437,7 +438,7 @@ impl WriteBackendMethods for GccCodegenBackend {
437438
}
438439

439440
fn run_thin_lto(
440-
cgcx: &CodegenContext<Self>,
441+
cgcx: &CodegenContext,
441442
dcx: DiagCtxtHandle<'_>,
442443
// FIXME(bjorn3): Limit LTO exports to these symbols
443444
_exported_symbols_for_lto: &[String],
@@ -457,7 +458,7 @@ impl WriteBackendMethods for GccCodegenBackend {
457458
}
458459

459460
fn optimize(
460-
_cgcx: &CodegenContext<Self>,
461+
_cgcx: &CodegenContext,
461462
_shared_emitter: &SharedEmitter,
462463
module: &mut ModuleCodegen<Self::Module>,
463464
config: &ModuleConfig,
@@ -466,15 +467,16 @@ impl WriteBackendMethods for GccCodegenBackend {
466467
}
467468

468469
fn optimize_thin(
469-
cgcx: &CodegenContext<Self>,
470+
cgcx: &CodegenContext,
470471
_shared_emitter: &SharedEmitter,
472+
_tm_factory: TargetMachineFactoryFn<Self>,
471473
thin: ThinModule<Self>,
472474
) -> ModuleCodegen<Self::Module> {
473475
back::lto::optimize_thin_module(thin, cgcx)
474476
}
475477

476478
fn codegen(
477-
cgcx: &CodegenContext<Self>,
479+
cgcx: &CodegenContext,
478480
shared_emitter: &SharedEmitter,
479481
module: ModuleCodegen<Self::Module>,
480482
config: &ModuleConfig,

0 commit comments

Comments
 (0)