Skip to content

Commit 2b92de4

Browse files
committed
Auto merge of #152551 - JonathanBrouwer:rollup-q2woQzs, r=JonathanBrouwer
Rollup of 11 pull requests Successful merges: - #146901 (Support AVRTiny devices in AVR inline assembly) - #150988 (Improve code suggestion for incorrect macro_rules! usage) - #152422 (Change query proc macro to be more rust-analyzer friendly) - #152496 (Fix multi-cgu+debug builds using autodiff by delaying autodiff till lto) - #152520 (Don't use `DepContext` in `rustc_middle::traits::cache`) - #152528 (Support serializing CodegenContext) - #152082 (Move tests) - #152444 (`-Znext-solver` Prevent committing unfulfilled unsized coercion) - #152486 (remove redundant backchain attribute in codegen) - #152529 (sparc64: enable abi compatibility test) - #152548 (reject inline const patterns pre-expansion)
2 parents 47611e1 + fa90379 commit 2b92de4

Some content is hidden

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

54 files changed

+1228
-400
lines changed

compiler/rustc_codegen_gcc/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<_, _> =

compiler/rustc_codegen_gcc/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
}

compiler/rustc_codegen_gcc/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};
@@ -427,26 +428,28 @@ impl WriteBackendMethods for GccCodegenBackend {
427428

428429
fn run_and_optimize_fat_lto(
429430
cgcx: &CodegenContext,
431+
prof: &SelfProfilerRef,
430432
shared_emitter: &SharedEmitter,
431433
_tm_factory: TargetMachineFactoryFn<Self>,
432434
// FIXME(bjorn3): Limit LTO exports to these symbols
433435
_exported_symbols_for_lto: &[String],
434436
each_linked_rlib_for_lto: &[PathBuf],
435437
modules: Vec<FatLtoInput<Self>>,
436438
) -> ModuleCodegen<Self::Module> {
437-
back::lto::run_fat(cgcx, shared_emitter, each_linked_rlib_for_lto, modules)
439+
back::lto::run_fat(cgcx, prof, shared_emitter, each_linked_rlib_for_lto, modules)
438440
}
439441

440442
fn run_thin_lto(
441443
cgcx: &CodegenContext,
444+
prof: &SelfProfilerRef,
442445
dcx: DiagCtxtHandle<'_>,
443446
// FIXME(bjorn3): Limit LTO exports to these symbols
444447
_exported_symbols_for_lto: &[String],
445448
each_linked_rlib_for_lto: &[PathBuf],
446449
modules: Vec<(String, Self::ThinBuffer)>,
447450
cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>,
448451
) -> (Vec<ThinModule<Self>>, Vec<WorkProduct>) {
449-
back::lto::run_thin(cgcx, dcx, each_linked_rlib_for_lto, modules, cached_modules)
452+
back::lto::run_thin(cgcx, prof, dcx, each_linked_rlib_for_lto, modules, cached_modules)
450453
}
451454

452455
fn print_pass_timings(&self) {
@@ -459,6 +462,7 @@ impl WriteBackendMethods for GccCodegenBackend {
459462

460463
fn optimize(
461464
_cgcx: &CodegenContext,
465+
_prof: &SelfProfilerRef,
462466
_shared_emitter: &SharedEmitter,
463467
module: &mut ModuleCodegen<Self::Module>,
464468
config: &ModuleConfig,
@@ -468,6 +472,7 @@ impl WriteBackendMethods for GccCodegenBackend {
468472

469473
fn optimize_thin(
470474
cgcx: &CodegenContext,
475+
_prof: &SelfProfilerRef,
471476
_shared_emitter: &SharedEmitter,
472477
_tm_factory: TargetMachineFactoryFn<Self>,
473478
thin: ThinModule<Self>,
@@ -477,11 +482,12 @@ impl WriteBackendMethods for GccCodegenBackend {
477482

478483
fn codegen(
479484
cgcx: &CodegenContext,
485+
prof: &SelfProfilerRef,
480486
shared_emitter: &SharedEmitter,
481487
module: ModuleCodegen<Self::Module>,
482488
config: &ModuleConfig,
483489
) -> CompiledModule {
484-
back::write::codegen(cgcx, shared_emitter, module, config)
490+
back::write::codegen(cgcx, prof, shared_emitter, module, config)
485491
}
486492

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

compiler/rustc_codegen_llvm/src/attributes.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -301,17 +301,6 @@ fn stackprotector_attr<'ll>(cx: &SimpleCx<'ll>, sess: &Session) -> Option<&'ll A
301301
Some(sspattr.create_attr(cx.llcx))
302302
}
303303

304-
fn backchain_attr<'ll>(cx: &SimpleCx<'ll>, sess: &Session) -> Option<&'ll Attribute> {
305-
if sess.target.arch != Arch::S390x {
306-
return None;
307-
}
308-
309-
let requested_features = sess.opts.cg.target_feature.split(',');
310-
let found_positive = requested_features.clone().any(|r| r == "+backchain");
311-
312-
if found_positive { Some(llvm::CreateAttrString(cx.llcx, "backchain")) } else { None }
313-
}
314-
315304
pub(crate) fn target_cpu_attr<'ll>(cx: &SimpleCx<'ll>, sess: &Session) -> &'ll Attribute {
316305
let target_cpu = llvm_util::target_cpu(sess);
317306
llvm::CreateAttrStringValue(cx.llcx, "target-cpu", target_cpu)
@@ -530,9 +519,6 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
530519
if let Some(align) = codegen_fn_attrs.alignment {
531520
llvm::set_alignment(llfn, align);
532521
}
533-
if let Some(backchain) = backchain_attr(cx, sess) {
534-
to_add.push(backchain);
535-
}
536522
to_add.extend(patchable_function_entry_attrs(
537523
cx,
538524
sess,

0 commit comments

Comments
 (0)