Skip to content

Commit 3930056

Browse files
committed
rustup: update to nightly-2025-03-29 (~1.87).
1 parent f9c818d commit 3930056

20 files changed

+196
-109
lines changed

crates/rustc_codegen_spirv/build.rs

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ use std::{env, fs, mem};
1818
/// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/
1919
//const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml");
2020
const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain]
21-
channel = "nightly-2025-02-16"
21+
channel = "nightly-2025-03-29"
2222
components = ["rust-src", "rustc-dev", "llvm-tools"]
23-
# commit_hash = 9cd60bd2ccc41bc898d2ad86728f14035d2df72d"#;
23+
# commit_hash = 920d95eaf23d7eb6b415d09868e4f793024fa604"#;
2424

2525
fn rustc_output(arg: &str) -> Result<String, Box<dyn Error>> {
2626
let rustc = env::var("RUSTC").unwrap_or_else(|_| "rustc".into());
@@ -159,9 +159,9 @@ fn generate_pqp_cg_ssa() -> Result<(), Box<dyn Error>> {
159159
}
160160
}
161161

162-
// HACK(eddyb) remove `windows` dependency (from MSVC linker output
163-
// parsing, which `rustc_codegen_spirv` will never invoke anyway).
164162
if relative_path == Path::new("src/back/link.rs") {
163+
// HACK(eddyb) remove `windows` dependency (from MSVC linker output
164+
// parsing, which `rustc_codegen_spirv` will never invoke anyway).
165165
src = src.replace(
166166
"#[cfg(not(windows))]
167167
fn escape_linker_output(",
@@ -179,6 +179,33 @@ mod win {",
179179
"#[cfg(any())]
180180
mod win {",
181181
);
182+
// HACK(eddyb) remove `object` dependency (for Windows `raw_dylib`
183+
// handling, which `rustc_codegen_spirv` will never invoke anyway).
184+
src = src.replace("mod raw_dylib;", "// mod raw_dylib;");
185+
src = src.replace(
186+
"
187+
for output_path in raw_dylib::",
188+
"
189+
#[cfg(any())]
190+
for output_path in raw_dylib::",
191+
);
192+
src = src.replace(
193+
"
194+
for link_path in raw_dylib::",
195+
"
196+
#[cfg(any())]
197+
for link_path in raw_dylib::",
198+
);
199+
}
200+
if relative_path == Path::new("src/back/metadata.rs") {
201+
// HACK(eddyb) remove `object` dependency.
202+
src = src.replace("
203+
pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static>> {","
204+
pub(crate) fn create_object_file(_: &Session) -> Option<write::Object<'static>> {
205+
None
206+
}
207+
#[cfg(any())]
208+
pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static>> {");
182209
}
183210

184211
// HACK(eddyb) "typed alloca" patches.
@@ -259,6 +286,9 @@ mod win {",
259286
println!("cargo::warning={line}");
260287
}
261288
println!("cargo::warning=");
289+
290+
// HACK(eddyb) allow the warning to be cleared after `lib.rs` is fixed.
291+
println!("cargo:rerun-if-changed=src/lib.rs");
262292
}
263293

264294
// HACK(eddyb) write a file that can be `include!`d from `lib.rs`.

crates/rustc_codegen_spirv/src/abi.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use itertools::Itertools;
88
use rspirv::spirv::{Dim, ImageFormat, StorageClass, Word};
99
use rustc_abi::ExternAbi as Abi;
1010
use rustc_abi::{
11-
Align, BackendRepr, FieldsShape, LayoutData, Primitive, ReprFlags, ReprOptions, Scalar, Size,
12-
TagEncoding, VariantIdx, Variants,
11+
Align, BackendRepr, FieldIdx, FieldsShape, LayoutData, Primitive, ReprFlags, ReprOptions,
12+
Scalar, Size, TagEncoding, VariantIdx, Variants,
1313
};
1414
use rustc_data_structures::fx::FxHashMap;
1515
use rustc_errors::ErrorGuaranteed;
@@ -106,6 +106,7 @@ pub(crate) fn provide(providers: &mut Providers) {
106106
ref variants,
107107
backend_repr,
108108
largest_niche,
109+
uninhabited,
109110
align,
110111
size,
111112
max_repr_align,
@@ -153,6 +154,7 @@ pub(crate) fn provide(providers: &mut Providers) {
153154
},
154155
backend_repr,
155156
largest_niche,
157+
uninhabited,
156158
align,
157159
size,
158160
max_repr_align,
@@ -201,7 +203,7 @@ pub(crate) fn provide(providers: &mut Providers) {
201203
let trivial_struct = match tcx.hir_node_by_def_id(def_id) {
202204
rustc_hir::Node::Item(item) => match item.kind {
203205
rustc_hir::ItemKind::Struct(
204-
_,
206+
..,
205207
&rustc_hir::Generics {
206208
params:
207209
&[]
@@ -465,7 +467,7 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {
465467
// `ScalarPair`.
466468
// There's a few layers that we go through here. First we inspect layout.backend_repr, then if relevant, layout.fields, etc.
467469
match self.backend_repr {
468-
BackendRepr::Uninhabited => SpirvType::Adt {
470+
_ if self.uninhabited => SpirvType::Adt {
469471
def_id: def_id_for_spirv_type_adt(*self),
470472
size: Some(Size::ZERO),
471473
align: Align::from_bytes(0).unwrap(),
@@ -526,7 +528,7 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {
526528
if let TyKind::Adt(adt, _) = self.ty.kind() {
527529
if let Variants::Single { index } = self.variants {
528530
for i in self.fields.index_by_increasing_offset() {
529-
let field = &adt.variants()[index].fields[i.into()];
531+
let field = &adt.variants()[index].fields[FieldIdx::new(i)];
530532
field_names.push(field.name);
531533
}
532534
}
@@ -545,7 +547,7 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {
545547
}
546548
.def_with_name(cx, span, TyLayoutNameKey::from(*self))
547549
}
548-
BackendRepr::Vector { element, count } => {
550+
BackendRepr::SimdVector { element, count } => {
549551
let elem_spirv = trans_scalar(cx, span, *self, element, Size::ZERO);
550552
SpirvType::Vector {
551553
element: elem_spirv,
@@ -815,7 +817,7 @@ fn trans_struct<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>) -
815817
field_offsets.push(offset);
816818
if let Variants::Single { index } = ty.variants {
817819
if let TyKind::Adt(adt, _) = ty.ty.kind() {
818-
let field = &adt.variants()[index].fields[i.into()];
820+
let field = &adt.variants()[index].fields[FieldIdx::new(i)];
819821
field_names.push(field.name);
820822
} else {
821823
// FIXME(eddyb) this looks like something that should exist in rustc.

crates/rustc_codegen_spirv/src/attr.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ fn target_from_impl_item(tcx: TyCtxt<'_>, impl_item: &hir::ImplItem<'_>) -> Targ
253253
match impl_item.kind {
254254
hir::ImplItemKind::Const(..) => Target::AssocConst,
255255
hir::ImplItemKind::Fn(..) => {
256-
let parent_owner_id = tcx.hir().get_parent_item(impl_item.hir_id());
257-
let containing_item = tcx.hir().expect_item(parent_owner_id.def_id);
256+
let parent_owner_id = tcx.hir_get_parent_item(impl_item.hir_id());
257+
let containing_item = tcx.hir_expect_item(parent_owner_id.def_id);
258258
let containing_impl_is_for_trait = match &containing_item.kind {
259259
hir::ItemKind::Impl(hir::Impl { of_trait, .. }) => of_trait.is_some(),
260260
_ => unreachable!("parent of an ImplItem must be an Impl"),
@@ -280,7 +280,7 @@ impl CheckSpirvAttrVisitor<'_> {
280280

281281
let parse_attrs = |attrs| crate::symbols::parse_attrs_for_checking(&self.sym, attrs);
282282

283-
let attrs = self.tcx.hir().attrs(hir_id);
283+
let attrs = self.tcx.hir_attrs(hir_id);
284284
for parse_attr_result in parse_attrs(attrs) {
285285
let (span, parsed_attr) = match parse_attr_result {
286286
Ok(span_and_parsed_attr) => span_and_parsed_attr,
@@ -326,10 +326,9 @@ impl CheckSpirvAttrVisitor<'_> {
326326
| SpirvAttribute::SpecConstant(_) => match target {
327327
Target::Param => {
328328
let parent_hir_id = self.tcx.parent_hir_id(hir_id);
329-
let parent_is_entry_point =
330-
parse_attrs(self.tcx.hir().attrs(parent_hir_id))
331-
.filter_map(|r| r.ok())
332-
.any(|(_, attr)| matches!(attr, SpirvAttribute::Entry(_)));
329+
let parent_is_entry_point = parse_attrs(self.tcx.hir_attrs(parent_hir_id))
330+
.filter_map(|r| r.ok())
331+
.any(|(_, attr)| matches!(attr, SpirvAttribute::Entry(_)));
333332
if !parent_is_entry_point {
334333
self.tcx.dcx().span_err(
335334
span,
@@ -417,8 +416,8 @@ impl CheckSpirvAttrVisitor<'_> {
417416
impl<'tcx> Visitor<'tcx> for CheckSpirvAttrVisitor<'tcx> {
418417
type NestedFilter = nested_filter::OnlyBodies;
419418

420-
fn nested_visit_map(&mut self) -> Self::Map {
421-
self.tcx.hir()
419+
fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
420+
self.tcx
422421
}
423422

424423
fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
@@ -497,8 +496,7 @@ fn check_mod_attrs(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) {
497496
tcx,
498497
sym: Symbols::get(),
499498
};
500-
tcx.hir()
501-
.visit_item_likes_in_module(module_def_id, check_spirv_attr_visitor);
499+
tcx.hir_visit_item_likes_in_module(module_def_id, check_spirv_attr_visitor);
502500
if module_def_id.is_top_level_module() {
503501
check_spirv_attr_visitor.check_spirv_attributes(CRATE_HIR_ID, Target::Mod);
504502
}

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1851,7 +1851,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
18511851
place.val.llval,
18521852
place.val.align,
18531853
);
1854-
OperandValue::Immediate(self.to_immediate(llval, place.layout))
1854+
OperandValue::Immediate(llval)
18551855
} else if let BackendRepr::ScalarPair(a, b) = place.layout.backend_repr {
18561856
let b_offset = a
18571857
.primitive()

crates/rustc_codegen_spirv/src/builder/intrinsics.rs

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,10 @@ impl Builder<'_, '_> {
4646
),
4747
};
4848
let int_ty = SpirvType::Integer(width, false).def(self.span(), self);
49-
let (mask_sign, mask_value) = match width {
50-
32 => (
51-
self.constant_u32(self.span(), 1 << 31),
52-
self.constant_u32(self.span(), u32::MAX >> 1),
53-
),
54-
64 => (
55-
self.constant_u64(self.span(), 1 << 63),
56-
self.constant_u64(self.span(), u64::MAX >> 1),
57-
),
58-
_ => bug!("copysign must have width 32 or 64, not {}", width),
49+
let [mask_sign, mask_value] = {
50+
let sign_bit = 1u128.checked_shl(width - 1).unwrap();
51+
let value_mask = sign_bit - 1;
52+
[sign_bit, value_mask].map(|v| self.constant_int(int_ty, v))
5953
};
6054
let val_bits = self.bitcast(val, int_ty);
6155
let sign_bits = self.bitcast(sign, int_ty);
@@ -154,30 +148,44 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {
154148
result
155149
}
156150

157-
sym::sqrtf32 | sym::sqrtf64 => self.gl_op(GLOp::Sqrt, ret_ty, [args[0].immediate()]),
158-
sym::powif32 | sym::powif64 => {
151+
sym::sqrtf32 | sym::sqrtf64 | sym::sqrtf128 => {
152+
self.gl_op(GLOp::Sqrt, ret_ty, [args[0].immediate()])
153+
}
154+
sym::powif32 | sym::powif64 | sym::powif128 => {
159155
let float = self.sitofp(args[1].immediate(), args[0].immediate().ty);
160156
self.gl_op(GLOp::Pow, ret_ty, [args[0].immediate(), float])
161157
}
162-
sym::sinf32 | sym::sinf64 => self.gl_op(GLOp::Sin, ret_ty, [args[0].immediate()]),
163-
sym::cosf32 | sym::cosf64 => self.gl_op(GLOp::Cos, ret_ty, [args[0].immediate()]),
164-
sym::powf32 | sym::powf64 => self.gl_op(
158+
sym::sinf32 | sym::sinf64 | sym::sinf128 => {
159+
self.gl_op(GLOp::Sin, ret_ty, [args[0].immediate()])
160+
}
161+
sym::cosf32 | sym::cosf64 | sym::cosf128 => {
162+
self.gl_op(GLOp::Cos, ret_ty, [args[0].immediate()])
163+
}
164+
sym::powf32 | sym::powf64 | sym::powf128 => self.gl_op(
165165
GLOp::Pow,
166166
ret_ty,
167167
[args[0].immediate(), args[1].immediate()],
168168
),
169-
sym::expf32 | sym::expf64 => self.gl_op(GLOp::Exp, ret_ty, [args[0].immediate()]),
170-
sym::exp2f32 | sym::exp2f64 => self.gl_op(GLOp::Exp2, ret_ty, [args[0].immediate()]),
171-
sym::logf32 | sym::logf64 => self.gl_op(GLOp::Log, ret_ty, [args[0].immediate()]),
172-
sym::log2f32 | sym::log2f64 => self.gl_op(GLOp::Log2, ret_ty, [args[0].immediate()]),
173-
sym::log10f32 | sym::log10f64 => {
169+
sym::expf32 | sym::expf64 | sym::expf128 => {
170+
self.gl_op(GLOp::Exp, ret_ty, [args[0].immediate()])
171+
}
172+
sym::exp2f32 | sym::exp2f64 | sym::exp2f128 => {
173+
self.gl_op(GLOp::Exp2, ret_ty, [args[0].immediate()])
174+
}
175+
sym::logf32 | sym::logf64 | sym::logf128 => {
176+
self.gl_op(GLOp::Log, ret_ty, [args[0].immediate()])
177+
}
178+
sym::log2f32 | sym::log2f64 | sym::log2f128 => {
179+
self.gl_op(GLOp::Log2, ret_ty, [args[0].immediate()])
180+
}
181+
sym::log10f32 | sym::log10f64 | sym::log10f128 => {
174182
// spir-v glsl doesn't have log10, so,
175183
// log10(x) == (1 / ln(10)) * ln(x)
176184
let mul = self.constant_float(args[0].immediate().ty, 1.0 / 10.0f64.ln());
177185
let ln = self.gl_op(GLOp::Log, ret_ty, [args[0].immediate()]);
178186
self.fmul(mul, ln)
179187
}
180-
sym::fmaf32 | sym::fmaf64 => self.gl_op(
188+
sym::fmaf32 | sym::fmaf64 | sym::fmaf128 => self.gl_op(
181189
GLOp::Fma,
182190
ret_ty,
183191
[
@@ -186,30 +194,37 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {
186194
args[2].immediate(),
187195
],
188196
),
189-
sym::fabsf32 | sym::fabsf64 => self.gl_op(GLOp::FAbs, ret_ty, [args[0].immediate()]),
190-
sym::minnumf32 | sym::minnumf64 => self.gl_op(
197+
sym::fabsf32 | sym::fabsf64 | sym::fabsf128 => {
198+
self.gl_op(GLOp::FAbs, ret_ty, [args[0].immediate()])
199+
}
200+
sym::minnumf32 | sym::minnumf64 | sym::minnumf128 => self.gl_op(
191201
GLOp::FMin,
192202
ret_ty,
193203
[args[0].immediate(), args[1].immediate()],
194204
),
195-
sym::maxnumf32 | sym::maxnumf64 => self.gl_op(
205+
sym::maxnumf32 | sym::maxnumf64 | sym::maxnumf128 => self.gl_op(
196206
GLOp::FMax,
197207
ret_ty,
198208
[args[0].immediate(), args[1].immediate()],
199209
),
200-
sym::copysignf32 | sym::copysignf64 => {
210+
sym::copysignf32 | sym::copysignf64 | sym::copysignf128 => {
201211
let val = args[0].immediate();
202212
let sign = args[1].immediate();
203213
self.copysign(val, sign)
204214
}
205-
sym::floorf32 | sym::floorf64 => self.gl_op(GLOp::Floor, ret_ty, [args[0].immediate()]),
206-
sym::ceilf32 | sym::ceilf64 => self.gl_op(GLOp::Ceil, ret_ty, [args[0].immediate()]),
207-
sym::truncf32 | sym::truncf64 => self.gl_op(GLOp::Trunc, ret_ty, [args[0].immediate()]),
208-
sym::rintf32 | sym::rintf64 => {
215+
sym::floorf32 | sym::floorf64 | sym::floorf128 => {
216+
self.gl_op(GLOp::Floor, ret_ty, [args[0].immediate()])
217+
}
218+
sym::ceilf32 | sym::ceilf64 | sym::ceilf128 => {
219+
self.gl_op(GLOp::Ceil, ret_ty, [args[0].immediate()])
220+
}
221+
sym::truncf32 | sym::truncf64 | sym::truncf128 => {
222+
self.gl_op(GLOp::Trunc, ret_ty, [args[0].immediate()])
223+
}
224+
sym::round_ties_even_f32 | sym::round_ties_even_f64 | sym::round_ties_even_f128 => {
209225
self.gl_op(GLOp::RoundEven, ret_ty, [args[0].immediate()])
210226
}
211-
// TODO: Correctness of all these rounds
212-
sym::nearbyintf32 | sym::nearbyintf64 | sym::roundf32 | sym::roundf64 => {
227+
sym::roundf32 | sym::roundf64 | sym::roundf128 => {
213228
self.gl_op(GLOp::Round, ret_ty, [args[0].immediate()])
214229
}
215230

crates/rustc_codegen_spirv/src/builder/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl<'a, 'tcx> ArgAbiBuilderMethods<'tcx> for Builder<'a, 'tcx> {
260260
}
261261
}
262262

263-
impl<'a, 'tcx> AbiBuilderMethods<'tcx> for Builder<'a, 'tcx> {
263+
impl AbiBuilderMethods for Builder<'_, '_> {
264264
fn get_param(&mut self, index: usize) -> Self::Value {
265265
self.function_parameter_values.borrow()[&self.current_fn.def(self)][index]
266266
}

crates/rustc_codegen_spirv/src/codegen_cx/constant.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,13 @@ impl<'tcx> CodegenCx<'tcx> {
109109
}
110110
}
111111

112-
impl<'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'tcx> {
112+
impl ConstCodegenMethods for CodegenCx<'_> {
113113
fn const_null(&self, t: Self::Type) -> Self::Value {
114114
self.constant_null(t)
115115
}
116116
fn const_undef(&self, ty: Self::Type) -> Self::Value {
117117
self.undef(ty)
118118
}
119-
fn is_undef(&self, v: Self::Value) -> bool {
120-
matches!(self.builder.lookup_const(v), Some(SpirvConst::Undef))
121-
}
122119
fn const_poison(&self, ty: Self::Type) -> Self::Value {
123120
// No distinction between undef and poison.
124121
self.const_undef(ty)
@@ -319,7 +316,12 @@ impl<'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'tcx> {
319316
// the actual value generation until after a pointer to this value is cast
320317
// to its final type (e.g. that will be loaded as).
321318
// FIXME(eddyb) replace this with `qptr` handling of constant data.
322-
fn const_data_from_alloc(&self, alloc: ConstAllocation<'tcx>) -> Self::Value {
319+
fn const_data_from_alloc(&self, alloc: ConstAllocation<'_>) -> Self::Value {
320+
// HACK(eddyb) the `ConstCodegenMethods` trait no longer guarantees the
321+
// lifetime that `alloc` is interned for, but since it *is* interned,
322+
// we can cheaply recover it (see also the `ty::Lift` infrastructure).
323+
let alloc = self.tcx.lift(alloc).unwrap();
324+
323325
let void_type = SpirvType::Void.def(DUMMY_SP, self);
324326
self.def_constant(void_type, SpirvConst::ConstDataFromAlloc(alloc))
325327
}

crates/rustc_codegen_spirv/src/codegen_cx/entry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl<'tcx> CodegenCx<'tcx> {
8282
.span_err(span, format!("cannot declare {name} as an entry point"));
8383
return;
8484
};
85-
self.tcx.hir().body_owned_by(fn_local_def_id).params
85+
self.tcx.hir_body_owned_by(fn_local_def_id).params
8686
};
8787
for (arg_abi, hir_param) in fn_abi.args.iter().zip(hir_params) {
8888
match arg_abi.mode {
@@ -429,7 +429,7 @@ impl<'tcx> CodegenCx<'tcx> {
429429
call_args: &mut Vec<SpirvValue>,
430430
decoration_locations: &mut FxHashMap<StorageClass, u32>,
431431
) {
432-
let attrs = AggregatedSpirvAttributes::parse(self, self.tcx.hir().attrs(hir_param.hir_id));
432+
let attrs = AggregatedSpirvAttributes::parse(self, self.tcx.hir_attrs(hir_param.hir_id));
433433

434434
let EntryParamDeducedFromRustRefOrValue {
435435
value_layout,

0 commit comments

Comments
 (0)