Skip to content

Commit 2d0121c

Browse files
committed
Update to nightly-2024-06-20.
1 parent c3b732d commit 2d0121c

File tree

8 files changed

+46
-28
lines changed

8 files changed

+46
-28
lines changed

crates/rustc_codegen_spirv/build.rs

+2-2
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-05-20"
13+
channel = "nightly-2024-06-20"
1414
components = ["rust-src", "rustc-dev", "llvm-tools"]
15-
# commit_hash = d84b9037541f45dc2c52a41d723265af211c0497"#;
15+
# commit_hash = d8a38b00024cd7156dea4ce8fd8ae113a2745e7f"#;
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/abi.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use rustc_middle::query::Providers;
1212
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout};
1313
use rustc_middle::ty::GenericArgsRef;
1414
use rustc_middle::ty::{
15-
self, Const, CoroutineArgs, FloatTy, IntTy, ParamEnv, PolyFnSig, Ty, TyCtxt, TyKind, UintTy,
15+
self, Const, CoroutineArgs, CoroutineArgsExt, FloatTy, IntTy, ParamEnv, PolyFnSig, Ty, TyCtxt,
16+
TyKind, UintTy,
1617
};
1718
use rustc_middle::{bug, span_bug};
1819
use rustc_span::def_id::DefId;
@@ -867,7 +868,10 @@ fn trans_intrinsic_type<'tcx>(
867868
cx: &CodegenCx<'tcx>,
868869
const_: Const<'tcx>,
869870
) -> Result<P, ErrorGuaranteed> {
870-
assert!(const_.ty().is_integral());
871+
assert!(
872+
matches!(const_.kind(), ty::ConstKind::Value(ty, _) if ty.is_integral()),
873+
"Expected an integral type"
874+
);
871875
let value = const_.eval_bits(cx.tcx, ParamEnv::reveal_all());
872876
match P::from_u128(value) {
873877
Some(v) => Ok(v),

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

+13-8
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
337337
let exit_bb = self.append_sibling_block("memset_exit");
338338

339339
let count = self.udiv(size_bytes, size_elem_const);
340-
let index = self.alloca(Size::from_bytes(size_bytes.ty), zero_align);
340+
let index = self.alloca(Size::from_bits(32), zero_align);
341341
self.store(zero, index, zero_align);
342342
self.br(header_bb);
343343

@@ -1412,10 +1412,15 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
14121412
fn to_immediate_scalar(&mut self, val: Self::Value, _scalar: Scalar) -> Self::Value {
14131413
val
14141414
}
1415+
fn alloca(&mut self, size: Size, _align: Align) -> Self::Value {
1416+
// Define a u32 type for the allocation.
1417+
let u32_type = SpirvType::Integer(32, false).def(rustc_span::DUMMY_SP, self.cx);
14151418

1416-
fn alloca(&mut self, ty: Size, _align: Align) -> Self::Value {
1417-
let ptr_ty = self.type_ptr_to(ty.bits_usize() as u32);
1418-
// "All OpVariable instructions in a function must be the first instructions in the first block."
1419+
// Define a pointer to the u32 type.
1420+
let ptr_ty = SpirvType::Pointer { pointee: u32_type }.def(rustc_span::DUMMY_SP, self.cx);
1421+
1422+
// "All OpVariable instructions in a function must be the first instructions in
1423+
// the first block."
14191424
let mut builder = self.emit();
14201425
builder.select_block(Some(0)).unwrap();
14211426
let index = {
@@ -1446,7 +1451,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
14461451
result_id.with_type(ptr_ty)
14471452
}
14481453

1449-
fn dynamic_alloca(&mut self, _size: Self::Value, _align: Align) -> Self::Value {
1454+
fn dynamic_alloca(&mut self, _len: Self::Value, _align: Align) -> Self::Value {
14501455
self.fatal("array alloca not supported yet")
14511456
}
14521457

@@ -3171,10 +3176,10 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
31713176
let debug_printf_fmt = match (spec, scalar) {
31723177
// FIXME(eddyb) support more of these,
31733178
// potentially recursing to print ADTs.
3174-
(' ' | '?', Some(Int(I32, false))) => "%u",
3179+
(' ' | '?', Some(Int(_i32, false))) => "%u",
31753180
('x', Some(Int(I32, false))) => "%x",
3176-
(' ' | '?', Some(Int(I32, true))) => "%i",
3177-
(' ' | '?', Some(F32)) => "%f",
3181+
(' ' | '?', Some(Int(_i32, true))) => "%i",
3182+
(' ' | '?', Some(_f32)) => "%f",
31783183

31793184
_ => "",
31803185
};

crates/rustc_codegen_spirv/src/codegen_cx/constant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
251251
match scalar {
252252
Scalar::Int(int) => {
253253
assert_eq!(int.size(), layout.primitive().size(self));
254-
let data = int.assert_uint(int.size());
254+
let data = int.to_uint(int.size());
255255

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

crates/rustc_codegen_spirv/src/codegen_cx/entry.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl<'tcx> CodegenCx<'tcx> {
8282
let body = self
8383
.tcx
8484
.hir()
85-
.body(self.tcx.hir().body_owned_by(fn_local_def_id));
85+
.body(self.tcx.hir().body_owned_by(fn_local_def_id).id());
8686
body.params
8787
};
8888
for (arg_abi, hir_param) in fn_abi.args.iter().zip(hir_params) {

crates/rustc_codegen_spirv/src/lib.rs

+13-11
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#![feature(assert_matches)]
2020
#![feature(result_flattening)]
2121
#![feature(lint_reasons)]
22-
#![feature(lazy_cell)]
2322
// crate-specific exceptions:
2423
#![allow(
2524
unsafe_code, // rustc_codegen_ssa requires unsafe functions in traits to be impl'd
@@ -98,13 +97,13 @@ use rustc_codegen_ssa::traits::{
9897
};
9998
use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleCodegen, ModuleKind};
10099
use rustc_data_structures::fx::FxIndexMap;
101-
use rustc_errors::{DiagCtxt, ErrorGuaranteed, FatalError};
100+
use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed, FatalError};
102101
use rustc_metadata::EncodedMetadata;
103102
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
104103
use rustc_middle::mir::mono::{MonoItem, MonoItemData};
105104
use rustc_middle::mir::pretty::write_mir_pretty;
106105
use rustc_middle::ty::print::with_no_trimmed_paths;
107-
use rustc_middle::ty::{self, Instance, InstanceDef, TyCtxt};
106+
use rustc_middle::ty::{self, Instance, InstanceKind, TyCtxt};
108107
use rustc_session::config::{self, OutputFilenames, OutputType};
109108
use rustc_session::Session;
110109
use rustc_span::symbol::{sym, Symbol};
@@ -120,7 +119,7 @@ fn dump_mir(tcx: TyCtxt<'_>, mono_items: &[(MonoItem<'_>, MonoItemData)], path:
120119
let mut file = File::create(path).unwrap();
121120
for &(mono_item, _) in mono_items {
122121
if let MonoItem::Fn(instance) = mono_item {
123-
if matches!(instance.def, InstanceDef::Item(_)) {
122+
if matches!(instance.def, InstanceKind::Item(_)) {
124123
let mut mir = Cursor::new(Vec::new());
125124
if write_mir_pretty(tcx, Some(instance.def_id()), &mut mir).is_ok() {
126125
writeln!(file, "{}", String::from_utf8(mir.into_inner()).unwrap()).unwrap();
@@ -136,7 +135,7 @@ fn is_blocklisted_fn<'tcx>(
136135
instance: Instance<'tcx>,
137136
) -> bool {
138137
// TODO: These sometimes have a constant value of an enum variant with a hole
139-
if let InstanceDef::Item(def_id) = instance.def {
138+
if let InstanceKind::Item(def_id) = instance.def {
140139
if let Some(debug_trait_def_id) = tcx.get_diagnostic_item(sym::Debug) {
141140
// Helper for detecting `<_ as core::fmt::Debug>::fmt` (in impls).
142141
let is_debug_fmt_method = |def_id| match tcx.opt_associated_item(def_id) {
@@ -185,6 +184,9 @@ impl ThinBufferMethods for SpirvThinBuffer {
185184
fn data(&self) -> &[u8] {
186185
spirv_tools::binary::from_binary(&self.0)
187186
}
187+
fn thin_link_data(&self) -> &[u8] {
188+
unimplemented!();
189+
}
188190
}
189191

190192
#[derive(Clone)]
@@ -277,7 +279,7 @@ impl WriteBackendMethods for SpirvCodegenBackend {
277279

278280
fn run_link(
279281
_cgcx: &CodegenContext<Self>,
280-
_diag_handler: &DiagCtxt,
282+
_diag_handler: DiagCtxtHandle<'_>,
281283
_modules: Vec<ModuleCodegen<Self::Module>>,
282284
) -> Result<ModuleCodegen<Self::Module>, FatalError> {
283285
todo!()
@@ -309,7 +311,7 @@ impl WriteBackendMethods for SpirvCodegenBackend {
309311

310312
unsafe fn optimize(
311313
_: &CodegenContext<Self>,
312-
_: &DiagCtxt,
314+
_: DiagCtxtHandle<'_>,
313315
_: &ModuleCodegen<Self::Module>,
314316
_: &ModuleConfig,
315317
) -> Result<(), FatalError> {
@@ -340,7 +342,7 @@ impl WriteBackendMethods for SpirvCodegenBackend {
340342

341343
unsafe fn codegen(
342344
cgcx: &CodegenContext<Self>,
343-
_diag_handler: &DiagCtxt,
345+
_diag_handler: DiagCtxtHandle<'_>,
344346
module: ModuleCodegen<Self::Module>,
345347
_config: &ModuleConfig,
346348
) -> Result<CompiledModule, FatalError> {
@@ -364,7 +366,7 @@ impl WriteBackendMethods for SpirvCodegenBackend {
364366
})
365367
}
366368

367-
fn prepare_thin(module: ModuleCodegen<Self::Module>) -> (String, Self::ThinBuffer) {
369+
fn prepare_thin(module: ModuleCodegen<Self::Module>, _want_summary: bool) -> (String, Self::ThinBuffer) {
368370
(module.name, SpirvThinBuffer(module.module_llvm))
369371
}
370372

@@ -484,8 +486,8 @@ pub fn __rustc_codegen_backend() -> Box<dyn CodegenBackend> {
484486
// Tweak rustc's default ICE panic hook, to direct people to `rust-gpu`.
485487
rustc_driver::install_ice_hook(
486488
"https://github.com/rust-gpu/rust-gpu/issues/new",
487-
|handler| {
488-
handler.note(concat!(
489+
|dcx| {
490+
dcx.handle().note(concat!(
489491
"`rust-gpu` version `",
490492
env!("CARGO_PKG_VERSION"),
491493
"`"

crates/rustc_codegen_spirv/src/linker/test.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use rspirv::dr::{Loader, Module};
33
use rustc_errors::registry::Registry;
44
use rustc_session::config::{Input, OutputFilenames, OutputTypes};
55
use rustc_session::CompilerIO;
6+
use rustc_session::parse::ParseSess;
67
use rustc_span::FileName;
78
use std::io::Write;
89
use std::sync::{Arc, Mutex};
@@ -169,7 +170,11 @@ fn link_with_linker_opts(
169170

170171
// HACK(eddyb) inject `write_diags` into `sess`, to work around
171172
// the removals in https://github.com/rust-lang/rust/pull/102992.
172-
sess.psess.dcx = {
173+
// HACK(legneato): This can be simplified to use `set_dcx()` when updating
174+
// to a rustc version containing
175+
// https://github.com/rust-lang/rust/commit/bde1f4dd57abd8e86dd7d7b325640558c4437d1f.
176+
let source_map = sess.psess.clone_source_map();
177+
let dcx = {
173178
let fallback_bundle = {
174179
extern crate rustc_error_messages;
175180
rustc_error_messages::fallback_fluent_bundle(
@@ -185,6 +190,8 @@ fn link_with_linker_opts(
185190
.with_flags(sess.opts.unstable_opts.dcx_flags(true))
186191
};
187192

193+
sess.psess = ParseSess::with_dcx(dcx, source_map);
194+
188195
let res = link(
189196
&sess,
190197
modules,

rust-toolchain.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[toolchain]
2-
channel = "nightly-2024-05-20"
2+
channel = "nightly-2024-06-20"
33
components = ["rust-src", "rustc-dev", "llvm-tools"]
4-
# commit_hash = d84b9037541f45dc2c52a41d723265af211c0497
4+
# commit_hash = d8a38b00024cd7156dea4ce8fd8ae113a2745e7f
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)