Skip to content

Commit 5082281

Browse files
committed
Auto merge of rust-lang#113879 - nnethercote:codegen_ssa-cleanups, r=bjorn3
`codegen_ssa` cleanups Some clarifications I made when reading this code closely. r? `@tmiasko`
2 parents 03b8b50 + c17c8dc commit 5082281

File tree

9 files changed

+200
-199
lines changed

9 files changed

+200
-199
lines changed

compiler/rustc_codegen_gcc/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ use gccjit::{Context, OptimizationLevel, CType};
7171
use rustc_ast::expand::allocator::AllocatorKind;
7272
use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleCodegen};
7373
use rustc_codegen_ssa::base::codegen_crate;
74-
use rustc_codegen_ssa::back::write::{CodegenContext, FatLTOInput, ModuleConfig, TargetMachineFactoryFn};
74+
use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput, ModuleConfig, TargetMachineFactoryFn};
7575
use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule};
7676
use rustc_codegen_ssa::target_features::supported_target_features;
7777
use rustc_codegen_ssa::traits::{CodegenBackend, ExtraBackendMethods, ModuleBufferMethods, ThinBufferMethods, WriteBackendMethods};
@@ -217,14 +217,14 @@ impl WriteBackendMethods for GccCodegenBackend {
217217
type ThinData = ();
218218
type ThinBuffer = ThinBuffer;
219219

220-
fn run_fat_lto(_cgcx: &CodegenContext<Self>, mut modules: Vec<FatLTOInput<Self>>, _cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>) -> Result<LtoModuleCodegen<Self>, FatalError> {
220+
fn run_fat_lto(_cgcx: &CodegenContext<Self>, mut modules: Vec<FatLtoInput<Self>>, _cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>) -> Result<LtoModuleCodegen<Self>, FatalError> {
221221
// TODO(antoyo): implement LTO by sending -flto to libgccjit and adding the appropriate gcc linker plugins.
222222
// NOTE: implemented elsewhere.
223223
// TODO(antoyo): what is implemented elsewhere ^ ?
224224
let module =
225225
match modules.remove(0) {
226-
FatLTOInput::InMemory(module) => module,
227-
FatLTOInput::Serialized { .. } => {
226+
FatLtoInput::InMemory(module) => module,
227+
FatLtoInput::Serialized { .. } => {
228228
unimplemented!();
229229
}
230230
};

compiler/rustc_codegen_llvm/src/back/lto.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{LlvmCodegenBackend, ModuleLlvm};
77
use object::read::archive::ArchiveFile;
88
use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule, ThinShared};
99
use rustc_codegen_ssa::back::symbol_export;
10-
use rustc_codegen_ssa::back::write::{CodegenContext, FatLTOInput, TargetMachineFactoryConfig};
10+
use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput, TargetMachineFactoryConfig};
1111
use rustc_codegen_ssa::traits::*;
1212
use rustc_codegen_ssa::{looks_like_rust_object_file, ModuleCodegen, ModuleKind};
1313
use rustc_data_structures::fx::FxHashMap;
@@ -166,7 +166,7 @@ fn get_bitcode_slice_from_object_data(obj: &[u8]) -> Result<&[u8], LtoBitcodeFro
166166
/// for further optimization.
167167
pub(crate) fn run_fat(
168168
cgcx: &CodegenContext<LlvmCodegenBackend>,
169-
modules: Vec<FatLTOInput<LlvmCodegenBackend>>,
169+
modules: Vec<FatLtoInput<LlvmCodegenBackend>>,
170170
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
171171
) -> Result<LtoModuleCodegen<LlvmCodegenBackend>, FatalError> {
172172
let diag_handler = cgcx.create_diag_handler();
@@ -220,7 +220,7 @@ pub(crate) fn prepare_thin(module: ModuleCodegen<ModuleLlvm>) -> (String, ThinBu
220220
fn fat_lto(
221221
cgcx: &CodegenContext<LlvmCodegenBackend>,
222222
diag_handler: &Handler,
223-
modules: Vec<FatLTOInput<LlvmCodegenBackend>>,
223+
modules: Vec<FatLtoInput<LlvmCodegenBackend>>,
224224
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
225225
mut serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>,
226226
symbols_below_threshold: &[*const libc::c_char],
@@ -245,8 +245,8 @@ fn fat_lto(
245245
}));
246246
for module in modules {
247247
match module {
248-
FatLTOInput::InMemory(m) => in_memory.push(m),
249-
FatLTOInput::Serialized { name, buffer } => {
248+
FatLtoInput::InMemory(m) => in_memory.push(m),
249+
FatLtoInput::Serialized { name, buffer } => {
250250
info!("pushing serialized module {:?}", name);
251251
let buffer = SerializedModule::Local(buffer);
252252
serialized_modules.push((buffer, CString::new(name).unwrap()));

compiler/rustc_codegen_llvm/src/lib.rs

+2-14
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub use llvm_util::target_features;
2828
use rustc_ast::expand::allocator::AllocatorKind;
2929
use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule};
3030
use rustc_codegen_ssa::back::write::{
31-
CodegenContext, FatLTOInput, ModuleConfig, TargetMachineFactoryConfig, TargetMachineFactoryFn,
31+
CodegenContext, FatLtoInput, ModuleConfig, TargetMachineFactoryConfig, TargetMachineFactoryFn,
3232
};
3333
use rustc_codegen_ssa::traits::*;
3434
use rustc_codegen_ssa::ModuleCodegen;
@@ -141,18 +141,6 @@ impl ExtraBackendMethods for LlvmCodegenBackend {
141141
back::write::target_machine_factory(sess, optlvl, target_features)
142142
}
143143

144-
fn spawn_thread<F, T>(time_trace: bool, f: F) -> std::thread::JoinHandle<T>
145-
where
146-
F: FnOnce() -> T,
147-
F: Send + 'static,
148-
T: Send + 'static,
149-
{
150-
std::thread::spawn(move || {
151-
let _profiler = TimeTraceProfiler::new(time_trace);
152-
f()
153-
})
154-
}
155-
156144
fn spawn_named_thread<F, T>(
157145
time_trace: bool,
158146
name: String,
@@ -212,7 +200,7 @@ impl WriteBackendMethods for LlvmCodegenBackend {
212200
}
213201
fn run_fat_lto(
214202
cgcx: &CodegenContext<Self>,
215-
modules: Vec<FatLTOInput<Self>>,
203+
modules: Vec<FatLtoInput<Self>>,
216204
cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>,
217205
) -> Result<LtoModuleCodegen<Self>, FatalError> {
218206
back::lto::run_fat(cgcx, modules, cached_modules)

0 commit comments

Comments
 (0)