Skip to content

Commit 70ae207

Browse files
authored
Merge pull request #852 from rust-lang/sync_from_rust_2026_02_13
Sync from rust 2026/02/13
2 parents 1920fb1 + 3fdb366 commit 70ae207

File tree

5 files changed

+31
-22
lines changed

5 files changed

+31
-22
lines changed

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2026-02-13"
2+
channel = "nightly-2026-02-14"
33
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

src/back/lto.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput, SharedEmitter}
3030
use rustc_codegen_ssa::traits::*;
3131
use rustc_codegen_ssa::{ModuleCodegen, ModuleKind, looks_like_rust_object_file};
3232
use rustc_data_structures::memmap::Mmap;
33+
use rustc_data_structures::profiling::SelfProfilerRef;
3334
use rustc_errors::{DiagCtxt, DiagCtxtHandle};
3435
use rustc_log::tracing::info;
3536
use rustc_middle::bug;
@@ -112,6 +113,7 @@ fn save_as_file(obj: &[u8], path: &Path) -> Result<(), LtoBitcodeFromRlib> {
112113
/// for further optimization.
113114
pub(crate) fn run_fat(
114115
cgcx: &CodegenContext,
116+
prof: &SelfProfilerRef,
115117
shared_emitter: &SharedEmitter,
116118
each_linked_rlib_for_lto: &[PathBuf],
117119
modules: Vec<FatLtoInput<GccCodegenBackend>>,
@@ -123,6 +125,7 @@ pub(crate) fn run_fat(
123125
lto_data.symbols_below_threshold.iter().map(|c| c.as_ptr()).collect::<Vec<_>>();*/
124126
fat_lto(
125127
cgcx,
128+
prof,
126129
dcx,
127130
modules,
128131
lto_data.upstream_modules,
@@ -133,13 +136,14 @@ pub(crate) fn run_fat(
133136

134137
fn fat_lto(
135138
cgcx: &CodegenContext,
139+
prof: &SelfProfilerRef,
136140
_dcx: DiagCtxtHandle<'_>,
137141
modules: Vec<FatLtoInput<GccCodegenBackend>>,
138142
mut serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>,
139143
tmp_path: TempDir,
140144
//symbols_below_threshold: &[String],
141145
) -> ModuleCodegen<GccContext> {
142-
let _timer = cgcx.prof.generic_activity("GCC_fat_lto_build_monolithic_module");
146+
let _timer = prof.generic_activity("GCC_fat_lto_build_monolithic_module");
143147
info!("going for a fat lto");
144148

145149
// Sort out all our lists of incoming modules into two lists.
@@ -223,8 +227,7 @@ fn fat_lto(
223227
// We add the object files and save in should_combine_object_files that we should combine
224228
// them into a single object file when compiling later.
225229
for (bc_decoded, name) in serialized_modules {
226-
let _timer = cgcx
227-
.prof
230+
let _timer = prof
228231
.generic_activity_with_arg_recorder("GCC_fat_lto_link_module", |recorder| {
229232
recorder.record_arg(format!("{:?}", name))
230233
});
@@ -284,6 +287,7 @@ impl ModuleBufferMethods for ModuleBuffer {
284287
/// can simply be copied over from the incr. comp. cache.
285288
pub(crate) fn run_thin(
286289
cgcx: &CodegenContext,
290+
prof: &SelfProfilerRef,
287291
dcx: DiagCtxtHandle<'_>,
288292
each_linked_rlib_for_lto: &[PathBuf],
289293
modules: Vec<(String, ThinBuffer)>,
@@ -298,6 +302,7 @@ pub(crate) fn run_thin(
298302
}
299303
thin_lto(
300304
cgcx,
305+
prof,
301306
dcx,
302307
modules,
303308
lto_data.upstream_modules,
@@ -345,15 +350,16 @@ pub(crate) fn prepare_thin(module: ModuleCodegen<GccContext>) -> (String, ThinBu
345350
/// all of the `LtoModuleCodegen` units returned below and destroyed once
346351
/// they all go out of scope.
347352
fn thin_lto(
348-
cgcx: &CodegenContext,
353+
_cgcx: &CodegenContext,
354+
prof: &SelfProfilerRef,
349355
_dcx: DiagCtxtHandle<'_>,
350356
modules: Vec<(String, ThinBuffer)>,
351357
serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>,
352358
tmp_path: TempDir,
353359
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
354360
//_symbols_below_threshold: &[String],
355361
) -> (Vec<ThinModule<GccCodegenBackend>>, Vec<WorkProduct>) {
356-
let _timer = cgcx.prof.generic_activity("LLVM_thin_lto_global_analysis");
362+
let _timer = prof.generic_activity("LLVM_thin_lto_global_analysis");
357363
info!("going for that thin, thin LTO");
358364

359365
/*let green_modules: FxHashMap<_, _> =

src/back/write.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use rustc_codegen_ssa::back::write::{
66
BitcodeSection, CodegenContext, EmitObj, ModuleConfig, SharedEmitter,
77
};
88
use rustc_codegen_ssa::{CompiledModule, ModuleCodegen};
9+
use rustc_data_structures::profiling::SelfProfilerRef;
910
use rustc_errors::DiagCtxt;
1011
use rustc_fs_util::link_or_copy;
1112
use rustc_log::tracing::debug;
@@ -18,14 +19,15 @@ use crate::{GccContext, LtoMode};
1819

1920
pub(crate) fn codegen(
2021
cgcx: &CodegenContext,
22+
prof: &SelfProfilerRef,
2123
shared_emitter: &SharedEmitter,
2224
module: ModuleCodegen<GccContext>,
2325
config: &ModuleConfig,
2426
) -> CompiledModule {
2527
let dcx = DiagCtxt::new(Box::new(shared_emitter.clone()));
2628
let dcx = dcx.handle();
2729

28-
let _timer = cgcx.prof.generic_activity_with_arg("GCC_module_codegen", &*module.name);
30+
let _timer = prof.generic_activity_with_arg("GCC_module_codegen", &*module.name);
2931
{
3032
let context = &module.module_llvm.context;
3133

@@ -44,9 +46,8 @@ pub(crate) fn codegen(
4446
);
4547

4648
if config.bitcode_needed() {
47-
let _timer = cgcx
48-
.prof
49-
.generic_activity_with_arg("GCC_module_codegen_make_bitcode", &*module.name);
49+
let _timer =
50+
prof.generic_activity_with_arg("GCC_module_codegen_make_bitcode", &*module.name);
5051

5152
// TODO(antoyo)
5253
/*if let Some(bitcode_filename) = bc_out.file_name() {
@@ -58,8 +59,7 @@ pub(crate) fn codegen(
5859
}*/
5960

6061
if config.emit_bc || config.emit_obj == EmitObj::Bitcode {
61-
let _timer = cgcx
62-
.prof
62+
let _timer = prof
6363
.generic_activity_with_arg("GCC_module_codegen_emit_bitcode", &*module.name);
6464
if lto_supported {
6565
context.add_command_line_option("-flto=auto");
@@ -70,8 +70,7 @@ pub(crate) fn codegen(
7070
}
7171

7272
if config.emit_obj == EmitObj::ObjectCode(BitcodeSection::Full) {
73-
let _timer = cgcx
74-
.prof
73+
let _timer = prof
7574
.generic_activity_with_arg("GCC_module_codegen_embed_bitcode", &*module.name);
7675
if lto_supported {
7776
// TODO(antoyo): maybe we should call embed_bitcode to have the proper iOS fixes?
@@ -98,7 +97,7 @@ pub(crate) fn codegen(
9897

9998
if config.emit_asm {
10099
let _timer =
101-
cgcx.prof.generic_activity_with_arg("GCC_module_codegen_emit_asm", &*module.name);
100+
prof.generic_activity_with_arg("GCC_module_codegen_emit_asm", &*module.name);
102101
let path = cgcx.output_filenames.temp_path_for_cgu(
103102
OutputType::Assembly,
104103
&module.name,
@@ -109,9 +108,8 @@ pub(crate) fn codegen(
109108

110109
match config.emit_obj {
111110
EmitObj::ObjectCode(_) => {
112-
let _timer = cgcx
113-
.prof
114-
.generic_activity_with_arg("GCC_module_codegen_emit_obj", &*module.name);
111+
let _timer =
112+
prof.generic_activity_with_arg("GCC_module_codegen_emit_obj", &*module.name);
115113
if env::var("CG_GCCJIT_DUMP_MODULE_NAMES").as_deref() == Ok("1") {
116114
println!("Module {}", module.name);
117115
}

src/declare.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
151151
///
152152
/// If there’s a value with the same name already declared, the function will
153153
/// update the declaration and return existing Value instead.
154-
#[expect(clippy::let_and_return)]
155154
fn declare_raw_fn<'gcc>(
156155
cx: &CodegenCx<'gcc, '_>,
157156
name: &str,

src/lib.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ use rustc_codegen_ssa::target_features::cfg_target_feature;
9090
use rustc_codegen_ssa::traits::{CodegenBackend, ExtraBackendMethods, WriteBackendMethods};
9191
use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleCodegen, TargetConfig};
9292
use rustc_data_structures::fx::FxIndexMap;
93+
use rustc_data_structures::profiling::SelfProfilerRef;
9394
use rustc_data_structures::sync::IntoDynSyncSend;
9495
use rustc_errors::DiagCtxtHandle;
9596
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
@@ -429,26 +430,28 @@ impl WriteBackendMethods for GccCodegenBackend {
429430

430431
fn run_and_optimize_fat_lto(
431432
cgcx: &CodegenContext,
433+
prof: &SelfProfilerRef,
432434
shared_emitter: &SharedEmitter,
433435
_tm_factory: TargetMachineFactoryFn<Self>,
434436
// FIXME(bjorn3): Limit LTO exports to these symbols
435437
_exported_symbols_for_lto: &[String],
436438
each_linked_rlib_for_lto: &[PathBuf],
437439
modules: Vec<FatLtoInput<Self>>,
438440
) -> ModuleCodegen<Self::Module> {
439-
back::lto::run_fat(cgcx, shared_emitter, each_linked_rlib_for_lto, modules)
441+
back::lto::run_fat(cgcx, prof, shared_emitter, each_linked_rlib_for_lto, modules)
440442
}
441443

442444
fn run_thin_lto(
443445
cgcx: &CodegenContext,
446+
prof: &SelfProfilerRef,
444447
dcx: DiagCtxtHandle<'_>,
445448
// FIXME(bjorn3): Limit LTO exports to these symbols
446449
_exported_symbols_for_lto: &[String],
447450
each_linked_rlib_for_lto: &[PathBuf],
448451
modules: Vec<(String, Self::ThinBuffer)>,
449452
cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>,
450453
) -> (Vec<ThinModule<Self>>, Vec<WorkProduct>) {
451-
back::lto::run_thin(cgcx, dcx, each_linked_rlib_for_lto, modules, cached_modules)
454+
back::lto::run_thin(cgcx, prof, dcx, each_linked_rlib_for_lto, modules, cached_modules)
452455
}
453456

454457
fn print_pass_timings(&self) {
@@ -461,6 +464,7 @@ impl WriteBackendMethods for GccCodegenBackend {
461464

462465
fn optimize(
463466
_cgcx: &CodegenContext,
467+
_prof: &SelfProfilerRef,
464468
_shared_emitter: &SharedEmitter,
465469
module: &mut ModuleCodegen<Self::Module>,
466470
config: &ModuleConfig,
@@ -470,6 +474,7 @@ impl WriteBackendMethods for GccCodegenBackend {
470474

471475
fn optimize_thin(
472476
cgcx: &CodegenContext,
477+
_prof: &SelfProfilerRef,
473478
_shared_emitter: &SharedEmitter,
474479
_tm_factory: TargetMachineFactoryFn<Self>,
475480
thin: ThinModule<Self>,
@@ -479,11 +484,12 @@ impl WriteBackendMethods for GccCodegenBackend {
479484

480485
fn codegen(
481486
cgcx: &CodegenContext,
487+
prof: &SelfProfilerRef,
482488
shared_emitter: &SharedEmitter,
483489
module: ModuleCodegen<Self::Module>,
484490
config: &ModuleConfig,
485491
) -> CompiledModule {
486-
back::write::codegen(cgcx, shared_emitter, module, config)
492+
back::write::codegen(cgcx, prof, shared_emitter, module, config)
487493
}
488494

489495
fn prepare_thin(module: ModuleCodegen<Self::Module>) -> (String, Self::ThinBuffer) {

0 commit comments

Comments
 (0)