Skip to content

Commit 5642ab5

Browse files
committed
rustup: update to nightly-2024-11-22 (~1.84).
1 parent b42e928 commit 5642ab5

18 files changed

+132
-132
lines changed

crates/rustc_codegen_spirv/build.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ use std::{env, fs, mem};
1515
/// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/
1616
//const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml");
1717
const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain]
18-
channel = "nightly-2024-10-12"
18+
channel = "nightly-2024-11-22"
1919
components = ["rust-src", "rustc-dev", "llvm-tools"]
20-
# commit_hash = 1bc403daadbebb553ccc211a0a8eebb73989665f"#;
20+
# commit_hash = b19329a37cedf2027517ae22c87cf201f93d776e"#;
2121

2222
fn rustc_output(arg: &str) -> Result<String, Box<dyn Error>> {
2323
let rustc = env::var("RUSTC").unwrap_or_else(|_| "rustc".into());

crates/rustc_codegen_spirv/src/abi.rs

+54-51
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ use rspirv::spirv::{Dim, ImageFormat, StorageClass, Word};
99
use rustc_data_structures::fx::FxHashMap;
1010
use rustc_errors::ErrorGuaranteed;
1111
use rustc_index::Idx;
12-
use rustc_middle::mir::interpret::ErrorHandled;
1312
use rustc_middle::query::Providers;
1413
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout};
1514
use rustc_middle::ty::{
16-
self, Const, CoroutineArgs, CoroutineArgsExt as _, FloatTy, IntTy, ParamEnv, PolyFnSig, Ty,
17-
TyCtxt, TyKind, UintTy,
15+
self, Const, CoroutineArgs, CoroutineArgsExt as _, FloatTy, IntTy, PolyFnSig, Ty, TyCtxt,
16+
TyKind, UintTy,
1817
};
1918
use rustc_middle::ty::{GenericArgsRef, ScalarInt};
2019
use rustc_middle::{bug, span_bug};
@@ -23,10 +22,10 @@ use rustc_span::def_id::DefId;
2322
use rustc_span::{Span, Symbol};
2423
use rustc_target::abi::call::{ArgAbi, ArgAttributes, FnAbi, PassMode};
2524
use rustc_target::abi::{
26-
Abi, Align, FieldsShape, LayoutS, Primitive, ReprFlags, ReprOptions, Scalar, Size, TagEncoding,
27-
VariantIdx, Variants,
25+
Align, BackendRepr, FieldsShape, LayoutData, Primitive, ReprFlags, ReprOptions, Scalar, Size,
26+
TagEncoding, VariantIdx, Variants,
2827
};
29-
use rustc_target::spec::abi::Abi as SpecAbi;
28+
use rustc_target::spec::abi::Abi;
3029
use std::cell::RefCell;
3130
use std::collections::hash_map::Entry;
3231
use std::fmt;
@@ -47,8 +46,8 @@ pub(crate) fn provide(providers: &mut Providers) {
4746
let result = (rustc_interface::DEFAULT_QUERY_PROVIDERS.fn_sig)(tcx, def_id);
4847
result.map_bound(|outer| {
4948
outer.map_bound(|mut inner| {
50-
if let SpecAbi::C { .. } = inner.abi {
51-
inner.abi = SpecAbi::Unadjusted;
49+
if let Abi::C { .. } = inner.abi {
50+
inner.abi = Abi::Unadjusted;
5251
}
5352
inner
5453
})
@@ -98,22 +97,21 @@ pub(crate) fn provide(providers: &mut Providers) {
9897
Ok(readjust_fn_abi(tcx, result?))
9998
};
10099

101-
// FIXME(eddyb) remove this by deriving `Clone` for `LayoutS` upstream.
102-
// FIXME(eddyb) the `S` suffix is a naming antipattern, rename upstream.
100+
// FIXME(eddyb) remove this by deriving `Clone` for `LayoutData` upstream.
103101
fn clone_layout<FieldIdx: Idx, VariantIdx: Idx>(
104-
layout: &LayoutS<FieldIdx, VariantIdx>,
105-
) -> LayoutS<FieldIdx, VariantIdx> {
106-
let LayoutS {
102+
layout: &LayoutData<FieldIdx, VariantIdx>,
103+
) -> LayoutData<FieldIdx, VariantIdx> {
104+
let LayoutData {
107105
ref fields,
108106
ref variants,
109-
abi,
107+
backend_repr,
110108
largest_niche,
111109
align,
112110
size,
113111
max_repr_align,
114112
unadjusted_abi_align,
115113
} = *layout;
116-
LayoutS {
114+
LayoutData {
117115
fields: match *fields {
118116
FieldsShape::Primitive => FieldsShape::Primitive,
119117
FieldsShape::Union(count) => FieldsShape::Union(count),
@@ -151,7 +149,7 @@ pub(crate) fn provide(providers: &mut Providers) {
151149
variants: variants.clone(),
152150
},
153151
},
154-
abi,
152+
backend_repr,
155153
largest_niche,
156154
align,
157155
size,
@@ -171,7 +169,7 @@ pub(crate) fn provide(providers: &mut Providers) {
171169
};
172170

173171
if hide_niche {
174-
layout = tcx.mk_layout(LayoutS {
172+
layout = tcx.mk_layout(LayoutData {
175173
largest_niche: None,
176174
..clone_layout(layout.0.0)
177175
});
@@ -192,6 +190,10 @@ pub(crate) fn provide(providers: &mut Providers) {
192190
// an option (may require Rust-GPU distinguishing between "SPIR-V interface"
193191
// and "Rust-facing" types, which is even worse when the `OpTypeVector`s
194192
// may be e.g. nested in `struct`s/arrays/etc. - at least buffers are easy).
193+
//
194+
// FIXME(eddyb) maybe using `#[spirv(vector)]` and `BackendRepr::Memory`,
195+
// no claims at `rustc`-understood SIMD whatsoever, would be enough?
196+
// (i.e. only SPIR-V caring about such a type vs a struct/array)
195197
providers.check_well_formed = |tcx, def_id| {
196198
let trivial_struct = match tcx.hir_node_by_def_id(def_id) {
197199
rustc_hir::Node::Item(item) => match item.kind {
@@ -263,6 +265,14 @@ pub(crate) fn provide(providers: &mut Providers) {
263265

264266
(rustc_interface::DEFAULT_QUERY_PROVIDERS.check_well_formed)(tcx, def_id)
265267
};
268+
269+
// HACK(eddyb) work around https://github.com/rust-lang/rust/pull/132173
270+
// (and further changes from https://github.com/rust-lang/rust/pull/132843)
271+
// starting to ban SIMD ABI misuse (or at least starting to warn about it).
272+
//
273+
// FIXME(eddyb) same as the FIXME comment on `check_well_formed`:
274+
// need to migrate away from `#[repr(simd)]` ASAP.
275+
providers.check_mono_item = |_, _| {};
266276
}
267277

268278
/// If a struct contains a pointer to itself, even indirectly, then doing a naiive recursive walk
@@ -450,9 +460,9 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {
450460

451461
// Note: ty.layout is orthogonal to ty.ty, e.g. `ManuallyDrop<Result<isize, isize>>` has abi
452462
// `ScalarPair`.
453-
// There's a few layers that we go through here. First we inspect layout.abi, then if relevant, layout.fields, etc.
454-
match self.abi {
455-
Abi::Uninhabited => SpirvType::Adt {
463+
// There's a few layers that we go through here. First we inspect layout.backend_repr, then if relevant, layout.fields, etc.
464+
match self.backend_repr {
465+
BackendRepr::Uninhabited => SpirvType::Adt {
456466
def_id: def_id_for_spirv_type_adt(*self),
457467
size: Some(Size::ZERO),
458468
align: Align::from_bytes(0).unwrap(),
@@ -461,13 +471,13 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {
461471
field_names: None,
462472
}
463473
.def_with_name(cx, span, TyLayoutNameKey::from(*self)),
464-
Abi::Scalar(scalar) => trans_scalar(cx, span, *self, scalar, Size::ZERO),
465-
Abi::ScalarPair(a, b) => {
466-
// NOTE(eddyb) unlike `Abi::Scalar`'s simpler newtype-unpacking
467-
// behavior, `Abi::ScalarPair` can be composed in two ways:
468-
// * two `Abi::Scalar` fields (and any number of ZST fields),
474+
BackendRepr::Scalar(scalar) => trans_scalar(cx, span, *self, scalar, Size::ZERO),
475+
BackendRepr::ScalarPair(a, b) => {
476+
// NOTE(eddyb) unlike `BackendRepr::Scalar`'s simpler newtype-unpacking
477+
// behavior, `BackendRepr::ScalarPair` can be composed in two ways:
478+
// * two `BackendRepr::Scalar` fields (and any number of ZST fields),
469479
// gets handled the same as a `struct { a, b }`, further below
470-
// * an `Abi::ScalarPair` field (and any number of ZST fields),
480+
// * an `BackendRepr::ScalarPair` field (and any number of ZST fields),
471481
// which requires more work to allow taking a reference to
472482
// that field, and there are two potential approaches:
473483
// 1. wrapping that field's SPIR-V type in a single-field
@@ -477,7 +487,7 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {
477487
// 2. reusing that field's SPIR-V type, instead of defining
478488
// a new one, offering the `(a, b)` shape `rustc_codegen_ssa`
479489
// expects, while letting noop pointercasts access the sole
480-
// `Abi::ScalarPair` field - this is the approach taken here
490+
// `BackendRepr::ScalarPair` field - this is the approach taken here
481491
let mut non_zst_fields = (0..self.fields.count())
482492
.map(|i| (i, self.field(cx, i)))
483493
.filter(|(_, field)| !field.is_zst());
@@ -491,7 +501,7 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {
491501
if self.fields.offset(i) == Size::ZERO
492502
&& field.size == self.size
493503
&& field.align == self.align
494-
&& field.abi == self.abi
504+
&& field.backend_repr == self.backend_repr
495505
{
496506
return field.spirv_type(span, cx);
497507
}
@@ -532,15 +542,15 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {
532542
}
533543
.def_with_name(cx, span, TyLayoutNameKey::from(*self))
534544
}
535-
Abi::Vector { element, count } => {
545+
BackendRepr::Vector { element, count } => {
536546
let elem_spirv = trans_scalar(cx, span, *self, element, Size::ZERO);
537547
SpirvType::Vector {
538548
element: elem_spirv,
539549
count: count as u32,
540550
}
541551
.def(span, cx)
542552
}
543-
Abi::Aggregate { sized: _ } => trans_aggregate(cx, span, *self),
553+
BackendRepr::Memory { sized: _ } => trans_aggregate(cx, span, *self),
544554
}
545555
}
546556
}
@@ -553,8 +563,8 @@ pub fn scalar_pair_element_backend_type<'tcx>(
553563
ty: TyAndLayout<'tcx>,
554564
index: usize,
555565
) -> Word {
556-
let [a, b] = match ty.layout.abi() {
557-
Abi::ScalarPair(a, b) => [a, b],
566+
let [a, b] = match ty.layout.backend_repr() {
567+
BackendRepr::ScalarPair(a, b) => [a, b],
558568
other => span_bug!(
559569
span,
560570
"scalar_pair_element_backend_type invalid abi: {:?}",
@@ -901,7 +911,7 @@ fn trans_intrinsic_type<'tcx>(
901911
// ) -> P {
902912
// let adt_def = const_.ty.ty_adt_def().unwrap();
903913
// assert!(adt_def.is_enum());
904-
// let destructured = cx.tcx.destructure_const(ParamEnv::reveal_all().and(const_));
914+
// let destructured = cx.tcx.destructure_const(TypingEnv::fully_monomorphized().and(const_));
905915
// let idx = destructured.variant.unwrap();
906916
// let value = const_.ty.discriminant_for_variant(cx.tcx, idx).unwrap().val as u64;
907917
// <_>::from_u64(value).unwrap()
@@ -974,24 +984,17 @@ fn trans_intrinsic_type<'tcx>(
974984
cx: &CodegenCx<'tcx>,
975985
const_: Const<'tcx>,
976986
) -> Result<P, ErrorGuaranteed> {
977-
const_
978-
.eval(cx.tcx, ParamEnv::reveal_all(), DUMMY_SP)
979-
.map_err(|e| match e {
980-
ErrorHandled::Reported(reported_error_info, _) => {
981-
Some(reported_error_info.into())
982-
}
983-
ErrorHandled::TooGeneric(_) => None,
984-
})
985-
.and_then(|(const_ty, const_val)| {
986-
assert!(const_ty.is_integral());
987-
P::from_scalar_int(const_val.try_to_scalar_int().ok_or(None)?).ok_or(None)
988-
})
989-
.map_err(|already_reported| {
990-
already_reported.unwrap_or_else(|| {
991-
cx.tcx
992-
.dcx()
993-
.err(format!("invalid value for Image const generic: {const_}"))
994-
})
987+
let (const_val, const_ty) = const_
988+
.try_to_valtree()
989+
.expect("expected monomorphic const in codegen");
990+
assert!(const_ty.is_integral());
991+
const_val
992+
.try_to_scalar_int()
993+
.and_then(P::from_scalar_int)
994+
.ok_or_else(|| {
995+
cx.tcx
996+
.dcx()
997+
.err(format!("invalid value for Image const generic: {const_}"))
995998
})
996999
}
9971000

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

+4-14
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use rustc_middle::ty::layout::LayoutOf;
2828
use rustc_middle::ty::{self, Ty};
2929
use rustc_span::Span;
3030
use rustc_target::abi::call::FnAbi;
31-
use rustc_target::abi::{Abi, Align, Scalar, Size, WrappingRange};
31+
use rustc_target::abi::{Align, BackendRepr, Scalar, Size, WrappingRange};
3232
use smallvec::SmallVec;
3333
use std::borrow::Cow;
3434
use std::cell::Cell;
@@ -1523,7 +1523,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
15231523
place.val.align,
15241524
);
15251525
OperandValue::Immediate(self.to_immediate(llval, place.layout))
1526-
} else if let Abi::ScalarPair(a, b) = place.layout.abi {
1526+
} else if let BackendRepr::ScalarPair(a, b) = place.layout.backend_repr {
15271527
let b_offset = a
15281528
.primitive()
15291529
.size(self)
@@ -2668,16 +2668,6 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
26682668
// ignore
26692669
}
26702670

2671-
fn instrprof_increment(
2672-
&mut self,
2673-
_fn_name: Self::Value,
2674-
_hash: Self::Value,
2675-
_num_counters: Self::Value,
2676-
_index: Self::Value,
2677-
) {
2678-
todo!()
2679-
}
2680-
26812671
fn call(
26822672
&mut self,
26832673
callee_ty: Self::Type,
@@ -3176,8 +3166,8 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
31763166

31773167
let layout = self.layout_of(ty);
31783168

3179-
let scalar = match layout.abi {
3180-
Abi::Scalar(scalar) => Some(scalar.primitive()),
3169+
let scalar = match layout.backend_repr {
3170+
BackendRepr::Scalar(scalar) => Some(scalar.primitive()),
31813171
_ => None,
31823172
};
31833173
let debug_printf_fmt = match (spec, scalar) {

crates/rustc_codegen_spirv/src/builder/intrinsics.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_codegen_ssa::mir::operand::OperandRef;
1313
use rustc_codegen_ssa::mir::place::PlaceRef;
1414
use rustc_codegen_ssa::traits::{BuilderMethods, IntrinsicCallBuilderMethods};
1515
use rustc_middle::ty::layout::LayoutOf;
16-
use rustc_middle::ty::{FnDef, Instance, ParamEnv, Ty, TyKind};
16+
use rustc_middle::ty::{FnDef, Instance, Ty, TyKind, TypingEnv};
1717
use rustc_middle::{bug, ty};
1818
use rustc_span::Span;
1919
use rustc_span::sym;
@@ -75,7 +75,7 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {
7575
llresult: Self::Value,
7676
_span: Span,
7777
) -> Result<(), ty::Instance<'tcx>> {
78-
let callee_ty = instance.ty(self.tcx, ParamEnv::reveal_all());
78+
let callee_ty = instance.ty(self.tcx, TypingEnv::fully_monomorphized());
7979

8080
let (def_id, fn_args) = match *callee_ty.kind() {
8181
FnDef(def_id, fn_args) => (def_id, fn_args),
@@ -85,7 +85,7 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {
8585
let sig = callee_ty.fn_sig(self.tcx);
8686
let sig = self
8787
.tcx
88-
.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), sig);
88+
.normalize_erasing_late_bound_regions(TypingEnv::fully_monomorphized(), sig);
8989
let arg_tys = sig.inputs();
9090
let name = self.tcx.item_name(def_id);
9191

crates/rustc_codegen_spirv/src/builder/mod.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ use rustc_errors::{Diag, DiagMessage};
2828
use rustc_middle::mir::coverage::CoverageKind;
2929
use rustc_middle::span_bug;
3030
use rustc_middle::ty::layout::{
31-
FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasParamEnv, HasTyCtxt, LayoutError, LayoutOfHelpers,
32-
TyAndLayout,
31+
FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasTyCtxt, HasTypingEnv, LayoutError,
32+
LayoutOfHelpers, TyAndLayout,
3333
};
34-
use rustc_middle::ty::{Instance, ParamEnv, Ty, TyCtxt};
34+
use rustc_middle::ty::{Instance, Ty, TyCtxt, TypingEnv};
3535
use rustc_span::Span;
3636
use rustc_span::def_id::DefId;
3737
use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode};
@@ -175,6 +175,10 @@ impl<'a, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'tcx> {
175175
todo!()
176176
}
177177

178+
fn get_dbg_loc(&self) -> Option<Self::DILocation> {
179+
None
180+
}
181+
178182
fn insert_reference_to_gdb_debug_scripts_section_global(&mut self) {
179183
todo!()
180184
}
@@ -264,9 +268,9 @@ impl<'a, 'tcx> BackendTypes for Builder<'a, 'tcx> {
264268
type DILocation = <CodegenCx<'tcx> as BackendTypes>::DILocation;
265269
}
266270

267-
impl<'a, 'tcx> HasParamEnv<'tcx> for Builder<'a, 'tcx> {
268-
fn param_env(&self) -> ParamEnv<'tcx> {
269-
self.cx.param_env()
271+
impl<'a, 'tcx> HasTypingEnv<'tcx> for Builder<'a, 'tcx> {
272+
fn typing_env(&self) -> TypingEnv<'tcx> {
273+
self.cx.typing_env()
270274
}
271275
}
272276

crates/rustc_codegen_spirv/src/codegen_cx/declare.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_middle::bug;
1616
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
1717
use rustc_middle::mir::mono::{Linkage, MonoItem, Visibility};
1818
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf};
19-
use rustc_middle::ty::{self, Instance, ParamEnv, TypeVisitableExt};
19+
use rustc_middle::ty::{self, Instance, TypeVisitableExt, TypingEnv};
2020
use rustc_span::Span;
2121
use rustc_span::def_id::DefId;
2222
use rustc_target::abi::Align;
@@ -257,7 +257,7 @@ impl<'tcx> CodegenCx<'tcx> {
257257
"get_static() should always hit the cache for statics defined in the same CGU, but did not for `{def_id:?}`"
258258
);
259259

260-
let ty = instance.ty(self.tcx, ParamEnv::reveal_all());
260+
let ty = instance.ty(self.tcx, TypingEnv::fully_monomorphized());
261261
let sym = self.tcx.symbol_name(instance).name;
262262
let span = self.tcx.def_span(def_id);
263263
let g = self.declare_global(span, self.layout_of(ty).spirv_type(span, self));
@@ -289,7 +289,7 @@ impl<'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'tcx> {
289289
symbol_name: &str,
290290
) {
291291
let instance = Instance::mono(self.tcx, def_id);
292-
let ty = instance.ty(self.tcx, ParamEnv::reveal_all());
292+
let ty = instance.ty(self.tcx, TypingEnv::fully_monomorphized());
293293
let span = self.tcx.def_span(def_id);
294294
let spvty = self.layout_of(ty).spirv_type(span, self);
295295
let linkage = match linkage {

crates/rustc_codegen_spirv/src/codegen_cx/entry.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ impl<'tcx> CodegenCx<'tcx> {
240240
if is_ref
241241
&& !value_layout
242242
.ty
243-
.is_freeze(self.tcx, ty::ParamEnv::reveal_all()) =>
243+
.is_freeze(self.tcx, ty::TypingEnv::fully_monomorphized()) =>
244244
{
245245
hir::Mutability::Mut
246246
}

0 commit comments

Comments
 (0)