Skip to content

Commit 8afae47

Browse files
eddybFirestar99
authored andcommitted
rustup: update to nightly-2024-04-24.
1 parent cf9c4c7 commit 8afae47

File tree

13 files changed

+151
-130
lines changed

13 files changed

+151
-130
lines changed

crates/rustc_codegen_spirv/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ use std::process::{Command, ExitCode};
1010
/// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/
1111
//const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml");
1212
const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain]
13-
channel = "nightly-2024-04-01"
13+
channel = "nightly-2024-04-24"
1414
components = ["rust-src", "rustc-dev", "llvm-tools"]
15-
# commit_hash = 805813650248c1a2f6f271460d728d1bb852d2a7"#;
15+
# commit_hash = 244da22fabd9fa677bbd0ac601a88e5ca6917526"#;
1616

1717
fn get_rustc_commit_hash() -> Result<String, Box<dyn Error>> {
1818
let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc"));

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

Lines changed: 64 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,13 +1451,13 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
14511451
return OperandRef::zero_sized(place.layout);
14521452
}
14531453

1454-
let val = if let Some(llextra) = place.llextra {
1455-
OperandValue::Ref(place.llval, Some(llextra), place.align)
1454+
let val = if place.val.llextra.is_some() {
1455+
OperandValue::Ref(place.val)
14561456
} else if self.cx.is_backend_immediate(place.layout) {
14571457
let llval = self.load(
14581458
place.layout.spirv_type(self.span(), self),
1459-
place.llval,
1460-
place.align,
1459+
place.val.llval,
1460+
place.val.align,
14611461
);
14621462
OperandValue::Immediate(self.to_immediate(llval, place.layout))
14631463
} else if let Abi::ScalarPair(a, b) = place.layout.abi {
@@ -1468,9 +1468,9 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
14681468

14691469
let mut load = |i, scalar: Scalar, align| {
14701470
let llptr = if i == 0 {
1471-
place.llval
1471+
place.val.llval
14721472
} else {
1473-
self.inbounds_ptradd(place.llval, self.const_usize(b_offset.bytes()))
1473+
self.inbounds_ptradd(place.val.llval, self.const_usize(b_offset.bytes()))
14741474
};
14751475
let load = self.load(
14761476
self.scalar_pair_element_backend_type(place.layout, i, false),
@@ -1481,11 +1481,11 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
14811481
};
14821482

14831483
OperandValue::Pair(
1484-
load(0, a, place.align),
1485-
load(1, b, place.align.restrict_for_offset(b_offset)),
1484+
load(0, a, place.val.align),
1485+
load(1, b, place.val.align.restrict_for_offset(b_offset)),
14861486
)
14871487
} else {
1488-
OperandValue::Ref(place.llval, None, place.align)
1488+
OperandValue::Ref(place.val)
14891489
};
14901490
OperandRef {
14911491
val,
@@ -1501,11 +1501,11 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
15011501
dest: PlaceRef<'tcx, Self::Value>,
15021502
) {
15031503
let zero = self.const_usize(0);
1504-
let start = dest.project_index(self, zero).llval;
1504+
let start = dest.project_index(self, zero).val.llval;
15051505

15061506
let elem_layout = dest.layout.field(self.cx(), 0);
15071507
let elem_ty = elem_layout.spirv_type(self.span(), self);
1508-
let align = dest.align.restrict_for_offset(elem_layout.size);
1508+
let align = dest.val.align.restrict_for_offset(elem_layout.size);
15091509

15101510
for i in 0..count {
15111511
let current = self.inbounds_gep(elem_ty, start, &[self.const_usize(i)]);
@@ -2834,12 +2834,13 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
28342834
// are decoded to values of this `enum`. For instructions that
28352835
// produce results, the result ID is the first `ID` value.
28362836
#[derive(Debug)]
2837-
enum Inst<'tcx, ID> {
2837+
enum Inst<ID> {
28382838
Bitcast(ID, ID),
28392839
CompositeExtract(ID, ID, u32),
2840-
InBoundsAccessChain(ID, ID, SpirvConst<'tcx, 'tcx>),
2840+
InBoundsAccessChain(ID, ID, u32),
28412841
Store(ID, ID),
28422842
Load(ID, ID),
2843+
CopyMemory(ID, ID),
28432844
Call(ID, ID, SmallVec<[ID; 4]>),
28442845

28452846
// HACK(eddyb) this only exists for better error reporting,
@@ -2882,14 +2883,17 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
28822883
match (inst.class.opcode, inst.result_id, &id_operands[..]) {
28832884
(Op::Bitcast, Some(r), &[x]) => Inst::Bitcast(r, x),
28842885
(Op::InBoundsAccessChain, Some(r), &[p, i]) => {
2885-
Inst::InBoundsAccessChain(
2886-
r,
2887-
p,
2888-
self.builder.lookup_const_by_id(i)?,
2889-
)
2886+
if let Some(SpirvConst::U32(i)) =
2887+
self.builder.lookup_const_by_id(i)
2888+
{
2889+
Inst::InBoundsAccessChain(r, p, i)
2890+
} else {
2891+
Inst::Unsupported(inst.class.opcode)
2892+
}
28902893
}
28912894
(Op::Store, None, &[p, v]) => Inst::Store(p, v),
28922895
(Op::Load, Some(r), &[p]) => Inst::Load(r, p),
2896+
(Op::CopyMemory, None, &[a, b]) => Inst::CopyMemory(a, b),
28932897
(Op::FunctionCall, Some(r), [f, args @ ..]) => {
28942898
Inst::Call(r, *f, args.iter().copied().collect())
28952899
}
@@ -2989,46 +2993,50 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
29892993
};
29902994
require_local_var(rt_args_array_ptr_id, "[fmt::rt::Argument; N]")?;
29912995

2992-
// Each runtime argument has 3 instructions to call one of
2993-
// the `fmt::rt::Argument::new_*` functions (and split its
2994-
// scalar pair result), and 5 instructions to store it into
2995-
// the appropriate slot in the array. The groups of 3 and 5
2996+
// Each runtime argument has 4 instructions to call one of
2997+
// the `fmt::rt::Argument::new_*` functions (and temporarily
2998+
// store its result), and 4 instructions to copy it into
2999+
// the appropriate slot in the array. The groups of 4 and 4
29963000
// instructions, for all runtime args, are each separate.
2997-
let stores_to_rt_args_array =
2998-
try_rev_take(rt_args_count * 5).ok_or_else(|| {
3001+
let copies_to_rt_args_array =
3002+
try_rev_take(rt_args_count * 4).ok_or_else(|| {
29993003
FormatArgsNotRecognized(
3000-
"[fmt::rt::Argument; N] stores: ran out of instructions".into(),
3004+
"[fmt::rt::Argument; N] copies: ran out of instructions".into(),
30013005
)
30023006
})?;
3003-
let stores_to_rt_args_array = stores_to_rt_args_array.chunks(5);
3004-
let rt_arg_new_calls = try_rev_take(rt_args_count * 3).ok_or_else(|| {
3007+
let copies_to_rt_args_array = copies_to_rt_args_array.chunks(4);
3008+
let rt_arg_new_calls = try_rev_take(rt_args_count * 4).ok_or_else(|| {
30053009
FormatArgsNotRecognized(
30063010
"fmt::rt::Argument::new calls: ran out of instructions".into(),
30073011
)
30083012
})?;
3009-
let rt_arg_new_calls = rt_arg_new_calls.chunks(3);
3013+
let rt_arg_new_calls = rt_arg_new_calls.chunks(4);
30103014

3011-
for (rt_arg_idx, (rt_arg_new_call_insts, store_to_rt_args_array_insts)) in
3012-
rt_arg_new_calls.zip(stores_to_rt_args_array).enumerate()
3015+
for (rt_arg_idx, (rt_arg_new_call_insts, copy_to_rt_args_array_insts)) in
3016+
rt_arg_new_calls.zip(copies_to_rt_args_array).enumerate()
30133017
{
3014-
let (a, b) = match rt_arg_new_call_insts[..] {
3018+
let call_ret_slot_ptr = match rt_arg_new_call_insts[..] {
30153019
[
30163020
Inst::Call(call_ret_id, callee_id, ref call_args),
3017-
Inst::CompositeExtract(a, a_parent_pair, 0),
3018-
Inst::CompositeExtract(b, b_parent_pair, 1),
3019-
] if [a_parent_pair, b_parent_pair] == [call_ret_id; 2] => self
3020-
.fmt_rt_arg_new_fn_ids_to_ty_and_spec
3021-
.borrow()
3022-
.get(&callee_id)
3023-
.and_then(|&(ty, spec)| match call_args[..] {
3024-
[x] => {
3025-
decoded_format_args
3026-
.ref_arg_ids_with_ty_and_spec
3027-
.push((x, ty, spec));
3028-
Some((a, b))
3029-
}
3030-
_ => None,
3031-
}),
3021+
Inst::InBoundsAccessChain(tmp_slot_field_ptr, tmp_slot_ptr, 0),
3022+
Inst::CompositeExtract(field, wrapper_newtype, 0),
3023+
Inst::Store(st_dst_ptr, st_val),
3024+
] if wrapper_newtype == call_ret_id
3025+
&& (st_dst_ptr, st_val) == (tmp_slot_field_ptr, field) =>
3026+
{
3027+
self.fmt_rt_arg_new_fn_ids_to_ty_and_spec
3028+
.borrow()
3029+
.get(&callee_id)
3030+
.and_then(|&(ty, spec)| match call_args[..] {
3031+
[x] => {
3032+
decoded_format_args
3033+
.ref_arg_ids_with_ty_and_spec
3034+
.push((x, ty, spec));
3035+
Some(tmp_slot_ptr)
3036+
}
3037+
_ => None,
3038+
})
3039+
}
30323040
_ => None,
30333041
}
30343042
.ok_or_else(|| {
@@ -3037,25 +3045,20 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
30373045
))
30383046
})?;
30393047

3040-
match store_to_rt_args_array_insts[..] {
3048+
match copy_to_rt_args_array_insts[..] {
30413049
[
3042-
Inst::InBoundsAccessChain(
3043-
array_slot_ptr,
3044-
array_base_ptr,
3045-
SpirvConst::U32(array_idx),
3046-
),
3047-
Inst::InBoundsAccessChain(a_ptr, a_base_ptr, SpirvConst::U32(0)),
3048-
Inst::Store(a_st_dst, a_st_val),
3049-
Inst::InBoundsAccessChain(b_ptr, b_base_ptr, SpirvConst::U32(1)),
3050-
Inst::Store(b_st_dst, b_st_val),
3051-
] if array_base_ptr == rt_args_array_ptr_id
3050+
Inst::InBoundsAccessChain(array_slot, array_base, array_idx),
3051+
Inst::InBoundsAccessChain(dst_field_ptr, dst_base_ptr, 0),
3052+
Inst::InBoundsAccessChain(src_field_ptr, src_base_ptr, 0),
3053+
Inst::CopyMemory(copy_dst, copy_src),
3054+
] if array_base == rt_args_array_ptr_id
30523055
&& array_idx as usize == rt_arg_idx
3053-
&& [a_base_ptr, b_base_ptr] == [array_slot_ptr; 2]
3054-
&& (a, b) == (a_st_val, b_st_val)
3055-
&& (a_ptr, b_ptr) == (a_st_dst, b_st_dst) => {}
3056+
&& dst_base_ptr == array_slot
3057+
&& src_base_ptr == call_ret_slot_ptr
3058+
&& (copy_dst, copy_src) == (dst_field_ptr, src_field_ptr) => {}
30563059
_ => {
30573060
return Err(FormatArgsNotRecognized(format!(
3058-
"[fmt::rt::Argument; N] stores sequence ({store_to_rt_args_array_insts:?})"
3061+
"[fmt::rt::Argument; N] copies sequence ({copy_to_rt_args_array_insts:?})"
30593062
)));
30603063
}
30613064
}

crates/rustc_codegen_spirv/src/builder/intrinsics.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ impl Builder<'_, '_> {
4646
let (mask_sign, mask_value) = match width {
4747
32 => (
4848
self.constant_u32(self.span(), 1 << 31),
49-
self.constant_u32(self.span(), u32::max_value() >> 1),
49+
self.constant_u32(self.span(), u32::MAX >> 1),
5050
),
5151
64 => (
5252
self.constant_u64(self.span(), 1 << 63),
53-
self.constant_u64(self.span(), u64::max_value() >> 1),
53+
self.constant_u64(self.span(), u64::MAX >> 1),
5454
),
5555
_ => bug!("copysign must have width 32 or 64, not {}", width),
5656
};
@@ -106,7 +106,7 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> {
106106
let layout = self.layout_of(fn_args.type_at(0));
107107
let load = self.volatile_load(layout.spirv_type(self.span(), self), ptr);
108108
if !result.layout.is_zst() {
109-
self.store(load, result.llval, result.align);
109+
self.store(load, result.val.llval, result.val.align);
110110
}
111111
return Ok(());
112112
}

crates/rustc_codegen_spirv/src/builder/spirv_asm.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
488488
if let Some(OutRegister::Place(place)) = out_register {
489489
self.emit()
490490
.store(
491-
place.llval.def(self),
491+
place.val.llval.def(self),
492492
result_id.unwrap(),
493493
None,
494494
std::iter::empty(),
@@ -946,14 +946,14 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
946946
} => {
947947
self.check_reg(span, reg);
948948
match place {
949-
Some(place) => match self.lookup_type(place.llval.ty) {
949+
Some(place) => match self.lookup_type(place.val.llval.ty) {
950950
SpirvType::Pointer { pointee } => Some(pointee),
951951
other => {
952952
self.tcx.dcx().span_err(
953953
span,
954954
format!(
955955
"out register type not pointer: {}",
956-
other.debug(place.llval.ty, self)
956+
other.debug(place.val.llval.ty, self)
957957
),
958958
);
959959
None

crates/rustc_codegen_spirv/src/codegen_cx/constant.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ impl<'tcx> CodegenCx<'tcx> {
2020
self.def_constant(ty, SpirvConst::U32(val as u32))
2121
}
2222

23+
pub fn constant_i8(&self, span: Span, val: i8) -> SpirvValue {
24+
let ty = SpirvType::Integer(8, true).def(span, self);
25+
self.def_constant(ty, SpirvConst::U32(val as u32))
26+
}
27+
2328
pub fn constant_i16(&self, span: Span, val: i16) -> SpirvValue {
2429
let ty = SpirvType::Integer(16, true).def(span, self);
2530
self.def_constant(ty, SpirvConst::U32(val as u32))
@@ -156,6 +161,9 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
156161
fn const_bool(&self, val: bool) -> Self::Value {
157162
self.constant_bool(DUMMY_SP, val)
158163
}
164+
fn const_i8(&self, i: i8) -> Self::Value {
165+
self.constant_i8(DUMMY_SP, i)
166+
}
159167
fn const_i16(&self, i: i16) -> Self::Value {
160168
self.constant_i16(DUMMY_SP, i)
161169
}
@@ -243,7 +251,7 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
243251
match scalar {
244252
Scalar::Int(int) => {
245253
assert_eq!(int.size(), layout.primitive().size(self));
246-
let data = int.to_bits(int.size()).unwrap();
254+
let data = int.assert_uint(int.size());
247255

248256
match layout.primitive() {
249257
Primitive::Int(int_size, int_signedness) => match self.lookup_type(ty) {

crates/rustc_codegen_spirv/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@ impl WriteBackendMethods for SpirvCodegenBackend {
359359
object: Some(path),
360360
dwarf_object: None,
361361
bytecode: None,
362+
assembly: None,
363+
llvm_ir: None,
362364
})
363365
}
364366

crates/rustc_codegen_spirv/src/linker/test.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,27 @@ fn link_with_linker_opts(
122122
// is really a silent unwinding device, that should be treated the same as
123123
// `Err(ErrorGuaranteed)` returns from `link`).
124124
rustc_driver::catch_fatal_errors(|| {
125+
rustc_data_structures::jobserver::initialize_checked(|err| {
126+
unreachable!("jobserver error: {err}");
127+
});
128+
125129
let mut early_dcx =
126130
rustc_session::EarlyDiagCtxt::new(rustc_session::config::ErrorOutputType::default());
127-
early_dcx.initialize_checked_jobserver();
128131
let matches =
129132
rustc_driver::handle_options(&early_dcx, &["".to_string(), "x.rs".to_string()])
130133
.unwrap();
131134
let sopts = rustc_session::config::build_session_options(&mut early_dcx, &matches);
132135

133-
rustc_span::create_session_globals_then(sopts.edition, || {
136+
let target = "spirv-unknown-spv1.0"
137+
.parse::<crate::target::SpirvTarget>()
138+
.unwrap()
139+
.rustc_target();
140+
let sm_inputs = rustc_span::source_map::SourceMapInputs {
141+
file_loader: Box::new(rustc_span::source_map::RealFileLoader),
142+
path_mapping: sopts.file_path_mapping(),
143+
hash_kind: sopts.unstable_opts.src_hash_algorithm(&target),
144+
};
145+
rustc_span::create_session_globals_then(sopts.edition, Some(sm_inputs), || {
134146
let mut sess = rustc_session::build_session(
135147
early_dcx,
136148
sopts,
@@ -147,11 +159,7 @@ fn link_with_linker_opts(
147159
Registry::new(&[]),
148160
Default::default(),
149161
Default::default(),
150-
Default::default(),
151-
"spirv-unknown-spv1.0"
152-
.parse::<crate::target::SpirvTarget>()
153-
.unwrap()
154-
.rustc_target(),
162+
target,
155163
Default::default(),
156164
rustc_interface::util::rustc_version_str().unwrap_or("unknown"),
157165
Default::default(),

examples/runners/ash/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ impl RenderCtx {
941941
let present_index = unsafe {
942942
match self.base.swapchain_loader.acquire_next_image(
943943
self.swapchain,
944-
std::u64::MAX,
944+
u64::MAX,
945945
self.sync.present_complete_semaphore,
946946
vk::Fence::null(),
947947
) {
@@ -1058,7 +1058,7 @@ impl RenderCtx {
10581058
unsafe {
10591059
self.base
10601060
.device
1061-
.wait_for_fences(&[self.sync.draw_commands_reuse_fence], true, std::u64::MAX)
1061+
.wait_for_fences(&[self.sync.draw_commands_reuse_fence], true, u64::MAX)
10621062
.expect("Wait for fence failed.");
10631063

10641064
self.base

rust-toolchain.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[toolchain]
2-
channel = "nightly-2024-04-01"
2+
channel = "nightly-2024-04-24"
33
components = ["rust-src", "rustc-dev", "llvm-tools"]
4-
# commit_hash = 805813650248c1a2f6f271460d728d1bb852d2a7
4+
# commit_hash = 244da22fabd9fa677bbd0ac601a88e5ca6917526
55

66
# Whenever changing the nightly channel, update the commit hash above, and make
77
# sure to change `REQUIRED_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` also.

0 commit comments

Comments
 (0)