Skip to content

Commit c511e30

Browse files
committed
Auto merge of rust-lang#136811 - workingjubilee:rollup-u3p1rno, r=workingjubilee
Rollup of 9 pull requests Successful merges: - rust-lang#134626 (Add Four Codegen Tests) - rust-lang#135408 (x86: make SSE2 required for i686 hardfloat targets and use it to pass SIMD types) - rust-lang#136155 (Enable sanitizers on MSVC CI jobs) - rust-lang#136419 (adding autodiff tests) - rust-lang#136603 (compiler: gate `extern "{abi}"` in ast_lowering) - rust-lang#136628 (ci: upgrade to crosstool-ng 1.27.0) - rust-lang#136714 (Update `compiler-builtins` to 0.1.146) - rust-lang#136731 (rustc_middle: parallel: TyCtxt: remove "unsafe impl DynSend/DynSync") - rust-lang#136761 (tests: `-Copt-level=3` instead of `-O` in codegen tests) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8c04e39 + 563390f commit c511e30

File tree

355 files changed

+1267
-967
lines changed

Some content is hidden

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

355 files changed

+1267
-967
lines changed

Cargo.lock

+3-1
Original file line numberDiff line numberDiff line change
@@ -3317,7 +3317,6 @@ dependencies = [
33173317
"rand 0.8.5",
33183318
"rand_xoshiro",
33193319
"rustc_data_structures",
3320-
"rustc_feature",
33213320
"rustc_index",
33223321
"rustc_macros",
33233322
"rustc_serialize",
@@ -3379,6 +3378,7 @@ dependencies = [
33793378
"rustc_ast_pretty",
33803379
"rustc_data_structures",
33813380
"rustc_errors",
3381+
"rustc_feature",
33823382
"rustc_fluent_macro",
33833383
"rustc_hir",
33843384
"rustc_index",
@@ -3683,6 +3683,7 @@ version = "0.0.0"
36833683
dependencies = [
36843684
"ctrlc",
36853685
"libc",
3686+
"rustc_abi",
36863687
"rustc_ast",
36873688
"rustc_ast_lowering",
36883689
"rustc_ast_passes",
@@ -4337,6 +4338,7 @@ version = "0.0.0"
43374338
dependencies = [
43384339
"rustc_abi",
43394340
"rustc_ast",
4341+
"rustc_ast_lowering",
43404342
"rustc_ast_pretty",
43414343
"rustc_attr_parsing",
43424344
"rustc_data_structures",

compiler/rustc_abi/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ bitflags = "2.4.1"
99
rand = { version = "0.8.4", default-features = false, optional = true }
1010
rand_xoshiro = { version = "0.6.0", optional = true }
1111
rustc_data_structures = { path = "../rustc_data_structures", optional = true }
12-
rustc_feature = { path = "../rustc_feature", optional = true }
1312
rustc_index = { path = "../rustc_index", default-features = false }
1413
rustc_macros = { path = "../rustc_macros", optional = true }
1514
rustc_serialize = { path = "../rustc_serialize", optional = true }
@@ -24,7 +23,6 @@ default = ["nightly", "randomize"]
2423
# without depending on rustc_data_structures, rustc_macros and rustc_serialize
2524
nightly = [
2625
"dep:rustc_data_structures",
27-
"dep:rustc_feature",
2826
"dep:rustc_macros",
2927
"dep:rustc_serialize",
3028
"dep:rustc_span",

compiler/rustc_abi/src/callconv.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#[cfg(feature = "nightly")]
2-
use crate::{BackendRepr, FieldsShape, TyAbiInterface, TyAndLayout};
3-
use crate::{Primitive, Size, Variants};
2+
use crate::{BackendRepr, FieldsShape, Primitive, Size, TyAbiInterface, TyAndLayout, Variants};
43

54
mod reg;
65

compiler/rustc_abi/src/extern_abi.rs

+9-121
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::fmt;
22

33
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
4-
use rustc_span::{Span, Symbol, sym};
54

65
#[cfg(test)]
76
mod tests;
@@ -95,14 +94,14 @@ impl Abi {
9594

9695
#[derive(Copy, Clone)]
9796
pub struct AbiData {
98-
abi: Abi,
97+
pub abi: Abi,
9998

10099
/// Name of this ABI as we like it called.
101-
name: &'static str,
100+
pub name: &'static str,
102101
}
103102

104103
#[allow(non_upper_case_globals)]
105-
const AbiDatas: &[AbiData] = &[
104+
pub const AbiDatas: &[AbiData] = &[
106105
AbiData { abi: Abi::Rust, name: "Rust" },
107106
AbiData { abi: Abi::C { unwind: false }, name: "C" },
108107
AbiData { abi: Abi::C { unwind: true }, name: "C-unwind" },
@@ -142,129 +141,18 @@ const AbiDatas: &[AbiData] = &[
142141
];
143142

144143
#[derive(Copy, Clone, Debug)]
145-
pub enum AbiUnsupported {
146-
Unrecognized,
147-
Reason { explain: &'static str },
148-
}
149-
144+
pub struct AbiUnsupported {}
150145
/// Returns the ABI with the given name (if any).
151146
pub fn lookup(name: &str) -> Result<Abi, AbiUnsupported> {
152-
AbiDatas.iter().find(|abi_data| name == abi_data.name).map(|&x| x.abi).ok_or_else(|| match name {
153-
"riscv-interrupt" => AbiUnsupported::Reason {
154-
explain: "please use one of riscv-interrupt-m or riscv-interrupt-s for machine- or supervisor-level interrupts, respectively",
155-
},
156-
"riscv-interrupt-u" => AbiUnsupported::Reason {
157-
explain: "user-mode interrupt handlers have been removed from LLVM pending standardization, see: https://reviews.llvm.org/D149314",
158-
},
159-
"wasm" => AbiUnsupported::Reason {
160-
explain: "non-standard wasm ABI is no longer supported",
161-
},
162-
163-
_ => AbiUnsupported::Unrecognized,
164-
165-
})
166-
}
167-
168-
pub fn all_names() -> Vec<&'static str> {
169-
AbiDatas.iter().map(|d| d.name).collect()
170-
}
171-
172-
pub fn enabled_names(features: &rustc_feature::Features, span: Span) -> Vec<&'static str> {
173147
AbiDatas
174148
.iter()
175-
.map(|d| d.name)
176-
.filter(|name| is_enabled(features, span, name).is_ok())
177-
.collect()
149+
.find(|abi_data| name == abi_data.name)
150+
.map(|&x| x.abi)
151+
.ok_or_else(|| AbiUnsupported {})
178152
}
179153

180-
pub enum AbiDisabled {
181-
Unstable { feature: Symbol, explain: &'static str },
182-
Unrecognized,
183-
}
184-
185-
pub fn is_enabled(
186-
features: &rustc_feature::Features,
187-
span: Span,
188-
name: &str,
189-
) -> Result<(), AbiDisabled> {
190-
let s = is_stable(name);
191-
if let Err(AbiDisabled::Unstable { feature, .. }) = s {
192-
if features.enabled(feature) || span.allows_unstable(feature) {
193-
return Ok(());
194-
}
195-
}
196-
s
197-
}
198-
199-
/// Returns whether the ABI is stable to use.
200-
///
201-
/// Note that there is a separate check determining whether the ABI is even supported
202-
/// on the current target; see `fn is_abi_supported` in `rustc_target::spec`.
203-
pub fn is_stable(name: &str) -> Result<(), AbiDisabled> {
204-
match name {
205-
// Stable
206-
"Rust" | "C" | "C-unwind" | "cdecl" | "cdecl-unwind" | "stdcall" | "stdcall-unwind"
207-
| "fastcall" | "fastcall-unwind" | "aapcs" | "aapcs-unwind" | "win64" | "win64-unwind"
208-
| "sysv64" | "sysv64-unwind" | "system" | "system-unwind" | "efiapi" | "thiscall"
209-
| "thiscall-unwind" => Ok(()),
210-
"rust-intrinsic" => Err(AbiDisabled::Unstable {
211-
feature: sym::intrinsics,
212-
explain: "intrinsics are subject to change",
213-
}),
214-
"vectorcall" => Err(AbiDisabled::Unstable {
215-
feature: sym::abi_vectorcall,
216-
explain: "vectorcall is experimental and subject to change",
217-
}),
218-
"vectorcall-unwind" => Err(AbiDisabled::Unstable {
219-
feature: sym::abi_vectorcall,
220-
explain: "vectorcall-unwind ABI is experimental and subject to change",
221-
}),
222-
"rust-call" => Err(AbiDisabled::Unstable {
223-
feature: sym::unboxed_closures,
224-
explain: "rust-call ABI is subject to change",
225-
}),
226-
"rust-cold" => Err(AbiDisabled::Unstable {
227-
feature: sym::rust_cold_cc,
228-
explain: "rust-cold is experimental and subject to change",
229-
}),
230-
"ptx-kernel" => Err(AbiDisabled::Unstable {
231-
feature: sym::abi_ptx,
232-
explain: "PTX ABIs are experimental and subject to change",
233-
}),
234-
"unadjusted" => Err(AbiDisabled::Unstable {
235-
feature: sym::abi_unadjusted,
236-
explain: "unadjusted ABI is an implementation detail and perma-unstable",
237-
}),
238-
"msp430-interrupt" => Err(AbiDisabled::Unstable {
239-
feature: sym::abi_msp430_interrupt,
240-
explain: "msp430-interrupt ABI is experimental and subject to change",
241-
}),
242-
"x86-interrupt" => Err(AbiDisabled::Unstable {
243-
feature: sym::abi_x86_interrupt,
244-
explain: "x86-interrupt ABI is experimental and subject to change",
245-
}),
246-
"gpu-kernel" => Err(AbiDisabled::Unstable {
247-
feature: sym::abi_gpu_kernel,
248-
explain: "gpu-kernel ABI is experimental and subject to change",
249-
}),
250-
"avr-interrupt" | "avr-non-blocking-interrupt" => Err(AbiDisabled::Unstable {
251-
feature: sym::abi_avr_interrupt,
252-
explain: "avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change",
253-
}),
254-
"riscv-interrupt-m" | "riscv-interrupt-s" => Err(AbiDisabled::Unstable {
255-
feature: sym::abi_riscv_interrupt,
256-
explain: "riscv-interrupt ABIs are experimental and subject to change",
257-
}),
258-
"C-cmse-nonsecure-call" => Err(AbiDisabled::Unstable {
259-
feature: sym::abi_c_cmse_nonsecure_call,
260-
explain: "C-cmse-nonsecure-call ABI is experimental and subject to change",
261-
}),
262-
"C-cmse-nonsecure-entry" => Err(AbiDisabled::Unstable {
263-
feature: sym::cmse_nonsecure_entry,
264-
explain: "C-cmse-nonsecure-entry ABI is experimental and subject to change",
265-
}),
266-
_ => Err(AbiDisabled::Unrecognized),
267-
}
154+
pub fn all_names() -> Vec<&'static str> {
155+
AbiDatas.iter().map(|d| d.name).collect()
268156
}
269157

270158
impl Abi {

compiler/rustc_abi/src/extern_abi/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn lookup_cdecl() {
1818
#[test]
1919
fn lookup_baz() {
2020
let abi = lookup("baz");
21-
assert_matches!(abi, Err(AbiUnsupported::Unrecognized));
21+
assert_matches!(abi, Err(AbiUnsupported {}));
2222
}
2323

2424
#[test]

compiler/rustc_abi/src/lib.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ mod extern_abi;
6666

6767
pub use callconv::{Heterogeneous, HomogeneousAggregate, Reg, RegKind};
6868
#[cfg(feature = "nightly")]
69-
pub use extern_abi::{
70-
AbiDisabled, AbiUnsupported, ExternAbi, all_names, enabled_names, is_enabled, is_stable, lookup,
71-
};
69+
pub use extern_abi::{AbiDatas, AbiUnsupported, ExternAbi, all_names, lookup};
7270
#[cfg(feature = "nightly")]
7371
pub use layout::{FIRST_VARIANT, FieldIdx, Layout, TyAbiInterface, TyAndLayout, VariantIdx};
7472
pub use layout::{LayoutCalculator, LayoutCalculatorError};

compiler/rustc_ast/src/expand/autodiff_attrs.rs

+6-18
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,6 @@ pub enum DiffMode {
3030
Forward,
3131
/// The target function, to be created using reverse mode AD.
3232
Reverse,
33-
/// The target function, to be created using forward mode AD.
34-
/// This target function will also be used as a source for higher order derivatives,
35-
/// so compute it before all Forward/Reverse targets and optimize it through llvm.
36-
ForwardFirst,
37-
/// The target function, to be created using reverse mode AD.
38-
/// This target function will also be used as a source for higher order derivatives,
39-
/// so compute it before all Forward/Reverse targets and optimize it through llvm.
40-
ReverseFirst,
4133
}
4234

4335
/// Dual and Duplicated (and their Only variants) are getting lowered to the same Enzyme Activity.
@@ -92,10 +84,10 @@ pub struct AutoDiffAttrs {
9284

9385
impl DiffMode {
9486
pub fn is_rev(&self) -> bool {
95-
matches!(self, DiffMode::Reverse | DiffMode::ReverseFirst)
87+
matches!(self, DiffMode::Reverse)
9688
}
9789
pub fn is_fwd(&self) -> bool {
98-
matches!(self, DiffMode::Forward | DiffMode::ForwardFirst)
90+
matches!(self, DiffMode::Forward)
9991
}
10092
}
10193

@@ -106,8 +98,6 @@ impl Display for DiffMode {
10698
DiffMode::Source => write!(f, "Source"),
10799
DiffMode::Forward => write!(f, "Forward"),
108100
DiffMode::Reverse => write!(f, "Reverse"),
109-
DiffMode::ForwardFirst => write!(f, "ForwardFirst"),
110-
DiffMode::ReverseFirst => write!(f, "ReverseFirst"),
111101
}
112102
}
113103
}
@@ -125,12 +115,12 @@ pub fn valid_ret_activity(mode: DiffMode, activity: DiffActivity) -> bool {
125115
match mode {
126116
DiffMode::Error => false,
127117
DiffMode::Source => false,
128-
DiffMode::Forward | DiffMode::ForwardFirst => {
118+
DiffMode::Forward => {
129119
activity == DiffActivity::Dual
130120
|| activity == DiffActivity::DualOnly
131121
|| activity == DiffActivity::Const
132122
}
133-
DiffMode::Reverse | DiffMode::ReverseFirst => {
123+
DiffMode::Reverse => {
134124
activity == DiffActivity::Const
135125
|| activity == DiffActivity::Active
136126
|| activity == DiffActivity::ActiveOnly
@@ -166,10 +156,10 @@ pub fn valid_input_activity(mode: DiffMode, activity: DiffActivity) -> bool {
166156
return match mode {
167157
DiffMode::Error => false,
168158
DiffMode::Source => false,
169-
DiffMode::Forward | DiffMode::ForwardFirst => {
159+
DiffMode::Forward => {
170160
matches!(activity, Dual | DualOnly | Const)
171161
}
172-
DiffMode::Reverse | DiffMode::ReverseFirst => {
162+
DiffMode::Reverse => {
173163
matches!(activity, Active | ActiveOnly | Duplicated | DuplicatedOnly | Const)
174164
}
175165
};
@@ -200,8 +190,6 @@ impl FromStr for DiffMode {
200190
"Source" => Ok(DiffMode::Source),
201191
"Forward" => Ok(DiffMode::Forward),
202192
"Reverse" => Ok(DiffMode::Reverse),
203-
"ForwardFirst" => Ok(DiffMode::ForwardFirst),
204-
"ReverseFirst" => Ok(DiffMode::ReverseFirst),
205193
_ => Err(()),
206194
}
207195
}

compiler/rustc_ast_lowering/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ rustc_ast = { path = "../rustc_ast" }
1313
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
1414
rustc_data_structures = { path = "../rustc_data_structures" }
1515
rustc_errors = { path = "../rustc_errors" }
16+
rustc_feature = { path = "../rustc_feature" }
1617
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
1718
rustc_hir = { path = "../rustc_hir" }
1819
rustc_index = { path = "../rustc_index" }

compiler/rustc_ast_lowering/src/delegation.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ use std::iter;
4141
use ast::visit::Visitor;
4242
use hir::def::{DefKind, PartialRes, Res};
4343
use hir::{BodyId, HirId};
44+
use rustc_abi::ExternAbi;
4445
use rustc_ast::*;
4546
use rustc_errors::ErrorGuaranteed;
4647
use rustc_hir::def_id::DefId;
4748
use rustc_middle::span_bug;
4849
use rustc_middle::ty::{Asyncness, ResolverAstLowering};
4950
use rustc_span::{Ident, Span};
50-
use rustc_target::spec::abi;
5151
use {rustc_ast as ast, rustc_hir as hir};
5252

5353
use super::{GenericArgsMode, ImplTraitContext, LoweringContext, ParamMode};
@@ -398,7 +398,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
398398
safety: hir::Safety::Safe.into(),
399399
constness: hir::Constness::NotConst,
400400
asyncness: hir::IsAsync::NotAsync,
401-
abi: abi::Abi::Rust,
401+
abi: ExternAbi::Rust,
402402
}
403403
}
404404

compiler/rustc_ast_lowering/src/errors.rs

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use rustc_errors::DiagArgFromDisplay;
12
use rustc_errors::codes::*;
2-
use rustc_errors::{Diag, DiagArgFromDisplay, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic};
33
use rustc_macros::{Diagnostic, Subdiagnostic};
44
use rustc_span::{Ident, Span, Symbol};
55

@@ -32,8 +32,6 @@ pub(crate) struct InvalidAbi {
3232
pub abi: Symbol,
3333
pub command: String,
3434
#[subdiagnostic]
35-
pub explain: Option<InvalidAbiReason>,
36-
#[subdiagnostic]
3735
pub suggestion: Option<InvalidAbiSuggestion>,
3836
}
3937

@@ -45,19 +43,6 @@ pub(crate) struct TupleStructWithDefault {
4543
pub span: Span,
4644
}
4745

48-
pub(crate) struct InvalidAbiReason(pub &'static str);
49-
50-
impl Subdiagnostic for InvalidAbiReason {
51-
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
52-
self,
53-
diag: &mut Diag<'_, G>,
54-
_: &F,
55-
) {
56-
#[allow(rustc::untranslatable_diagnostic)]
57-
diag.note(self.0);
58-
}
59-
}
60-
6146
#[derive(Subdiagnostic)]
6247
#[suggestion(
6348
ast_lowering_invalid_abi_suggestion,

0 commit comments

Comments
 (0)