Skip to content

Commit ef2efa4

Browse files
committed
Auto merge of #142545 - fmease:rollup-pylzhqt, r=fmease
Rollup of 9 pull requests Successful merges: - #133952 (Remove wasm legacy abi) - #134661 (Reduce precedence of expressions that have an outer attr) - #141769 (Move metadata object generation for dylibs to the linker code ) - #141864 (Handle win32 separator for cygwin paths) - #141937 (Report never type lints in dependencies) - #142347 (Async drop - fix for StorageLive/StorageDead codegen for pinned future) - #142389 (Apply ABI attributes on return types in `rustc_codegen_cranelift`) - #142470 (Add some missing mailmap entries) - #142481 (Add `f16` inline asm support for LoongArch) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 586ad39 + 562859f commit ef2efa4

File tree

96 files changed

+3376
-1150
lines changed

Some content is hidden

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

96 files changed

+3376
-1150
lines changed

.mailmap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@ Alona Enraght-Moony <code@alona.page> <nixon@caminus.local>
3434
Alona Enraght-Moony <code@alona.page> <contact@alona.page>
3535
Amanda Stjerna <mail@amandastjerna.se> <albin.stjerna@gmail.com>
3636
Amanda Stjerna <mail@amandastjerna.se> <amanda.stjerna@it.uu.se>
37+
Amanieu d'Antras <amanieu@gmail.com> <amanieu.dantras@huawei.com>
3738
Amos Onn <amosonn@gmail.com>
3839
Ana-Maria Mihalache <mihalacheana.maria@yahoo.com>
3940
Anatoly Ikorsky <aikorsky@gmail.com>
4041
Andre Bogus <bogusandre@gmail.com>
42+
Andre Bogus <bogusandre@gmail.com> <andre.bogus@aleph-alpha.de>
43+
Andre Bogus <bogusandre@gmail.com> <andre.bogus@ankordata.de>
4144
Andrea Ciliberti <meziu210@icloud.com>
4245
Andreas Gal <gal@mozilla.com> <andreas.gal@gmail.com>
4346
Andreas Jonson <andjo403@users.noreply.github.com>
@@ -116,6 +119,7 @@ Carol Willing <carolcode@willingconsulting.com>
116119
Chandler Deng <chandde@microsoft.com>
117120
Charles Lew <crlf0710@gmail.com> CrLF0710 <crlf0710@gmail.com>
118121
Chris C Cerami <chrisccerami@users.noreply.github.com> Chris C Cerami <chrisccerami@gmail.com>
122+
Chris Denton <chris@chrisdenton.dev> <christophersdenton@gmail.com>
119123
Chris Denton <chris@chrisdenton.dev> Chris Denton <ChrisDenton@users.noreply.github.com>
120124
Chris Gregory <czipperz@gmail.com>
121125
Chris Pardy <chrispardy36@gmail.com>
@@ -403,6 +407,8 @@ Urgau <urgau@numericable.fr> <3616612+Urgau@users.noreply.github.com>
403407
Lucy <luxx4x@protonmail.com>
404408
Lukas H. <lukaramu@users.noreply.github.com>
405409
Lukas Lueg <lukas.lueg@gmail.com>
410+
Lukas Wirth <lukastw97@gmail.com> <lukas.wirth@ferrous-systems.com>
411+
Lukas Wirth <lukastw97@gmail.com> <me@lukaswirth.dev>
406412
Luke Metz <luke.metz@students.olin.edu>
407413
Luqman Aden <me@luqman.ca> <laden@csclub.uwaterloo.ca>
408414
Luqman Aden <me@luqman.ca> <laden@mozilla.com>
@@ -493,6 +499,7 @@ Nicolas Abram <abramlujan@gmail.com>
493499
Nicole Mazzuca <npmazzuca@gmail.com>
494500
Niko Matsakis <rust@nikomatsakis.com>
495501
Niko Matsakis <rust@nikomatsakis.com> <niko@alum.mit.edu>
502+
Niko Matsakis <rust@nikomatsakis.com> <nikomat@amazon.com>
496503
Noratrieb <48135649+Noratrieb@users.noreply.github.com>
497504
Noratrieb <48135649+Noratrieb@users.noreply.github.com> <48135649+Nilstrieb@users.noreply.github.com>
498505
Noratrieb <48135649+Noratrieb@users.noreply.github.com> <nilstrieb@gmail.com>

compiler/rustc_ast/src/ast.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,11 +1450,20 @@ impl Expr {
14501450
}
14511451

14521452
pub fn precedence(&self) -> ExprPrecedence {
1453+
fn prefix_attrs_precedence(attrs: &AttrVec) -> ExprPrecedence {
1454+
for attr in attrs {
1455+
if let AttrStyle::Outer = attr.style {
1456+
return ExprPrecedence::Prefix;
1457+
}
1458+
}
1459+
ExprPrecedence::Unambiguous
1460+
}
1461+
14531462
match &self.kind {
14541463
ExprKind::Closure(closure) => {
14551464
match closure.fn_decl.output {
14561465
FnRetTy::Default(_) => ExprPrecedence::Jump,
1457-
FnRetTy::Ty(_) => ExprPrecedence::Unambiguous,
1466+
FnRetTy::Ty(_) => prefix_attrs_precedence(&self.attrs),
14581467
}
14591468
}
14601469

@@ -1463,7 +1472,7 @@ impl Expr {
14631472
| ExprKind::Yield(YieldKind::Prefix(value))
14641473
| ExprKind::Yeet(value) => match value {
14651474
Some(_) => ExprPrecedence::Jump,
1466-
None => ExprPrecedence::Unambiguous,
1475+
None => prefix_attrs_precedence(&self.attrs),
14671476
},
14681477

14691478
ExprKind::Become(_) => ExprPrecedence::Jump,
@@ -1490,7 +1499,7 @@ impl Expr {
14901499
| ExprKind::Let(..)
14911500
| ExprKind::Unary(..) => ExprPrecedence::Prefix,
14921501

1493-
// Never need parens
1502+
// Need parens if and only if there are prefix attributes.
14941503
ExprKind::Array(_)
14951504
| ExprKind::Await(..)
14961505
| ExprKind::Use(..)
@@ -1525,7 +1534,7 @@ impl Expr {
15251534
| ExprKind::While(..)
15261535
| ExprKind::Yield(YieldKind::Postfix(..))
15271536
| ExprKind::Err(_)
1528-
| ExprKind::Dummy => ExprPrecedence::Unambiguous,
1537+
| ExprKind::Dummy => prefix_attrs_precedence(&self.attrs),
15291538
}
15301539
}
15311540

compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Argument passing
22
3-
use cranelift_codegen::ir::{ArgumentExtension, ArgumentPurpose};
3+
use cranelift_codegen::ir::ArgumentPurpose;
44
use rustc_abi::{Reg, RegKind};
55
use rustc_target::callconv::{
66
ArgAbi, ArgAttributes, ArgExtension as RustcArgExtension, CastTarget, PassMode,
@@ -32,13 +32,12 @@ fn reg_to_abi_param(reg: Reg) -> AbiParam {
3232
AbiParam::new(clif_ty)
3333
}
3434

35-
fn apply_arg_attrs_to_abi_param(mut param: AbiParam, arg_attrs: ArgAttributes) -> AbiParam {
35+
fn apply_attrs_to_abi_param(param: AbiParam, arg_attrs: ArgAttributes) -> AbiParam {
3636
match arg_attrs.arg_ext {
37-
RustcArgExtension::None => {}
38-
RustcArgExtension::Zext => param.extension = ArgumentExtension::Uext,
39-
RustcArgExtension::Sext => param.extension = ArgumentExtension::Sext,
37+
RustcArgExtension::None => param,
38+
RustcArgExtension::Zext => param.uext(),
39+
RustcArgExtension::Sext => param.sext(),
4040
}
41-
param
4241
}
4342

4443
fn cast_target_to_abi_params(cast: &CastTarget) -> SmallVec<[AbiParam; 2]> {
@@ -82,7 +81,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
8281
match self.mode {
8382
PassMode::Ignore => smallvec![],
8483
PassMode::Direct(attrs) => match self.layout.backend_repr {
85-
BackendRepr::Scalar(scalar) => smallvec![apply_arg_attrs_to_abi_param(
84+
BackendRepr::Scalar(scalar) => smallvec![apply_attrs_to_abi_param(
8685
AbiParam::new(scalar_to_clif_type(tcx, scalar)),
8786
attrs
8887
)],
@@ -97,8 +96,8 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
9796
let a = scalar_to_clif_type(tcx, a);
9897
let b = scalar_to_clif_type(tcx, b);
9998
smallvec![
100-
apply_arg_attrs_to_abi_param(AbiParam::new(a), attrs_a),
101-
apply_arg_attrs_to_abi_param(AbiParam::new(b), attrs_b),
99+
apply_attrs_to_abi_param(AbiParam::new(a), attrs_a),
100+
apply_attrs_to_abi_param(AbiParam::new(b), attrs_b),
102101
]
103102
}
104103
_ => unreachable!("{:?}", self.layout.backend_repr),
@@ -112,19 +111,19 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
112111
// Abi requires aligning struct size to pointer size
113112
let size = self.layout.size.align_to(tcx.data_layout.pointer_align.abi);
114113
let size = u32::try_from(size.bytes()).unwrap();
115-
smallvec![apply_arg_attrs_to_abi_param(
114+
smallvec![apply_attrs_to_abi_param(
116115
AbiParam::special(pointer_ty(tcx), ArgumentPurpose::StructArgument(size),),
117116
attrs
118117
)]
119118
} else {
120-
smallvec![apply_arg_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), attrs)]
119+
smallvec![apply_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), attrs)]
121120
}
122121
}
123122
PassMode::Indirect { attrs, meta_attrs: Some(meta_attrs), on_stack } => {
124123
assert!(!on_stack);
125124
smallvec![
126-
apply_arg_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), attrs),
127-
apply_arg_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), meta_attrs),
125+
apply_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), attrs),
126+
apply_attrs_to_abi_param(AbiParam::new(pointer_ty(tcx)), meta_attrs),
128127
]
129128
}
130129
}
@@ -133,30 +132,46 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
133132
fn get_abi_return(&self, tcx: TyCtxt<'tcx>) -> (Option<AbiParam>, Vec<AbiParam>) {
134133
match self.mode {
135134
PassMode::Ignore => (None, vec![]),
136-
PassMode::Direct(_) => match self.layout.backend_repr {
137-
BackendRepr::Scalar(scalar) => {
138-
(None, vec![AbiParam::new(scalar_to_clif_type(tcx, scalar))])
139-
}
135+
PassMode::Direct(attrs) => match self.layout.backend_repr {
136+
BackendRepr::Scalar(scalar) => (
137+
None,
138+
vec![apply_attrs_to_abi_param(
139+
AbiParam::new(scalar_to_clif_type(tcx, scalar)),
140+
attrs,
141+
)],
142+
),
140143
BackendRepr::SimdVector { .. } => {
141144
let vector_ty = crate::intrinsics::clif_vector_type(tcx, self.layout);
142-
(None, vec![AbiParam::new(vector_ty)])
145+
(None, vec![apply_attrs_to_abi_param(AbiParam::new(vector_ty), attrs)])
143146
}
144147
_ => unreachable!("{:?}", self.layout.backend_repr),
145148
},
146-
PassMode::Pair(_, _) => match self.layout.backend_repr {
149+
PassMode::Pair(attrs_a, attrs_b) => match self.layout.backend_repr {
147150
BackendRepr::ScalarPair(a, b) => {
148151
let a = scalar_to_clif_type(tcx, a);
149152
let b = scalar_to_clif_type(tcx, b);
150-
(None, vec![AbiParam::new(a), AbiParam::new(b)])
153+
(
154+
None,
155+
vec![
156+
apply_attrs_to_abi_param(AbiParam::new(a), attrs_a),
157+
apply_attrs_to_abi_param(AbiParam::new(b), attrs_b),
158+
],
159+
)
151160
}
152161
_ => unreachable!("{:?}", self.layout.backend_repr),
153162
},
154163
PassMode::Cast { ref cast, .. } => {
155164
(None, cast_target_to_abi_params(cast).into_iter().collect())
156165
}
157-
PassMode::Indirect { attrs: _, meta_attrs: None, on_stack } => {
166+
PassMode::Indirect { attrs, meta_attrs: None, on_stack } => {
158167
assert!(!on_stack);
159-
(Some(AbiParam::special(pointer_ty(tcx), ArgumentPurpose::StructReturn)), vec![])
168+
(
169+
Some(apply_attrs_to_abi_param(
170+
AbiParam::special(pointer_ty(tcx), ArgumentPurpose::StructReturn),
171+
attrs,
172+
)),
173+
vec![],
174+
)
160175
}
161176
PassMode::Indirect { attrs: _, meta_attrs: Some(_), on_stack: _ } => {
162177
unreachable!("unsized return value")

compiler/rustc_codegen_cranelift/src/driver/aot.rs

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@ use std::thread::JoinHandle;
1111
use cranelift_object::{ObjectBuilder, ObjectModule};
1212
use rustc_codegen_ssa::assert_module_sources::CguReuse;
1313
use rustc_codegen_ssa::back::link::ensure_removed;
14-
use rustc_codegen_ssa::back::metadata::create_compressed_metadata_file;
1514
use rustc_codegen_ssa::base::determine_cgu_reuse;
1615
use rustc_codegen_ssa::{
1716
CodegenResults, CompiledModule, CrateInfo, ModuleKind, errors as ssa_errors,
1817
};
1918
use rustc_data_structures::profiling::SelfProfilerRef;
2019
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
2120
use rustc_data_structures::sync::{IntoDynSyncSend, par_map};
22-
use rustc_metadata::EncodedMetadata;
2321
use rustc_metadata::fs::copy_to_stdout;
2422
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
2523
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
@@ -61,8 +59,6 @@ impl<HCX> HashStable<HCX> for OngoingModuleCodegen {
6159
pub(crate) struct OngoingCodegen {
6260
modules: Vec<OngoingModuleCodegen>,
6361
allocator_module: Option<CompiledModule>,
64-
metadata_module: Option<CompiledModule>,
65-
metadata: EncodedMetadata,
6662
crate_info: CrateInfo,
6763
concurrency_limiter: ConcurrencyLimiter,
6864
}
@@ -134,8 +130,6 @@ impl OngoingCodegen {
134130
let codegen_results = CodegenResults {
135131
modules,
136132
allocator_module: self.allocator_module,
137-
metadata_module: self.metadata_module,
138-
metadata: self.metadata,
139133
crate_info: self.crate_info,
140134
};
141135

@@ -646,42 +640,6 @@ fn module_codegen(
646640
}))
647641
}
648642

649-
fn emit_metadata_module(tcx: TyCtxt<'_>, metadata: &EncodedMetadata) -> CompiledModule {
650-
use rustc_middle::mir::mono::CodegenUnitNameBuilder;
651-
652-
let _timer = tcx.sess.timer("write compressed metadata");
653-
654-
let cgu_name_builder = &mut CodegenUnitNameBuilder::new(tcx);
655-
let metadata_cgu_name = cgu_name_builder
656-
.build_cgu_name(LOCAL_CRATE, ["crate"], Some("metadata"))
657-
.as_str()
658-
.to_string();
659-
660-
let tmp_file = tcx.output_filenames(()).temp_path_for_cgu(
661-
OutputType::Metadata,
662-
&metadata_cgu_name,
663-
tcx.sess.invocation_temp.as_deref(),
664-
);
665-
666-
let symbol_name = rustc_middle::middle::exported_symbols::metadata_symbol_name(tcx);
667-
let obj = create_compressed_metadata_file(tcx.sess, metadata, &symbol_name);
668-
669-
if let Err(err) = std::fs::write(&tmp_file, obj) {
670-
tcx.dcx().fatal(format!("error writing metadata object file: {}", err));
671-
}
672-
673-
CompiledModule {
674-
name: metadata_cgu_name,
675-
kind: ModuleKind::Metadata,
676-
object: Some(tmp_file),
677-
dwarf_object: None,
678-
bytecode: None,
679-
assembly: None,
680-
llvm_ir: None,
681-
links_from_incr_cache: Vec::new(),
682-
}
683-
}
684-
685643
fn emit_allocator_module(tcx: TyCtxt<'_>) -> Option<CompiledModule> {
686644
let mut allocator_module = make_module(tcx.sess, "allocator_shim".to_string());
687645
let created_alloc_shim = crate::allocator::codegen(tcx, &mut allocator_module);
@@ -706,11 +664,7 @@ fn emit_allocator_module(tcx: TyCtxt<'_>) -> Option<CompiledModule> {
706664
}
707665
}
708666

709-
pub(crate) fn run_aot(
710-
tcx: TyCtxt<'_>,
711-
metadata: EncodedMetadata,
712-
need_metadata_module: bool,
713-
) -> Box<OngoingCodegen> {
667+
pub(crate) fn run_aot(tcx: TyCtxt<'_>) -> Box<OngoingCodegen> {
714668
// FIXME handle `-Ctarget-cpu=native`
715669
let target_cpu = match tcx.sess.opts.cg.target_cpu {
716670
Some(ref name) => name,
@@ -726,8 +680,6 @@ pub(crate) fn run_aot(
726680
return Box::new(OngoingCodegen {
727681
modules: vec![],
728682
allocator_module: None,
729-
metadata_module: None,
730-
metadata,
731683
crate_info: CrateInfo::new(tcx, target_cpu),
732684
concurrency_limiter: ConcurrencyLimiter::new(0),
733685
});
@@ -787,14 +739,9 @@ pub(crate) fn run_aot(
787739

788740
let allocator_module = emit_allocator_module(tcx);
789741

790-
let metadata_module =
791-
if need_metadata_module { Some(emit_metadata_module(tcx, &metadata)) } else { None };
792-
793742
Box::new(OngoingCodegen {
794743
modules,
795744
allocator_module,
796-
metadata_module,
797-
metadata,
798745
crate_info: CrateInfo::new(tcx, target_cpu),
799746
concurrency_limiter: concurrency_limiter.0,
800747
})

compiler/rustc_codegen_cranelift/src/lib.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ use cranelift_codegen::isa::TargetIsa;
4646
use cranelift_codegen::settings::{self, Configurable};
4747
use rustc_codegen_ssa::traits::CodegenBackend;
4848
use rustc_codegen_ssa::{CodegenResults, TargetConfig};
49-
use rustc_metadata::EncodedMetadata;
5049
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
5150
use rustc_session::Session;
5251
use rustc_session::config::OutputFilenames;
@@ -238,12 +237,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
238237
println!("Cranelift version: {}", cranelift_codegen::VERSION);
239238
}
240239

241-
fn codegen_crate(
242-
&self,
243-
tcx: TyCtxt<'_>,
244-
metadata: EncodedMetadata,
245-
need_metadata_module: bool,
246-
) -> Box<dyn Any> {
240+
fn codegen_crate(&self, tcx: TyCtxt<'_>) -> Box<dyn Any> {
247241
info!("codegen crate {}", tcx.crate_name(LOCAL_CRATE));
248242
let config = self.config.clone().unwrap_or_else(|| {
249243
BackendConfig::from_opts(&tcx.sess.opts.cg.llvm_args)
@@ -256,7 +250,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
256250
#[cfg(not(feature = "jit"))]
257251
tcx.dcx().fatal("jit support was disabled when compiling rustc_codegen_cranelift");
258252
} else {
259-
driver::aot::run_aot(tcx, metadata, need_metadata_module)
253+
driver::aot::run_aot(tcx)
260254
}
261255
}
262256

compiler/rustc_codegen_gcc/src/builder.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use rustc_middle::ty::{self, AtomicOrdering, Instance, Ty, TyCtxt};
3030
use rustc_span::Span;
3131
use rustc_span::def_id::DefId;
3232
use rustc_target::callconv::FnAbi;
33-
use rustc_target::spec::{HasTargetSpec, HasWasmCAbiOpt, HasX86AbiOpt, Target, WasmCAbi, X86Abi};
33+
use rustc_target::spec::{HasTargetSpec, HasX86AbiOpt, Target, X86Abi};
3434

3535
use crate::common::{SignType, TypeReflection, type_is_pointer};
3636
use crate::context::CodegenCx;
@@ -2394,12 +2394,6 @@ impl<'tcx> HasTargetSpec for Builder<'_, '_, 'tcx> {
23942394
}
23952395
}
23962396

2397-
impl<'tcx> HasWasmCAbiOpt for Builder<'_, '_, 'tcx> {
2398-
fn wasm_c_abi_opt(&self) -> WasmCAbi {
2399-
self.cx.wasm_c_abi_opt()
2400-
}
2401-
}
2402-
24032397
impl<'tcx> HasX86AbiOpt for Builder<'_, '_, 'tcx> {
24042398
fn x86_abi_opt(&self) -> X86Abi {
24052399
self.cx.x86_abi_opt()

0 commit comments

Comments
 (0)