Skip to content

Commit 468492c

Browse files
committedMay 3, 2022
Auto merge of #96663 - JohnTitor:rollup-lthuzdq, r=JohnTitor
Rollup of 8 pull requests Successful merges: - #93097 (Switch settings menu to full js) - #96587 (Refactor the WriteBackendMethods and ExtraBackendMethods traits) - #96589 (Use source callsite in check_argument_types suggestion) - #96599 (Update `RValue::Discriminant` documentation) - #96614 (Add a regression test for #92305) - #96629 (Fix invalid keyword order for function declarations) - #96641 (Use a yes/no enum instead of a bool.) - #96646 (Mitigate impact of subtle invalid call suggestion logic) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents c110cfa + 279d801 commit 468492c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+707
-337
lines changed
 

‎compiler/rustc_codegen_gcc/src/lib.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,12 @@ impl CodegenBackend for GccCodegenBackend {
139139
}
140140

141141
impl ExtraBackendMethods for GccCodegenBackend {
142-
fn new_metadata<'tcx>(&self, _tcx: TyCtxt<'tcx>, _mod_name: &str) -> Self::Module {
143-
GccContext {
142+
fn codegen_allocator<'tcx>(&self, tcx: TyCtxt<'tcx>, module_name: &str, kind: AllocatorKind, has_alloc_error_handler: bool) -> Self::Module {
143+
let mut mods = GccContext {
144144
context: Context::default(),
145-
}
146-
}
147-
148-
fn codegen_allocator<'tcx>(&self, tcx: TyCtxt<'tcx>, mods: &mut Self::Module, module_name: &str, kind: AllocatorKind, has_alloc_error_handler: bool) {
149-
unsafe { allocator::codegen(tcx, mods, module_name, kind, has_alloc_error_handler) }
145+
};
146+
unsafe { allocator::codegen(tcx, &mut mods, module_name, kind, has_alloc_error_handler); }
147+
mods
150148
}
151149

152150
fn compile_codegen_unit<'tcx>(&self, tcx: TyCtxt<'tcx>, cgu_name: Symbol) -> (ModuleCodegen<Self::Module>, u64) {
@@ -213,7 +211,7 @@ impl WriteBackendMethods for GccCodegenBackend {
213211
unimplemented!();
214212
}
215213
};
216-
Ok(LtoModuleCodegen::Fat { module: Some(module), _serialized_bitcode: vec![] })
214+
Ok(LtoModuleCodegen::Fat { module, _serialized_bitcode: vec![] })
217215
}
218216

219217
fn run_thin_lto(_cgcx: &CodegenContext<Self>, _modules: Vec<(String, Self::ThinBuffer)>, _cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>) -> Result<(Vec<LtoModuleCodegen<Self>>, Vec<WorkProduct>), FatalError> {
@@ -229,7 +227,12 @@ impl WriteBackendMethods for GccCodegenBackend {
229227
Ok(())
230228
}
231229

232-
unsafe fn optimize_thin(_cgcx: &CodegenContext<Self>, _thin: &mut ThinModule<Self>) -> Result<ModuleCodegen<Self::Module>, FatalError> {
230+
fn optimize_fat(_cgcx: &CodegenContext<Self>, _module: &mut ModuleCodegen<Self::Module>) -> Result<(), FatalError> {
231+
// TODO(antoyo)
232+
Ok(())
233+
}
234+
235+
unsafe fn optimize_thin(_cgcx: &CodegenContext<Self>, _thin: ThinModule<Self>) -> Result<ModuleCodegen<Self::Module>, FatalError> {
233236
unimplemented!();
234237
}
235238

@@ -245,11 +248,6 @@ impl WriteBackendMethods for GccCodegenBackend {
245248
unimplemented!();
246249
}
247250

248-
fn run_lto_pass_manager(_cgcx: &CodegenContext<Self>, _module: &ModuleCodegen<Self::Module>, _config: &ModuleConfig, _thin: bool) -> Result<(), FatalError> {
249-
// TODO(antoyo)
250-
Ok(())
251-
}
252-
253251
fn run_link(cgcx: &CodegenContext<Self>, diag_handler: &Handler, modules: Vec<ModuleCodegen<Self::Module>>) -> Result<ModuleCodegen<Self::Module>, FatalError> {
254252
back::write::link(cgcx, diag_handler, modules)
255253
}

‎compiler/rustc_codegen_llvm/src/back/lto.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ use crate::llvm::{self, build_string, False, True};
66
use crate::{llvm_util, LlvmCodegenBackend, ModuleLlvm};
77
use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule, ThinShared};
88
use rustc_codegen_ssa::back::symbol_export;
9-
use rustc_codegen_ssa::back::write::{
10-
CodegenContext, FatLTOInput, ModuleConfig, TargetMachineFactoryConfig,
11-
};
9+
use rustc_codegen_ssa::back::write::{CodegenContext, FatLTOInput, TargetMachineFactoryConfig};
1210
use rustc_codegen_ssa::traits::*;
1311
use rustc_codegen_ssa::{looks_like_rust_object_file, ModuleCodegen, ModuleKind};
1412
use rustc_data_structures::fx::FxHashMap;
@@ -353,7 +351,7 @@ fn fat_lto(
353351
}
354352
}
355353

356-
Ok(LtoModuleCodegen::Fat { module: Some(module), _serialized_bitcode: serialized_bitcode })
354+
Ok(LtoModuleCodegen::Fat { module, _serialized_bitcode: serialized_bitcode })
357355
}
358356

359357
crate struct Linker<'a>(&'a mut llvm::Linker<'a>);
@@ -578,11 +576,11 @@ fn thin_lto(
578576
pub(crate) fn run_pass_manager(
579577
cgcx: &CodegenContext<LlvmCodegenBackend>,
580578
diag_handler: &Handler,
581-
module: &ModuleCodegen<ModuleLlvm>,
582-
config: &ModuleConfig,
579+
module: &mut ModuleCodegen<ModuleLlvm>,
583580
thin: bool,
584581
) -> Result<(), FatalError> {
585582
let _timer = cgcx.prof.extra_verbose_generic_activity("LLVM_lto_optimize", &*module.name);
583+
let config = cgcx.config(module.kind);
586584

587585
// Now we have one massive module inside of llmod. Time to run the
588586
// LTO-specific optimization passes that LLVM provides.
@@ -726,7 +724,7 @@ impl Drop for ThinBuffer {
726724
}
727725

728726
pub unsafe fn optimize_thin_module(
729-
thin_module: &mut ThinModule<LlvmCodegenBackend>,
727+
thin_module: ThinModule<LlvmCodegenBackend>,
730728
cgcx: &CodegenContext<LlvmCodegenBackend>,
731729
) -> Result<ModuleCodegen<ModuleLlvm>, FatalError> {
732730
let diag_handler = cgcx.create_diag_handler();
@@ -743,7 +741,7 @@ pub unsafe fn optimize_thin_module(
743741
// that LLVM Context and Module.
744742
let llcx = llvm::LLVMRustContextCreate(cgcx.fewer_names);
745743
let llmod_raw = parse_module(llcx, module_name, thin_module.data(), &diag_handler)? as *const _;
746-
let module = ModuleCodegen {
744+
let mut module = ModuleCodegen {
747745
module_llvm: ModuleLlvm { llmod_raw, llcx, tm },
748746
name: thin_module.name().to_string(),
749747
kind: ModuleKind::Regular,
@@ -859,8 +857,7 @@ pub unsafe fn optimize_thin_module(
859857
// little differently.
860858
{
861859
info!("running thin lto passes over {}", module.name);
862-
let config = cgcx.config(module.kind);
863-
run_pass_manager(cgcx, &diag_handler, &module, config, true)?;
860+
run_pass_manager(cgcx, &diag_handler, &mut module, true)?;
864861
save_temp_bitcode(cgcx, &module, "thin-lto-after-pm");
865862
}
866863
}

0 commit comments

Comments
 (0)
Please sign in to comment.