From e2bf67637643dfe0d8eab4cac7e2db9a0974736c Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sat, 3 Aug 2024 02:56:17 +0300 Subject: [PATCH 01/32] WIP: fix CHANGELOG (TODO: missing entries!). --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40a625a443..142529e30f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,13 +30,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Changed 🛠 +- [PR#1115](https://github.com/EmbarkStudios/rust-gpu/pull/1115) relaxed `glam` version requirements (from `>=0.22, <=0.24` to `>=0.22, <=0.25`) - [PR#1127](https://github.com/EmbarkStudios/rust-gpu/pull/1127) updated `spirv-tools` to `0.10.0`, which follows `vulkan-sdk-1.3.275` - [PR#1101](https://github.com/EmbarkStudios/rust-gpu/pull/1101) added `ignore` and `no_run` to documentation to make `cargo test` pass - [PR#1112](https://github.com/EmbarkStudios/rust-gpu/pull/1112) updated wgpu and winit in example runners - [PR#1100](https://github.com/EmbarkStudios/rust-gpu/pull/1100) updated toolchain to `nightly-2023-09-30` - [PR#1091](https://github.com/EmbarkStudios/rust-gpu/pull/1091) updated toolchain to `nightly-2023-08-29` - [PR#1085](https://github.com/EmbarkStudios/rust-gpu/pull/1085) updated toolchain to `nightly-2023-07-08` -- [PR#1115](https://github.com/EmbarkStudios/rust-gpu/pull/1115) relaxed `glam` version requirements (from `>=0.22, <=0.24` to `>=0.22, <=0.25`) ### Fixed 🩹 - [PR#1129](https://github.com/EmbarkStudios/rust-gpu/pull/1129) fixed [#1062](https://github.com/EmbarkStudios/rust-gpu/issues/1062) by not flipping the comparison of the rotate amount with zero From a0a75251b993eb5b32114b3eaa6bcb8746f0dc40 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sat, 3 Aug 2024 10:14:48 +0300 Subject: [PATCH 02/32] examples/shaders/shared: remove unused `feature(lang_items)`. --- examples/shaders/shared/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/shaders/shared/src/lib.rs b/examples/shaders/shared/src/lib.rs index 7fd5c04ab6..37979f4d7c 100644 --- a/examples/shaders/shared/src/lib.rs +++ b/examples/shaders/shared/src/lib.rs @@ -1,6 +1,6 @@ //! Ported to Rust from -#![cfg_attr(target_arch = "spirv", no_std, feature(lang_items))] +#![cfg_attr(target_arch = "spirv", no_std)] use core::f32::consts::PI; use glam::{vec3, Vec3}; From 34e53b29651b42fa5bf50e441b857caa633288ec Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Thu, 8 Aug 2024 17:26:12 +0300 Subject: [PATCH 03/32] tests: also test the `debugPrintf` generated from panics. --- tests/ui/dis/panic_builtin_bounds_check.rs | 31 +++++++++++++++ .../ui/dis/panic_builtin_bounds_check.stderr | 38 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 tests/ui/dis/panic_builtin_bounds_check.rs create mode 100644 tests/ui/dis/panic_builtin_bounds_check.stderr diff --git a/tests/ui/dis/panic_builtin_bounds_check.rs b/tests/ui/dis/panic_builtin_bounds_check.rs new file mode 100644 index 0000000000..9430008694 --- /dev/null +++ b/tests/ui/dis/panic_builtin_bounds_check.rs @@ -0,0 +1,31 @@ +#![crate_name = "panic_builtin_bounds_check"] + +// Test that bounds checking panics get converted to `debugPrintf` correctly. + +// build-pass +// compile-flags: -C target-feature=+ext:SPV_KHR_non_semantic_info +// compile-flags: -C llvm-args=--abort-strategy=debug-printf +// compile-flags: -C llvm-args=--disassemble + +// FIXME(eddyb) consider using such replacements also for dealing +// with `OpLine` changing all the time (esp. in libcore functions). +// +// normalize-stderr-test "; (SPIR-V|Generator: rspirv|Version: 1\.\d+|Bound: \d+)\n" -> "" +// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" +// normalize-stderr-test "OpSource .*\n" -> "" +// normalize-stderr-test "OpExtension .SPV_KHR_vulkan_memory_model.\n" -> "" +// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" + +// FIXME(eddyb) handle this one in the test runner. +// normalize-stderr-test "\S*/lib/rustlib/" -> "$$SYSROOT/lib/rustlib/" + +use spirv_std::spirv; + +fn array_bounds_check(x: [u32; 4], i: usize) -> u32 { + x[i] +} + +#[spirv(fragment)] +pub fn main() { + array_bounds_check([0, 1, 2, 3], 5); +} diff --git a/tests/ui/dis/panic_builtin_bounds_check.stderr b/tests/ui/dis/panic_builtin_bounds_check.stderr new file mode 100644 index 0000000000..68ea014383 --- /dev/null +++ b/tests/ui/dis/panic_builtin_bounds_check.stderr @@ -0,0 +1,38 @@ +OpCapability Shader +OpCapability Float64 +OpCapability Int64 +OpCapability Int16 +OpCapability Int8 +OpCapability ShaderClockKHR +OpExtension "SPV_KHR_non_semantic_info" +OpExtension "SPV_KHR_shader_clock" +%1 = OpExtInstImport "NonSemantic.DebugPrintf" +OpMemoryModel Logical Simple +OpEntryPoint Fragment %2 "main" +OpExecutionMode %2 OriginUpperLeft +%3 = OpString "/n[Rust panicked at $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs:180:5]/n index out of bounds: the len is %u but the index is %u/n in main()/n" +%4 = OpString $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs" +%5 = OpString "$DIR/panic_builtin_bounds_check.rs" +%6 = OpTypeVoid +%7 = OpTypeFunction %6 +%8 = OpTypeBool +%9 = OpTypeInt 32 0 +%10 = OpConstant %9 5 +%11 = OpConstant %9 4 +%2 = OpFunction %6 None %7 +%12 = OpLabel +OpLine %5 25 4 +%13 = OpULessThan %8 %10 %11 +OpNoLine +OpSelectionMerge %14 None +OpBranchConditional %13 %15 %16 +%15 = OpLabel +OpBranch %14 +%16 = OpLabel +OpLine %4 180 4 +%17 = OpExtInst %6 %1 1 %3 %11 %10 +OpNoLine +OpBranch %14 +%14 = OpLabel +OpReturn +OpFunctionEnd From 880528d5a9e8280a45d502da8f82036a2e901094 Mon Sep 17 00:00:00 2001 From: Christian Legnitto Date: Mon, 27 Nov 2023 00:17:18 -0400 Subject: [PATCH 04/32] rustup: update to `nightly-2023-11-26`. --- CHANGELOG.md | 1 + crates/rustc_codegen_spirv/build.rs | 4 +- crates/rustc_codegen_spirv/src/abi.rs | 15 +- .../src/builder/builder_methods.rs | 2 +- .../src/builder/intrinsics.rs | 2 +- crates/rustc_codegen_spirv/src/builder/mod.rs | 2 +- .../rustc_codegen_spirv/src/builder_spirv.rs | 2 +- .../src/codegen_cx/type_.rs | 3 +- crates/rustc_codegen_spirv/src/linker/dce.rs | 2 +- crates/rustc_codegen_spirv/src/linker/test.rs | 1 + rust-toolchain.toml | 4 +- .../ui/dis/panic_builtin_bounds_check.stderr | 4 +- tests/ui/dis/ptr_copy.normal.stderr | 10 +- tests/ui/dis/ptr_read.stderr | 2 +- tests/ui/dis/ptr_read_method.stderr | 2 +- tests/ui/dis/ptr_write.stderr | 2 +- tests/ui/dis/ptr_write_method.stderr | 2 +- tests/ui/image/query/query_levels_err.stderr | 2 +- tests/ui/image/query/query_lod_err.stderr | 2 +- tests/ui/image/query/query_size_err.stderr | 2 +- .../ui/image/query/query_size_lod_err.stderr | 2 +- tests/ui/lang/control_flow/issue_764.stderr | 2 +- .../core/ptr/allocate_const_scalar.stderr | 2 +- .../core/ref/member_ref_arg-broken.stderr | 2 +- tests/ui/lang/core/unwrap_or.stderr | 4 +- .../invalid-matrix-type-empty.stderr | 2 +- tests/ui/spirv-attr/invalid-target.rs | 3 +- tests/ui/spirv-attr/invalid-target.stderr | 176 +++++++++--------- tests/ui/spirv-attr/invariant-invalid.stderr | 2 +- .../runtime_descriptor_array_error.stderr | 2 +- tests/ui/target_features_err.stderr | 2 +- 31 files changed, 137 insertions(+), 128 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 142529e30f..d05722aeb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Changed 🛠 +- [PR#1102](https://github.com/EmbarkStudios/rust-gpu/pull/1102) updated toolchain to `nightly-2023-11-26` - [PR#1115](https://github.com/EmbarkStudios/rust-gpu/pull/1115) relaxed `glam` version requirements (from `>=0.22, <=0.24` to `>=0.22, <=0.25`) - [PR#1127](https://github.com/EmbarkStudios/rust-gpu/pull/1127) updated `spirv-tools` to `0.10.0`, which follows `vulkan-sdk-1.3.275` - [PR#1101](https://github.com/EmbarkStudios/rust-gpu/pull/1101) added `ignore` and `no_run` to documentation to make `cargo test` pass diff --git a/crates/rustc_codegen_spirv/build.rs b/crates/rustc_codegen_spirv/build.rs index 6421463ba5..dcb3163d50 100644 --- a/crates/rustc_codegen_spirv/build.rs +++ b/crates/rustc_codegen_spirv/build.rs @@ -10,9 +10,9 @@ use std::process::{Command, ExitCode}; /// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/ //const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml"); const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain] -channel = "nightly-2023-09-30" +channel = "nightly-2023-11-26" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = 8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72"#; +# commit_hash = f5dc2653fdd8b5d177b2ccbd84057954340a89fc"#; fn get_rustc_commit_hash() -> Result> { let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc")); diff --git a/crates/rustc_codegen_spirv/src/abi.rs b/crates/rustc_codegen_spirv/src/abi.rs index fbe20ed462..38586dc9aa 100644 --- a/crates/rustc_codegen_spirv/src/abi.rs +++ b/crates/rustc_codegen_spirv/src/abi.rs @@ -12,7 +12,7 @@ use rustc_middle::query::Providers; use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout}; use rustc_middle::ty::GenericArgsRef; use rustc_middle::ty::{ - self, Const, FloatTy, GeneratorArgs, IntTy, ParamEnv, PolyFnSig, Ty, TyCtxt, TyKind, + self, Const, CoroutineArgs, FloatTy, IntTy, ParamEnv, PolyFnSig, Ty, TyCtxt, TyKind, TypeAndMut, UintTy, }; use rustc_middle::{bug, span_bug}; @@ -64,6 +64,9 @@ pub(crate) fn provide(providers: &mut Providers) { ) -> &'tcx FnAbi<'tcx, Ty<'tcx>> { let readjust_arg_abi = |arg: &ArgAbi<'tcx, Ty<'tcx>>| { let mut arg = ArgAbi::new(&tcx, arg.layout, |_, _, _| ArgAttributes::new()); + // FIXME: this is bad! https://github.com/rust-lang/rust/issues/115666 + // + arg.make_direct_deprecated(); // Avoid pointlessly passing ZSTs, just like the official Rust ABI. if arg.layout.is_zst() { @@ -96,7 +99,9 @@ pub(crate) fn provide(providers: &mut Providers) { // FIXME(eddyb) remove this by deriving `Clone` for `LayoutS` upstream. // FIXME(eddyb) the `S` suffix is a naming antipattern, rename upstream. - fn clone_layout(layout: &LayoutS) -> LayoutS { + fn clone_layout( + layout: &LayoutS, + ) -> LayoutS { let LayoutS { ref fields, ref variants, @@ -744,7 +749,7 @@ fn trans_struct<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>) - fn def_id_for_spirv_type_adt(layout: TyAndLayout<'_>) -> Option { match *layout.ty.kind() { TyKind::Adt(def, _) => Some(def.did()), - TyKind::Foreign(def_id) | TyKind::Closure(def_id, _) | TyKind::Generator(def_id, ..) => { + TyKind::Foreign(def_id) | TyKind::Closure(def_id, _) | TyKind::Coroutine(def_id, ..) => { Some(def_id) } _ => None, @@ -779,8 +784,8 @@ impl fmt::Display for TyLayoutNameKey<'_> { write!(f, "::{}", def.variants()[index].name)?; } } - if let (TyKind::Generator(_, _, _), Some(index)) = (self.ty.kind(), self.variant) { - write!(f, "::{}", GeneratorArgs::variant_name(index))?; + if let (TyKind::Coroutine(_, _, _), Some(index)) = (self.ty.kind(), self.variant) { + write!(f, "::{}", CoroutineArgs::variant_name(index))?; } Ok(()) } diff --git a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs index 86766ff75f..4e1cad8186 100644 --- a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs +++ b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs @@ -3037,7 +3037,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { self.intcast(val, dest_ty, false) } - fn do_not_inline(&mut self, _llret: Self::Value) { + fn apply_attrs_to_cleanup_callsite(&mut self, _llret: Self::Value) { // Ignore } } diff --git a/crates/rustc_codegen_spirv/src/builder/intrinsics.rs b/crates/rustc_codegen_spirv/src/builder/intrinsics.rs index 9d8b886ea8..45e9b861c6 100644 --- a/crates/rustc_codegen_spirv/src/builder/intrinsics.rs +++ b/crates/rustc_codegen_spirv/src/builder/intrinsics.rs @@ -12,8 +12,8 @@ use rustc_codegen_ssa::traits::{BuilderMethods, IntrinsicCallMethods}; use rustc_middle::bug; use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::{FnDef, Instance, ParamEnv, Ty, TyKind}; -use rustc_span::source_map::Span; use rustc_span::sym; +use rustc_span::Span; use rustc_target::abi::call::{FnAbi, PassMode}; use std::assert_matches::assert_matches; diff --git a/crates/rustc_codegen_spirv/src/builder/mod.rs b/crates/rustc_codegen_spirv/src/builder/mod.rs index 9fec40232e..fbc12d2ddd 100644 --- a/crates/rustc_codegen_spirv/src/builder/mod.rs +++ b/crates/rustc_codegen_spirv/src/builder/mod.rs @@ -29,7 +29,7 @@ use rustc_middle::ty::layout::{ }; use rustc_middle::ty::{Instance, ParamEnv, Ty, TyCtxt}; use rustc_span::def_id::DefId; -use rustc_span::source_map::Span; +use rustc_span::Span; use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode}; use rustc_target::abi::{HasDataLayout, Size, TargetDataLayout}; use rustc_target::spec::{HasTargetSpec, Target}; diff --git a/crates/rustc_codegen_spirv/src/builder_spirv.rs b/crates/rustc_codegen_spirv/src/builder_spirv.rs index 6a7c8e72a2..7d6249cafc 100644 --- a/crates/rustc_codegen_spirv/src/builder_spirv.rs +++ b/crates/rustc_codegen_spirv/src/builder_spirv.rs @@ -767,7 +767,7 @@ impl<'tcx> BuilderSpirv<'tcx> { FileName::Real(name) => { name.to_string_lossy(FileNameDisplayPreference::Remapped) } - _ => sf.name.prefer_remapped().to_string().into(), + _ => sf.name.prefer_remapped_unconditionaly().to_string().into(), }; let file_name = { // FIXME(eddyb) it should be possible to arena-allocate a diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs b/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs index 6effea59b9..c6a086c5a9 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs @@ -9,7 +9,8 @@ use rustc_middle::ty::layout::{ }; use rustc_middle::ty::Ty; use rustc_middle::{bug, span_bug}; -use rustc_span::source_map::{Span, Spanned, DUMMY_SP}; +use rustc_span::source_map::Spanned; +use rustc_span::{Span, DUMMY_SP}; use rustc_target::abi::call::{CastTarget, FnAbi, Reg}; use rustc_target::abi::{Abi, AddressSpace, FieldsShape}; diff --git a/crates/rustc_codegen_spirv/src/linker/dce.rs b/crates/rustc_codegen_spirv/src/linker/dce.rs index ac9bf3c7fd..3cc865a741 100644 --- a/crates/rustc_codegen_spirv/src/linker/dce.rs +++ b/crates/rustc_codegen_spirv/src/linker/dce.rs @@ -281,7 +281,7 @@ fn instruction_is_pure(inst: &Instruction) -> bool { | PtrEqual | PtrNotEqual | PtrDiff => true, - Variable => inst.operands.get(0) == Some(&Operand::StorageClass(StorageClass::Function)), + Variable => inst.operands.first() == Some(&Operand::StorageClass(StorageClass::Function)), _ => false, } } diff --git a/crates/rustc_codegen_spirv/src/linker/test.rs b/crates/rustc_codegen_spirv/src/linker/test.rs index 7e92b89f47..417408576c 100644 --- a/crates/rustc_codegen_spirv/src/linker/test.rs +++ b/crates/rustc_codegen_spirv/src/linker/test.rs @@ -155,6 +155,7 @@ fn link_with_linker_opts( rustc_interface::util::rustc_version_str().unwrap_or("unknown"), Default::default(), Default::default(), + Default::default(), ); // HACK(eddyb) inject `write_diags` into `sess`, to work around diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 884ca31985..98315c67df 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,7 +1,7 @@ [toolchain] -channel = "nightly-2023-09-30" +channel = "nightly-2023-11-26" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = 8ce4540bd6fe7d58d4bc05f1b137d61937d3cf72 +# commit_hash = f5dc2653fdd8b5d177b2ccbd84057954340a89fc # Whenever changing the nightly channel, update the commit hash above, and make # sure to change `REQUIRED_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` also. diff --git a/tests/ui/dis/panic_builtin_bounds_check.stderr b/tests/ui/dis/panic_builtin_bounds_check.stderr index 68ea014383..a254d88b7a 100644 --- a/tests/ui/dis/panic_builtin_bounds_check.stderr +++ b/tests/ui/dis/panic_builtin_bounds_check.stderr @@ -10,7 +10,7 @@ OpExtension "SPV_KHR_shader_clock" OpMemoryModel Logical Simple OpEntryPoint Fragment %2 "main" OpExecutionMode %2 OriginUpperLeft -%3 = OpString "/n[Rust panicked at $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs:180:5]/n index out of bounds: the len is %u but the index is %u/n in main()/n" +%3 = OpString "/n[Rust panicked at $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs:189:5]/n index out of bounds: the len is %u but the index is %u/n in main()/n" %4 = OpString $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs" %5 = OpString "$DIR/panic_builtin_bounds_check.rs" %6 = OpTypeVoid @@ -29,7 +29,7 @@ OpBranchConditional %13 %15 %16 %15 = OpLabel OpBranch %14 %16 = OpLabel -OpLine %4 180 4 +OpLine %4 189 4 %17 = OpExtInst %6 %1 1 %3 %11 %10 OpNoLine OpBranch %14 diff --git a/tests/ui/dis/ptr_copy.normal.stderr b/tests/ui/dis/ptr_copy.normal.stderr index 43c045e5b8..7182c5f4ba 100644 --- a/tests/ui/dis/ptr_copy.normal.stderr +++ b/tests/ui/dis/ptr_copy.normal.stderr @@ -1,13 +1,13 @@ error: cannot memcpy dynamically sized data - --> $CORE_SRC/intrinsics.rs:2778:9 + --> $CORE_SRC/intrinsics.rs:2776:9 | -2778 | copy(src, dst, count) +2776 | copy(src, dst, count) | ^^^^^^^^^^^^^^^^^^^^^ | note: used from within `core::intrinsics::copy::` - --> $CORE_SRC/intrinsics.rs:2764:21 + --> $CORE_SRC/intrinsics.rs:2762:21 | -2764 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { +2762 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { | ^^^^ note: called by `ptr_copy::copy_via_raw_ptr` --> $DIR/ptr_copy.rs:28:18 @@ -25,5 +25,5 @@ note: called by `main` 32 | pub fn main(i: f32, o: &mut f32) { | ^^^^ -error: aborting due to previous error +error: aborting due to 1 previous error diff --git a/tests/ui/dis/ptr_read.stderr b/tests/ui/dis/ptr_read.stderr index 722af616d8..c4f70a0853 100644 --- a/tests/ui/dis/ptr_read.stderr +++ b/tests/ui/dis/ptr_read.stderr @@ -2,7 +2,7 @@ %4 = OpFunctionParameter %5 %6 = OpFunctionParameter %5 %7 = OpLabel -OpLine %8 1183 8 +OpLine %8 1200 8 %9 = OpLoad %10 %4 OpLine %11 7 13 OpStore %6 %9 diff --git a/tests/ui/dis/ptr_read_method.stderr b/tests/ui/dis/ptr_read_method.stderr index 722af616d8..c4f70a0853 100644 --- a/tests/ui/dis/ptr_read_method.stderr +++ b/tests/ui/dis/ptr_read_method.stderr @@ -2,7 +2,7 @@ %4 = OpFunctionParameter %5 %6 = OpFunctionParameter %5 %7 = OpLabel -OpLine %8 1183 8 +OpLine %8 1200 8 %9 = OpLoad %10 %4 OpLine %11 7 13 OpStore %6 %9 diff --git a/tests/ui/dis/ptr_write.stderr b/tests/ui/dis/ptr_write.stderr index b86b31d184..f2f9af23c9 100644 --- a/tests/ui/dis/ptr_write.stderr +++ b/tests/ui/dis/ptr_write.stderr @@ -4,7 +4,7 @@ %7 = OpLabel OpLine %8 7 35 %9 = OpLoad %10 %4 -OpLine %11 1382 8 +OpLine %11 1400 8 OpStore %6 %9 OpNoLine OpReturn diff --git a/tests/ui/dis/ptr_write_method.stderr b/tests/ui/dis/ptr_write_method.stderr index 013ba2e906..2141c5964c 100644 --- a/tests/ui/dis/ptr_write_method.stderr +++ b/tests/ui/dis/ptr_write_method.stderr @@ -4,7 +4,7 @@ %7 = OpLabel OpLine %8 7 37 %9 = OpLoad %10 %4 -OpLine %11 1382 8 +OpLine %11 1400 8 OpStore %6 %9 OpNoLine OpReturn diff --git a/tests/ui/image/query/query_levels_err.stderr b/tests/ui/image/query/query_levels_err.stderr index ae524b7ef5..2f03a3f426 100644 --- a/tests/ui/image/query/query_levels_err.stderr +++ b/tests/ui/image/query/query_levels_err.stderr @@ -18,6 +18,6 @@ note: required by a bound in `Image::::query_levels` -error: aborting due to previous error +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/image/query/query_lod_err.stderr b/tests/ui/image/query/query_lod_err.stderr index 5ad3b758fa..0b6a9a052c 100644 --- a/tests/ui/image/query/query_lod_err.stderr +++ b/tests/ui/image/query/query_lod_err.stderr @@ -18,6 +18,6 @@ note: required by a bound in `Image::::query_lod` -error: aborting due to previous error +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/image/query/query_size_err.stderr b/tests/ui/image/query/query_size_err.stderr index 9311a1d78b..b35b9c1298 100644 --- a/tests/ui/image/query/query_size_err.stderr +++ b/tests/ui/image/query/query_size_err.stderr @@ -23,6 +23,6 @@ note: required by a bound in `Image::::query_size` -error: aborting due to previous error +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/image/query/query_size_lod_err.stderr b/tests/ui/image/query/query_size_lod_err.stderr index ed06527761..20464eb29a 100644 --- a/tests/ui/image/query/query_size_lod_err.stderr +++ b/tests/ui/image/query/query_size_lod_err.stderr @@ -18,6 +18,6 @@ note: required by a bound in `Image::::query_size_lod` -error: aborting due to previous error +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/lang/control_flow/issue_764.stderr b/tests/ui/lang/control_flow/issue_764.stderr index fc05159549..7e5182792d 100644 --- a/tests/ui/lang/control_flow/issue_764.stderr +++ b/tests/ui/lang/control_flow/issue_764.stderr @@ -1,4 +1,4 @@ error: module has recursion, which is not allowed: `<(i32, issue_764::Transform2D) as issue_764::GivesFinalTransform>::get_final_transform` calls `<(i32, issue_764::Transform2D) as issue_764::GivesFinalTransform>::get_final_transform` -error: aborting due to previous error +error: aborting due to 1 previous error diff --git a/tests/ui/lang/core/ptr/allocate_const_scalar.stderr b/tests/ui/lang/core/ptr/allocate_const_scalar.stderr index a85b884892..df6374b37b 100644 --- a/tests/ui/lang/core/ptr/allocate_const_scalar.stderr +++ b/tests/ui/lang/core/ptr/allocate_const_scalar.stderr @@ -11,5 +11,5 @@ note: called by `main` 15 | pub fn main(output: &mut Unique<[u8; 4]>) { | ^^^^ -error: aborting due to previous error +error: aborting due to 1 previous error diff --git a/tests/ui/lang/core/ref/member_ref_arg-broken.stderr b/tests/ui/lang/core/ref/member_ref_arg-broken.stderr index 0c0759c940..66dee4fc15 100644 --- a/tests/ui/lang/core/ref/member_ref_arg-broken.stderr +++ b/tests/ui/lang/core/ref/member_ref_arg-broken.stderr @@ -8,5 +8,5 @@ error: error:0:0 - OpLoad Pointer '$ID[%$ID]' is not a logical pointer. = note: spirv-val failed = note: module `$TEST_BUILD_DIR/lang/core/ref/member_ref_arg-broken.default` -error: aborting due to previous error; 2 warnings emitted +error: aborting due to 1 previous error; 2 warnings emitted diff --git a/tests/ui/lang/core/unwrap_or.stderr b/tests/ui/lang/core/unwrap_or.stderr index 3b3100c773..8448d926fe 100644 --- a/tests/ui/lang/core/unwrap_or.stderr +++ b/tests/ui/lang/core/unwrap_or.stderr @@ -3,9 +3,9 @@ OpLine %5 13 11 %6 = OpCompositeInsert %7 %8 %9 0 %10 = OpCompositeExtract %11 %6 1 -OpLine %12 956 14 +OpLine %12 952 14 %13 = OpBitcast %14 %8 -OpLine %12 956 8 +OpLine %12 952 8 %15 = OpIEqual %16 %13 %17 OpNoLine OpSelectionMerge %18 None diff --git a/tests/ui/spirv-attr/invalid-matrix-type-empty.stderr b/tests/ui/spirv-attr/invalid-matrix-type-empty.stderr index 6a02d04dd9..d34ef0ac5e 100644 --- a/tests/ui/spirv-attr/invalid-matrix-type-empty.stderr +++ b/tests/ui/spirv-attr/invalid-matrix-type-empty.stderr @@ -4,5 +4,5 @@ error: #[spirv(matrix)] type must have at least two fields 7 | pub struct EmptyStruct {} | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +error: aborting due to 1 previous error diff --git a/tests/ui/spirv-attr/invalid-target.rs b/tests/ui/spirv-attr/invalid-target.rs index 9bc0c525cf..2dbd5bb106 100644 --- a/tests/ui/spirv-attr/invalid-target.rs +++ b/tests/ui/spirv-attr/invalid-target.rs @@ -288,7 +288,8 @@ fn _fn( vertex, // fn-only uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only )] - (1, 2, 3) // expression + (1, 2, 3) + // expression ); match () { diff --git a/tests/ui/spirv-attr/invalid-target.stderr b/tests/ui/spirv-attr/invalid-target.stderr index d659b95039..c8733ab54f 100644 --- a/tests/ui/spirv-attr/invalid-target.stderr +++ b/tests/ui/spirv-attr/invalid-target.stderr @@ -1583,267 +1583,267 @@ error: attribute is only valid on a function parameter, not on a expression | ^^^^^^^^^ error: attribute is only valid on a struct, not on a match arm - --> $DIR/invalid-target.rs:296:13 + --> $DIR/invalid-target.rs:297:13 | -296 | sampler, block, sampled_image, generic_image_type, // struct-only +297 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^ error: attribute is only valid on a struct, not on a match arm - --> $DIR/invalid-target.rs:296:22 + --> $DIR/invalid-target.rs:297:22 | -296 | sampler, block, sampled_image, generic_image_type, // struct-only +297 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^ error: attribute is only valid on a struct, not on a match arm - --> $DIR/invalid-target.rs:296:29 + --> $DIR/invalid-target.rs:297:29 | -296 | sampler, block, sampled_image, generic_image_type, // struct-only +297 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^^^^^^^ error: attribute is only valid on a struct, not on a match arm - --> $DIR/invalid-target.rs:296:44 + --> $DIR/invalid-target.rs:297:44 | -296 | sampler, block, sampled_image, generic_image_type, // struct-only +297 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^^^^^^^^^^^^ error: attribute is only valid on a function, not on a match arm - --> $DIR/invalid-target.rs:297:13 + --> $DIR/invalid-target.rs:298:13 | -297 | vertex, // fn-only +298 | vertex, // fn-only | ^^^^^^ error: attribute is only valid on a function parameter, not on a match arm - --> $DIR/invalid-target.rs:298:13 + --> $DIR/invalid-target.rs:299:13 | -298 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +299 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^ error: attribute is only valid on a function parameter, not on a match arm - --> $DIR/invalid-target.rs:298:22 + --> $DIR/invalid-target.rs:299:22 | -298 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +299 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^ error: attribute is only valid on a function parameter, not on a match arm - --> $DIR/invalid-target.rs:298:32 + --> $DIR/invalid-target.rs:299:32 | -298 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +299 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^^^^^^^^^^ error: attribute is only valid on a function parameter, not on a match arm - --> $DIR/invalid-target.rs:298:52 + --> $DIR/invalid-target.rs:299:52 | -298 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +299 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^^^ error: attribute is only valid on a function parameter, not on a match arm - --> $DIR/invalid-target.rs:298:65 + --> $DIR/invalid-target.rs:299:65 | -298 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +299 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^ error: attribute is only valid on a function parameter, not on a match arm - --> $DIR/invalid-target.rs:298:71 + --> $DIR/invalid-target.rs:299:71 | -298 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +299 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^ error: attribute is only valid on a struct, not on a lifetime parameter - --> $DIR/invalid-target.rs:306:9 + --> $DIR/invalid-target.rs:307:9 | -306 | sampler, block, sampled_image, generic_image_type, // struct-only +307 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^ error: attribute is only valid on a struct, not on a lifetime parameter - --> $DIR/invalid-target.rs:306:18 + --> $DIR/invalid-target.rs:307:18 | -306 | sampler, block, sampled_image, generic_image_type, // struct-only +307 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^ error: attribute is only valid on a struct, not on a lifetime parameter - --> $DIR/invalid-target.rs:306:25 + --> $DIR/invalid-target.rs:307:25 | -306 | sampler, block, sampled_image, generic_image_type, // struct-only +307 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^^^^^^^ error: attribute is only valid on a struct, not on a lifetime parameter - --> $DIR/invalid-target.rs:306:40 + --> $DIR/invalid-target.rs:307:40 | -306 | sampler, block, sampled_image, generic_image_type, // struct-only +307 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^^^^^^^^^^^^ error: attribute is only valid on a function, not on a lifetime parameter - --> $DIR/invalid-target.rs:307:9 + --> $DIR/invalid-target.rs:308:9 | -307 | vertex, // fn-only +308 | vertex, // fn-only | ^^^^^^ error: attribute is only valid on a function parameter, not on a lifetime parameter - --> $DIR/invalid-target.rs:308:9 + --> $DIR/invalid-target.rs:309:9 | -308 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +309 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^ error: attribute is only valid on a function parameter, not on a lifetime parameter - --> $DIR/invalid-target.rs:308:18 + --> $DIR/invalid-target.rs:309:18 | -308 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +309 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^ error: attribute is only valid on a function parameter, not on a lifetime parameter - --> $DIR/invalid-target.rs:308:28 + --> $DIR/invalid-target.rs:309:28 | -308 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +309 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^^^^^^^^^^ error: attribute is only valid on a function parameter, not on a lifetime parameter - --> $DIR/invalid-target.rs:308:48 + --> $DIR/invalid-target.rs:309:48 | -308 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +309 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^^^ error: attribute is only valid on a function parameter, not on a lifetime parameter - --> $DIR/invalid-target.rs:308:61 + --> $DIR/invalid-target.rs:309:61 | -308 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +309 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^ error: attribute is only valid on a function parameter, not on a lifetime parameter - --> $DIR/invalid-target.rs:308:67 + --> $DIR/invalid-target.rs:309:67 | -308 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +309 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^ error: attribute is only valid on a struct, not on a type parameter - --> $DIR/invalid-target.rs:311:9 + --> $DIR/invalid-target.rs:312:9 | -311 | sampler, block, sampled_image, generic_image_type, // struct-only +312 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^ error: attribute is only valid on a struct, not on a type parameter - --> $DIR/invalid-target.rs:311:18 + --> $DIR/invalid-target.rs:312:18 | -311 | sampler, block, sampled_image, generic_image_type, // struct-only +312 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^ error: attribute is only valid on a struct, not on a type parameter - --> $DIR/invalid-target.rs:311:25 + --> $DIR/invalid-target.rs:312:25 | -311 | sampler, block, sampled_image, generic_image_type, // struct-only +312 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^^^^^^^ error: attribute is only valid on a struct, not on a type parameter - --> $DIR/invalid-target.rs:311:40 + --> $DIR/invalid-target.rs:312:40 | -311 | sampler, block, sampled_image, generic_image_type, // struct-only +312 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^^^^^^^^^^^^ error: attribute is only valid on a function, not on a type parameter - --> $DIR/invalid-target.rs:312:9 + --> $DIR/invalid-target.rs:313:9 | -312 | vertex, // fn-only +313 | vertex, // fn-only | ^^^^^^ error: attribute is only valid on a function parameter, not on a type parameter - --> $DIR/invalid-target.rs:313:9 + --> $DIR/invalid-target.rs:314:9 | -313 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +314 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^ error: attribute is only valid on a function parameter, not on a type parameter - --> $DIR/invalid-target.rs:313:18 + --> $DIR/invalid-target.rs:314:18 | -313 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +314 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^ error: attribute is only valid on a function parameter, not on a type parameter - --> $DIR/invalid-target.rs:313:28 + --> $DIR/invalid-target.rs:314:28 | -313 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +314 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^^^^^^^^^^ error: attribute is only valid on a function parameter, not on a type parameter - --> $DIR/invalid-target.rs:313:48 + --> $DIR/invalid-target.rs:314:48 | -313 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +314 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^^^ error: attribute is only valid on a function parameter, not on a type parameter - --> $DIR/invalid-target.rs:313:61 + --> $DIR/invalid-target.rs:314:61 | -313 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +314 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^ error: attribute is only valid on a function parameter, not on a type parameter - --> $DIR/invalid-target.rs:313:67 + --> $DIR/invalid-target.rs:314:67 | -313 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +314 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^ error: attribute is only valid on a struct, not on a const parameter - --> $DIR/invalid-target.rs:316:9 + --> $DIR/invalid-target.rs:317:9 | -316 | sampler, block, sampled_image, generic_image_type, // struct-only +317 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^ error: attribute is only valid on a struct, not on a const parameter - --> $DIR/invalid-target.rs:316:18 + --> $DIR/invalid-target.rs:317:18 | -316 | sampler, block, sampled_image, generic_image_type, // struct-only +317 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^ error: attribute is only valid on a struct, not on a const parameter - --> $DIR/invalid-target.rs:316:25 + --> $DIR/invalid-target.rs:317:25 | -316 | sampler, block, sampled_image, generic_image_type, // struct-only +317 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^^^^^^^ error: attribute is only valid on a struct, not on a const parameter - --> $DIR/invalid-target.rs:316:40 + --> $DIR/invalid-target.rs:317:40 | -316 | sampler, block, sampled_image, generic_image_type, // struct-only +317 | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^^^^^^^^^^^^ error: attribute is only valid on a function, not on a const parameter - --> $DIR/invalid-target.rs:317:9 + --> $DIR/invalid-target.rs:318:9 | -317 | vertex, // fn-only +318 | vertex, // fn-only | ^^^^^^ error: attribute is only valid on a function parameter, not on a const parameter - --> $DIR/invalid-target.rs:318:9 + --> $DIR/invalid-target.rs:319:9 | -318 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +319 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^ error: attribute is only valid on a function parameter, not on a const parameter - --> $DIR/invalid-target.rs:318:18 + --> $DIR/invalid-target.rs:319:18 | -318 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +319 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^ error: attribute is only valid on a function parameter, not on a const parameter - --> $DIR/invalid-target.rs:318:28 + --> $DIR/invalid-target.rs:319:28 | -318 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +319 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^^^^^^^^^^ error: attribute is only valid on a function parameter, not on a const parameter - --> $DIR/invalid-target.rs:318:48 + --> $DIR/invalid-target.rs:319:48 | -318 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +319 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^^^ error: attribute is only valid on a function parameter, not on a const parameter - --> $DIR/invalid-target.rs:318:61 + --> $DIR/invalid-target.rs:319:61 | -318 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +319 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^ error: attribute is only valid on a function parameter, not on a const parameter - --> $DIR/invalid-target.rs:318:67 + --> $DIR/invalid-target.rs:319:67 | -318 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only +319 | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^ error: attribute is only valid on a struct, not on a associated type diff --git a/tests/ui/spirv-attr/invariant-invalid.stderr b/tests/ui/spirv-attr/invariant-invalid.stderr index 4ba05ebacc..8db5f32424 100644 --- a/tests/ui/spirv-attr/invariant-invalid.stderr +++ b/tests/ui/spirv-attr/invariant-invalid.stderr @@ -4,5 +4,5 @@ error: `#[spirv(invariant)]` is only valid on Output variables 7 | pub fn main(#[spirv(invariant)] input: f32) {} | ^^^^^^^^^ -error: aborting due to previous error +error: aborting due to 1 previous error diff --git a/tests/ui/storage_class/runtime_descriptor_array_error.stderr b/tests/ui/storage_class/runtime_descriptor_array_error.stderr index efe0352a43..a6025a5fd0 100644 --- a/tests/ui/storage_class/runtime_descriptor_array_error.stderr +++ b/tests/ui/storage_class/runtime_descriptor_array_error.stderr @@ -10,5 +10,5 @@ warning: use &[T] instead of &RuntimeArray 8 | #[spirv(uniform, descriptor_set = 0, binding = 0)] two: &RuntimeArray, | ^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error; 1 warning emitted +error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/target_features_err.stderr b/tests/ui/target_features_err.stderr index 8b5b679cb0..9195a361f2 100644 --- a/tests/ui/target_features_err.stderr +++ b/tests/ui/target_features_err.stderr @@ -1,4 +1,4 @@ error: Invalid Capability: `rayTracingKHR` -error: aborting due to previous error +error: aborting due to 1 previous error From 01fb43f21d6079e4ec19a7f11d588aca8325b40c Mon Sep 17 00:00:00 2001 From: Christian Legnitto Date: Sun, 17 Dec 2023 13:18:38 -0400 Subject: [PATCH 05/32] rustup: update to `nightly-2023-12-16`. --- CHANGELOG.md | 2 +- crates/rustc_codegen_spirv/build.rs | 4 ++-- crates/rustc_codegen_spirv/src/attr.rs | 6 +++--- crates/rustc_codegen_spirv/src/codegen_cx/constant.rs | 3 ++- crates/rustc_codegen_spirv/src/lib.rs | 2 +- crates/rustc_codegen_spirv/src/link.rs | 2 +- crates/rustc_codegen_spirv/src/linker/mod.rs | 2 +- crates/rustc_codegen_spirv/src/linker/test.rs | 3 ++- crates/rustc_codegen_spirv/src/symbols.rs | 2 +- rust-toolchain.toml | 4 ++-- tests/ui/dis/panic_builtin_bounds_check.stderr | 4 ++-- tests/ui/dis/ptr_copy.normal.stderr | 8 ++++---- tests/ui/dis/ptr_read.stderr | 2 +- tests/ui/dis/ptr_read_method.stderr | 2 +- tests/ui/dis/ptr_write.stderr | 2 +- tests/ui/dis/ptr_write_method.stderr | 2 +- tests/ui/lang/core/ptr/allocate_const_scalar.stderr | 11 ++++++++++- tests/ui/lang/core/ptr/allocate_vec_like.stderr | 11 +++++++++++ 18 files changed, 47 insertions(+), 25 deletions(-) create mode 100644 tests/ui/lang/core/ptr/allocate_vec_like.stderr diff --git a/CHANGELOG.md b/CHANGELOG.md index d05722aeb7..9d988ae791 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Changed 🛠 -- [PR#1102](https://github.com/EmbarkStudios/rust-gpu/pull/1102) updated toolchain to `nightly-2023-11-26` +- [PR#1109](https://github.com/EmbarkStudios/rust-gpu/pull/1109) updated toolchain to `nightly-2023-12-16` - [PR#1115](https://github.com/EmbarkStudios/rust-gpu/pull/1115) relaxed `glam` version requirements (from `>=0.22, <=0.24` to `>=0.22, <=0.25`) - [PR#1127](https://github.com/EmbarkStudios/rust-gpu/pull/1127) updated `spirv-tools` to `0.10.0`, which follows `vulkan-sdk-1.3.275` - [PR#1101](https://github.com/EmbarkStudios/rust-gpu/pull/1101) added `ignore` and `no_run` to documentation to make `cargo test` pass diff --git a/crates/rustc_codegen_spirv/build.rs b/crates/rustc_codegen_spirv/build.rs index dcb3163d50..3f8886e383 100644 --- a/crates/rustc_codegen_spirv/build.rs +++ b/crates/rustc_codegen_spirv/build.rs @@ -10,9 +10,9 @@ use std::process::{Command, ExitCode}; /// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/ //const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml"); const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain] -channel = "nightly-2023-11-26" +channel = "nightly-2023-12-16" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = f5dc2653fdd8b5d177b2ccbd84057954340a89fc"#; +# commit_hash = a96d57bdb6d2bb6d233d7d5aaefc2995ab99be01"#; fn get_rustc_commit_hash() -> Result> { let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc")); diff --git a/crates/rustc_codegen_spirv/src/attr.rs b/crates/rustc_codegen_spirv/src/attr.rs index b796e86db6..b59f683aa7 100644 --- a/crates/rustc_codegen_spirv/src/attr.rs +++ b/crates/rustc_codegen_spirv/src/attr.rs @@ -148,13 +148,13 @@ impl AggregatedSpirvAttributes { pub fn parse<'tcx>(cx: &CodegenCx<'tcx>, attrs: &'tcx [Attribute]) -> Self { let mut aggregated_attrs = Self::default(); - // NOTE(eddyb) `delay_span_bug` ensures that if attribute checking fails + // NOTE(eddyb) `span_delayed_bug` ensures that if attribute checking fails // to see an attribute error, it will cause an ICE instead. for parse_attr_result in crate::symbols::parse_attrs_for_checking(&cx.sym, attrs) { let (span, parsed_attr) = match parse_attr_result { Ok(span_and_parsed_attr) => span_and_parsed_attr, Err((span, msg)) => { - cx.tcx.sess.delay_span_bug(span, msg); + cx.tcx.sess.span_delayed_bug(span, msg); continue; } }; @@ -166,7 +166,7 @@ impl AggregatedSpirvAttributes { }) => { cx.tcx .sess - .delay_span_bug(span, format!("multiple {category} attributes")); + .span_delayed_bug(span, format!("multiple {category} attributes")); } } } diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs b/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs index 83b60b4fdd..eed04cd4c1 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs @@ -290,7 +290,8 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> { } } Scalar::Ptr(ptr, _) => { - let (alloc_id, offset) = ptr.into_parts(); + let (prov, offset) = ptr.into_parts(); + let alloc_id = prov.alloc_id(); let (base_addr, _base_addr_space) = match self.tcx.global_alloc(alloc_id) { GlobalAlloc::Memory(alloc) => { let pointee = match self.lookup_type(ty) { diff --git a/crates/rustc_codegen_spirv/src/lib.rs b/crates/rustc_codegen_spirv/src/lib.rs index 89e81668f0..f9635f5c68 100644 --- a/crates/rustc_codegen_spirv/src/lib.rs +++ b/crates/rustc_codegen_spirv/src/lib.rs @@ -500,7 +500,7 @@ pub fn __rustc_codegen_backend() -> Box { rustc_driver::install_ice_hook( "https://github.com/EmbarkStudios/rust-gpu/issues/new", |handler| { - handler.note_without_error(concat!( + handler.note(concat!( "`rust-gpu` version `", env!("CARGO_PKG_VERSION"), "`" diff --git a/crates/rustc_codegen_spirv/src/link.rs b/crates/rustc_codegen_spirv/src/link.rs index 08df00797b..a926a2ae08 100644 --- a/crates/rustc_codegen_spirv/src/link.rs +++ b/crates/rustc_codegen_spirv/src/link.rs @@ -350,7 +350,7 @@ fn do_spirv_opt( } Level::Error => sess.struct_err(msg.message).forget_guarantee(), Level::Warning => sess.struct_warn(msg.message), - Level::Info | Level::Debug => sess.struct_note_without_error(msg.message), + Level::Info | Level::Debug => sess.struct_note(msg.message), }; err.note(format!("module `{}`", filename.display())); diff --git a/crates/rustc_codegen_spirv/src/linker/mod.rs b/crates/rustc_codegen_spirv/src/linker/mod.rs index 3606779ee9..8c5b93235e 100644 --- a/crates/rustc_codegen_spirv/src/linker/mod.rs +++ b/crates/rustc_codegen_spirv/src/linker/mod.rs @@ -534,7 +534,7 @@ pub fn link( } if any_spirt_bugs { - let mut note = sess.struct_note_without_error("SPIR-T bugs were reported"); + let mut note = sess.struct_note("SPIR-T bugs were reported"); note.help(format!( "pretty-printed SPIR-T was saved to {}.html", dump_spirt_file_path.as_ref().unwrap().display() diff --git a/crates/rustc_codegen_spirv/src/linker/test.rs b/crates/rustc_codegen_spirv/src/linker/test.rs index 417408576c..4b94588943 100644 --- a/crates/rustc_codegen_spirv/src/linker/test.rs +++ b/crates/rustc_codegen_spirv/src/linker/test.rs @@ -125,6 +125,7 @@ fn link_with_linker_opts( let mut early_error_handler = rustc_session::EarlyErrorHandler::new( rustc_session::config::ErrorOutputType::default(), ); + early_error_handler.initialize_checked_jobserver(); let matches = rustc_driver::handle_options( &early_error_handler, &["".to_string(), "x.rs".to_string()], @@ -135,7 +136,7 @@ fn link_with_linker_opts( rustc_span::create_session_globals_then(sopts.edition, || { let mut sess = rustc_session::build_session( - &early_error_handler, + early_error_handler, sopts, CompilerIO { input: Input::Str { diff --git a/crates/rustc_codegen_spirv/src/symbols.rs b/crates/rustc_codegen_spirv/src/symbols.rs index 4129187b39..5fbd18e036 100644 --- a/crates/rustc_codegen_spirv/src/symbols.rs +++ b/crates/rustc_codegen_spirv/src/symbols.rs @@ -569,7 +569,7 @@ fn parse_local_size_attr(arg: &NestedMetaItem) -> Result<[u32; 3], ParseAttrErro } Ok(local_size) } - Some(tuple) if tuple.is_empty() => Err(( + Some([]) => Err(( arg.span, "#[spirv(compute(threads(x, y, z)))] must have the x dimension specified, trailing ones may be elided".to_string(), )), diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 98315c67df..93684251f0 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,7 +1,7 @@ [toolchain] -channel = "nightly-2023-11-26" +channel = "nightly-2023-12-16" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = f5dc2653fdd8b5d177b2ccbd84057954340a89fc +# commit_hash = a96d57bdb6d2bb6d233d7d5aaefc2995ab99be01 # Whenever changing the nightly channel, update the commit hash above, and make # sure to change `REQUIRED_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` also. diff --git a/tests/ui/dis/panic_builtin_bounds_check.stderr b/tests/ui/dis/panic_builtin_bounds_check.stderr index a254d88b7a..43307c309d 100644 --- a/tests/ui/dis/panic_builtin_bounds_check.stderr +++ b/tests/ui/dis/panic_builtin_bounds_check.stderr @@ -10,7 +10,7 @@ OpExtension "SPV_KHR_shader_clock" OpMemoryModel Logical Simple OpEntryPoint Fragment %2 "main" OpExecutionMode %2 OriginUpperLeft -%3 = OpString "/n[Rust panicked at $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs:189:5]/n index out of bounds: the len is %u but the index is %u/n in main()/n" +%3 = OpString "/n[Rust panicked at $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs:208:5]/n index out of bounds: the len is %u but the index is %u/n in main()/n" %4 = OpString $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs" %5 = OpString "$DIR/panic_builtin_bounds_check.rs" %6 = OpTypeVoid @@ -29,7 +29,7 @@ OpBranchConditional %13 %15 %16 %15 = OpLabel OpBranch %14 %16 = OpLabel -OpLine %4 189 4 +OpLine %4 208 4 %17 = OpExtInst %6 %1 1 %3 %11 %10 OpNoLine OpBranch %14 diff --git a/tests/ui/dis/ptr_copy.normal.stderr b/tests/ui/dis/ptr_copy.normal.stderr index 7182c5f4ba..76c49bd4e5 100644 --- a/tests/ui/dis/ptr_copy.normal.stderr +++ b/tests/ui/dis/ptr_copy.normal.stderr @@ -1,13 +1,13 @@ error: cannot memcpy dynamically sized data - --> $CORE_SRC/intrinsics.rs:2776:9 + --> $CORE_SRC/intrinsics.rs:2793:9 | -2776 | copy(src, dst, count) +2793 | copy(src, dst, count) | ^^^^^^^^^^^^^^^^^^^^^ | note: used from within `core::intrinsics::copy::` - --> $CORE_SRC/intrinsics.rs:2762:21 + --> $CORE_SRC/intrinsics.rs:2779:21 | -2762 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { +2779 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { | ^^^^ note: called by `ptr_copy::copy_via_raw_ptr` --> $DIR/ptr_copy.rs:28:18 diff --git a/tests/ui/dis/ptr_read.stderr b/tests/ui/dis/ptr_read.stderr index c4f70a0853..17cc16c310 100644 --- a/tests/ui/dis/ptr_read.stderr +++ b/tests/ui/dis/ptr_read.stderr @@ -2,7 +2,7 @@ %4 = OpFunctionParameter %5 %6 = OpFunctionParameter %5 %7 = OpLabel -OpLine %8 1200 8 +OpLine %8 1215 8 %9 = OpLoad %10 %4 OpLine %11 7 13 OpStore %6 %9 diff --git a/tests/ui/dis/ptr_read_method.stderr b/tests/ui/dis/ptr_read_method.stderr index c4f70a0853..17cc16c310 100644 --- a/tests/ui/dis/ptr_read_method.stderr +++ b/tests/ui/dis/ptr_read_method.stderr @@ -2,7 +2,7 @@ %4 = OpFunctionParameter %5 %6 = OpFunctionParameter %5 %7 = OpLabel -OpLine %8 1200 8 +OpLine %8 1215 8 %9 = OpLoad %10 %4 OpLine %11 7 13 OpStore %6 %9 diff --git a/tests/ui/dis/ptr_write.stderr b/tests/ui/dis/ptr_write.stderr index f2f9af23c9..a34bffdedc 100644 --- a/tests/ui/dis/ptr_write.stderr +++ b/tests/ui/dis/ptr_write.stderr @@ -4,7 +4,7 @@ %7 = OpLabel OpLine %8 7 35 %9 = OpLoad %10 %4 -OpLine %11 1400 8 +OpLine %11 1415 8 OpStore %6 %9 OpNoLine OpReturn diff --git a/tests/ui/dis/ptr_write_method.stderr b/tests/ui/dis/ptr_write_method.stderr index 2141c5964c..c6607d192d 100644 --- a/tests/ui/dis/ptr_write_method.stderr +++ b/tests/ui/dis/ptr_write_method.stderr @@ -4,7 +4,7 @@ %7 = OpLabel OpLine %8 7 37 %9 = OpLoad %10 %4 -OpLine %11 1400 8 +OpLine %11 1415 8 OpStore %6 %9 OpNoLine OpReturn diff --git a/tests/ui/lang/core/ptr/allocate_const_scalar.stderr b/tests/ui/lang/core/ptr/allocate_const_scalar.stderr index df6374b37b..b52a31b6a3 100644 --- a/tests/ui/lang/core/ptr/allocate_const_scalar.stderr +++ b/tests/ui/lang/core/ptr/allocate_const_scalar.stderr @@ -1,3 +1,12 @@ +warning: the feature `ptr_internals` is internal to the compiler or standard library + --> $DIR/allocate_const_scalar.rs:6:12 + | +6 | #![feature(ptr_internals)] + | ^^^^^^^^^^^^^ + | + = note: using it is strongly discouraged + = note: `#[warn(internal_features)]` on by default + error: pointer has non-null integer address | note: used from within `allocate_const_scalar::main` @@ -11,5 +20,5 @@ note: called by `main` 15 | pub fn main(output: &mut Unique<[u8; 4]>) { | ^^^^ -error: aborting due to 1 previous error +error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/lang/core/ptr/allocate_vec_like.stderr b/tests/ui/lang/core/ptr/allocate_vec_like.stderr new file mode 100644 index 0000000000..d4376b8486 --- /dev/null +++ b/tests/ui/lang/core/ptr/allocate_vec_like.stderr @@ -0,0 +1,11 @@ +warning: the feature `ptr_internals` is internal to the compiler or standard library + --> $DIR/allocate_vec_like.rs:4:12 + | +4 | #![feature(ptr_internals)] + | ^^^^^^^^^^^^^ + | + = note: using it is strongly discouraged + = note: `#[warn(internal_features)]` on by default + +warning: 1 warning emitted + From 010d352b1bbf4c94a71ea7180a35703cef683ded Mon Sep 17 00:00:00 2001 From: Christian Legnitto Date: Mon, 1 Jan 2024 22:44:31 -0400 Subject: [PATCH 06/32] rustup: update to `nightly-2023-12-31`. --- CHANGELOG.md | 2 +- crates/rustc_codegen_spirv/build.rs | 4 +- crates/rustc_codegen_spirv/src/abi.rs | 28 +++++----- crates/rustc_codegen_spirv/src/attr.rs | 16 +++--- .../src/builder/builder_methods.rs | 11 +++- crates/rustc_codegen_spirv/src/builder/mod.rs | 19 +++---- .../src/builder/spirv_asm.rs | 50 ++++++++--------- .../rustc_codegen_spirv/src/builder_spirv.rs | 6 +- .../src/codegen_cx/constant.rs | 38 ++++++------- .../src/codegen_cx/declare.rs | 8 +-- .../src/codegen_cx/entry.rs | 56 +++++++++---------- .../rustc_codegen_spirv/src/codegen_cx/mod.rs | 6 +- .../src/codegen_cx/type_.rs | 14 ++--- crates/rustc_codegen_spirv/src/lib.rs | 8 +-- crates/rustc_codegen_spirv/src/link.rs | 40 +++++++------ .../src/linker/import_export_link.rs | 7 ++- .../rustc_codegen_spirv/src/linker/inline.rs | 7 ++- crates/rustc_codegen_spirv/src/linker/mod.rs | 9 +-- .../src/linker/simple_passes.rs | 13 +++-- .../src/linker/spirt_passes/diagnostics.rs | 15 +++-- crates/rustc_codegen_spirv/src/linker/test.rs | 13 ++--- .../rustc_codegen_spirv/src/linker/zombies.rs | 8 +-- crates/rustc_codegen_spirv/src/spirv_type.rs | 2 +- rust-toolchain.toml | 4 +- tests/ui/dis/issue-1062.stderr | 2 +- tests/ui/dis/ptr_copy.normal.stderr | 8 +-- 26 files changed, 205 insertions(+), 189 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d988ae791..f234cda856 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Changed 🛠 -- [PR#1109](https://github.com/EmbarkStudios/rust-gpu/pull/1109) updated toolchain to `nightly-2023-12-16` +- [PR#1109](https://github.com/EmbarkStudios/rust-gpu/pull/1109) updated toolchain to `nightly-2023-12-31` - [PR#1115](https://github.com/EmbarkStudios/rust-gpu/pull/1115) relaxed `glam` version requirements (from `>=0.22, <=0.24` to `>=0.22, <=0.25`) - [PR#1127](https://github.com/EmbarkStudios/rust-gpu/pull/1127) updated `spirv-tools` to `0.10.0`, which follows `vulkan-sdk-1.3.275` - [PR#1101](https://github.com/EmbarkStudios/rust-gpu/pull/1101) added `ignore` and `no_run` to documentation to make `cargo test` pass diff --git a/crates/rustc_codegen_spirv/build.rs b/crates/rustc_codegen_spirv/build.rs index 3f8886e383..432e3a6dab 100644 --- a/crates/rustc_codegen_spirv/build.rs +++ b/crates/rustc_codegen_spirv/build.rs @@ -10,9 +10,9 @@ use std::process::{Command, ExitCode}; /// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/ //const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml"); const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain] -channel = "nightly-2023-12-16" +channel = "nightly-2023-12-31" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = a96d57bdb6d2bb6d233d7d5aaefc2995ab99be01"#; +# commit_hash = 2a3e63551fe21458637480a97b65a2d15dec8062"#; fn get_rustc_commit_hash() -> Result> { let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc")); diff --git a/crates/rustc_codegen_spirv/src/abi.rs b/crates/rustc_codegen_spirv/src/abi.rs index 38586dc9aa..f6a82a86fb 100644 --- a/crates/rustc_codegen_spirv/src/abi.rs +++ b/crates/rustc_codegen_spirv/src/abi.rs @@ -580,7 +580,7 @@ fn dig_scalar_pointee<'tcx>( let new_pointee = dig_scalar_pointee(cx, field, offset - field_offset); match pointee { Some(old_pointee) if old_pointee != new_pointee => { - cx.tcx.sess.fatal(format!( + cx.tcx.dcx().fatal(format!( "dig_scalar_pointee: unsupported Pointer with different \ pointee types ({old_pointee:?} vs {new_pointee:?}) at offset {offset:?} in {layout:#?}" )); @@ -728,7 +728,7 @@ fn trans_struct<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>) - if i == 0 { field_names.push(cx.sym.discriminant); } else { - cx.tcx.sess.fatal("Variants::Multiple has multiple fields") + cx.tcx.dcx().fatal("Variants::Multiple has multiple fields") } }; } @@ -784,7 +784,7 @@ impl fmt::Display for TyLayoutNameKey<'_> { write!(f, "::{}", def.variants()[index].name)?; } } - if let (TyKind::Coroutine(_, _, _), Some(index)) = (self.ty.kind(), self.variant) { + if let (TyKind::Coroutine(_, _), Some(index)) = (self.ty.kind(), self.variant) { write!(f, "::{}", CoroutineArgs::variant_name(index))?; } Ok(()) @@ -804,7 +804,7 @@ fn trans_intrinsic_type<'tcx>( if ty.size != Size::from_bytes(4) { return Err(cx .tcx - .sess + .dcx() .err("#[spirv(generic_image)] type must have size 4")); } @@ -848,7 +848,7 @@ fn trans_intrinsic_type<'tcx>( _ => { return Err(cx .tcx - .sess + .dcx() .span_err(span, "Invalid sampled type to `Image`.")); } }; @@ -871,7 +871,7 @@ fn trans_intrinsic_type<'tcx>( Some(v) => Ok(v), None => Err(cx .tcx - .sess + .dcx() .err(format!("Invalid value for Image const generic: {value}"))), } } @@ -897,7 +897,7 @@ fn trans_intrinsic_type<'tcx>( IntrinsicType::Sampler => { // see SpirvType::sizeof if ty.size != Size::from_bytes(4) { - return Err(cx.tcx.sess.err("#[spirv(sampler)] type must have size 4")); + return Err(cx.tcx.dcx().err("#[spirv(sampler)] type must have size 4")); } Ok(SpirvType::Sampler.def(span, cx)) } @@ -910,7 +910,7 @@ fn trans_intrinsic_type<'tcx>( if ty.size != Size::from_bytes(4) { return Err(cx .tcx - .sess + .dcx() .err("#[spirv(sampled_image)] type must have size 4")); } @@ -923,7 +923,7 @@ fn trans_intrinsic_type<'tcx>( } else { Err(cx .tcx - .sess + .dcx() .err("#[spirv(sampled_image)] type must have a generic image type")) } } @@ -931,7 +931,7 @@ fn trans_intrinsic_type<'tcx>( if ty.size != Size::from_bytes(4) { return Err(cx .tcx - .sess + .dcx() .err("#[spirv(runtime_array)] type must have size 4")); } @@ -943,7 +943,7 @@ fn trans_intrinsic_type<'tcx>( } else { Err(cx .tcx - .sess + .dcx() .err("#[spirv(runtime_array)] type must have a generic element type")) } } @@ -958,12 +958,12 @@ fn trans_intrinsic_type<'tcx>( if field_types.len() < 2 { return Err(cx .tcx - .sess + .dcx() .span_err(span, "#[spirv(matrix)] type must have at least two fields")); } let elem_type = field_types[0]; if !field_types.iter().all(|&ty| ty == elem_type) { - return Err(cx.tcx.sess.span_err( + return Err(cx.tcx.dcx().span_err( span, "#[spirv(matrix)] type fields must all be the same type", )); @@ -973,7 +973,7 @@ fn trans_intrinsic_type<'tcx>( ty => { return Err(cx .tcx - .sess + .dcx() .struct_span_err(span, "#[spirv(matrix)] type fields must all be vectors") .note(format!("field type is {}", ty.debug(elem_type, cx))) .emit()); diff --git a/crates/rustc_codegen_spirv/src/attr.rs b/crates/rustc_codegen_spirv/src/attr.rs index b59f683aa7..a7c16f9139 100644 --- a/crates/rustc_codegen_spirv/src/attr.rs +++ b/crates/rustc_codegen_spirv/src/attr.rs @@ -154,7 +154,7 @@ impl AggregatedSpirvAttributes { let (span, parsed_attr) = match parse_attr_result { Ok(span_and_parsed_attr) => span_and_parsed_attr, Err((span, msg)) => { - cx.tcx.sess.span_delayed_bug(span, msg); + cx.tcx.dcx().span_delayed_bug(span, msg); continue; } }; @@ -165,7 +165,7 @@ impl AggregatedSpirvAttributes { category, }) => { cx.tcx - .sess + .dcx() .span_delayed_bug(span, format!("multiple {category} attributes")); } } @@ -278,7 +278,7 @@ impl CheckSpirvAttrVisitor<'_> { let (span, parsed_attr) = match parse_attr_result { Ok(span_and_parsed_attr) => span_and_parsed_attr, Err((span, msg)) => { - self.tcx.sess.span_err(span, msg); + self.tcx.dcx().span_err(span, msg); continue; } }; @@ -323,7 +323,7 @@ impl CheckSpirvAttrVisitor<'_> { .filter_map(|r| r.ok()) .any(|(_, attr)| matches!(attr, SpirvAttribute::Entry(_))); if !parent_is_entry_point { - self.tcx.sess.span_err( + self.tcx.dcx().span_err( span, "attribute is only valid on a parameter of an entry-point function", ); @@ -346,7 +346,7 @@ impl CheckSpirvAttrVisitor<'_> { }; if let Err(msg) = valid { - self.tcx.sess.span_err( + self.tcx.dcx().span_err( span, format!("`{storage_class:?}` storage class {msg}"), ); @@ -367,7 +367,7 @@ impl CheckSpirvAttrVisitor<'_> { }; match valid_target { Err(Expected(expected_target)) => { - self.tcx.sess.span_err( + self.tcx.dcx().span_err( span, format!( "attribute is only valid on a {expected_target}, not on a {target}" @@ -381,7 +381,7 @@ impl CheckSpirvAttrVisitor<'_> { category, }) => { self.tcx - .sess + .dcx() .struct_span_err( span, format!("only one {category} attribute is allowed on a {target}"), @@ -397,7 +397,7 @@ impl CheckSpirvAttrVisitor<'_> { // so we can perform further checks, emit warnings, etc. if let Some(block_attr) = aggregated_attrs.block { - self.tcx.sess.span_warn( + self.tcx.dcx().span_warn( block_attr.span, "#[spirv(block)] is no longer needed and should be removed", ); diff --git a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs index 4e1cad8186..efd1d7056d 100644 --- a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs +++ b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs @@ -2282,7 +2282,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { order: AtomicOrdering, failure_order: AtomicOrdering, _weak: bool, - ) -> Self::Value { + ) -> (Self::Value, Self::Value) { assert_ty_eq!(self, cmp.ty, src.ty); let ty = src.ty; @@ -2310,7 +2310,12 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { ) .unwrap() .with_type(access_ty); - self.bitcast(result, ty) + let result = self.bitcast(result, ty); + + let val = self.extract_value(result, 0); + let success = self.extract_value(result, 1); + + (val, success) } fn atomic_rmw( @@ -2987,7 +2992,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { Err(FormatArgsNotRecognized(step)) => { if let Some(current_span) = self.current_span { - let mut warn = self.tcx.sess.struct_span_warn( + let mut warn = self.tcx.dcx().struct_span_warn( current_span, "failed to find and remove `format_args!` construction for this `panic!`", ); diff --git a/crates/rustc_codegen_spirv/src/builder/mod.rs b/crates/rustc_codegen_spirv/src/builder/mod.rs index fbc12d2ddd..869b494f53 100644 --- a/crates/rustc_codegen_spirv/src/builder/mod.rs +++ b/crates/rustc_codegen_spirv/src/builder/mod.rs @@ -20,7 +20,7 @@ use rustc_codegen_ssa::traits::{ AbiBuilderMethods, ArgAbiMethods, BackendTypes, BuilderMethods, CoverageInfoBuilderMethods, DebugInfoBuilderMethods, HasCodegen, StaticBuilderMethods, TypeMembershipMethods, }; -use rustc_errors::{DiagnosticBuilder, DiagnosticMessage, ErrorGuaranteed}; +use rustc_errors::{DiagnosticBuilder, DiagnosticMessage}; use rustc_middle::mir::Coverage; use rustc_middle::span_bug; use rustc_middle::ty::layout::{ @@ -69,32 +69,29 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } #[track_caller] - pub fn struct_err( - &self, - msg: impl Into, - ) -> DiagnosticBuilder<'_, ErrorGuaranteed> { + pub fn struct_err(&self, msg: impl Into) -> DiagnosticBuilder<'_> { if let Some(current_span) = self.current_span { - self.tcx.sess.struct_span_err(current_span, msg) + self.tcx.dcx().struct_span_err(current_span, msg) } else { - self.tcx.sess.struct_err(msg) + self.tcx.dcx().struct_err(msg) } } #[track_caller] pub fn err(&self, msg: impl Into) { if let Some(current_span) = self.current_span { - self.tcx.sess.span_err(current_span, msg); + self.tcx.dcx().span_err(current_span, msg); } else { - self.tcx.sess.err(msg); + self.tcx.dcx().err(msg); } } #[track_caller] pub fn fatal(&self, msg: impl Into) -> ! { if let Some(current_span) = self.current_span { - self.tcx.sess.span_fatal(current_span, msg) + self.tcx.dcx().span_fatal(current_span, msg) } else { - self.tcx.sess.fatal(msg) + self.tcx.dcx().fatal(msg) } } diff --git a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs index 97c4d9cfa1..52fa469314 100644 --- a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs +++ b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs @@ -101,7 +101,7 @@ impl<'a, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'tcx> { } => { if let Some(modifier) = modifier { self.tcx - .sess + .dcx() .span_err(span, format!("asm modifiers are not supported: {modifier}")); } let line = tokens.last_mut().unwrap(); @@ -455,7 +455,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { } Token::Placeholder(_, span) | Token::Typeof(_, span, _) => { self.tcx - .sess + .dcx() .span_err(span, "cannot use a dynamic value as an instruction type"); return; } @@ -582,7 +582,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { )); } if tokens.next().is_some() { - self.tcx.sess.err(format!( + self.tcx.dcx().err(format!( "too many operands to instruction: {}", instruction.class.opname )); @@ -798,7 +798,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { )) => {} _ => { self.tcx - .sess + .dcx() .span_err(span, format!("invalid register: {reg}")); } } @@ -831,7 +831,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { } Token::Typeof(_, span, _) => { self.tcx - .sess + .dcx() .span_err(span, "cannot assign to a typeof expression"); None } @@ -839,7 +839,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { InlineAsmOperandRef::In { reg, value: _ } => { self.check_reg(span, reg); self.tcx - .sess + .dcx() .span_err(span, "in register cannot be assigned to"); None } @@ -852,7 +852,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { match place { Some(place) => Some(OutRegister::Place(*place)), None => { - self.tcx.sess.span_err(span, "missing place for register"); + self.tcx.dcx().span_err(span, "missing place for register"); None } } @@ -867,26 +867,26 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { match out_place { Some(out_place) => Some(OutRegister::Place(*out_place)), None => { - self.tcx.sess.span_err(span, "missing place for register"); + self.tcx.dcx().span_err(span, "missing place for register"); None } } } InlineAsmOperandRef::Const { string: _ } => { self.tcx - .sess + .dcx() .span_err(span, "cannot write to const asm argument"); None } InlineAsmOperandRef::SymFn { instance: _ } => { self.tcx - .sess + .dcx() .span_err(span, "cannot write to function asm argument"); None } InlineAsmOperandRef::SymStatic { def_id: _ } => { self.tcx - .sess + .dcx() .span_err(span, "cannot write to static variable asm argument"); None } @@ -921,7 +921,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { TypeofKind::Dereference => match self.lookup_type(ty) { SpirvType::Pointer { pointee } => pointee, other => { - self.tcx.sess.span_err( + self.tcx.dcx().span_err( span, format!( "cannot use typeof* on non-pointer type: {}", @@ -943,7 +943,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { Some(place) => match self.lookup_type(place.llval.ty) { SpirvType::Pointer { pointee } => Some(pointee), other => { - self.tcx.sess.span_err( + self.tcx.dcx().span_err( span, format!( "out register type not pointer: {}", @@ -955,7 +955,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { }, None => { self.tcx - .sess + .dcx() .span_err(span, "missing place for out register typeof"); None } @@ -972,18 +972,18 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { } InlineAsmOperandRef::Const { string: _ } => { self.tcx - .sess + .dcx() .span_err(span, "cannot take the type of a const asm argument"); None } InlineAsmOperandRef::SymFn { instance: _ } => { self.tcx - .sess + .dcx() .span_err(span, "cannot take the type of a function asm argument"); None } InlineAsmOperandRef::SymStatic { def_id: _ } => { - self.tcx.sess.span_err( + self.tcx.dcx().span_err( span, "cannot take the type of a static variable asm argument", ); @@ -1002,7 +1002,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { } => { self.check_reg(span, reg); self.tcx - .sess + .dcx() .span_err(span, "out register cannot be used as a value"); None } @@ -1017,19 +1017,19 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { } InlineAsmOperandRef::Const { string: _ } => { self.tcx - .sess + .dcx() .span_err(span, "const asm argument not supported yet"); None } InlineAsmOperandRef::SymFn { instance: _ } => { self.tcx - .sess + .dcx() .span_err(span, "function asm argument not supported yet"); None } InlineAsmOperandRef::SymStatic { def_id: _ } => { self.tcx - .sess + .dcx() .span_err(span, "static variable asm argument not supported yet"); None } @@ -1161,13 +1161,13 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { self.err(format!("expected a literal, not a string for a {kind:?}")); } Some(Token::Placeholder(_, span)) => { - self.tcx.sess.span_err( + self.tcx.dcx().span_err( span, format!("expected a literal, not a dynamic value for a {kind:?}"), ); } Some(Token::Typeof(_, span, _)) => { - self.tcx.sess.span_err( + self.tcx.dcx().span_err( span, format!("expected a literal, not a type for a {kind:?}"), ); @@ -1363,13 +1363,13 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { self.err(format!("expected a literal, not a string for a {kind:?}")); } Token::Placeholder(_, span) => { - self.tcx.sess.span_err( + self.tcx.dcx().span_err( span, format!("expected a literal, not a dynamic value for a {kind:?}"), ); } Token::Typeof(_, span, _) => { - self.tcx.sess.span_err( + self.tcx.dcx().span_err( span, format!("expected a literal, not a type for a {kind:?}"), ); diff --git a/crates/rustc_codegen_spirv/src/builder_spirv.rs b/crates/rustc_codegen_spirv/src/builder_spirv.rs index 7d6249cafc..00b51c383d 100644 --- a/crates/rustc_codegen_spirv/src/builder_spirv.rs +++ b/crates/rustc_codegen_spirv/src/builder_spirv.rs @@ -163,7 +163,7 @@ impl SpirvValue { SpirvValueKind::IllegalTypeUsed(id) => { cx.tcx - .sess + .dcx() .struct_span_err(span, "Can't use type as a value") .note(format!("Type: *{}", cx.debug_type(id))) .emit(); @@ -367,7 +367,7 @@ impl Eq for DebugFileKey {} impl Hash for DebugFileKey { fn hash(&self, state: &mut H) { let Self(sf) = self; - sf.name_hash.hash(state); + sf.stable_id.hash(state); sf.src_hash.hash(state); } } @@ -392,7 +392,7 @@ pub struct DebugFileSpirv<'tcx> { /// same time, mutating the central module object all at once. Unfortunately, rspirv doesn't work /// like that. Instead, there is a single builder object, which owns a module and a "cursor". This /// cursor indicates to the builder where to append instructions when an instruction is added - -/// e.g. if add() is called, then `OpAdd` is appended to the basic block pointed to by the cursor. +/// e.g. if `add()` is called, then `OpAdd` is appended to the basic block pointed to by the cursor. /// /// So! We emulate the LLVM system by treating the rspirv Builder as the "central module object", /// then, when a "builder object" is created, we store a reference to a `RefCell`, diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs b/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs index eed04cd4c1..ba123ea594 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs @@ -64,7 +64,7 @@ impl<'tcx> CodegenCx<'tcx> { 0 | 1 => self.def_constant(ty, SpirvConst::Bool(val != 0)), _ => self .tcx - .sess + .dcx() .fatal(format!("Invalid constant value for bool: {val}")), }, SpirvType::Integer(128, _) => { @@ -72,7 +72,7 @@ impl<'tcx> CodegenCx<'tcx> { self.zombie_no_span(result.def_cx(self), "u128 constant"); result } - other => self.tcx.sess.fatal(format!( + other => self.tcx.dcx().fatal(format!( "constant_int invalid on type {}", other.debug(ty, self) )), @@ -93,7 +93,7 @@ impl<'tcx> CodegenCx<'tcx> { match self.lookup_type(ty) { SpirvType::Float(32) => self.def_constant(ty, SpirvConst::F32((val as f32).to_bits())), SpirvType::Float(64) => self.def_constant(ty, SpirvConst::F64(val.to_bits())), - other => self.tcx.sess.fatal(format!( + other => self.tcx.dcx().fatal(format!( "constant_float invalid on type {}", other.debug(ty, self) )), @@ -257,10 +257,10 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> { 1 => self.constant_bool(DUMMY_SP, true), _ => self .tcx - .sess + .dcx() .fatal(format!("Invalid constant value for bool: {data}")), }, - other => self.tcx.sess.fatal(format!( + other => self.tcx.dcx().fatal(format!( "scalar_to_backend Primitive::Int not supported on type {}", other.debug(ty, self) )), @@ -296,7 +296,7 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> { GlobalAlloc::Memory(alloc) => { let pointee = match self.lookup_type(ty) { SpirvType::Pointer { pointee } => pointee, - other => self.tcx.sess.fatal(format!( + other => self.tcx.dcx().fatal(format!( "GlobalAlloc::Memory type not implemented: {}", other.debug(ty, self) )), @@ -316,7 +316,7 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> { .unwrap_memory(); let pointee = match self.lookup_type(ty) { SpirvType::Pointer { pointee } => pointee, - other => self.tcx.sess.fatal(format!( + other => self.tcx.dcx().fatal(format!( "GlobalAlloc::VTable type not implemented: {}", other.debug(ty, self) )), @@ -335,7 +335,7 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> { base_addr } else { self.tcx - .sess + .dcx() .fatal("Non-zero scalar_to_backend ptr.offset not supported") // let offset = self.constant_u64(ptr.offset.bytes()); // self.gep(base_addr, once(offset)) @@ -345,7 +345,7 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> { value } else { self.tcx - .sess + .dcx() .fatal("Non-pointer-typed scalar_to_backend Scalar::Ptr not supported"); // unsafe { llvm::LLVMConstPtrToInt(llval, llty) } } @@ -447,7 +447,7 @@ impl<'tcx> CodegenCx<'tcx> { match ty_concrete { SpirvType::Void => self .tcx - .sess + .dcx() .fatal("cannot create const alloc of type void"), SpirvType::Bool | SpirvType::Integer(..) @@ -465,7 +465,7 @@ impl<'tcx> CodegenCx<'tcx> { 128 => Integer::I128, other => { self.tcx - .sess + .dcx() .fatal(format!("invalid size for integer: {other}")); } }; @@ -476,7 +476,7 @@ impl<'tcx> CodegenCx<'tcx> { 64 => Primitive::F64, other => { self.tcx - .sess + .dcx() .fatal(format!("invalid size for float: {other}")); } }, @@ -602,26 +602,26 @@ impl<'tcx> CodegenCx<'tcx> { } SpirvType::Function { .. } => self .tcx - .sess + .dcx() .fatal("TODO: SpirvType::Function not supported yet in create_const_alloc"), - SpirvType::Image { .. } => self.tcx.sess.fatal("cannot create a constant image value"), + SpirvType::Image { .. } => self.tcx.dcx().fatal("cannot create a constant image value"), SpirvType::Sampler => self .tcx - .sess + .dcx() .fatal("cannot create a constant sampler value"), SpirvType::SampledImage { .. } => self .tcx - .sess + .dcx() .fatal("cannot create a constant sampled image value"), SpirvType::InterfaceBlock { .. } => self .tcx - .sess + .dcx() .fatal("cannot create a constant interface block value"), SpirvType::AccelerationStructureKhr => self .tcx - .sess + .dcx() .fatal("cannot create a constant acceleration structure"), - SpirvType::RayQueryKhr => self.tcx.sess.fatal("cannot create a constant ray query"), + SpirvType::RayQueryKhr => self.tcx.dcx().fatal("cannot create a constant ray query"), } } } diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs b/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs index 0786c22835..a927cc1259 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs @@ -167,7 +167,7 @@ impl<'tcx> CodegenCx<'tcx> { self.libm_intrinsics.borrow_mut().insert(fn_id, intrinsic); } None => { - self.tcx.sess.err(format!( + self.tcx.dcx().err(format!( "missing libm intrinsic {symbol_name}, which is {instance}" )); } @@ -279,7 +279,7 @@ impl<'tcx> PreDefineMethods<'tcx> for CodegenCx<'tcx> { Linkage::External => Some(LinkageType::Export), Linkage::Internal => None, other => { - self.tcx.sess.err(format!( + self.tcx.dcx().err(format!( "TODO: Linkage type {other:?} not supported yet for static var symbol {symbol_name}" )); None @@ -308,7 +308,7 @@ impl<'tcx> PreDefineMethods<'tcx> for CodegenCx<'tcx> { Linkage::External | Linkage::WeakAny => Some(LinkageType::Export), Linkage::Internal => None, other => { - self.tcx.sess.err(format!( + self.tcx.dcx().err(format!( "TODO: Linkage type {other:?} not supported yet for function symbol {symbol_name}" )); None @@ -340,7 +340,7 @@ impl<'tcx> StaticMethods for CodegenCx<'tcx> { }; let value_ty = match self.lookup_type(g.ty) { SpirvType::Pointer { pointee } => pointee, - other => self.tcx.sess.fatal(format!( + other => self.tcx.dcx().fatal(format!( "global had non-pointer type {}", other.debug(g.ty, self) )), diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs b/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs index 04e8268568..7af4d77aaf 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs @@ -75,7 +75,7 @@ impl<'tcx> CodegenCx<'tcx> { id } else { self.tcx - .sess + .dcx() .span_err(span, format!("cannot declare {name} as an entry point")); return; }; @@ -93,7 +93,7 @@ impl<'tcx> CodegenCx<'tcx> { // the `FnAbi` readjustment to only use `PassMode::Pair` for // pointers to `!Sized` types, but not other `ScalarPair`s. if !matches!(arg_abi.layout.ty.kind(), ty::Ref(..)) { - self.tcx.sess.span_err( + self.tcx.dcx().span_err( hir_param.ty_span, format!( "entry point parameter type not yet supported \ @@ -105,7 +105,7 @@ impl<'tcx> CodegenCx<'tcx> { } // FIXME(eddyb) support these (by just ignoring them) - if there // is any validation concern, it should be done on the types. - PassMode::Ignore => self.tcx.sess.span_fatal( + PassMode::Ignore => self.tcx.dcx().span_fatal( hir_param.ty_span, format!( "entry point parameter type not yet supported \ @@ -123,7 +123,7 @@ impl<'tcx> CodegenCx<'tcx> { if fn_abi.ret.layout.ty.is_unit() { assert_matches!(fn_abi.ret.mode, PassMode::Ignore); } else { - self.tcx.sess.span_err( + self.tcx.dcx().span_err( span, format!( "entry point should return `()`, not `{}`", @@ -274,7 +274,7 @@ impl<'tcx> CodegenCx<'tcx> { if is_ref { Some(StorageClass::UniformConstant) } else { - self.tcx.sess.span_err( + self.tcx.dcx().span_err( hir_param.ty_span, format!( "entry parameter type must be by-reference: `&{}`", @@ -291,7 +291,7 @@ impl<'tcx> CodegenCx<'tcx> { let storage_class = storage_class_attr.value; if !is_ref { - self.tcx.sess.span_fatal( + self.tcx.dcx().span_fatal( hir_param.ty_span, format!( "invalid entry param type `{}` for storage class `{storage_class:?}` \ @@ -303,13 +303,13 @@ impl<'tcx> CodegenCx<'tcx> { } match deduced_storage_class_from_ty { - Some(deduced) if storage_class == deduced => self.tcx.sess.span_warn( + Some(deduced) if storage_class == deduced => self.tcx.dcx().span_warn( storage_class_attr.span, "redundant storage class attribute, storage class is deduced from type", ), Some(deduced) => { self.tcx - .sess + .dcx() .struct_span_err(hir_param.span, "storage class mismatch") .span_label( storage_class_attr.span, @@ -338,7 +338,7 @@ impl<'tcx> CodegenCx<'tcx> { .unwrap_or_else(|| match (is_ref, explicit_mutbl) { (false, _) => StorageClass::Input, (true, hir::Mutability::Mut) => StorageClass::Output, - (true, hir::Mutability::Not) => self.tcx.sess.span_fatal( + (true, hir::Mutability::Not) => self.tcx.dcx().span_fatal( hir_param.ty_span, format!( "invalid entry param type `{}` (expected `{}` or `&mut {1}`)", @@ -355,7 +355,7 @@ impl<'tcx> CodegenCx<'tcx> { let storage_class_requires_read_only = expected_mutbl_for(storage_class) == hir::Mutability::Not; if !ref_is_read_only && storage_class_requires_read_only { - let mut err = self.tcx.sess.struct_span_err( + let mut err = self.tcx.dcx().struct_span_err( hir_param.ty_span, format!( "entry-point requires {}...", @@ -395,7 +395,7 @@ impl<'tcx> CodegenCx<'tcx> { let mut storage_class = Ok(storage_class); if let Some(spec_constant) = attrs.spec_constant { if ref_or_value_layout.ty != self.tcx.types.u32 { - self.tcx.sess.span_err( + self.tcx.dcx().span_err( hir_param.ty_span, format!( "unsupported `#[spirv(spec_constant)]` type `{}` (expected `{}`)", @@ -403,7 +403,7 @@ impl<'tcx> CodegenCx<'tcx> { ), ); } else if let Some(storage_class) = attrs.storage_class { - self.tcx.sess.span_err( + self.tcx.dcx().span_err( storage_class.span, "`#[spirv(spec_constant)]` cannot have a storage class", ); @@ -494,7 +494,7 @@ impl<'tcx> CodegenCx<'tcx> { // value. We currently only do that with unsized types, so if a type is a pair for some // other reason (e.g. a tuple), we bail. self.tcx - .sess + .dcx() .span_fatal(hir_param.ty_span, "pair type not supported yet") } let var_ptr_spirv_type; @@ -518,7 +518,7 @@ impl<'tcx> CodegenCx<'tcx> { match self.lookup_type(value_spirv_type) { SpirvType::RuntimeArray { .. } => {} _ => { - self.tcx.sess.span_err( + self.tcx.dcx().span_err( hir_param.ty_span, "only plain slices are supported as unsized types", ); @@ -538,7 +538,7 @@ impl<'tcx> CodegenCx<'tcx> { // It's OK to use a RuntimeArray and not have a length parameter, but // it's just nicer ergonomics to use a slice. self.tcx - .sess + .dcx() .span_warn(hir_param.ty_span, "use &[T] instead of &RuntimeArray"); } None @@ -552,7 +552,7 @@ impl<'tcx> CodegenCx<'tcx> { match self.lookup_type(value_spirv_type) { SpirvType::RuntimeArray { .. } => { if is_unsized_with_len { - self.tcx.sess.span_err( + self.tcx.dcx().span_err( hir_param.ty_span, "uniform_constant must use &RuntimeArray, not &[T]", ); @@ -560,7 +560,7 @@ impl<'tcx> CodegenCx<'tcx> { } _ => { if is_unsized { - self.tcx.sess.span_err( + self.tcx.dcx().span_err( hir_param.ty_span, "only plain slices are supported as unsized types", ); @@ -581,7 +581,7 @@ impl<'tcx> CodegenCx<'tcx> { var_ptr_spirv_type = self.type_ptr_to(value_spirv_type); if is_unsized { - self.tcx.sess.span_fatal( + self.tcx.dcx().span_fatal( hir_param.ty_span, format!( "unsized types are not supported for {}", @@ -644,7 +644,7 @@ impl<'tcx> CodegenCx<'tcx> { let mut decoration_supersedes_location = false; if let Some(builtin) = attrs.builtin { if let Err(SpecConstant { .. }) = storage_class { - self.tcx.sess.span_fatal( + self.tcx.dcx().span_fatal( builtin.span, format!( "`#[spirv(spec_constant)]` cannot be `{:?}` builtin", @@ -661,7 +661,7 @@ impl<'tcx> CodegenCx<'tcx> { } if let Some(descriptor_set) = attrs.descriptor_set { if let Err(SpecConstant { .. }) = storage_class { - self.tcx.sess.span_fatal( + self.tcx.dcx().span_fatal( descriptor_set.span, "`#[spirv(descriptor_set = ...)]` cannot apply to `#[spirv(spec_constant)]`", ); @@ -675,7 +675,7 @@ impl<'tcx> CodegenCx<'tcx> { } if let Some(binding) = attrs.binding { if let Err(SpecConstant { .. }) = storage_class { - self.tcx.sess.span_fatal( + self.tcx.dcx().span_fatal( binding.span, "`#[spirv(binding = ...)]` cannot apply to `#[spirv(spec_constant)]`", ); @@ -689,7 +689,7 @@ impl<'tcx> CodegenCx<'tcx> { } if let Some(flat) = attrs.flat { if let Err(SpecConstant { .. }) = storage_class { - self.tcx.sess.span_fatal( + self.tcx.dcx().span_fatal( flat.span, "`#[spirv(flat)]` cannot apply to `#[spirv(spec_constant)]`", ); @@ -699,7 +699,7 @@ impl<'tcx> CodegenCx<'tcx> { } if let Some(invariant) = attrs.invariant { if storage_class != Ok(StorageClass::Output) { - self.tcx.sess.span_fatal( + self.tcx.dcx().span_fatal( invariant.span, "`#[spirv(invariant)]` is only valid on Output variables", ); @@ -732,17 +732,17 @@ impl<'tcx> CodegenCx<'tcx> { ); } else if is_subpass_input { self.tcx - .sess + .dcx() .span_err(hir_param.ty_span, "Missing capability InputAttachment"); } else { - self.tcx.sess.span_err( + self.tcx.dcx().span_err( attachment_index.span, "#[spirv(input_attachment_index)] is only valid on Image types with dim = SubpassData" ); } decoration_supersedes_location = true; } else if is_subpass_input { - self.tcx.sess.span_err( + self.tcx.dcx().span_err( hir_param.ty_span, "Image types with dim = SubpassData require #[spirv(input_attachment_index)] decoration", ); @@ -839,7 +839,7 @@ impl<'tcx> CodegenCx<'tcx> { && !(is_builtin && matches!(storage_class, StorageClass::Input | StorageClass::Output)) { self.tcx - .sess + .dcx() .span_err(span, "entry-point parameter cannot contain `bool`s"); } @@ -887,7 +887,7 @@ impl<'tcx> CodegenCx<'tcx> { _ => None, }; if let Some((span, must_or_cannot)) = flat_mismatch { - self.tcx.sess.span_err( + self.tcx.dcx().span_err( span, format!( "`{execution_model:?}` entry-point `{storage_class:?}` parameter \ diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs index e9a378d038..e784431133 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs @@ -106,7 +106,7 @@ impl<'tcx> CodegenCx<'tcx> { .map(|s| s.parse()) .collect::>() .unwrap_or_else(|error| { - tcx.sess.err(error); + tcx.dcx().err(error); Vec::new() }); @@ -269,7 +269,9 @@ impl CodegenArgs { pub fn from_session(sess: &Session) -> Self { match CodegenArgs::parse(&sess.opts.cg.llvm_args) { Ok(ok) => ok, - Err(err) => sess.fatal(format!("Unable to parse llvm-args: {err}")), + Err(err) => sess + .dcx() + .fatal(format!("Unable to parse llvm-args: {err}")), } } diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs b/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs index c6a086c5a9..6b6a57dece 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs @@ -20,7 +20,7 @@ impl<'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'tcx> { #[inline] fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! { if let LayoutError::SizeOverflow(_) = err { - self.tcx.sess.span_fatal(span, err.to_string()) + self.tcx.dcx().span_fatal(span, err.to_string()) } else { span_bug!(span, "failed to get layout for `{}`: {}", ty, err) } @@ -38,7 +38,7 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'tcx> { fn_abi_request: FnAbiRequest<'tcx>, ) -> ! { if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err { - self.tcx.sess.emit_fatal(Spanned { span, node: err }) + self.tcx.dcx().emit_fatal(Spanned { span, node: err }) } else { match fn_abi_request { FnAbiRequest::OfFnPtr { sig, extra_args } => { @@ -211,7 +211,7 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> { 64 => TypeKind::Double, other => self .tcx - .sess + .dcx() .fatal(format!("Invalid float width in type_kind: {other}")), }, SpirvType::Adt { .. } | SpirvType::InterfaceBlock { .. } => { @@ -241,7 +241,7 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> { match self.lookup_type(ty) { SpirvType::Pointer { pointee } => pointee, SpirvType::Vector { element, .. } => element, - spirv_type => self.tcx.sess.fatal(format!( + spirv_type => self.tcx.dcx().fatal(format!( "element_type called on invalid type: {spirv_type:?}" )), } @@ -253,7 +253,7 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> { SpirvType::Vector { count, .. } => count as usize, ty => self .tcx - .sess + .dcx() .fatal(format!("vector_length called on non-vector type: {ty:?}")), } } @@ -263,7 +263,7 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> { SpirvType::Float(width) => width as usize, ty => self .tcx - .sess + .dcx() .fatal(format!("float_width called on non-float type: {ty:?}")), } } @@ -274,7 +274,7 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> { SpirvType::Integer(width, _) => width as u64, ty => self .tcx - .sess + .dcx() .fatal(format!("int_width called on non-integer type: {ty:?}")), } } diff --git a/crates/rustc_codegen_spirv/src/lib.rs b/crates/rustc_codegen_spirv/src/lib.rs index f9635f5c68..864d767394 100644 --- a/crates/rustc_codegen_spirv/src/lib.rs +++ b/crates/rustc_codegen_spirv/src/lib.rs @@ -99,7 +99,7 @@ use rustc_codegen_ssa::traits::{ }; use rustc_codegen_ssa::{CodegenResults, CompiledModule, ModuleCodegen, ModuleKind}; use rustc_data_structures::fx::FxIndexMap; -use rustc_errors::{ErrorGuaranteed, FatalError, Handler}; +use rustc_errors::{DiagCtxt, ErrorGuaranteed, FatalError}; use rustc_metadata::EncodedMetadata; use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; use rustc_middle::mir::mono::{MonoItem, MonoItemData}; @@ -294,7 +294,7 @@ impl WriteBackendMethods for SpirvCodegenBackend { fn run_link( _cgcx: &CodegenContext, - _diag_handler: &Handler, + _diag_handler: &DiagCtxt, _modules: Vec>, ) -> Result, FatalError> { todo!() @@ -326,7 +326,7 @@ impl WriteBackendMethods for SpirvCodegenBackend { unsafe fn optimize( _: &CodegenContext, - _: &Handler, + _: &DiagCtxt, _: &ModuleCodegen, _: &ModuleConfig, ) -> Result<(), FatalError> { @@ -357,7 +357,7 @@ impl WriteBackendMethods for SpirvCodegenBackend { unsafe fn codegen( cgcx: &CodegenContext, - _diag_handler: &Handler, + _diag_handler: &DiagCtxt, module: ModuleCodegen, _config: &ModuleConfig, ) -> Result { diff --git a/crates/rustc_codegen_spirv/src/link.rs b/crates/rustc_codegen_spirv/src/link.rs index a926a2ae08..77c6b5ca01 100644 --- a/crates/rustc_codegen_spirv/src/link.rs +++ b/crates/rustc_codegen_spirv/src/link.rs @@ -9,7 +9,7 @@ use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModul use rustc_codegen_ssa::back::write::CodegenContext; use rustc_codegen_ssa::{CodegenResults, NativeLib}; use rustc_data_structures::fx::FxHashSet; -use rustc_errors::FatalError; +use rustc_errors::{DiagnosticBuilder, FatalError}; use rustc_metadata::fs::METADATA_FILENAME; use rustc_middle::bug; use rustc_middle::dep_graph::WorkProduct; @@ -87,7 +87,8 @@ pub fn link( ); } other => { - sess.err(format!("CrateType {other:?} not supported yet")); + sess.dcx() + .err(format!("CrateType {other:?} not supported yet")); } } match out_filename { @@ -124,7 +125,7 @@ fn link_rlib(sess: &Session, codegen_results: &CodegenResults, out_filename: &Pa .. } = lib.kind { - sess.err(format!( + sess.dcx().err(format!( "adding native library to rlib not supported yet: {}", lib.name )); @@ -278,7 +279,7 @@ fn post_link_single_module( (optlevel, false) => format!("optlevel={optlevel:?}"), (optlevel, true) => format!("optlevel={optlevel:?}, debuginfo=None"), }; - sess.warn(format!( + sess.dcx().warn(format!( "`spirv-opt` should have ran ({reason}) but was disabled by `--no-spirv-opt`" )); spv_binary @@ -295,7 +296,9 @@ fn post_link_single_module( let save_modules_timer = sess.timer("link_save_modules"); if let Err(e) = std::fs::write(out_filename, spirv_tools::binary::from_binary(&spv_binary)) { - let mut err = sess.struct_err("failed to serialize spirv-binary to disk"); + let mut err = sess + .dcx() + .struct_err("failed to serialize spirv-binary to disk"); err.note(format!("module `{}`", out_filename.display())); err.note(format!("I/O error: {e:#}")); err.emit(); @@ -343,14 +346,15 @@ fn do_spirv_opt( // TODO: Adds spans here? Not sure how useful with binary, but maybe? let mut err = match msg.level { - Level::Fatal | Level::InternalError => { - // FIXME(eddyb) this was `struct_fatal` but that doesn't seem - // necessary and also lacks `.forget_guarantee()`. - sess.struct_err(msg.message).forget_guarantee() - } - Level::Error => sess.struct_err(msg.message).forget_guarantee(), - Level::Warning => sess.struct_warn(msg.message), - Level::Info | Level::Debug => sess.struct_note(msg.message), + // We have to manually construct this after `forget_guarantee` was removed in + // + Level::Error | Level::Fatal | Level::InternalError => DiagnosticBuilder::<()>::new( + sess.dcx(), + rustc_errors::Level::Error { lint: false }, + msg.message, + ), + Level::Warning => sess.dcx().struct_warn(msg.message), + Level::Info | Level::Debug => sess.dcx().struct_note(msg.message), }; err.note(format!("module `{}`", filename.display())); @@ -363,7 +367,7 @@ fn do_spirv_opt( Ok(spirv_tools::binary::Binary::OwnedU32(words)) => words, Ok(binary) => binary.as_words().to_vec(), Err(e) => { - let mut err = sess.struct_warn(e.to_string()); + let mut err = sess.dcx().struct_warn(e.to_string()); err.note("spirv-opt failed, leaving as unoptimized"); err.note(format!("module `{}`", filename.display())); err.emit(); @@ -383,7 +387,7 @@ fn do_spirv_val( let validator = val::create(sess.target.options.env.parse().ok()); if let Err(e) = validator.validate(spv_binary, Some(options)) { - let mut err = sess.struct_err(e.to_string()); + let mut err = sess.dcx().struct_err(e.to_string()); err.note("spirv-val failed"); err.note(format!("module `{}`", filename.display())); err.emit(); @@ -433,7 +437,7 @@ fn add_upstream_rust_crates( Linkage::Static => rlibs.push(src.rlib.as_ref().unwrap().0.clone()), //Linkage::Dynamic => rlibs.push(src.dylib.as_ref().unwrap().0.clone()), Linkage::Dynamic => { - sess.err("TODO: Linkage::Dynamic not supported yet"); + sess.dcx().err("TODO: Linkage::Dynamic not supported yet"); } } } @@ -467,7 +471,7 @@ fn add_upstream_native_libraries( .. } => {} - _ => sess.fatal(format!( + _ => sess.dcx().fatal(format!( "`NativeLibKind::{:?}` (name={:?}) not supported yet", lib.kind, lib.name )), @@ -600,7 +604,7 @@ fn do_link( match link_result { Ok(v) => v, Err(rustc_errors::ErrorGuaranteed { .. }) => { - sess.abort_if_errors(); + sess.dcx().abort_if_errors(); bug!("Linker errored, but no error reported"); } } diff --git a/crates/rustc_codegen_spirv/src/linker/import_export_link.rs b/crates/rustc_codegen_spirv/src/linker/import_export_link.rs index 160a1dd1c7..2300083de6 100644 --- a/crates/rustc_codegen_spirv/src/linker/import_export_link.rs +++ b/crates/rustc_codegen_spirv/src/linker/import_export_link.rs @@ -56,7 +56,9 @@ fn find_import_export_pairs_and_killed_params( }; let type_id = *type_map.get(&id).expect("Unexpected op"); if exports.insert(name, (id, type_id)).is_some() { - return Err(sess.err(format!("Multiple exports found for {name:?}"))); + return Err(sess + .dcx() + .err(format!("Multiple exports found for {name:?}"))); } } let mut any_err = None; @@ -68,7 +70,7 @@ fn find_import_export_pairs_and_killed_params( }; let (export_id, export_type) = match exports.get(name) { None => { - any_err = Some(sess.err(format!("Unresolved symbol {name:?}"))); + any_err = Some(sess.dcx().err(format!("Unresolved symbol {name:?}"))); continue; } Some(&x) => x, @@ -184,6 +186,7 @@ fn check_tys_equal( result } Err(sess + .dcx() .struct_err(format!("Types mismatch for {name:?}")) .note(format!( "import type: {}", diff --git a/crates/rustc_codegen_spirv/src/linker/inline.rs b/crates/rustc_codegen_spirv/src/linker/inline.rs index c036464ade..10f53e02e0 100644 --- a/crates/rustc_codegen_spirv/src/linker/inline.rs +++ b/crates/rustc_codegen_spirv/src/linker/inline.rs @@ -117,7 +117,7 @@ pub fn inline(sess: &Session, module: &mut Module) -> super::Result<()> { if !inlined_to_legalize_dont_inlines.is_empty() { let names = get_names(module); for f in inlined_to_legalize_dont_inlines { - sess.warn(format!( + sess.dcx().warn(format!( "`#[inline(never)]` function `{}` needs to be inlined \ because it has illegal argument or return types", get_name(&names, f) @@ -235,7 +235,7 @@ fn deny_recursion_in_module(sess: &Session, module: &Module) -> super::Result<() let names = get_names(module); let current_name = get_name(&names, module.functions[current].def_id().unwrap()); let next_name = get_name(&names, module.functions[next].def_id().unwrap()); - *has_recursion = Some(sess.err(format!( + *has_recursion = Some(sess.dcx().err(format!( "module has recursion, which is not allowed: `{current_name}` calls `{next_name}`" ))); break; @@ -625,8 +625,9 @@ impl Inliner<'_, '_> { }; let return_jump = self.id(); // Rewrite OpReturns of the callee. + #[allow(clippy::needless_borrow)] let (mut inlined_callee_blocks, extra_debug_insts_pre_call, extra_debug_insts_post_call) = - self.get_inlined_blocks(callee, call_debug_insts, return_variable, return_jump); + self.get_inlined_blocks(&callee, call_debug_insts, return_variable, return_jump); // Clone the IDs of the callee, because otherwise they'd be defined multiple times if the // fn is inlined multiple times. self.add_clone_id_rules(&mut rewrite_rules, &inlined_callee_blocks); diff --git a/crates/rustc_codegen_spirv/src/linker/mod.rs b/crates/rustc_codegen_spirv/src/linker/mod.rs index 8c5b93235e..8ea308d42c 100644 --- a/crates/rustc_codegen_spirv/src/linker/mod.rs +++ b/crates/rustc_codegen_spirv/src/linker/mod.rs @@ -167,7 +167,7 @@ pub fn link( bound += module.header.as_ref().unwrap().bound - 1; let this_version = module.header.as_ref().unwrap().version(); if version != this_version { - return Err(sess.err(format!( + return Err(sess.dcx().err(format!( "cannot link two modules with different SPIR-V versions: v{}.{} and v{}.{}", version.0, version.1, this_version.0, this_version.1 ))); @@ -426,6 +426,7 @@ pub fn link( }; return Err(sess + .dcx() .struct_err(format!("{e}")) .note("while lowering SPIR-V module to SPIR-T (spirt::spv::lower)") .note(format!("input SPIR-V module {was_saved_msg}")) @@ -534,7 +535,7 @@ pub fn link( } if any_spirt_bugs { - let mut note = sess.struct_note("SPIR-T bugs were reported"); + let mut note = sess.dcx().struct_note("SPIR-T bugs were reported"); note.help(format!( "pretty-printed SPIR-T was saved to {}.html", dump_spirt_file_path.as_ref().unwrap().display() @@ -576,12 +577,12 @@ pub fn link( if ext_inst_set.starts_with(custom_insts::CUSTOM_EXT_INST_SET_PREFIX) { let expected = &custom_insts::CUSTOM_EXT_INST_SET[..]; if ext_inst_set == expected { - return Err(sess.err(format!( + return Err(sess.dcx().err(format!( "`OpExtInstImport {ext_inst_set:?}` should not have been \ left around after SPIR-T passes" ))); } else { - return Err(sess.err(format!( + return Err(sess.dcx().err(format!( "unsupported `OpExtInstImport {ext_inst_set:?}` (expected {expected:?} name - version mismatch?)" ))); diff --git a/crates/rustc_codegen_spirv/src/linker/simple_passes.rs b/crates/rustc_codegen_spirv/src/linker/simple_passes.rs index 7ca44add13..2375cf24db 100644 --- a/crates/rustc_codegen_spirv/src/linker/simple_passes.rs +++ b/crates/rustc_codegen_spirv/src/linker/simple_passes.rs @@ -245,12 +245,13 @@ pub fn check_fragment_insts(sess: &Session, module: &Module) -> Result<()> { .collect::>() .join("\n"); any_err = Some( - sess.struct_err(format!( - "{} cannot be used outside a fragment shader", - inst.class.opname - )) - .note(note) - .emit(), + sess.dcx() + .struct_err(format!( + "{} cannot be used outside a fragment shader", + inst.class.opname + )) + .note(note) + .emit(), ); } } diff --git a/crates/rustc_codegen_spirv/src/linker/spirt_passes/diagnostics.rs b/crates/rustc_codegen_spirv/src/linker/spirt_passes/diagnostics.rs index b658c4b09f..236e282e63 100644 --- a/crates/rustc_codegen_spirv/src/linker/spirt_passes/diagnostics.rs +++ b/crates/rustc_codegen_spirv/src/linker/spirt_passes/diagnostics.rs @@ -3,7 +3,7 @@ use crate::custom_decorations::{ }; use crate::custom_insts::{self, CustomInst, CustomOp}; use rustc_data_structures::fx::FxIndexSet; -use rustc_errors::DiagnosticBuilder; +use rustc_errors::{DiagnosticBuilder, EmissionGuarantee}; use rustc_session::Session; use rustc_span::{Span, DUMMY_SP}; use smallvec::SmallVec; @@ -306,11 +306,11 @@ impl UseOrigin<'_> { } } - fn note( + fn note( &self, cx: &Context, span_regen: &mut SpanRegenerator<'_>, - err: &mut DiagnosticBuilder<'_, impl rustc_errors::EmissionGuarantee>, + err: &mut DiagnosticBuilder<'_, G>, ) { let wk = &super::SpvSpecWithExtras::get().well_known; @@ -420,7 +420,10 @@ impl DiagnosticReporter<'_> { self.span_regen.spirt_attrs_to_rustc_span(self.cx, attrs) }) .unwrap_or(DUMMY_SP); - let mut err = self.sess.struct_span_err(def_span, reason.to_string()); + let mut err = self + .sess + .dcx() + .struct_span_err(def_span, reason.to_string()); for use_origin in use_stack_for_def.iter().rev() { use_origin.note(self.cx, &mut self.span_regen, &mut err); } @@ -463,14 +466,14 @@ impl DiagnosticReporter<'_> { let msg = [prefix, msg.to_string(), suffix].concat(); match level { DiagLevel::Bug(_) | DiagLevel::Error => { - let mut err = self.sess.struct_span_err(def_span, msg); + let mut err = self.sess.dcx().struct_span_err(def_span, msg); for use_origin in use_stack_for_def.iter().rev() { use_origin.note(self.cx, &mut self.span_regen, &mut err); } self.overall_result = Err(err.emit()); } DiagLevel::Warning => { - let mut warn = self.sess.struct_span_warn(def_span, msg); + let mut warn = self.sess.dcx().struct_span_warn(def_span, msg); for use_origin in use_stack_for_def.iter().rev() { use_origin.note(self.cx, &mut self.span_regen, &mut warn); } diff --git a/crates/rustc_codegen_spirv/src/linker/test.rs b/crates/rustc_codegen_spirv/src/linker/test.rs index 4b94588943..b3c2e5fd81 100644 --- a/crates/rustc_codegen_spirv/src/linker/test.rs +++ b/crates/rustc_codegen_spirv/src/linker/test.rs @@ -122,9 +122,8 @@ fn link_with_linker_opts( // is really a silent unwinding device, that should be treated the same as // `Err(ErrorGuaranteed)` returns from `link`). rustc_driver::catch_fatal_errors(|| { - let mut early_error_handler = rustc_session::EarlyErrorHandler::new( - rustc_session::config::ErrorOutputType::default(), - ); + let mut early_error_handler = + rustc_session::EarlyDiagCtxt::new(rustc_session::config::ErrorOutputType::default()); early_error_handler.initialize_checked_jobserver(); let matches = rustc_driver::handle_options( &early_error_handler, @@ -161,7 +160,7 @@ fn link_with_linker_opts( // HACK(eddyb) inject `write_diags` into `sess`, to work around // the removals in https://github.com/rust-lang/rust/pull/102992. - sess.parse_sess.span_diagnostic = { + sess.parse_sess.dcx = { let fallback_bundle = { extern crate rustc_error_messages; rustc_error_messages::fallback_fluent_bundle( @@ -173,8 +172,8 @@ fn link_with_linker_opts( rustc_errors::emitter::EmitterWriter::new(Box::new(buf), fallback_bundle) .sm(Some(sess.parse_sess.clone_source_map())); - rustc_errors::Handler::with_emitter(Box::new(emitter)) - .with_flags(sess.opts.unstable_opts.diagnostic_handler_flags(true)) + rustc_errors::DiagCtxt::with_emitter(Box::new(emitter)) + .with_flags(sess.opts.unstable_opts.dcx_flags(true)) }; let res = link( @@ -192,7 +191,7 @@ fn link_with_linker_opts( ), Default::default(), ); - assert_eq!(sess.has_errors(), res.as_ref().err().copied()); + assert_eq!(sess.dcx().has_errors(), res.as_ref().err().copied()); res.map(|res| match res { LinkResult::SingleModule(m) => *m, LinkResult::MultipleModules { .. } => unreachable!(), diff --git a/crates/rustc_codegen_spirv/src/linker/zombies.rs b/crates/rustc_codegen_spirv/src/linker/zombies.rs index 6e73af472d..a33dca831f 100644 --- a/crates/rustc_codegen_spirv/src/linker/zombies.rs +++ b/crates/rustc_codegen_spirv/src/linker/zombies.rs @@ -6,7 +6,7 @@ use crate::custom_insts::{self, CustomOp}; use rspirv::dr::{Instruction, Module, Operand}; use rspirv::spirv::{Op, Word}; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; -use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed}; +use rustc_errors::DiagnosticBuilder; use rustc_session::Session; use rustc_span::{Span, DUMMY_SP}; use smallvec::SmallVec; @@ -239,7 +239,7 @@ impl<'a> ZombieReporter<'a> { fn add_use_note_to_err( &mut self, - err: &mut DiagnosticBuilder<'a, ErrorGuaranteed>, + err: &mut DiagnosticBuilder<'a>, span: Span, zombie: Zombie<'_>, zombie_use: &ZombieUse<'_>, @@ -278,7 +278,7 @@ impl<'a> ZombieReporter<'a> { fn build_errors_keyed_by_leaf_id( &mut self, zombie: Zombie<'_>, - ) -> FxIndexMap> { + ) -> FxIndexMap> { // FIXME(eddyb) this is a bit inefficient, compared to some kind of // "small map", but this is the error path, and being correct is more // important here - in particular, we don't want to ignore *any* leaves. @@ -294,7 +294,7 @@ impl<'a> ZombieReporter<'a> { let reason = self.span_regen.zombie_for_id(zombie.id).unwrap().reason; errors_keyed_by_leaf_id.insert( zombie.id, - self.sess.struct_span_err(span, reason.to_string()), + self.sess.dcx().struct_span_err(span, reason.to_string()), ); } ZombieKind::Uses(zombie_uses) => { diff --git a/crates/rustc_codegen_spirv/src/spirv_type.rs b/crates/rustc_codegen_spirv/src/spirv_type.rs index 73cfdc662f..7cfffc6d79 100644 --- a/crates/rustc_codegen_spirv/src/spirv_type.rs +++ b/crates/rustc_codegen_spirv/src/spirv_type.rs @@ -297,7 +297,7 @@ impl SpirvType<'_> { } ref other => cx .tcx - .sess + .dcx() .fatal(format!("def_with_id invalid for type {other:?}")), }; cx.type_cache_def(result, self.tcx_arena_alloc_slices(cx), def_span); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 93684251f0..8a89005026 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,7 +1,7 @@ [toolchain] -channel = "nightly-2023-12-16" +channel = "nightly-2023-12-31" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = a96d57bdb6d2bb6d233d7d5aaefc2995ab99be01 +# commit_hash = 2a3e63551fe21458637480a97b65a2d15dec8062 # Whenever changing the nightly channel, update the commit hash above, and make # sure to change `REQUIRED_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` also. diff --git a/tests/ui/dis/issue-1062.stderr b/tests/ui/dis/issue-1062.stderr index 49d0ff772f..a19190c5b1 100644 --- a/tests/ui/dis/issue-1062.stderr +++ b/tests/ui/dis/issue-1062.stderr @@ -4,7 +4,7 @@ OpLine %5 11 12 %6 = OpLoad %7 %8 OpLine %5 11 35 %9 = OpLoad %7 %10 -OpLine %11 1142 4 +OpLine %11 1145 4 %12 = OpBitwiseAnd %7 %9 %13 %14 = OpISub %7 %15 %12 %16 = OpShiftLeftLogical %7 %6 %12 diff --git a/tests/ui/dis/ptr_copy.normal.stderr b/tests/ui/dis/ptr_copy.normal.stderr index 76c49bd4e5..06c839cbf0 100644 --- a/tests/ui/dis/ptr_copy.normal.stderr +++ b/tests/ui/dis/ptr_copy.normal.stderr @@ -1,13 +1,13 @@ error: cannot memcpy dynamically sized data - --> $CORE_SRC/intrinsics.rs:2793:9 + --> $CORE_SRC/intrinsics.rs:2794:9 | -2793 | copy(src, dst, count) +2794 | copy(src, dst, count) | ^^^^^^^^^^^^^^^^^^^^^ | note: used from within `core::intrinsics::copy::` - --> $CORE_SRC/intrinsics.rs:2779:21 + --> $CORE_SRC/intrinsics.rs:2780:21 | -2779 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { +2780 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { | ^^^^ note: called by `ptr_copy::copy_via_raw_ptr` --> $DIR/ptr_copy.rs:28:18 From f22e083128bb9d6b54562f2ce976a1d5c4cabbc9 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sat, 3 Aug 2024 02:32:37 +0300 Subject: [PATCH 07/32] spirv-builder: disable MIR "GVN" optimization pass. --- crates/spirv-builder/src/lib.rs | 5 +++++ tests/src/main.rs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/crates/spirv-builder/src/lib.rs b/crates/spirv-builder/src/lib.rs index 57ef35ccbd..498d89b6ab 100644 --- a/crates/spirv-builder/src/lib.rs +++ b/crates/spirv-builder/src/lib.rs @@ -565,6 +565,11 @@ fn invoke_rustc(builder: &SpirvBuilder) -> Result { // HACK(eddyb) we need this for `core::fmt::rt::Argument::new_*` calls // to *never* be inlined, so we can pattern-match the calls themselves. "-Zinline-mir=off".to_string(), + // HACK(eddyb) similar to turning MIR inlining off, we also can't allow + // optimizations that drastically impact (the quality of) codegen, and + // GVN currently can lead to the memcpy-out-of-const-alloc-global-var + // pattern, even for `ScalarPair` (e.g. `return None::;`). + "-Zmir-enable-passes=-GVN".to_string(), ]; // Wrapper for `env::var` that appropriately informs Cargo of the dependency. diff --git a/tests/src/main.rs b/tests/src/main.rs index d808ab9a3f..f7f58eaf9e 100644 --- a/tests/src/main.rs +++ b/tests/src/main.rs @@ -345,6 +345,11 @@ fn rust_flags(codegen_backend_path: &Path) -> String { // HACK(eddyb) we need this for `core::fmt::rt::Argument::new_*` calls // to *never* be inlined, so we can pattern-match the calls themselves. "-Zinline-mir=off", + // HACK(eddyb) similar to turning MIR inlining off, we also can't allow + // optimizations that drastically impact (the quality of) codegen, and + // GVN currently can lead to the memcpy-out-of-const-alloc-global-var + // pattern, even for `ScalarPair` (e.g. `return None::;`). + "-Zmir-enable-passes=-GVN", // NOTE(eddyb) flags copied from `spirv-builder` are all above this line. "-Cdebuginfo=2", "-Cembed-bitcode=no", From 36d5f0ab7e0106e19f77edee2587d1b21d82dec3 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Fri, 2 Aug 2024 14:26:03 +0300 Subject: [PATCH 08/32] builder: fix `atomic_cmpxchg` for SPIR-V `OpAtomicCompareExchange`. --- crates/rustc_codegen_spirv/src/builder/builder_methods.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs index efd1d7056d..382313eba9 100644 --- a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs +++ b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs @@ -2310,10 +2310,9 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { ) .unwrap() .with_type(access_ty); - let result = self.bitcast(result, ty); - let val = self.extract_value(result, 0); - let success = self.extract_value(result, 1); + let val = self.bitcast(result, ty); + let success = self.icmp(IntPredicate::IntEQ, val, cmp); (val, success) } From f3d763b1bb95c12d9b4657b4a446459e3418f9ca Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Fri, 2 Aug 2024 20:31:38 +0300 Subject: [PATCH 09/32] builder: `struct_gep` implies `inbounds`. --- .../src/builder/builder_methods.rs | 16 ++++++---------- tests/ui/dis/index_user_dst.stderr | 2 +- tests/ui/dis/issue-1062.stderr | 4 ++-- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs index 382313eba9..10d3d85250 100644 --- a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs +++ b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs @@ -431,7 +431,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { .map(|idx| self.constant_u32(self.span(), idx).def(self)) .collect::>(); self.emit() - .access_chain(leaf_ptr_ty, None, ptr.def(self), indices) + .in_bounds_access_chain(leaf_ptr_ty, None, ptr.def(self), indices) .unwrap() .with_type(leaf_ptr_ty) }; @@ -1417,7 +1417,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { .collect::>(); return self .emit() - .access_chain(result_type, None, original_ptr, indices) + .in_bounds_access_chain(result_type, None, original_ptr, indices) .unwrap() .with_type(result_type); } @@ -1435,7 +1435,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { } let index_const = self.constant_u32(self.span(), idx as u32).def(self); self.emit() - .access_chain( + .in_bounds_access_chain( result_type, None, ptr.def(self), @@ -1744,7 +1744,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { .map(|idx| self.constant_u32(self.span(), idx).def(self)) .collect::>(); self.emit() - .access_chain(dest_ty, None, ptr.def(self), indices) + .in_bounds_access_chain(dest_ty, None, ptr.def(self), indices) .unwrap() .with_type(dest_ty) } else { @@ -2683,7 +2683,6 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { enum Inst<'tcx, ID> { Bitcast(ID, ID), CompositeExtract(ID, ID, u32), - AccessChain(ID, ID, SpirvConst<'tcx, 'tcx>), InBoundsAccessChain(ID, ID, SpirvConst<'tcx, 'tcx>), Store(ID, ID), Load(ID, ID), @@ -2721,9 +2720,6 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { Some( match (inst.class.opcode, inst.result_id, &id_operands[..]) { (Op::Bitcast, Some(r), &[x]) => Inst::Bitcast(r, x), - (Op::AccessChain, Some(r), &[p, i]) => { - Inst::AccessChain(r, p, self.builder.lookup_const_by_id(i)?) - } (Op::InBoundsAccessChain, Some(r), &[p, i]) => { Inst::InBoundsAccessChain( r, @@ -2887,9 +2883,9 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { array_base_ptr, SpirvConst::U32(array_idx), ), - Inst::AccessChain(a_ptr, a_base_ptr, SpirvConst::U32(0)), + Inst::InBoundsAccessChain(a_ptr, a_base_ptr, SpirvConst::U32(0)), Inst::Store(a_st_dst, a_st_val), - Inst::AccessChain(b_ptr, b_base_ptr, SpirvConst::U32(1)), + Inst::InBoundsAccessChain(b_ptr, b_base_ptr, SpirvConst::U32(1)), Inst::Store(b_st_dst, b_st_val), ] if array_base_ptr == rt_args_array_ptr_id && array_idx as usize == rt_arg_idx diff --git a/tests/ui/dis/index_user_dst.stderr b/tests/ui/dis/index_user_dst.stderr index ca2c5fab76..7cff35e049 100644 --- a/tests/ui/dis/index_user_dst.stderr +++ b/tests/ui/dis/index_user_dst.stderr @@ -1,7 +1,7 @@ %1 = OpFunction %2 None %3 %4 = OpLabel OpLine %5 9 12 -%6 = OpAccessChain %7 %8 %9 +%6 = OpInBoundsAccessChain %7 %8 %9 %10 = OpArrayLength %11 %8 0 OpLine %5 10 21 %12 = OpULessThan %13 %9 %10 diff --git a/tests/ui/dis/issue-1062.stderr b/tests/ui/dis/issue-1062.stderr index a19190c5b1..3a056d9326 100644 --- a/tests/ui/dis/issue-1062.stderr +++ b/tests/ui/dis/issue-1062.stderr @@ -20,9 +20,9 @@ OpLine %11 1145 4 %28 = OpIEqual %20 %23 %21 %29 = OpSelect %7 %28 %6 %27 OpLine %5 12 4 -%30 = OpAccessChain %31 %32 %21 +%30 = OpInBoundsAccessChain %31 %32 %21 OpStore %30 %22 -%33 = OpAccessChain %31 %32 %34 +%33 = OpInBoundsAccessChain %31 %32 %34 OpStore %33 %29 OpNoLine OpReturn From 9aad2f8da9838ae1b33b33090419f470866d044d Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Fri, 2 Aug 2024 13:01:58 +0300 Subject: [PATCH 10/32] rustup: update to `nightly-2024-01-05`. --- crates/rustc_codegen_spirv/build.rs | 4 ++-- rust-toolchain.toml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/rustc_codegen_spirv/build.rs b/crates/rustc_codegen_spirv/build.rs index 432e3a6dab..755485c263 100644 --- a/crates/rustc_codegen_spirv/build.rs +++ b/crates/rustc_codegen_spirv/build.rs @@ -10,9 +10,9 @@ use std::process::{Command, ExitCode}; /// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/ //const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml"); const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain] -channel = "nightly-2023-12-31" +channel = "nightly-2024-01-05" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = 2a3e63551fe21458637480a97b65a2d15dec8062"#; +# commit_hash = f688dd684faca5b31b156fac2c6e0ae81fc9bc90"#; fn get_rustc_commit_hash() -> Result> { let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc")); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 8a89005026..5d1c4dd015 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,7 +1,7 @@ [toolchain] -channel = "nightly-2023-12-31" +channel = "nightly-2024-01-05" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = 2a3e63551fe21458637480a97b65a2d15dec8062 +# commit_hash = f688dd684faca5b31b156fac2c6e0ae81fc9bc90 # Whenever changing the nightly channel, update the commit hash above, and make # sure to change `REQUIRED_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` also. From a21330b596356cbeef9ea084e114536c45098469 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Fri, 2 Aug 2024 14:43:49 +0300 Subject: [PATCH 11/32] rustup: update to `nightly-2024-01-06`. --- crates/rustc_codegen_spirv/build.rs | 4 ++-- crates/rustc_codegen_spirv/src/builder/intrinsics.rs | 5 ++++- crates/rustc_codegen_spirv/src/builder/mod.rs | 8 +++++--- crates/rustc_codegen_spirv/src/custom_decorations.rs | 5 ++++- crates/rustc_codegen_spirv/src/link.rs | 2 +- crates/rustc_codegen_spirv/src/linker/specializer.rs | 5 ++++- crates/rustc_codegen_spirv/src/linker/test.rs | 2 +- rust-toolchain.toml | 4 ++-- 8 files changed, 23 insertions(+), 12 deletions(-) diff --git a/crates/rustc_codegen_spirv/build.rs b/crates/rustc_codegen_spirv/build.rs index 755485c263..78565326a7 100644 --- a/crates/rustc_codegen_spirv/build.rs +++ b/crates/rustc_codegen_spirv/build.rs @@ -10,9 +10,9 @@ use std::process::{Command, ExitCode}; /// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/ //const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml"); const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain] -channel = "nightly-2024-01-05" +channel = "nightly-2024-01-06" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = f688dd684faca5b31b156fac2c6e0ae81fc9bc90"#; +# commit_hash = 595bc6f00369475047538fdae1ff8cea692ac385"#; fn get_rustc_commit_hash() -> Result> { let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc")); diff --git a/crates/rustc_codegen_spirv/src/builder/intrinsics.rs b/crates/rustc_codegen_spirv/src/builder/intrinsics.rs index 45e9b861c6..9e610955a8 100644 --- a/crates/rustc_codegen_spirv/src/builder/intrinsics.rs +++ b/crates/rustc_codegen_spirv/src/builder/intrinsics.rs @@ -105,7 +105,10 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> { let ptr = args[0].immediate(); let layout = self.layout_of(fn_args.type_at(0)); let load = self.volatile_load(layout.spirv_type(self.span(), self), ptr); - self.to_immediate(load, layout) + if !result.layout.is_zst() { + self.store(load, result.llval, result.align); + } + return; } sym::prefetch_read_data diff --git a/crates/rustc_codegen_spirv/src/builder/mod.rs b/crates/rustc_codegen_spirv/src/builder/mod.rs index 869b494f53..c68af474fc 100644 --- a/crates/rustc_codegen_spirv/src/builder/mod.rs +++ b/crates/rustc_codegen_spirv/src/builder/mod.rs @@ -14,7 +14,7 @@ use crate::builder_spirv::{BuilderCursor, SpirvValue, SpirvValueExt}; use crate::codegen_cx::CodegenCx; use crate::spirv_type::SpirvType; use rspirv::spirv::{self, Word}; -use rustc_codegen_ssa::mir::operand::OperandValue; +use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; use rustc_codegen_ssa::mir::place::PlaceRef; use rustc_codegen_ssa::traits::{ AbiBuilderMethods, ArgAbiMethods, BackendTypes, BuilderMethods, CoverageInfoBuilderMethods, @@ -301,7 +301,7 @@ impl<'a, 'tcx> ArgAbiMethods<'tcx> for Builder<'a, 'tcx> { match arg_abi.mode { PassMode::Ignore => {} PassMode::Direct(_) => { - OperandValue::Immediate(next(self, idx)).store(self, dst); + self.store_arg(arg_abi, next(self, idx), dst); } PassMode::Pair(..) => { OperandValue::Pair(next(self, idx), next(self, idx)).store(self, dst); @@ -323,7 +323,9 @@ impl<'a, 'tcx> ArgAbiMethods<'tcx> for Builder<'a, 'tcx> { match arg_abi.mode { PassMode::Ignore => {} PassMode::Direct(_) | PassMode::Pair(..) => { - OperandValue::Immediate(val).store(self, dst); + OperandRef::from_immediate_or_packed_pair(self, val, arg_abi.layout) + .val + .store(self, dst); } PassMode::Cast { .. } | PassMode::Indirect { .. } => span_bug!( self.span(), diff --git a/crates/rustc_codegen_spirv/src/custom_decorations.rs b/crates/rustc_codegen_spirv/src/custom_decorations.rs index 90844487d6..f1e992ed64 100644 --- a/crates/rustc_codegen_spirv/src/custom_decorations.rs +++ b/crates/rustc_codegen_spirv/src/custom_decorations.rs @@ -158,7 +158,10 @@ impl<'a> CustomDecoration<'a> for SrcLocDecoration<'a> { } fn decode(s: &'a str) -> Self { #[derive(Copy, Clone, Debug)] - struct InvalidSrcLoc<'a>(&'a str); + struct InvalidSrcLoc<'a>( + // HACK(eddyb) only exists for `fmt::Debug` in case of error. + #[allow(dead_code)] &'a str, + ); let err = InvalidSrcLoc(s); let (s, col_end) = s.rsplit_once(':').ok_or(err).unwrap(); diff --git a/crates/rustc_codegen_spirv/src/link.rs b/crates/rustc_codegen_spirv/src/link.rs index 77c6b5ca01..0c2d4e38c1 100644 --- a/crates/rustc_codegen_spirv/src/link.rs +++ b/crates/rustc_codegen_spirv/src/link.rs @@ -350,7 +350,7 @@ fn do_spirv_opt( // Level::Error | Level::Fatal | Level::InternalError => DiagnosticBuilder::<()>::new( sess.dcx(), - rustc_errors::Level::Error { lint: false }, + rustc_errors::Level::Error, msg.message, ), Level::Warning => sess.dcx().struct_warn(msg.message), diff --git a/crates/rustc_codegen_spirv/src/linker/specializer.rs b/crates/rustc_codegen_spirv/src/linker/specializer.rs index 3fb003b4b1..41481e6ebd 100644 --- a/crates/rustc_codegen_spirv/src/linker/specializer.rs +++ b/crates/rustc_codegen_spirv/src/linker/specializer.rs @@ -234,7 +234,10 @@ enum CopyOperand { } #[derive(Debug)] -struct NotSupportedAsCopyOperand(Operand); +struct NotSupportedAsCopyOperand( + // HACK(eddyb) only exists for `fmt::Debug` in case of error. + #[allow(dead_code)] Operand, +); impl TryFrom<&Operand> for CopyOperand { type Error = NotSupportedAsCopyOperand; diff --git a/crates/rustc_codegen_spirv/src/linker/test.rs b/crates/rustc_codegen_spirv/src/linker/test.rs index b3c2e5fd81..3ed1bf0c7f 100644 --- a/crates/rustc_codegen_spirv/src/linker/test.rs +++ b/crates/rustc_codegen_spirv/src/linker/test.rs @@ -169,7 +169,7 @@ fn link_with_linker_opts( ) }; let emitter = - rustc_errors::emitter::EmitterWriter::new(Box::new(buf), fallback_bundle) + rustc_errors::emitter::HumanEmitter::new(Box::new(buf), fallback_bundle) .sm(Some(sess.parse_sess.clone_source_map())); rustc_errors::DiagCtxt::with_emitter(Box::new(emitter)) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 5d1c4dd015..9da1d27438 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,7 +1,7 @@ [toolchain] -channel = "nightly-2024-01-05" +channel = "nightly-2024-01-06" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = f688dd684faca5b31b156fac2c6e0ae81fc9bc90 +# commit_hash = 595bc6f00369475047538fdae1ff8cea692ac385 # Whenever changing the nightly channel, update the commit hash above, and make # sure to change `REQUIRED_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` also. From 5c8fbb47aa005ae6c8ceb5a5dcdbe9f1a47d7863 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Fri, 2 Aug 2024 16:40:56 +0300 Subject: [PATCH 12/32] builder: handle `ptr_add`-like GEPs (introduced by rust-lang/rust#118991). --- .../src/builder/builder_methods.rs | 264 ++++++++++++++++-- crates/rustc_codegen_spirv/src/builder/mod.rs | 111 +------- 2 files changed, 244 insertions(+), 131 deletions(-) diff --git a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs index 10d3d85250..0c159d63d5 100644 --- a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs +++ b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs @@ -30,6 +30,7 @@ use std::borrow::Cow; use std::cell::Cell; use std::convert::TryInto; use std::iter::{self, empty}; +use std::ops::RangeInclusive; macro_rules! simple_op { ( @@ -412,9 +413,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // FIXME(eddyb) this isn't efficient, `recover_access_chain_from_offset` // could instead be doing all the extra digging itself. let mut indices = SmallVec::<[_; 8]>::new(); - while let Some((inner_indices, inner_ty)) = - self.recover_access_chain_from_offset(leaf_ty, Size::ZERO, Some(size), None) - { + while let Some((inner_indices, inner_ty)) = self.recover_access_chain_from_offset( + leaf_ty, + Size::ZERO, + Some(size)..=Some(size), + None, + ) { indices.extend(inner_indices); leaf_ty = inner_ty; } @@ -439,8 +443,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } /// If possible, return the appropriate `OpAccessChain` indices for going - /// from a pointer to `ty`, to a pointer to some leaf field/element of size - /// `leaf_size` (and optionally type `leaf_ty`), while adding `offset` bytes. + /// from a pointer to `ty`, to a pointer to some leaf field/element having + /// a size that fits `leaf_size_range` (and, optionally, the type `leaf_ty`), + /// while adding `offset` bytes. /// /// That is, try to turn `((_: *T) as *u8).add(offset) as *Leaf` into a series /// of struct field and array/vector element accesses. @@ -449,7 +454,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { mut ty: ::Type, mut offset: Size, // FIXME(eddyb) using `None` for "unsized" is a pretty bad design. - leaf_size_or_unsized: Option, + leaf_size_or_unsized_range: RangeInclusive>, leaf_ty: Option<::Type>, ) -> Option<(SmallVec<[u32; 8]>, ::Type)> { assert_ne!(Some(ty), leaf_ty); @@ -460,7 +465,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { Sized(Size), Unsized, } - let leaf_size = leaf_size_or_unsized.map_or(MaybeSized::Unsized, MaybeSized::Sized); + let leaf_size_range = { + let r = leaf_size_or_unsized_range; + let [start, end] = + [r.start(), r.end()].map(|x| x.map_or(MaybeSized::Unsized, MaybeSized::Sized)); + start..=end + }; // NOTE(eddyb) `ty` and `ty_kind`/`ty_size` should be kept in sync. let mut ty_kind = self.lookup_type(ty); @@ -493,7 +503,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { if MaybeSized::Sized(offset_in_field) < field_ty_size // If the field is a zero sized type, check the // expected size and type to get the correct entry - || offset_in_field == Size::ZERO && leaf_size == MaybeSized::Sized(Size::ZERO) && leaf_ty == Some(field_ty) + || offset_in_field == Size::ZERO + && leaf_size_range.contains(&MaybeSized::Sized(Size::ZERO)) && leaf_ty == Some(field_ty) { Some((i, field_ty, field_ty_kind, field_ty_size, offset_in_field)) } else { @@ -525,12 +536,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } // Avoid digging beyond the point the leaf could actually fit. - if ty_size < leaf_size { + if ty_size < *leaf_size_range.start() { return None; } if offset == Size::ZERO - && ty_size == leaf_size + && leaf_size_range.contains(&ty_size) && leaf_ty.map_or(true, |leaf_ty| leaf_ty == ty) { return Some((indices, ty)); @@ -538,6 +549,198 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } + fn maybe_inbounds_gep( + &mut self, + ty: Word, + ptr: SpirvValue, + combined_indices: &[SpirvValue], + is_inbounds: bool, + ) -> SpirvValue { + let (&ptr_base_index, indices) = combined_indices.split_first().unwrap(); + + // The first index is an offset to the pointer, the rest are actual members. + // https://llvm.org/docs/GetElementPtr.html + // "An OpAccessChain instruction is the equivalent of an LLVM getelementptr instruction where the first index element is zero." + // https://github.com/gpuweb/gpuweb/issues/33 + let mut result_pointee_type = ty; + let indices: Vec<_> = indices + .iter() + .map(|index| { + result_pointee_type = match self.lookup_type(result_pointee_type) { + SpirvType::Array { element, .. } | SpirvType::RuntimeArray { element } => { + element + } + _ => self.fatal(format!( + "GEP not implemented for type {}", + self.debug_type(result_pointee_type) + )), + }; + index.def(self) + }) + .collect(); + + // Special-case field accesses through a `pointercast`, to accesss the + // right field in the original type, for the `Logical` addressing model. + let ptr = ptr.strip_ptrcasts(); + let ptr_id = ptr.def(self); + let original_pointee_ty = match self.lookup_type(ptr.ty) { + SpirvType::Pointer { pointee } => pointee, + other => self.fatal(format!("gep called on non-pointer type: {other:?}")), + }; + + // HACK(eddyb) `struct_gep` itself is falling out of use, as it's being + // replaced upstream by `ptr_add` (aka `inbounds_gep` with byte offsets). + // + // FIXME(eddyb) get rid of everything other than: + // - constant byte offset (`ptr_add`?) + // - dynamic indexing of a single array + let const_ptr_offset = self + .builder + .lookup_const_u64(ptr_base_index) + .and_then(|idx| Some(idx * self.lookup_type(ty).sizeof(self)?)); + if let Some(const_ptr_offset) = const_ptr_offset { + if let Some((base_indices, base_pointee_ty)) = self.recover_access_chain_from_offset( + original_pointee_ty, + const_ptr_offset, + Some(Size::ZERO)..=None, + None, + ) { + // FIXME(eddyb) this condition is pretty limiting, but + // eventually it shouldn't matter if GEPs are going away. + if ty == base_pointee_ty || indices.is_empty() { + let result_pointee_type = if indices.is_empty() { + base_pointee_ty + } else { + result_pointee_type + }; + let indices = base_indices + .into_iter() + .map(|idx| self.constant_u32(self.span(), idx).def(self)) + .chain(indices) + .collect(); + return self.emit_access_chain( + self.type_ptr_to(result_pointee_type), + ptr_id, + None, + indices, + is_inbounds, + ); + } + } + } + + let result_type = self.type_ptr_to(result_pointee_type); + + // Check if `ptr_id` is defined by an `OpAccessChain`, and if it is, + // grab its base pointer and indices. + // + // FIXME(eddyb) this could get ridiculously expensive, at the very least + // it could use `.rev()`, hoping the base pointer was recently defined? + let maybe_original_access_chain = if ty == original_pointee_ty { + let emit = self.emit(); + let module = emit.module_ref(); + let func = &module.functions[emit.selected_function().unwrap()]; + let base_ptr_and_combined_indices = func + .all_inst_iter() + .find(|inst| inst.result_id == Some(ptr_id)) + .and_then(|ptr_def_inst| { + if matches!( + ptr_def_inst.class.opcode, + Op::AccessChain | Op::InBoundsAccessChain + ) { + let base_ptr = ptr_def_inst.operands[0].unwrap_id_ref(); + let indices = ptr_def_inst.operands[1..] + .iter() + .map(|op| op.unwrap_id_ref()) + .collect::>(); + Some((base_ptr, indices)) + } else { + None + } + }); + base_ptr_and_combined_indices + } else { + None + }; + if let Some((original_ptr, mut original_indices)) = maybe_original_access_chain { + // Transform the following: + // OpAccessChain original_ptr [a, b, c] + // OpPtrAccessChain ptr base [d, e, f] + // into + // OpAccessChain original_ptr [a, b, c + base, d, e, f] + // to remove the need for OpPtrAccessChain + let last = original_indices.last_mut().unwrap(); + *last = self + .add(last.with_type(ptr_base_index.ty), ptr_base_index) + .def(self); + original_indices.extend(indices); + return self.emit_access_chain( + result_type, + original_ptr, + None, + original_indices, + is_inbounds, + ); + } + + // HACK(eddyb) temporary workaround for untyped pointers upstream. + // FIXME(eddyb) replace with untyped memory SPIR-V + `qptr` or similar. + let ptr = self.pointercast(ptr, self.type_ptr_to(ty)); + let ptr_id = ptr.def(self); + + self.emit_access_chain( + result_type, + ptr_id, + Some(ptr_base_index), + indices, + is_inbounds, + ) + } + + fn emit_access_chain( + &self, + result_type: ::Type, + pointer: Word, + ptr_base_index: Option, + indices: Vec, + is_inbounds: bool, + ) -> SpirvValue { + let mut emit = self.emit(); + + let non_zero_ptr_base_index = + ptr_base_index.filter(|&idx| self.builder.lookup_const_u64(idx) != Some(0)); + if let Some(ptr_base_index) = non_zero_ptr_base_index { + let result = if is_inbounds { + emit.in_bounds_ptr_access_chain( + result_type, + None, + pointer, + ptr_base_index.def(self), + indices, + ) + } else { + emit.ptr_access_chain( + result_type, + None, + pointer, + ptr_base_index.def(self), + indices, + ) + } + .unwrap(); + self.zombie(result, "cannot offset a pointer to an arbitrary element"); + result + } else { + if is_inbounds { + emit.in_bounds_access_chain(result_type, None, pointer, indices) + } else { + emit.access_chain(result_type, None, pointer, indices) + } + .unwrap() + } + .with_type(result_type) + } + fn fptoint_sat( &mut self, signed: bool, @@ -1361,7 +1564,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { } fn gep(&mut self, ty: Self::Type, ptr: Self::Value, indices: &[Self::Value]) -> Self::Value { - self.gep_help(ty, ptr, indices, false) + self.maybe_inbounds_gep(ty, ptr, indices, false) } fn inbounds_gep( @@ -1370,7 +1573,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { ptr: Self::Value, indices: &[Self::Value], ) -> Self::Value { - self.gep_help(ty, ptr, indices, true) + self.maybe_inbounds_gep(ty, ptr, indices, true) } fn struct_gep(&mut self, ty: Self::Type, ptr: Self::Value, idx: u64) -> Self::Value { @@ -1395,6 +1598,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { "struct_gep not on struct, array, or vector type: {other:?}, index {idx}" )), }; + let result_pointee_size = self.lookup_type(result_pointee_type).sizeof(self); let result_type = self.type_ptr_to(result_pointee_type); // Special-case field accesses through a `pointercast`, to accesss the @@ -1407,7 +1611,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { if let Some((indices, _)) = self.recover_access_chain_from_offset( original_pointee_ty, offset, - self.lookup_type(result_pointee_type).sizeof(self), + result_pointee_size..=result_pointee_size, Some(result_pointee_type), ) { let original_ptr = ptr.def(self); @@ -1586,9 +1790,12 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { // FIXME(eddyb) this isn't efficient, `recover_access_chain_from_offset` // could instead be doing all the extra digging itself. let mut indices = SmallVec::<[_; 8]>::new(); - while let Some((inner_indices, inner_ty)) = - self.recover_access_chain_from_offset(leaf_ty, Size::ZERO, Some(size), None) - { + while let Some((inner_indices, inner_ty)) = self.recover_access_chain_from_offset( + leaf_ty, + Size::ZERO, + Some(size)..=Some(size), + None, + ) { indices.extend(inner_indices); leaf_ty = inner_ty; } @@ -1716,9 +1923,17 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { return self.const_bitcast(ptr, dest_ty); } + if ptr.ty == dest_ty { + return ptr; + } + // Strip a previous `pointercast`, to reveal the original pointer type. let ptr = ptr.strip_ptrcasts(); + if ptr.ty == dest_ty { + return ptr; + } + let ptr_pointee = match self.lookup_type(ptr.ty) { SpirvType::Pointer { pointee } => pointee, other => self.fatal(format!( @@ -1731,12 +1946,12 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { "pointercast called on non-pointer dest type: {other:?}" )), }; - if ptr.ty == dest_ty { - ptr - } else if let Some((indices, _)) = self.recover_access_chain_from_offset( + let dest_pointee_size = self.lookup_type(dest_pointee).sizeof(self); + + if let Some((indices, _)) = self.recover_access_chain_from_offset( ptr_pointee, Size::ZERO, - self.lookup_type(dest_pointee).sizeof(self), + dest_pointee_size..=dest_pointee_size, Some(dest_pointee), ) { let indices = indices @@ -2687,6 +2902,13 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { Store(ID, ID), Load(ID, ID), Call(ID, ID, SmallVec<[ID; 4]>), + + // HACK(eddyb) this only exists for better error reporting, + // as `Result, Op>` would only report one `Op`. + Unsupported( + // HACK(eddyb) only exists for `fmt::Debug` in case of error. + #[allow(dead_code)] Op, + ), } let taken_inst_idx_range = Cell::new(func.blocks[block_idx].instructions.len())..; @@ -2732,7 +2954,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { (Op::FunctionCall, Some(r), [f, args @ ..]) => { Inst::Call(r, *f, args.iter().copied().collect()) } - _ => return None, + _ => Inst::Unsupported(inst.class.opcode), }, ) }); diff --git a/crates/rustc_codegen_spirv/src/builder/mod.rs b/crates/rustc_codegen_spirv/src/builder/mod.rs index c68af474fc..ac24b78f20 100644 --- a/crates/rustc_codegen_spirv/src/builder/mod.rs +++ b/crates/rustc_codegen_spirv/src/builder/mod.rs @@ -13,7 +13,7 @@ use crate::abi::ConvSpirvType; use crate::builder_spirv::{BuilderCursor, SpirvValue, SpirvValueExt}; use crate::codegen_cx::CodegenCx; use crate::spirv_type::SpirvType; -use rspirv::spirv::{self, Word}; +use rspirv::spirv::Word; use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; use rustc_codegen_ssa::mir::place::PlaceRef; use rustc_codegen_ssa::traits::{ @@ -104,115 +104,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { SpirvType::Pointer { pointee: ty }.def(self.span(), self) } - // Given an ID, check if it's defined by an OpAccessChain, and if it is, return its ptr/indices - fn find_access_chain(&self, id: spirv::Word) -> Option<(spirv::Word, Vec)> { - let emit = self.emit(); - let module = emit.module_ref(); - let func = &module.functions[emit.selected_function().unwrap()]; - let ptr_def_inst = func.all_inst_iter().find(|inst| inst.result_id == Some(id)); - if let Some(ptr_def_inst) = ptr_def_inst { - if ptr_def_inst.class.opcode == spirv::Op::AccessChain - || ptr_def_inst.class.opcode == spirv::Op::InBoundsAccessChain - { - let ptr = ptr_def_inst.operands[0].unwrap_id_ref(); - let indices = ptr_def_inst.operands[1..] - .iter() - .map(|op| op.unwrap_id_ref()) - .collect::>(); - return Some((ptr, indices)); - } - } - None - } - - pub fn gep_help( - &mut self, - ty: Word, - ptr: SpirvValue, - indices: &[SpirvValue], - is_inbounds: bool, - ) -> SpirvValue { - // HACK(eddyb) temporary workaround for untyped pointers upstream. - // FIXME(eddyb) replace with untyped memory SPIR-V + `qptr` or similar. - let ptr = self.pointercast(ptr, self.type_ptr_to(ty)); - - // The first index is an offset to the pointer, the rest are actual members. - // https://llvm.org/docs/GetElementPtr.html - // "An OpAccessChain instruction is the equivalent of an LLVM getelementptr instruction where the first index element is zero." - // https://github.com/gpuweb/gpuweb/issues/33 - let mut result_indices = Vec::with_capacity(indices.len() - 1); - let mut result_pointee_type = ty; - for index in indices.iter().cloned().skip(1) { - result_indices.push(index.def(self)); - result_pointee_type = match self.lookup_type(result_pointee_type) { - SpirvType::Array { element, .. } | SpirvType::RuntimeArray { element } => element, - _ => self.fatal(format!( - "GEP not implemented for type {}", - self.debug_type(result_pointee_type) - )), - }; - } - let result_type = self.type_ptr_to(result_pointee_type); - - let ptr_id = ptr.def(self); - if let Some((original_ptr, mut original_indices)) = self.find_access_chain(ptr_id) { - // Transform the following: - // OpAccessChain original_ptr [a, b, c] - // OpPtrAccessChain ptr base [d, e, f] - // into - // OpAccessChain original_ptr [a, b, c + base, d, e, f] - // to remove the need for OpPtrAccessChain - let last = original_indices.last_mut().unwrap(); - *last = self - .add(last.with_type(indices[0].ty), indices[0]) - .def(self); - original_indices.append(&mut result_indices); - let zero = self.constant_int(indices[0].ty, 0); - self.emit_access_chain( - result_type, - original_ptr, - zero, - original_indices, - is_inbounds, - ) - } else { - self.emit_access_chain(result_type, ptr_id, indices[0], result_indices, is_inbounds) - } - } - - fn emit_access_chain( - &self, - result_type: spirv::Word, - pointer: spirv::Word, - base: SpirvValue, - indices: Vec, - is_inbounds: bool, - ) -> SpirvValue { - let mut emit = self.emit(); - if self.builder.lookup_const_u64(base) == Some(0) { - if is_inbounds { - emit.in_bounds_access_chain(result_type, None, pointer, indices) - } else { - emit.access_chain(result_type, None, pointer, indices) - } - .unwrap() - .with_type(result_type) - } else { - let result = if is_inbounds { - emit.in_bounds_ptr_access_chain(result_type, None, pointer, base.def(self), indices) - } else { - emit.ptr_access_chain(result_type, None, pointer, base.def(self), indices) - } - .unwrap() - .with_type(result_type); - self.zombie( - result.def(self), - "cannot offset a pointer to an arbitrary element", - ); - result - } - } - // TODO: Definitely add tests to make sure this impl is right. fn rotate(&mut self, value: SpirvValue, shift: SpirvValue, is_left: bool) -> SpirvValue { let width = match self.lookup_type(shift.ty) { From b9df8cbd4a8197c2a4fbc621be1f68cb05b77103 Mon Sep 17 00:00:00 2001 From: Christian Legnitto Date: Tue, 9 Jan 2024 18:05:59 -0400 Subject: [PATCH 13/32] rustup: update to `nightly-2024-01-08`. --- CHANGELOG.md | 2 +- crates/rustc_codegen_spirv/build.rs | 4 ++-- rust-toolchain.toml | 4 ++-- tests/ui/dis/ptr_copy.normal.stderr | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f234cda856..5c37c8cf1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Changed 🛠 -- [PR#1109](https://github.com/EmbarkStudios/rust-gpu/pull/1109) updated toolchain to `nightly-2023-12-31` +- [PR#1109](https://github.com/EmbarkStudios/rust-gpu/pull/1109) updated toolchain to `nightly-2024-01-08` - [PR#1115](https://github.com/EmbarkStudios/rust-gpu/pull/1115) relaxed `glam` version requirements (from `>=0.22, <=0.24` to `>=0.22, <=0.25`) - [PR#1127](https://github.com/EmbarkStudios/rust-gpu/pull/1127) updated `spirv-tools` to `0.10.0`, which follows `vulkan-sdk-1.3.275` - [PR#1101](https://github.com/EmbarkStudios/rust-gpu/pull/1101) added `ignore` and `no_run` to documentation to make `cargo test` pass diff --git a/crates/rustc_codegen_spirv/build.rs b/crates/rustc_codegen_spirv/build.rs index 78565326a7..fecbfa736f 100644 --- a/crates/rustc_codegen_spirv/build.rs +++ b/crates/rustc_codegen_spirv/build.rs @@ -10,9 +10,9 @@ use std::process::{Command, ExitCode}; /// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/ //const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml"); const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain] -channel = "nightly-2024-01-06" +channel = "nightly-2024-01-08" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = 595bc6f00369475047538fdae1ff8cea692ac385"#; +# commit_hash = 75c68cfd2b9870f2953b62d250bd7d0564a7b56d"#; fn get_rustc_commit_hash() -> Result> { let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc")); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 9da1d27438..5933e8a961 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,7 +1,7 @@ [toolchain] -channel = "nightly-2024-01-06" +channel = "nightly-2024-01-08" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = 595bc6f00369475047538fdae1ff8cea692ac385 +# commit_hash = 75c68cfd2b9870f2953b62d250bd7d0564a7b56d # Whenever changing the nightly channel, update the commit hash above, and make # sure to change `REQUIRED_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` also. diff --git a/tests/ui/dis/ptr_copy.normal.stderr b/tests/ui/dis/ptr_copy.normal.stderr index 06c839cbf0..12888433e7 100644 --- a/tests/ui/dis/ptr_copy.normal.stderr +++ b/tests/ui/dis/ptr_copy.normal.stderr @@ -1,13 +1,13 @@ error: cannot memcpy dynamically sized data - --> $CORE_SRC/intrinsics.rs:2794:9 + --> $CORE_SRC/intrinsics.rs:2800:9 | -2794 | copy(src, dst, count) +2800 | copy(src, dst, count) | ^^^^^^^^^^^^^^^^^^^^^ | note: used from within `core::intrinsics::copy::` - --> $CORE_SRC/intrinsics.rs:2780:21 + --> $CORE_SRC/intrinsics.rs:2786:21 | -2780 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { +2786 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { | ^^^^ note: called by `ptr_copy::copy_via_raw_ptr` --> $DIR/ptr_copy.rs:28:18 From fbc90a56066a251fcd3c95829b82564ec8d2697b Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sat, 3 Aug 2024 10:24:15 +0300 Subject: [PATCH 14/32] rustup: update to `nightly-2024-02-01`. --- crates/rustc_codegen_spirv/build.rs | 4 ++-- crates/rustc_codegen_spirv/src/abi.rs | 2 +- crates/rustc_codegen_spirv/src/attr.rs | 2 +- crates/rustc_codegen_spirv/src/builder/spirv_asm.rs | 6 +++--- crates/rustc_codegen_spirv/src/builder_spirv.rs | 2 +- crates/rustc_codegen_spirv/src/codegen_cx/entry.rs | 13 +++++-------- crates/rustc_codegen_spirv/src/lib.rs | 1 - crates/rustc_codegen_spirv/src/link.rs | 2 +- .../src/linker/import_export_link.rs | 4 ++-- crates/rustc_codegen_spirv/src/linker/mod.rs | 6 +++--- .../rustc_codegen_spirv/src/linker/simple_passes.rs | 2 +- crates/rustc_codegen_spirv/src/linker/zombies.rs | 2 +- crates/rustc_codegen_spirv/src/symbols.rs | 4 ++-- rust-toolchain.toml | 4 ++-- tests/ui/dis/issue-1062.stderr | 2 +- tests/ui/dis/ptr_copy.normal.stderr | 8 ++++---- tests/ui/spirv-attr/bad-deduce-storage-class.stderr | 6 +----- 17 files changed, 31 insertions(+), 39 deletions(-) diff --git a/crates/rustc_codegen_spirv/build.rs b/crates/rustc_codegen_spirv/build.rs index fecbfa736f..e336e8c028 100644 --- a/crates/rustc_codegen_spirv/build.rs +++ b/crates/rustc_codegen_spirv/build.rs @@ -10,9 +10,9 @@ use std::process::{Command, ExitCode}; /// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/ //const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml"); const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain] -channel = "nightly-2024-01-08" +channel = "nightly-2024-02-01" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = 75c68cfd2b9870f2953b62d250bd7d0564a7b56d"#; +# commit_hash = 11f32b73e0dc9287e305b5b9980d24aecdc8c17f"#; fn get_rustc_commit_hash() -> Result> { let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc")); diff --git a/crates/rustc_codegen_spirv/src/abi.rs b/crates/rustc_codegen_spirv/src/abi.rs index f6a82a86fb..0d11af538c 100644 --- a/crates/rustc_codegen_spirv/src/abi.rs +++ b/crates/rustc_codegen_spirv/src/abi.rs @@ -975,7 +975,7 @@ fn trans_intrinsic_type<'tcx>( .tcx .dcx() .struct_span_err(span, "#[spirv(matrix)] type fields must all be vectors") - .note(format!("field type is {}", ty.debug(elem_type, cx))) + .with_note(format!("field type is {}", ty.debug(elem_type, cx))) .emit()); } } diff --git a/crates/rustc_codegen_spirv/src/attr.rs b/crates/rustc_codegen_spirv/src/attr.rs index a7c16f9139..7e5dec741e 100644 --- a/crates/rustc_codegen_spirv/src/attr.rs +++ b/crates/rustc_codegen_spirv/src/attr.rs @@ -386,7 +386,7 @@ impl CheckSpirvAttrVisitor<'_> { span, format!("only one {category} attribute is allowed on a {target}"), ) - .span_note(prev_span, format!("previous {category} attribute")) + .with_span_note(prev_span, format!("previous {category} attribute")) .emit(); } }, diff --git a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs index 52fa469314..16fd3b45a2 100644 --- a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs +++ b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs @@ -306,10 +306,10 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { let storage_class = inst.operands[0].unwrap_storage_class(); if storage_class != StorageClass::Generic { self.struct_err("TypePointer in asm! requires `Generic` storage class") - .note(format!( + .with_note(format!( "`{storage_class:?}` storage class was specified" )) - .help(format!( + .with_help(format!( "the storage class will be inferred automatically (e.g. to `{storage_class:?}`)" )) .emit(); @@ -362,7 +362,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { self.struct_err(format!( "using `Op{op:?}` to return from within `asm!` is disallowed" )) - .note( + .with_note( "resuming execution, without falling through the end \ of the `asm!` block, is always undefined behavior", ) diff --git a/crates/rustc_codegen_spirv/src/builder_spirv.rs b/crates/rustc_codegen_spirv/src/builder_spirv.rs index 00b51c383d..c2cb6f3244 100644 --- a/crates/rustc_codegen_spirv/src/builder_spirv.rs +++ b/crates/rustc_codegen_spirv/src/builder_spirv.rs @@ -165,7 +165,7 @@ impl SpirvValue { cx.tcx .dcx() .struct_span_err(span, "Can't use type as a value") - .note(format!("Type: *{}", cx.debug_type(id))) + .with_note(format!("Type: *{}", cx.debug_type(id))) .emit(); id diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs b/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs index 7af4d77aaf..04eb2f93a3 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs @@ -311,20 +311,17 @@ impl<'tcx> CodegenCx<'tcx> { self.tcx .dcx() .struct_span_err(hir_param.span, "storage class mismatch") - .span_label( + .with_span_label( storage_class_attr.span, format!("`{storage_class:?}` specified in attribute"), ) - .span_label( + .with_span_label( hir_param.ty_span, format!("`{deduced:?}` deduced from type"), ) - .span_help( - storage_class_attr.span, - format!( - "remove storage class attribute to use `{deduced:?}` as storage class" - ), - ) + .with_help(format!( + "remove storage class attribute to use `{deduced:?}` as storage class" + )) .emit(); } None => (), diff --git a/crates/rustc_codegen_spirv/src/lib.rs b/crates/rustc_codegen_spirv/src/lib.rs index 864d767394..0e4c588762 100644 --- a/crates/rustc_codegen_spirv/src/lib.rs +++ b/crates/rustc_codegen_spirv/src/lib.rs @@ -16,7 +16,6 @@ //! [`spirv-tools`]: https://embarkstudios.github.io/rust-gpu/api/spirv_tools //! [`spirv-tools-sys`]: https://embarkstudios.github.io/rust-gpu/api/spirv_tools_sys #![feature(rustc_private)] -#![feature(array_methods)] #![feature(assert_matches)] #![feature(result_flattening)] #![feature(lint_reasons)] diff --git a/crates/rustc_codegen_spirv/src/link.rs b/crates/rustc_codegen_spirv/src/link.rs index 0c2d4e38c1..edaa12cdcd 100644 --- a/crates/rustc_codegen_spirv/src/link.rs +++ b/crates/rustc_codegen_spirv/src/link.rs @@ -484,7 +484,7 @@ fn add_upstream_native_libraries( // (see `compiler/rustc_codegen_ssa/src/back/link.rs`) fn relevant_lib(sess: &Session, lib: &NativeLib) -> bool { match lib.cfg { - Some(ref cfg) => rustc_attr::cfg_matches(cfg, &sess.parse_sess, CRATE_NODE_ID, None), + Some(ref cfg) => rustc_attr::cfg_matches(cfg, sess, CRATE_NODE_ID, None), None => true, } } diff --git a/crates/rustc_codegen_spirv/src/linker/import_export_link.rs b/crates/rustc_codegen_spirv/src/linker/import_export_link.rs index 2300083de6..68a789104a 100644 --- a/crates/rustc_codegen_spirv/src/linker/import_export_link.rs +++ b/crates/rustc_codegen_spirv/src/linker/import_export_link.rs @@ -188,11 +188,11 @@ fn check_tys_equal( Err(sess .dcx() .struct_err(format!("Types mismatch for {name:?}")) - .note(format!( + .with_note(format!( "import type: {}", format_ty_(&ty_defs, import_type) )) - .note(format!( + .with_note(format!( "export type: {}", format_ty_(&ty_defs, export_type) )) diff --git a/crates/rustc_codegen_spirv/src/linker/mod.rs b/crates/rustc_codegen_spirv/src/linker/mod.rs index 8ea308d42c..63ce090167 100644 --- a/crates/rustc_codegen_spirv/src/linker/mod.rs +++ b/crates/rustc_codegen_spirv/src/linker/mod.rs @@ -428,8 +428,8 @@ pub fn link( return Err(sess .dcx() .struct_err(format!("{e}")) - .note("while lowering SPIR-V module to SPIR-T (spirt::spv::lower)") - .note(format!("input SPIR-V module {was_saved_msg}")) + .with_note("while lowering SPIR-V module to SPIR-T (spirt::spv::lower)") + .with_note(format!("input SPIR-V module {was_saved_msg}")) .emit()); } } @@ -543,7 +543,7 @@ pub fn link( if opts.dump_spirt_passes.is_none() { note.help("re-run with `RUSTGPU_CODEGEN_ARGS=\"--dump-spirt-passes=$PWD\"` for more details"); } - note.note("pretty-printed SPIR-T is preferred when reporting Rust-GPU issues") + note.with_note("pretty-printed SPIR-T is preferred when reporting Rust-GPU issues") .emit(); } diff --git a/crates/rustc_codegen_spirv/src/linker/simple_passes.rs b/crates/rustc_codegen_spirv/src/linker/simple_passes.rs index 2375cf24db..b7673f1175 100644 --- a/crates/rustc_codegen_spirv/src/linker/simple_passes.rs +++ b/crates/rustc_codegen_spirv/src/linker/simple_passes.rs @@ -250,7 +250,7 @@ pub fn check_fragment_insts(sess: &Session, module: &Module) -> Result<()> { "{} cannot be used outside a fragment shader", inst.class.opname )) - .note(note) + .with_note(note) .emit(), ); } diff --git a/crates/rustc_codegen_spirv/src/linker/zombies.rs b/crates/rustc_codegen_spirv/src/linker/zombies.rs index a33dca831f..bd8d21f5e3 100644 --- a/crates/rustc_codegen_spirv/src/linker/zombies.rs +++ b/crates/rustc_codegen_spirv/src/linker/zombies.rs @@ -229,7 +229,7 @@ impl<'a> ZombieReporter<'a> { // list out all the leaves, but that shouldn't be a huge issue. for root_id in super::dce::collect_roots(self.module) { if let Some(zombie) = self.zombies.get_zombie_by_id(root_id) { - for (_, mut err) in self.build_errors_keyed_by_leaf_id(zombie) { + for (_, err) in self.build_errors_keyed_by_leaf_id(zombie) { result = Err(err.emit()); } } diff --git a/crates/rustc_codegen_spirv/src/symbols.rs b/crates/rustc_codegen_spirv/src/symbols.rs index 5fbd18e036..242622fc93 100644 --- a/crates/rustc_codegen_spirv/src/symbols.rs +++ b/crates/rustc_codegen_spirv/src/symbols.rs @@ -545,7 +545,7 @@ fn parse_attr_int_value(arg: &NestedMetaItem) -> Result { Some(&MetaItemLit { kind: LitKind::Int(x, LitIntType::Unsuffixed), .. - }) if x <= u32::MAX as u128 => Ok(x as u32), + }) if x <= u32::MAX as u128 => Ok(x.get() as u32), _ => Err((arg.span, "attribute value must be integer".to_string())), } } @@ -563,7 +563,7 @@ fn parse_local_size_attr(arg: &NestedMetaItem) -> Result<[u32; 3], ParseAttrErro NestedMetaItem::Lit(MetaItemLit { kind: LitKind::Int(x, LitIntType::Unsuffixed), .. - }) if *x <= u32::MAX as u128 => local_size[idx] = *x as u32, + }) if *x <= u32::MAX as u128 => local_size[idx] = x.get() as u32, _ => return Err((lit.span(), "must be a u32 literal".to_string())), } } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 5933e8a961..23109ae68c 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,7 +1,7 @@ [toolchain] -channel = "nightly-2024-01-08" +channel = "nightly-2024-02-01" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = 75c68cfd2b9870f2953b62d250bd7d0564a7b56d +# commit_hash = 11f32b73e0dc9287e305b5b9980d24aecdc8c17f # Whenever changing the nightly channel, update the commit hash above, and make # sure to change `REQUIRED_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` also. diff --git a/tests/ui/dis/issue-1062.stderr b/tests/ui/dis/issue-1062.stderr index 3a056d9326..7b56b2e329 100644 --- a/tests/ui/dis/issue-1062.stderr +++ b/tests/ui/dis/issue-1062.stderr @@ -4,7 +4,7 @@ OpLine %5 11 12 %6 = OpLoad %7 %8 OpLine %5 11 35 %9 = OpLoad %7 %10 -OpLine %11 1145 4 +OpLine %11 1157 4 %12 = OpBitwiseAnd %7 %9 %13 %14 = OpISub %7 %15 %12 %16 = OpShiftLeftLogical %7 %6 %12 diff --git a/tests/ui/dis/ptr_copy.normal.stderr b/tests/ui/dis/ptr_copy.normal.stderr index 12888433e7..c8a3321504 100644 --- a/tests/ui/dis/ptr_copy.normal.stderr +++ b/tests/ui/dis/ptr_copy.normal.stderr @@ -1,13 +1,13 @@ error: cannot memcpy dynamically sized data - --> $CORE_SRC/intrinsics.rs:2800:9 + --> $CORE_SRC/intrinsics.rs:2866:9 | -2800 | copy(src, dst, count) +2866 | copy(src, dst, count) | ^^^^^^^^^^^^^^^^^^^^^ | note: used from within `core::intrinsics::copy::` - --> $CORE_SRC/intrinsics.rs:2786:21 + --> $CORE_SRC/intrinsics.rs:2852:21 | -2786 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { +2852 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { | ^^^^ note: called by `ptr_copy::copy_via_raw_ptr` --> $DIR/ptr_copy.rs:28:18 diff --git a/tests/ui/spirv-attr/bad-deduce-storage-class.stderr b/tests/ui/spirv-attr/bad-deduce-storage-class.stderr index 55643c7604..d1295c78ab 100644 --- a/tests/ui/spirv-attr/bad-deduce-storage-class.stderr +++ b/tests/ui/spirv-attr/bad-deduce-storage-class.stderr @@ -7,11 +7,7 @@ error: storage class mismatch | | `UniformConstant` deduced from type | `Uniform` specified in attribute | -help: remove storage class attribute to use `UniformConstant` as storage class - --> $DIR/bad-deduce-storage-class.rs:8:13 - | -8 | #[spirv(uniform)] error: &Image!(2D, type=f32), - | ^^^^^^^ + = help: remove storage class attribute to use `UniformConstant` as storage class warning: redundant storage class attribute, storage class is deduced from type --> $DIR/bad-deduce-storage-class.rs:9:13 From 1d449a895b2dc92e23286939de4bc3d976513a66 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sat, 3 Aug 2024 03:12:19 +0300 Subject: [PATCH 15/32] rustup: update to `nightly-2024-03-01`. --- .cargo/{config => config.toml} | 0 Cargo.lock | 6 +++--- crates/rustc_codegen_spirv/build.rs | 4 ++-- crates/rustc_codegen_spirv/src/attr.rs | 2 +- .../src/builder/builder_methods.rs | 7 ++++++- .../src/builder/intrinsics.rs | 16 ++++++++++------ crates/rustc_codegen_spirv/src/builder/mod.rs | 4 ++-- .../rustc_codegen_spirv/src/builder/spirv_asm.rs | 1 - crates/rustc_codegen_spirv/src/builder_spirv.rs | 2 +- crates/rustc_codegen_spirv/src/codegen_cx/mod.rs | 4 ++-- crates/rustc_codegen_spirv/src/lib.rs | 13 ++++--------- crates/rustc_codegen_spirv/src/link.rs | 10 ++++------ crates/rustc_codegen_spirv/src/linker/inline.rs | 1 - .../src/linker/peephole_opts.rs | 4 ++-- .../src/linker/specializer.rs | 3 ++- .../src/linker/spirt_passes/diagnostics.rs | 4 ++-- .../src/linker/spirt_passes/reduce.rs | 1 - crates/rustc_codegen_spirv/src/linker/test.rs | 6 ++++-- crates/rustc_codegen_spirv/src/linker/zombies.rs | 9 +++------ crates/spirv-builder/src/lib.rs | 6 +++--- examples/runners/ash/src/main.rs | 2 -- examples/runners/wgpu/src/compute.rs | 2 +- rust-toolchain.toml | 4 ++-- tests/ui/dis/ptr_copy.normal.stderr | 8 ++++---- tests/ui/dis/ptr_read.stderr | 2 +- tests/ui/dis/ptr_read_method.stderr | 2 +- tests/ui/dis/ptr_write.stderr | 2 +- tests/ui/dis/ptr_write_method.stderr | 2 +- tests/ui/lang/core/unwrap_or.stderr | 4 ++-- 29 files changed, 64 insertions(+), 67 deletions(-) rename .cargo/{config => config.toml} (100%) diff --git a/.cargo/config b/.cargo/config.toml similarity index 100% rename from .cargo/config rename to .cargo/config.toml diff --git a/Cargo.lock b/Cargo.lock index 252d22e370..8c24fd844f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,9 +20,9 @@ checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" [[package]] name = "ahash" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ "getrandom", "once_cell", @@ -1163,7 +1163,7 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" dependencies = [ - "ahash 0.7.7", + "ahash 0.7.8", ] [[package]] diff --git a/crates/rustc_codegen_spirv/build.rs b/crates/rustc_codegen_spirv/build.rs index e336e8c028..68ebb080ed 100644 --- a/crates/rustc_codegen_spirv/build.rs +++ b/crates/rustc_codegen_spirv/build.rs @@ -10,9 +10,9 @@ use std::process::{Command, ExitCode}; /// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/ //const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml"); const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain] -channel = "nightly-2024-02-01" +channel = "nightly-2024-03-01" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = 11f32b73e0dc9287e305b5b9980d24aecdc8c17f"#; +# commit_hash = 878c8a2a62d49ca5c454547ad67290a1df746cb5"#; fn get_rustc_commit_hash() -> Result> { let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc")); diff --git a/crates/rustc_codegen_spirv/src/attr.rs b/crates/rustc_codegen_spirv/src/attr.rs index 7e5dec741e..9f67a1320a 100644 --- a/crates/rustc_codegen_spirv/src/attr.rs +++ b/crates/rustc_codegen_spirv/src/attr.rs @@ -317,7 +317,7 @@ impl CheckSpirvAttrVisitor<'_> { | SpirvAttribute::InputAttachmentIndex(_) | SpirvAttribute::SpecConstant(_) => match target { Target::Param => { - let parent_hir_id = self.tcx.hir().parent_id(hir_id); + let parent_hir_id = self.tcx.parent_hir_id(hir_id); let parent_is_entry_point = parse_attrs(self.tcx.hir().attrs(parent_hir_id)) .filter_map(|r| r.ok()) diff --git a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs index 0c159d63d5..bbfcc5d026 100644 --- a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs +++ b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs @@ -28,7 +28,6 @@ use rustc_target::abi::{Abi, Align, Scalar, Size, WrappingRange}; use smallvec::SmallVec; use std::borrow::Cow; use std::cell::Cell; -use std::convert::TryInto; use std::iter::{self, empty}; use std::ops::RangeInclusive; @@ -1193,11 +1192,14 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { int(a, b) => a.wrapping_add(b) } } + // FIXME(eddyb) try to annotate the SPIR-V for `fast` and `algebraic`. simple_op! {fadd, f_add} simple_op! {fadd_fast, f_add} // fast=normal + simple_op! {fadd_algebraic, f_add} // algebraic=normal simple_op! {sub, i_sub} simple_op! {fsub, f_sub} simple_op! {fsub_fast, f_sub} // fast=normal + simple_op! {fsub_algebraic, f_sub} // algebraic=normal simple_op! { mul, i_mul, // HACK(eddyb) `rustc_codegen_ssa` relies on `Builder` methods doing @@ -1208,6 +1210,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { } simple_op! {fmul, f_mul} simple_op! {fmul_fast, f_mul} // fast=normal + simple_op! {fmul_algebraic, f_mul} // algebraic=normal simple_op! {udiv, u_div} // Note: exactudiv is UB when there's a remainder, so it's valid to implement as a normal div. // TODO: Can we take advantage of the UB and emit something else? @@ -1217,10 +1220,12 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { simple_op! {exactsdiv, s_div} simple_op! {fdiv, f_div} simple_op! {fdiv_fast, f_div} // fast=normal + simple_op! {fdiv_algebraic, f_div} // algebraic=normal simple_op! {urem, u_mod} simple_op! {srem, s_rem} simple_op! {frem, f_rem} simple_op! {frem_fast, f_rem} // fast=normal + simple_op! {frem_algebraic, f_rem} // algebraic=normal simple_op_unchecked_type! {shl, shift_left_logical} simple_op_unchecked_type! {lshr, shift_right_logical} simple_op_unchecked_type! {ashr, shift_right_arithmetic} diff --git a/crates/rustc_codegen_spirv/src/builder/intrinsics.rs b/crates/rustc_codegen_spirv/src/builder/intrinsics.rs index 9e610955a8..4a7471ef73 100644 --- a/crates/rustc_codegen_spirv/src/builder/intrinsics.rs +++ b/crates/rustc_codegen_spirv/src/builder/intrinsics.rs @@ -9,9 +9,9 @@ use rspirv::spirv::GLOp; use rustc_codegen_ssa::mir::operand::OperandRef; use rustc_codegen_ssa::mir::place::PlaceRef; use rustc_codegen_ssa::traits::{BuilderMethods, IntrinsicCallMethods}; -use rustc_middle::bug; use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::{FnDef, Instance, ParamEnv, Ty, TyKind}; +use rustc_middle::{bug, ty}; use rustc_span::sym; use rustc_span::Span; use rustc_target::abi::call::{FnAbi, PassMode}; @@ -71,7 +71,7 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> { args: &[OperandRef<'tcx, Self::Value>], llresult: Self::Value, _span: Span, - ) { + ) -> Result<(), ty::Instance<'tcx>> { let callee_ty = instance.ty(self.tcx, ParamEnv::reveal_all()); let (def_id, fn_args) = match *callee_ty.kind() { @@ -98,7 +98,7 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> { sym::breakpoint => { self.abort(); assert!(fn_abi.ret.is_ignore()); - return; + return Ok(()); } sym::volatile_load | sym::unaligned_volatile_load => { @@ -108,7 +108,7 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> { if !result.layout.is_zst() { self.store(load, result.llval, result.align); } - return; + return Ok(()); } sym::prefetch_read_data @@ -117,7 +117,7 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> { | sym::prefetch_write_instruction => { // ignore assert!(fn_abi.ret.is_ignore()); - return; + return Ok(()); } sym::saturating_add => { @@ -336,7 +336,10 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> { undef } - _ => self.fatal(format!("TODO: Unknown intrinsic '{name}'")), + _ => { + // Call the fallback body instead of generating the intrinsic code + return Err(ty::Instance::new(instance.def_id(), instance.args)); + } }; if !fn_abi.ret.is_ignore() { @@ -345,6 +348,7 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> { .val .store(self, result); } + Ok(()) } fn abort(&mut self) { diff --git a/crates/rustc_codegen_spirv/src/builder/mod.rs b/crates/rustc_codegen_spirv/src/builder/mod.rs index ac24b78f20..13956447d4 100644 --- a/crates/rustc_codegen_spirv/src/builder/mod.rs +++ b/crates/rustc_codegen_spirv/src/builder/mod.rs @@ -20,7 +20,7 @@ use rustc_codegen_ssa::traits::{ AbiBuilderMethods, ArgAbiMethods, BackendTypes, BuilderMethods, CoverageInfoBuilderMethods, DebugInfoBuilderMethods, HasCodegen, StaticBuilderMethods, TypeMembershipMethods, }; -use rustc_errors::{DiagnosticBuilder, DiagnosticMessage}; +use rustc_errors::{Diag, DiagnosticMessage}; use rustc_middle::mir::Coverage; use rustc_middle::span_bug; use rustc_middle::ty::layout::{ @@ -69,7 +69,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } #[track_caller] - pub fn struct_err(&self, msg: impl Into) -> DiagnosticBuilder<'_> { + pub fn struct_err(&self, msg: impl Into) -> Diag<'_> { if let Some(current_span) = self.current_span { self.tcx.dcx().struct_span_err(current_span, msg) } else { diff --git a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs index 16fd3b45a2..cda68d053d 100644 --- a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs +++ b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs @@ -15,7 +15,6 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_middle::{bug, ty::Instance}; use rustc_span::{Span, DUMMY_SP}; use rustc_target::asm::{InlineAsmRegClass, InlineAsmRegOrRegClass, SpirVInlineAsmRegClass}; -use std::convert::TryFrom; pub struct InstructionTable { table: FxHashMap<&'static str, &'static rspirv::grammar::Instruction<'static>>, diff --git a/crates/rustc_codegen_spirv/src/builder_spirv.rs b/crates/rustc_codegen_spirv/src/builder_spirv.rs index c2cb6f3244..852ffddc83 100644 --- a/crates/rustc_codegen_spirv/src/builder_spirv.rs +++ b/crates/rustc_codegen_spirv/src/builder_spirv.rs @@ -37,7 +37,7 @@ pub enum SpirvValueKind { /// This can only happen in one specific case - which is as a result of /// `codegen_buffer_store_intrinsic`, that function is supposed to return - /// OpTypeVoid, however because it gets inline by the compiler it can't. + /// `OpTypeVoid`, however because it gets inline by the compiler it can't. /// Instead we return this, and trigger an error if we ever end up using the /// result of this function call (which we can't). IllegalTypeUsed(Word), diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs index e784431133..bd26d1bcef 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs @@ -70,9 +70,9 @@ pub struct CodegenCx<'tcx> { /// "specifier" as a `char` (' ' for `Display`, `x` for `LowerHex`, etc.) pub fmt_rt_arg_new_fn_ids_to_ty_and_spec: RefCell, char)>>, - /// Intrinsic for loading a from a &[u32]. The PassMode is the mode of the . + /// Intrinsic for loading a `` from a `&[u32]`. The `PassMode` is the mode of the ``. pub buffer_load_intrinsic_fn_id: RefCell>, - /// Intrinsic for storing a into a &[u32]. The PassMode is the mode of the . + /// Intrinsic for storing a `` into a `&[u32]`. The `PassMode` is the mode of the ``. pub buffer_store_intrinsic_fn_id: RefCell>, /// Some runtimes (e.g. intel-compute-runtime) disallow atomics on i8 and i16, even though it's allowed by the spec. diff --git a/crates/rustc_codegen_spirv/src/lib.rs b/crates/rustc_codegen_spirv/src/lib.rs index 0e4c588762..7b44b415c0 100644 --- a/crates/rustc_codegen_spirv/src/lib.rs +++ b/crates/rustc_codegen_spirv/src/lib.rs @@ -252,15 +252,11 @@ impl CodegenBackend for SpirvCodegenBackend { ongoing_codegen: Box, sess: &Session, _outputs: &OutputFilenames, - ) -> Result<(CodegenResults, FxIndexMap), ErrorGuaranteed> { - let (codegen_results, work_products) = ongoing_codegen + ) -> (CodegenResults, FxIndexMap) { + ongoing_codegen .downcast::>() .expect("Expected OngoingCodegen, found Box") - .join(sess); - - sess.compile_status()?; - - Ok((codegen_results, work_products)) + .join(sess) } fn link( @@ -278,8 +274,7 @@ impl CodegenBackend for SpirvCodegenBackend { ); drop(timer); - sess.compile_status()?; - Ok(()) + sess.dcx().has_errors().map_or(Ok(()), Err) } } diff --git a/crates/rustc_codegen_spirv/src/link.rs b/crates/rustc_codegen_spirv/src/link.rs index edaa12cdcd..eb909baa67 100644 --- a/crates/rustc_codegen_spirv/src/link.rs +++ b/crates/rustc_codegen_spirv/src/link.rs @@ -9,7 +9,7 @@ use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModul use rustc_codegen_ssa::back::write::CodegenContext; use rustc_codegen_ssa::{CodegenResults, NativeLib}; use rustc_data_structures::fx::FxHashSet; -use rustc_errors::{DiagnosticBuilder, FatalError}; +use rustc_errors::{Diag, FatalError}; use rustc_metadata::fs::METADATA_FILENAME; use rustc_middle::bug; use rustc_middle::dep_graph::WorkProduct; @@ -348,11 +348,9 @@ fn do_spirv_opt( let mut err = match msg.level { // We have to manually construct this after `forget_guarantee` was removed in // - Level::Error | Level::Fatal | Level::InternalError => DiagnosticBuilder::<()>::new( - sess.dcx(), - rustc_errors::Level::Error, - msg.message, - ), + Level::Error | Level::Fatal | Level::InternalError => { + Diag::<()>::new(sess.dcx(), rustc_errors::Level::Error, msg.message) + } Level::Warning => sess.dcx().struct_warn(msg.message), Level::Info | Level::Debug => sess.dcx().struct_note(msg.message), }; diff --git a/crates/rustc_codegen_spirv/src/linker/inline.rs b/crates/rustc_codegen_spirv/src/linker/inline.rs index 10f53e02e0..717a73f85b 100644 --- a/crates/rustc_codegen_spirv/src/linker/inline.rs +++ b/crates/rustc_codegen_spirv/src/linker/inline.rs @@ -15,7 +15,6 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::ErrorGuaranteed; use rustc_session::Session; use smallvec::SmallVec; -use std::convert::TryInto; use std::mem::{self, take}; type FunctionMap = FxHashMap; diff --git a/crates/rustc_codegen_spirv/src/linker/peephole_opts.rs b/crates/rustc_codegen_spirv/src/linker/peephole_opts.rs index 668f6f50e9..fbfd4f9fd8 100644 --- a/crates/rustc_codegen_spirv/src/linker/peephole_opts.rs +++ b/crates/rustc_codegen_spirv/src/linker/peephole_opts.rs @@ -107,10 +107,10 @@ enum IdentifiedOperand { /// The operand to the vectorized operation is a straight-up vector. Vector(Word), /// The operand to the vectorized operation is a collection of scalars that need to be packed - /// together with OpCompositeConstruct before using the vectorized operation. + /// together with `OpCompositeConstruct` before using the vectorized operation. Scalars(Vec), /// The operand to the vectorized operation is some non-value: for example, the `instruction` - /// operand in OpExtInst. + /// operand in `OpExtInst`. NonValue(Operand), } diff --git a/crates/rustc_codegen_spirv/src/linker/specializer.rs b/crates/rustc_codegen_spirv/src/linker/specializer.rs index 41481e6ebd..61f65967c8 100644 --- a/crates/rustc_codegen_spirv/src/linker/specializer.rs +++ b/crates/rustc_codegen_spirv/src/linker/specializer.rs @@ -58,7 +58,6 @@ use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use smallvec::SmallVec; use std::collections::{BTreeMap, VecDeque}; -use std::convert::{TryFrom, TryInto}; use std::ops::{Range, RangeTo}; use std::{fmt, io, iter, mem, slice}; @@ -378,6 +377,8 @@ enum InstructionLocation { } trait OperandIndexGetSet { + // FIXME(eddyb) how come this isn't used? (is iteration preferred?) + #[allow(dead_code)] fn index_get(&self, index: I) -> Operand; fn index_set(&mut self, index: I, operand: Operand); } diff --git a/crates/rustc_codegen_spirv/src/linker/spirt_passes/diagnostics.rs b/crates/rustc_codegen_spirv/src/linker/spirt_passes/diagnostics.rs index 236e282e63..4c4cbbc4bb 100644 --- a/crates/rustc_codegen_spirv/src/linker/spirt_passes/diagnostics.rs +++ b/crates/rustc_codegen_spirv/src/linker/spirt_passes/diagnostics.rs @@ -3,7 +3,7 @@ use crate::custom_decorations::{ }; use crate::custom_insts::{self, CustomInst, CustomOp}; use rustc_data_structures::fx::FxIndexSet; -use rustc_errors::{DiagnosticBuilder, EmissionGuarantee}; +use rustc_errors::EmissionGuarantee; use rustc_session::Session; use rustc_span::{Span, DUMMY_SP}; use smallvec::SmallVec; @@ -310,7 +310,7 @@ impl UseOrigin<'_> { &self, cx: &Context, span_regen: &mut SpanRegenerator<'_>, - err: &mut DiagnosticBuilder<'_, G>, + err: &mut rustc_errors::Diag<'_, G>, ) { let wk = &super::SpvSpecWithExtras::get().well_known; diff --git a/crates/rustc_codegen_spirv/src/linker/spirt_passes/reduce.rs b/crates/rustc_codegen_spirv/src/linker/spirt_passes/reduce.rs index cfe24dd31c..a4750586e7 100644 --- a/crates/rustc_codegen_spirv/src/linker/spirt_passes/reduce.rs +++ b/crates/rustc_codegen_spirv/src/linker/spirt_passes/reduce.rs @@ -10,7 +10,6 @@ use spirt::{ TypeCtor, TypeDef, Value, }; use std::collections::hash_map::Entry; -use std::convert::{TryFrom, TryInto}; use std::hash::Hash; use std::{iter, slice}; diff --git a/crates/rustc_codegen_spirv/src/linker/test.rs b/crates/rustc_codegen_spirv/src/linker/test.rs index 3ed1bf0c7f..399e5535cc 100644 --- a/crates/rustc_codegen_spirv/src/linker/test.rs +++ b/crates/rustc_codegen_spirv/src/linker/test.rs @@ -172,7 +172,7 @@ fn link_with_linker_opts( rustc_errors::emitter::HumanEmitter::new(Box::new(buf), fallback_bundle) .sm(Some(sess.parse_sess.clone_source_map())); - rustc_errors::DiagCtxt::with_emitter(Box::new(emitter)) + rustc_errors::DiagCtxt::new(Box::new(emitter)) .with_flags(sess.opts.unstable_opts.dcx_flags(true)) }; @@ -196,10 +196,12 @@ fn link_with_linker_opts( LinkResult::SingleModule(m) => *m, LinkResult::MultipleModules { .. } => unreachable!(), }) + .map_err(|_guar| ()) }) }) + .map_err(|_fatal| ()) .flatten() - .map_err(|_e| { + .map_err(|()| { let mut diags = output.unwrap_to_string(); if let Some(diags_without_trailing_newlines) = diags.strip_suffix("\n\n") { diags.truncate(diags_without_trailing_newlines.len()); diff --git a/crates/rustc_codegen_spirv/src/linker/zombies.rs b/crates/rustc_codegen_spirv/src/linker/zombies.rs index bd8d21f5e3..dd35113419 100644 --- a/crates/rustc_codegen_spirv/src/linker/zombies.rs +++ b/crates/rustc_codegen_spirv/src/linker/zombies.rs @@ -6,7 +6,7 @@ use crate::custom_insts::{self, CustomOp}; use rspirv::dr::{Instruction, Module, Operand}; use rspirv::spirv::{Op, Word}; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; -use rustc_errors::DiagnosticBuilder; +use rustc_errors::Diag; use rustc_session::Session; use rustc_span::{Span, DUMMY_SP}; use smallvec::SmallVec; @@ -239,7 +239,7 @@ impl<'a> ZombieReporter<'a> { fn add_use_note_to_err( &mut self, - err: &mut DiagnosticBuilder<'a>, + err: &mut Diag<'a>, span: Span, zombie: Zombie<'_>, zombie_use: &ZombieUse<'_>, @@ -275,10 +275,7 @@ impl<'a> ZombieReporter<'a> { err.span_note(span, note); } - fn build_errors_keyed_by_leaf_id( - &mut self, - zombie: Zombie<'_>, - ) -> FxIndexMap> { + fn build_errors_keyed_by_leaf_id(&mut self, zombie: Zombie<'_>) -> FxIndexMap> { // FIXME(eddyb) this is a bit inefficient, compared to some kind of // "small map", but this is the error path, and being correct is more // important here - in particular, we don't want to ignore *any* leaves. diff --git a/crates/spirv-builder/src/lib.rs b/crates/spirv-builder/src/lib.rs index 498d89b6ab..54a8c8e589 100644 --- a/crates/spirv-builder/src/lib.rs +++ b/crates/spirv-builder/src/lib.rs @@ -167,10 +167,10 @@ pub enum MetadataPrintout { pub enum SpirvMetadata { /// Strip all names and other debug information from SPIR-V output. None, - /// Only include OpNames for public interface variables (uniforms and the like), to allow + /// Only include `OpName`s for public interface variables (uniforms and the like), to allow /// shader reflection. NameVariables, - /// Include all OpNames for everything, and OpLines. Significantly increases binary size. + /// Include all `OpName`s for everything, and `OpLine`s. Significantly increases binary size. Full, } @@ -233,7 +233,7 @@ pub enum ShaderPanicStrategy { print_inputs: bool, /// Whether to also print a "backtrace" (i.e. the chain of function calls - /// that led to the `panic!). + /// that led to the `panic!`). /// /// As there is no way to dynamically compute this information, the string /// containing the full backtrace of each `panic!` is statically generated, diff --git a/examples/runners/ash/src/main.rs b/examples/runners/ash/src/main.rs index fddfae724b..4214e649a3 100644 --- a/examples/runners/ash/src/main.rs +++ b/examples/runners/ash/src/main.rs @@ -85,10 +85,8 @@ use winit::{ use std::{ borrow::Cow, collections::HashMap, - default::Default, ffi::{CStr, CString}, fs::File, - ops::Drop, sync::mpsc::{sync_channel, TryRecvError, TrySendError}, thread, }; diff --git a/examples/runners/wgpu/src/compute.rs b/examples/runners/wgpu/src/compute.rs index 20322ca0c7..e2686973d4 100644 --- a/examples/runners/wgpu/src/compute.rs +++ b/examples/runners/wgpu/src/compute.rs @@ -1,6 +1,6 @@ use crate::{maybe_watch, CompiledShaderModules, Options}; -use std::{convert::TryInto, time::Duration}; +use std::time::Duration; use wgpu::util::DeviceExt; pub fn start(options: &Options) { diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 23109ae68c..ed84106338 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,7 +1,7 @@ [toolchain] -channel = "nightly-2024-02-01" +channel = "nightly-2024-03-01" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = 11f32b73e0dc9287e305b5b9980d24aecdc8c17f +# commit_hash = 878c8a2a62d49ca5c454547ad67290a1df746cb5 # Whenever changing the nightly channel, update the commit hash above, and make # sure to change `REQUIRED_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` also. diff --git a/tests/ui/dis/ptr_copy.normal.stderr b/tests/ui/dis/ptr_copy.normal.stderr index c8a3321504..70adfd2165 100644 --- a/tests/ui/dis/ptr_copy.normal.stderr +++ b/tests/ui/dis/ptr_copy.normal.stderr @@ -1,13 +1,13 @@ error: cannot memcpy dynamically sized data - --> $CORE_SRC/intrinsics.rs:2866:9 + --> $CORE_SRC/intrinsics.rs:3010:9 | -2866 | copy(src, dst, count) +3010 | copy(src, dst, count) | ^^^^^^^^^^^^^^^^^^^^^ | note: used from within `core::intrinsics::copy::` - --> $CORE_SRC/intrinsics.rs:2852:21 + --> $CORE_SRC/intrinsics.rs:2990:21 | -2852 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { +2990 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { | ^^^^ note: called by `ptr_copy::copy_via_raw_ptr` --> $DIR/ptr_copy.rs:28:18 diff --git a/tests/ui/dis/ptr_read.stderr b/tests/ui/dis/ptr_read.stderr index 17cc16c310..7406d30785 100644 --- a/tests/ui/dis/ptr_read.stderr +++ b/tests/ui/dis/ptr_read.stderr @@ -2,7 +2,7 @@ %4 = OpFunctionParameter %5 %6 = OpFunctionParameter %5 %7 = OpLabel -OpLine %8 1215 8 +OpLine %8 1257 8 %9 = OpLoad %10 %4 OpLine %11 7 13 OpStore %6 %9 diff --git a/tests/ui/dis/ptr_read_method.stderr b/tests/ui/dis/ptr_read_method.stderr index 17cc16c310..7406d30785 100644 --- a/tests/ui/dis/ptr_read_method.stderr +++ b/tests/ui/dis/ptr_read_method.stderr @@ -2,7 +2,7 @@ %4 = OpFunctionParameter %5 %6 = OpFunctionParameter %5 %7 = OpLabel -OpLine %8 1215 8 +OpLine %8 1257 8 %9 = OpLoad %10 %4 OpLine %11 7 13 OpStore %6 %9 diff --git a/tests/ui/dis/ptr_write.stderr b/tests/ui/dis/ptr_write.stderr index a34bffdedc..857ed08f83 100644 --- a/tests/ui/dis/ptr_write.stderr +++ b/tests/ui/dis/ptr_write.stderr @@ -4,7 +4,7 @@ %7 = OpLabel OpLine %8 7 35 %9 = OpLoad %10 %4 -OpLine %11 1415 8 +OpLine %11 1465 8 OpStore %6 %9 OpNoLine OpReturn diff --git a/tests/ui/dis/ptr_write_method.stderr b/tests/ui/dis/ptr_write_method.stderr index c6607d192d..8786fbee9b 100644 --- a/tests/ui/dis/ptr_write_method.stderr +++ b/tests/ui/dis/ptr_write_method.stderr @@ -4,7 +4,7 @@ %7 = OpLabel OpLine %8 7 37 %9 = OpLoad %10 %4 -OpLine %11 1415 8 +OpLine %11 1465 8 OpStore %6 %9 OpNoLine OpReturn diff --git a/tests/ui/lang/core/unwrap_or.stderr b/tests/ui/lang/core/unwrap_or.stderr index 8448d926fe..cabe9e3131 100644 --- a/tests/ui/lang/core/unwrap_or.stderr +++ b/tests/ui/lang/core/unwrap_or.stderr @@ -3,9 +3,9 @@ OpLine %5 13 11 %6 = OpCompositeInsert %7 %8 %9 0 %10 = OpCompositeExtract %11 %6 1 -OpLine %12 952 14 +OpLine %12 954 14 %13 = OpBitcast %14 %8 -OpLine %12 952 8 +OpLine %12 954 8 %15 = OpIEqual %16 %13 %17 OpNoLine OpSelectionMerge %18 None From 907d84991b040ab5e19cf36d9e95187ddaec0882 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sat, 3 Aug 2024 17:20:46 +0300 Subject: [PATCH 16/32] rustup: update to `nightly-2024-03-11`. --- crates/rustc_codegen_spirv/build.rs | 4 +- crates/rustc_codegen_spirv/src/abi.rs | 2 + .../src/builder/builder_methods.rs | 80 ++----------------- crates/rustc_codegen_spirv/src/builder/mod.rs | 8 +- .../src/builder/spirv_asm.rs | 21 ++++- .../src/codegen_cx/constant.rs | 8 ++ .../src/codegen_cx/entry.rs | 17 ++-- .../src/codegen_cx/type_.rs | 26 ++---- crates/rustc_codegen_spirv/src/linker/mod.rs | 3 + crates/rustc_codegen_spirv/src/linker/test.rs | 21 +++-- crates/rustc_codegen_spirv/src/spirv_type.rs | 7 +- crates/rustc_codegen_spirv/src/target.rs | 1 + rust-toolchain.toml | 4 +- .../ui/dis/panic_builtin_bounds_check.stderr | 4 +- tests/ui/dis/ptr_copy.normal.stderr | 8 +- tests/ui/dis/ptr_read.stderr | 2 +- tests/ui/dis/ptr_read_method.stderr | 2 +- tests/ui/dis/ptr_write.stderr | 2 +- tests/ui/dis/ptr_write_method.stderr | 2 +- 19 files changed, 92 insertions(+), 130 deletions(-) diff --git a/crates/rustc_codegen_spirv/build.rs b/crates/rustc_codegen_spirv/build.rs index 68ebb080ed..76d0742c59 100644 --- a/crates/rustc_codegen_spirv/build.rs +++ b/crates/rustc_codegen_spirv/build.rs @@ -10,9 +10,9 @@ use std::process::{Command, ExitCode}; /// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/ //const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml"); const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain] -channel = "nightly-2024-03-01" +channel = "nightly-2024-03-11" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = 878c8a2a62d49ca5c454547ad67290a1df746cb5"#; +# commit_hash = 3b1717c052de4a2dbdd3badb0e7a885f40a8ad9e"#; fn get_rustc_commit_hash() -> Result> { let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc")); diff --git a/crates/rustc_codegen_spirv/src/abi.rs b/crates/rustc_codegen_spirv/src/abi.rs index 0d11af538c..b9d05636e8 100644 --- a/crates/rustc_codegen_spirv/src/abi.rs +++ b/crates/rustc_codegen_spirv/src/abi.rs @@ -505,8 +505,10 @@ fn trans_scalar<'tcx>( Primitive::Int(width, signedness) => { SpirvType::Integer(width.size().bits() as u32, signedness).def(span, cx) } + Primitive::F16 => SpirvType::Float(16).def(span, cx), Primitive::F32 => SpirvType::Float(32).def(span, cx), Primitive::F64 => SpirvType::Float(64).def(span, cx), + Primitive::F128 => SpirvType::Float(128).def(span, cx), Primitive::Pointer(_) => { let pointee_ty = dig_scalar_pointee(cx, ty, offset); // Pointers can be recursive. So, record what we're currently translating, and if we're already translating diff --git a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs index bbfcc5d026..b1d6bf18e8 100644 --- a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs +++ b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs @@ -1465,9 +1465,12 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { .size(self) .align_to(b.primitive().align(self).abi); - let pair_ty = place.layout.spirv_type(self.span(), self); let mut load = |i, scalar: Scalar, align| { - let llptr = self.struct_gep(pair_ty, place.llval, i as u64); + let llptr = if i == 0 { + place.llval + } else { + self.inbounds_ptradd(place.llval, self.const_usize(b_offset.bytes())) + }; let load = self.load( self.scalar_pair_element_backend_type(place.layout, i, false), llptr, @@ -1581,79 +1584,6 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { self.maybe_inbounds_gep(ty, ptr, indices, true) } - fn struct_gep(&mut self, ty: Self::Type, ptr: Self::Value, idx: u64) -> Self::Value { - let (offset, result_pointee_type) = match self.lookup_type(ty) { - SpirvType::Adt { - field_offsets, - field_types, - .. - } => (field_offsets[idx as usize], field_types[idx as usize]), - SpirvType::Array { element, .. } - | SpirvType::RuntimeArray { element, .. } - | SpirvType::Vector { element, .. } - | SpirvType::Matrix { element, .. } => ( - self.lookup_type(element).sizeof(self).unwrap() * idx, - element, - ), - SpirvType::InterfaceBlock { inner_type } => { - assert_eq!(idx, 0); - (Size::ZERO, inner_type) - } - other => self.fatal(format!( - "struct_gep not on struct, array, or vector type: {other:?}, index {idx}" - )), - }; - let result_pointee_size = self.lookup_type(result_pointee_type).sizeof(self); - let result_type = self.type_ptr_to(result_pointee_type); - - // Special-case field accesses through a `pointercast`, to accesss the - // right field in the original type, for the `Logical` addressing model. - let ptr = ptr.strip_ptrcasts(); - let original_pointee_ty = match self.lookup_type(ptr.ty) { - SpirvType::Pointer { pointee } => pointee, - other => self.fatal(format!("struct_gep called on non-pointer type: {other:?}")), - }; - if let Some((indices, _)) = self.recover_access_chain_from_offset( - original_pointee_ty, - offset, - result_pointee_size..=result_pointee_size, - Some(result_pointee_type), - ) { - let original_ptr = ptr.def(self); - let indices = indices - .into_iter() - .map(|idx| self.constant_u32(self.span(), idx).def(self)) - .collect::>(); - return self - .emit() - .in_bounds_access_chain(result_type, None, original_ptr, indices) - .unwrap() - .with_type(result_type); - } - - // FIXME(eddyb) can we even get to this point, with valid SPIR-V? - - // HACK(eddyb) temporary workaround for untyped pointers upstream. - // FIXME(eddyb) replace with untyped memory SPIR-V + `qptr` or similar. - let ptr = self.pointercast(ptr, self.type_ptr_to(ty)); - - // Important! LLVM, and therefore intel-compute-runtime, require the `getelementptr` instruction (and therefore - // OpAccessChain) on structs to be a constant i32. Not i64! i32. - if idx > u32::MAX as u64 { - self.fatal("struct_gep bigger than u32::MAX"); - } - let index_const = self.constant_u32(self.span(), idx as u32).def(self); - self.emit() - .in_bounds_access_chain( - result_type, - None, - ptr.def(self), - [index_const].iter().cloned(), - ) - .unwrap() - .with_type(result_type) - } - // intcast has the logic for dealing with bools, so use that fn trunc(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value { self.intcast(val, dest_ty, false) diff --git a/crates/rustc_codegen_spirv/src/builder/mod.rs b/crates/rustc_codegen_spirv/src/builder/mod.rs index 13956447d4..151b06a268 100644 --- a/crates/rustc_codegen_spirv/src/builder/mod.rs +++ b/crates/rustc_codegen_spirv/src/builder/mod.rs @@ -20,7 +20,7 @@ use rustc_codegen_ssa::traits::{ AbiBuilderMethods, ArgAbiMethods, BackendTypes, BuilderMethods, CoverageInfoBuilderMethods, DebugInfoBuilderMethods, HasCodegen, StaticBuilderMethods, TypeMembershipMethods, }; -use rustc_errors::{Diag, DiagnosticMessage}; +use rustc_errors::{Diag, DiagMessage}; use rustc_middle::mir::Coverage; use rustc_middle::span_bug; use rustc_middle::ty::layout::{ @@ -69,7 +69,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } #[track_caller] - pub fn struct_err(&self, msg: impl Into) -> Diag<'_> { + pub fn struct_err(&self, msg: impl Into) -> Diag<'_> { if let Some(current_span) = self.current_span { self.tcx.dcx().struct_span_err(current_span, msg) } else { @@ -78,7 +78,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } #[track_caller] - pub fn err(&self, msg: impl Into) { + pub fn err(&self, msg: impl Into) { if let Some(current_span) = self.current_span { self.tcx.dcx().span_err(current_span, msg); } else { @@ -87,7 +87,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } #[track_caller] - pub fn fatal(&self, msg: impl Into) -> ! { + pub fn fatal(&self, msg: impl Into) -> ! { if let Some(current_span) = self.current_span { self.tcx.dcx().span_fatal(current_span, msg) } else { diff --git a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs index cda68d053d..31c35f363d 100644 --- a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs +++ b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs @@ -58,7 +58,8 @@ impl<'a, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'tcx> { options: InlineAsmOptions, _line_spans: &[Span], _instance: Instance<'_>, - _dest_catch_funclet: Option<(Self::BasicBlock, Self::BasicBlock, Option<&Self::Funclet>)>, + _dest: Option, + _catch_funclet: Option<(Self::BasicBlock, Option<&Self::Funclet>)>, ) { const SUPPORTED_OPTIONS: InlineAsmOptions = InlineAsmOptions::NORETURN; let unsupported_options = options & !SUPPORTED_OPTIONS; @@ -889,6 +890,12 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { .span_err(span, "cannot write to static variable asm argument"); None } + InlineAsmOperandRef::Label { label: _ } => { + self.tcx + .dcx() + .span_err(span, "cannot write to label asm argument"); + None + } }, } } @@ -988,6 +995,12 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { ); None } + InlineAsmOperandRef::Label { label: _ } => { + self.tcx + .dcx() + .span_err(span, "cannot take the type of a label asm argument"); + None + } }, Token::Placeholder(hole, span) => match hole { InlineAsmOperandRef::In { reg, value } => { @@ -1032,6 +1045,12 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { .span_err(span, "static variable asm argument not supported yet"); None } + InlineAsmOperandRef::Label { label: _ } => { + self.tcx + .dcx() + .span_err(span, "label asm argument not supported yet"); + None + } }, } } diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs b/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs index ba123ea594..e5d0898dd8 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs @@ -265,6 +265,10 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> { other.debug(ty, self) )), }, + Primitive::F16 => self + .tcx + .dcx() + .fatal("scalar_to_backend Primitive::F16 not supported"), Primitive::F32 => { let res = self.constant_f32(DUMMY_SP, f32::from_bits(data as u32)); assert_eq!(res.ty, ty); @@ -275,6 +279,10 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> { assert_eq!(res.ty, ty); res } + Primitive::F128 => self + .tcx + .dcx() + .fatal("scalar_to_backend Primitive::F128 not supported"), Primitive::Pointer(_) => { if data == 0 { self.constant_null(ty) diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs b/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs index 04eb2f93a3..0dc4815fe1 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs @@ -505,11 +505,18 @@ impl<'tcx> CodegenCx<'tcx> { .def(hir_param.span, self); var_ptr_spirv_type = self.type_ptr_to(var_spirv_type); - let value_ptr = bx.struct_gep( - var_spirv_type, - var_id.unwrap().with_type(var_ptr_spirv_type), - 0, - ); + let zero_u32 = self.constant_u32(hir_param.span, 0).def_cx(self); + let value_ptr_spirv_type = self.type_ptr_to(value_spirv_type); + let value_ptr = bx + .emit() + .in_bounds_access_chain( + value_ptr_spirv_type, + None, + var_id.unwrap(), + [zero_u32].iter().cloned(), + ) + .unwrap() + .with_type(value_ptr_spirv_type); let value_len = if is_unsized_with_len { match self.lookup_type(value_spirv_type) { diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs b/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs index 6b6a57dece..599c5ff9b7 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs @@ -12,7 +12,7 @@ use rustc_middle::{bug, span_bug}; use rustc_span::source_map::Spanned; use rustc_span::{Span, DUMMY_SP}; use rustc_target::abi::call::{CastTarget, FnAbi, Reg}; -use rustc_target::abi::{Abi, AddressSpace, FieldsShape}; +use rustc_target::abi::{Abi, AddressSpace}; impl<'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'tcx> { type LayoutOfResult = TyAndLayout<'tcx>; @@ -107,23 +107,6 @@ impl<'tcx> LayoutTypeMethods<'tcx> for CodegenCx<'tcx> { } } - fn backend_field_index(&self, layout: TyAndLayout<'tcx>, index: usize) -> u64 { - match layout.abi { - Abi::Scalar(_) | Abi::ScalarPair(..) => { - bug!("backend_field_index({:?}): not applicable", layout); - } - _ => {} - } - match layout.fields { - FieldsShape::Primitive | FieldsShape::Union(_) => { - bug!("backend_field_index({:?}): not applicable", layout) - } - FieldsShape::Array { .. } => index as u64, - // note: codegen_llvm implements this as 1+index*2 due to padding fields - FieldsShape::Arbitrary { .. } => layout.fields.memory_index(index) as u64, - } - } - fn scalar_pair_element_backend_type( &self, layout: TyAndLayout<'tcx>, @@ -165,12 +148,18 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> { SpirvType::Integer(ptr_size, false).def(DUMMY_SP, self) } + fn type_f16(&self) -> Self::Type { + SpirvType::Float(16).def(DUMMY_SP, self) + } fn type_f32(&self) -> Self::Type { SpirvType::Float(32).def(DUMMY_SP, self) } fn type_f64(&self) -> Self::Type { SpirvType::Float(64).def(DUMMY_SP, self) } + fn type_f128(&self) -> Self::Type { + SpirvType::Float(128).def(DUMMY_SP, self) + } fn type_array(&self, ty: Self::Type, len: u64) -> Self::Type { SpirvType::Array { @@ -209,6 +198,7 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> { 16 => TypeKind::Half, 32 => TypeKind::Float, 64 => TypeKind::Double, + 128 => TypeKind::FP128, other => self .tcx .dcx() diff --git a/crates/rustc_codegen_spirv/src/linker/mod.rs b/crates/rustc_codegen_spirv/src/linker/mod.rs index 63ce090167..37fdf0c497 100644 --- a/crates/rustc_codegen_spirv/src/linker/mod.rs +++ b/crates/rustc_codegen_spirv/src/linker/mod.rs @@ -647,6 +647,9 @@ pub fn link( entry.insert((entry_name, module)); break; } + // FIXME(eddyb) false positive: `file_stem` was moved out of, + // so assigning it is necessary, but clippy doesn't know that. + #[allow(clippy::assigning_clones)] Entry::Occupied(entry) => { // FIXME(eddyb) there's no way to access the owned key // passed to `BTreeMap::entry` from `OccupiedEntry`. diff --git a/crates/rustc_codegen_spirv/src/linker/test.rs b/crates/rustc_codegen_spirv/src/linker/test.rs index 399e5535cc..f82010113b 100644 --- a/crates/rustc_codegen_spirv/src/linker/test.rs +++ b/crates/rustc_codegen_spirv/src/linker/test.rs @@ -122,20 +122,17 @@ fn link_with_linker_opts( // is really a silent unwinding device, that should be treated the same as // `Err(ErrorGuaranteed)` returns from `link`). rustc_driver::catch_fatal_errors(|| { - let mut early_error_handler = + let mut early_dcx = rustc_session::EarlyDiagCtxt::new(rustc_session::config::ErrorOutputType::default()); - early_error_handler.initialize_checked_jobserver(); - let matches = rustc_driver::handle_options( - &early_error_handler, - &["".to_string(), "x.rs".to_string()], - ) - .unwrap(); - let sopts = - rustc_session::config::build_session_options(&mut early_error_handler, &matches); + early_dcx.initialize_checked_jobserver(); + let matches = + rustc_driver::handle_options(&early_dcx, &["".to_string(), "x.rs".to_string()]) + .unwrap(); + let sopts = rustc_session::config::build_session_options(&mut early_dcx, &matches); rustc_span::create_session_globals_then(sopts.edition, || { let mut sess = rustc_session::build_session( - early_error_handler, + early_dcx, sopts, CompilerIO { input: Input::Str { @@ -160,7 +157,7 @@ fn link_with_linker_opts( // HACK(eddyb) inject `write_diags` into `sess`, to work around // the removals in https://github.com/rust-lang/rust/pull/102992. - sess.parse_sess.dcx = { + sess.psess.dcx = { let fallback_bundle = { extern crate rustc_error_messages; rustc_error_messages::fallback_fluent_bundle( @@ -170,7 +167,7 @@ fn link_with_linker_opts( }; let emitter = rustc_errors::emitter::HumanEmitter::new(Box::new(buf), fallback_bundle) - .sm(Some(sess.parse_sess.clone_source_map())); + .sm(Some(sess.psess.clone_source_map())); rustc_errors::DiagCtxt::new(Box::new(emitter)) .with_flags(sess.opts.unstable_opts.dcx_flags(true)) diff --git a/crates/rustc_codegen_spirv/src/spirv_type.rs b/crates/rustc_codegen_spirv/src/spirv_type.rs index 7cfffc6d79..226295958f 100644 --- a/crates/rustc_codegen_spirv/src/spirv_type.rs +++ b/crates/rustc_codegen_spirv/src/spirv_type.rs @@ -132,12 +132,17 @@ impl SpirvType<'_> { Self::Float(width) => { let result = cx.emit_global().type_float_id(id, width); match width { + 16 if !cx.builder.has_capability(Capability::Float16) => cx.zombie_with_span( + result, + def_span, + "`f16` without `OpCapability Float16`", + ), 64 if !cx.builder.has_capability(Capability::Float64) => cx.zombie_with_span( result, def_span, "`f64` without `OpCapability Float64`", ), - 32 | 64 => (), + 16 | 32 | 64 => (), other => cx.zombie_with_span( result, def_span, diff --git a/crates/rustc_codegen_spirv/src/target.rs b/crates/rustc_codegen_spirv/src/target.rs index 6b449605dc..1ca45d812b 100644 --- a/crates/rustc_codegen_spirv/src/target.rs +++ b/crates/rustc_codegen_spirv/src/target.rs @@ -97,6 +97,7 @@ impl SpirvTarget { pub fn rustc_target(&self) -> Target { Target { llvm_target: self.to_string().into(), + description: None, pointer_width: 32, data_layout: "e-m:e-p:32:32:32-i64:64-n8:16:32:64".into(), arch: ARCH.into(), diff --git a/rust-toolchain.toml b/rust-toolchain.toml index ed84106338..30cc29967a 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,7 +1,7 @@ [toolchain] -channel = "nightly-2024-03-01" +channel = "nightly-2024-03-11" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = 878c8a2a62d49ca5c454547ad67290a1df746cb5 +# commit_hash = 3b1717c052de4a2dbdd3badb0e7a885f40a8ad9e # Whenever changing the nightly channel, update the commit hash above, and make # sure to change `REQUIRED_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` also. diff --git a/tests/ui/dis/panic_builtin_bounds_check.stderr b/tests/ui/dis/panic_builtin_bounds_check.stderr index 43307c309d..94ee4dc001 100644 --- a/tests/ui/dis/panic_builtin_bounds_check.stderr +++ b/tests/ui/dis/panic_builtin_bounds_check.stderr @@ -10,7 +10,7 @@ OpExtension "SPV_KHR_shader_clock" OpMemoryModel Logical Simple OpEntryPoint Fragment %2 "main" OpExecutionMode %2 OriginUpperLeft -%3 = OpString "/n[Rust panicked at $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs:208:5]/n index out of bounds: the len is %u but the index is %u/n in main()/n" +%3 = OpString "/n[Rust panicked at $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs:209:5]/n index out of bounds: the len is %u but the index is %u/n in main()/n" %4 = OpString $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs" %5 = OpString "$DIR/panic_builtin_bounds_check.rs" %6 = OpTypeVoid @@ -29,7 +29,7 @@ OpBranchConditional %13 %15 %16 %15 = OpLabel OpBranch %14 %16 = OpLabel -OpLine %4 208 4 +OpLine %4 209 4 %17 = OpExtInst %6 %1 1 %3 %11 %10 OpNoLine OpBranch %14 diff --git a/tests/ui/dis/ptr_copy.normal.stderr b/tests/ui/dis/ptr_copy.normal.stderr index 70adfd2165..7ec17563dc 100644 --- a/tests/ui/dis/ptr_copy.normal.stderr +++ b/tests/ui/dis/ptr_copy.normal.stderr @@ -1,13 +1,13 @@ error: cannot memcpy dynamically sized data - --> $CORE_SRC/intrinsics.rs:3010:9 + --> $CORE_SRC/intrinsics.rs:3085:9 | -3010 | copy(src, dst, count) +3085 | copy(src, dst, count) | ^^^^^^^^^^^^^^^^^^^^^ | note: used from within `core::intrinsics::copy::` - --> $CORE_SRC/intrinsics.rs:2990:21 + --> $CORE_SRC/intrinsics.rs:3064:21 | -2990 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { +3064 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { | ^^^^ note: called by `ptr_copy::copy_via_raw_ptr` --> $DIR/ptr_copy.rs:28:18 diff --git a/tests/ui/dis/ptr_read.stderr b/tests/ui/dis/ptr_read.stderr index 7406d30785..1c618431d0 100644 --- a/tests/ui/dis/ptr_read.stderr +++ b/tests/ui/dis/ptr_read.stderr @@ -2,7 +2,7 @@ %4 = OpFunctionParameter %5 %6 = OpFunctionParameter %5 %7 = OpLabel -OpLine %8 1257 8 +OpLine %8 1284 8 %9 = OpLoad %10 %4 OpLine %11 7 13 OpStore %6 %9 diff --git a/tests/ui/dis/ptr_read_method.stderr b/tests/ui/dis/ptr_read_method.stderr index 7406d30785..1c618431d0 100644 --- a/tests/ui/dis/ptr_read_method.stderr +++ b/tests/ui/dis/ptr_read_method.stderr @@ -2,7 +2,7 @@ %4 = OpFunctionParameter %5 %6 = OpFunctionParameter %5 %7 = OpLabel -OpLine %8 1257 8 +OpLine %8 1284 8 %9 = OpLoad %10 %4 OpLine %11 7 13 OpStore %6 %9 diff --git a/tests/ui/dis/ptr_write.stderr b/tests/ui/dis/ptr_write.stderr index 857ed08f83..c5df883cb0 100644 --- a/tests/ui/dis/ptr_write.stderr +++ b/tests/ui/dis/ptr_write.stderr @@ -4,7 +4,7 @@ %7 = OpLabel OpLine %8 7 35 %9 = OpLoad %10 %4 -OpLine %11 1465 8 +OpLine %11 1493 8 OpStore %6 %9 OpNoLine OpReturn diff --git a/tests/ui/dis/ptr_write_method.stderr b/tests/ui/dis/ptr_write_method.stderr index 8786fbee9b..fb09d4230c 100644 --- a/tests/ui/dis/ptr_write_method.stderr +++ b/tests/ui/dis/ptr_write_method.stderr @@ -4,7 +4,7 @@ %7 = OpLabel OpLine %8 7 37 %9 = OpLoad %10 %4 -OpLine %11 1465 8 +OpLine %11 1493 8 OpStore %6 %9 OpNoLine OpReturn From 62296f3c54f1ab4cfa8b654f3d63fd83b81d126a Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sun, 4 Aug 2024 13:48:09 +0300 Subject: [PATCH 17/32] spirv-builder: pass JSON files to `--target` instead of relying on the backend's `target_override`. --- Cargo.lock | 4 +- crates/rustc_codegen_spirv-types/Cargo.toml | 1 + crates/rustc_codegen_spirv-types/src/lib.rs | 4 + crates/rustc_codegen_spirv/Cargo.toml | 2 - .../rustc_codegen_spirv/src/codegen_cx/mod.rs | 71 +++++++++++- crates/rustc_codegen_spirv/src/lib.rs | 11 -- crates/rustc_codegen_spirv/src/link.rs | 4 +- crates/spirv-builder/src/lib.rs | 92 +++++++++++++--- .../target-specs/spirv-unknown-opengl4.0.json | 21 ++++ .../target-specs/spirv-unknown-opengl4.1.json | 21 ++++ .../target-specs/spirv-unknown-opengl4.2.json | 21 ++++ .../target-specs/spirv-unknown-opengl4.3.json | 21 ++++ .../target-specs/spirv-unknown-opengl4.5.json | 21 ++++ .../target-specs/spirv-unknown-spv1.0.json | 21 ++++ .../target-specs/spirv-unknown-spv1.1.json | 21 ++++ .../target-specs/spirv-unknown-spv1.2.json | 21 ++++ .../target-specs/spirv-unknown-spv1.3.json | 21 ++++ .../target-specs/spirv-unknown-spv1.4.json | 21 ++++ .../target-specs/spirv-unknown-spv1.5.json | 21 ++++ .../target-specs/spirv-unknown-vulkan1.0.json | 21 ++++ .../target-specs/spirv-unknown-vulkan1.1.json | 21 ++++ .../spirv-unknown-vulkan1.1spv1.4.json | 21 ++++ .../target-specs/spirv-unknown-vulkan1.2.json | 21 ++++ tests/Cargo.toml | 1 + tests/src/main.rs | 103 +++++++++++------- 25 files changed, 534 insertions(+), 74 deletions(-) create mode 100644 crates/spirv-builder/target-specs/spirv-unknown-opengl4.0.json create mode 100644 crates/spirv-builder/target-specs/spirv-unknown-opengl4.1.json create mode 100644 crates/spirv-builder/target-specs/spirv-unknown-opengl4.2.json create mode 100644 crates/spirv-builder/target-specs/spirv-unknown-opengl4.3.json create mode 100644 crates/spirv-builder/target-specs/spirv-unknown-opengl4.5.json create mode 100644 crates/spirv-builder/target-specs/spirv-unknown-spv1.0.json create mode 100644 crates/spirv-builder/target-specs/spirv-unknown-spv1.1.json create mode 100644 crates/spirv-builder/target-specs/spirv-unknown-spv1.2.json create mode 100644 crates/spirv-builder/target-specs/spirv-unknown-spv1.3.json create mode 100644 crates/spirv-builder/target-specs/spirv-unknown-spv1.4.json create mode 100644 crates/spirv-builder/target-specs/spirv-unknown-spv1.5.json create mode 100644 crates/spirv-builder/target-specs/spirv-unknown-vulkan1.0.json create mode 100644 crates/spirv-builder/target-specs/spirv-unknown-vulkan1.1.json create mode 100644 crates/spirv-builder/target-specs/spirv-unknown-vulkan1.1spv1.4.json create mode 100644 crates/spirv-builder/target-specs/spirv-unknown-vulkan1.2.json diff --git a/Cargo.lock b/Cargo.lock index 8c24fd844f..93e2e36a75 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -538,6 +538,7 @@ version = "0.0.0" dependencies = [ "clap", "compiletest_rs", + "itertools", "rustc_codegen_spirv", ] @@ -2153,8 +2154,6 @@ dependencies = [ "rustc-demangle", "rustc_codegen_spirv-types", "sanitize-filename", - "serde", - "serde_json", "smallvec", "spirt", "spirv-tools", @@ -2168,6 +2167,7 @@ version = "0.9.0" dependencies = [ "rspirv", "serde", + "serde_json", ] [[package]] diff --git a/crates/rustc_codegen_spirv-types/Cargo.toml b/crates/rustc_codegen_spirv-types/Cargo.toml index 41b8119a89..ef0616c8e3 100644 --- a/crates/rustc_codegen_spirv-types/Cargo.toml +++ b/crates/rustc_codegen_spirv-types/Cargo.toml @@ -10,3 +10,4 @@ repository.workspace = true [dependencies] rspirv = "0.11" serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" diff --git a/crates/rustc_codegen_spirv-types/src/lib.rs b/crates/rustc_codegen_spirv-types/src/lib.rs index f4103e8c0e..c1ebdee660 100644 --- a/crates/rustc_codegen_spirv-types/src/lib.rs +++ b/crates/rustc_codegen_spirv-types/src/lib.rs @@ -4,3 +4,7 @@ pub use rspirv::spirv::Capability; mod compile_result; pub use compile_result::*; + +// HACK(eddyb) allows downstream crates to access the correct version directly. +pub use serde; +pub use serde_json; diff --git a/crates/rustc_codegen_spirv/Cargo.toml b/crates/rustc_codegen_spirv/Cargo.toml index 93b9bd635d..c1c469c645 100644 --- a/crates/rustc_codegen_spirv/Cargo.toml +++ b/crates/rustc_codegen_spirv/Cargo.toml @@ -54,8 +54,6 @@ rspirv = "0.11" rustc_codegen_spirv-types.workspace = true rustc-demangle = "0.1.21" sanitize-filename = "0.4" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" smallvec = { version = "1.6.1", features = ["union"] } spirt = "0.3.0" spirv-tools.workspace = true diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs index bd26d1bcef..91c79b1c07 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs @@ -10,6 +10,7 @@ use crate::spirv_type::{SpirvType, SpirvTypePrinter, TypeCache}; use crate::symbols::Symbols; use crate::target::SpirvTarget; +use itertools::Itertools as _; use rspirv::dr::{Module, Operand}; use rspirv::spirv::{Decoration, LinkageType, Op, Word}; use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece}; @@ -27,7 +28,7 @@ use rustc_span::symbol::Symbol; use rustc_span::{SourceFile, Span, DUMMY_SP}; use rustc_target::abi::call::{FnAbi, PassMode}; use rustc_target::abi::{AddressSpace, HasDataLayout, TargetDataLayout}; -use rustc_target::spec::{HasTargetSpec, Target}; +use rustc_target::spec::{HasTargetSpec, Target, TargetTriple}; use std::cell::RefCell; use std::collections::BTreeSet; use std::iter::once; @@ -87,6 +88,73 @@ pub struct CodegenCx<'tcx> { impl<'tcx> CodegenCx<'tcx> { pub fn new(tcx: TyCtxt<'tcx>, codegen_unit: &'tcx CodegenUnit<'tcx>) -> Self { + // Validate the target spec, as the backend doesn't control `--target`. + let target_triple = tcx.sess.opts.target_triple.triple(); + let target: SpirvTarget = target_triple.parse().unwrap_or_else(|_| { + let qualifier = if !target_triple.starts_with("spirv-") { + "non-SPIR-V " + } else { + "" + }; + tcx.dcx().fatal(format!( + "{qualifier}target `{target_triple}` not supported by `rustc_codegen_spirv`", + )) + }); + let target_spec_mismatched_jsons = { + use rustc_target::json::ToJson; + + // HACK(eddyb) this loads the same `serde_json` used by `rustc_target`. + extern crate serde_json; + + let expected = &target.rustc_target(); + let found = &tcx.sess.target; + match &tcx.sess.opts.target_triple { + // HACK(eddyb) if `--target=path/to/target/spec.json` was used, + // `tcx.sess.target.to_json()` could still differ from it, and + // ideally `spirv-builder` can be forced to pass an exact match. + // + // FIXME(eddyb) consider the `RUST_TARGET_PATH` env var alternative. + TargetTriple::TargetTriple(_) => { + // FIXME(eddyb) this case should be impossible as upstream + // `rustc` doesn't support `spirv-*` targets! + (expected != found).then(|| [expected, found].map(|spec| spec.to_json())) + } + TargetTriple::TargetJson { contents, .. } => { + let expected = expected.to_json(); + let found = serde_json::from_str(contents).unwrap(); + (expected != found).then_some([expected, found]) + } + } + }; + if let Some([expected, found]) = target_spec_mismatched_jsons { + let diff_keys = [&expected, &found] + .into_iter() + .flat_map(|json| json.as_object().into_iter().flat_map(|obj| obj.keys())) + .unique() + .filter(|k| expected.get(k) != found.get(k)); + + tcx.dcx() + .struct_fatal(format!("mismatched `{target_triple}` target spec")) + .with_note(format!( + "expected (built into `rustc_codegen_spirv`):\n{expected:#}" + )) + .with_note(match &tcx.sess.opts.target_triple { + TargetTriple::TargetJson { + path_for_rustdoc, + contents, + .. + } if !path_for_rustdoc.as_os_str().is_empty() => { + format!("found (`{}`):\n{contents}", path_for_rustdoc.display()) + } + _ => format!("found:\n{found:#}"), + }) + .with_help(format!( + "mismatched properties: {}", + diff_keys.map(|k| format!("{k:?}")).join(", ") + )) + .emit(); + } + let sym = Symbols::get(); let mut feature_names = tcx @@ -111,7 +179,6 @@ impl<'tcx> CodegenCx<'tcx> { }); let codegen_args = CodegenArgs::from_session(tcx.sess); - let target = tcx.sess.target.llvm_target.parse().unwrap(); Self { tcx, diff --git a/crates/rustc_codegen_spirv/src/lib.rs b/crates/rustc_codegen_spirv/src/lib.rs index 7b44b415c0..0ada0703bc 100644 --- a/crates/rustc_codegen_spirv/src/lib.rs +++ b/crates/rustc_codegen_spirv/src/lib.rs @@ -108,7 +108,6 @@ use rustc_middle::ty::{self, Instance, InstanceDef, TyCtxt}; use rustc_session::config::{self, OutputFilenames, OutputType}; use rustc_session::Session; use rustc_span::symbol::{sym, Symbol}; -use rustc_target::spec::{Target, TargetTriple}; use std::any::Any; use std::fs::{create_dir_all, File}; use std::io::Cursor; @@ -207,16 +206,6 @@ impl CodegenBackend for SpirvCodegenBackend { .collect() } - fn target_override(&self, opts: &config::Options) -> Option { - match opts.target_triple { - TargetTriple::TargetTriple(ref target) => target - .parse::() - .map(|target| target.rustc_target()) - .ok(), - TargetTriple::TargetJson { .. } => None, - } - } - fn provide(&self, providers: &mut rustc_middle::util::Providers) { // FIXME(eddyb) this is currently only passed back to us, specifically // into `target_machine_factory` (which is a noop), but it might make diff --git a/crates/rustc_codegen_spirv/src/link.rs b/crates/rustc_codegen_spirv/src/link.rs index eb909baa67..cedd92ff17 100644 --- a/crates/rustc_codegen_spirv/src/link.rs +++ b/crates/rustc_codegen_spirv/src/link.rs @@ -218,7 +218,9 @@ fn link_exe( }; let file = File::create(out_filename).unwrap(); - serde_json::to_writer(BufWriter::new(file), &compile_result).unwrap(); + // FIXME(eddyb) move this functionality into `rustc_codegen_spirv_types`. + rustc_codegen_spirv_types::serde_json::to_writer(BufWriter::new(file), &compile_result) + .unwrap(); } fn entry_points(module: &rspirv::dr::Module) -> Vec { diff --git a/crates/spirv-builder/src/lib.rs b/crates/spirv-builder/src/lib.rs index 54a8c8e589..0ab46600d2 100644 --- a/crates/spirv-builder/src/lib.rs +++ b/crates/spirv-builder/src/lib.rs @@ -118,6 +118,8 @@ pub use rustc_codegen_spirv_types::{CompileResult, ModuleResult}; #[derive(Debug)] #[non_exhaustive] pub enum SpirvBuilderError { + NonSpirvTarget { target: String }, + UnsupportedSpirvTargetEnv { target_env: String }, CratePathDoesntExist(PathBuf), BuildFailed, MultiModuleWithPrintMetadata, @@ -126,24 +128,49 @@ pub enum SpirvBuilderError { MetadataFileMalformed(serde_json::Error), } +const SPIRV_TARGET_PREFIX: &str = "spirv-unknown-"; + impl fmt::Display for SpirvBuilderError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - SpirvBuilderError::CratePathDoesntExist(path) => { - write!(f, "Crate path {} does not exist", path.display()) + Self::NonSpirvTarget { target } => { + write!( + f, + "expected `{SPIRV_TARGET_PREFIX}...` target, found `{target}`" + ) } - SpirvBuilderError::BuildFailed => f.write_str("Build failed"), - SpirvBuilderError::MultiModuleWithPrintMetadata => f.write_str( - "Multi-module build cannot be used with print_metadata = MetadataPrintout::Full", - ), - SpirvBuilderError::WatchWithPrintMetadata => { - f.write_str("Watching within build scripts will prevent build completion") + Self::UnsupportedSpirvTargetEnv { target_env } if target_env.starts_with("opencl") => { + write!( + f, + "OpenCL targets like `{SPIRV_TARGET_PREFIX}-{target_env}` are not supported" + ) + } + Self::UnsupportedSpirvTargetEnv { target_env } if target_env.starts_with("webgpu") => { + write!( + f, + "WebGPU targets like `{SPIRV_TARGET_PREFIX}-{target_env}` are not supported, \ + consider using `{SPIRV_TARGET_PREFIX}-vulkan1.0` instead" + ) } - SpirvBuilderError::MetadataFileMissing(_) => { - f.write_str("Multi-module metadata file missing") + Self::UnsupportedSpirvTargetEnv { target_env } => { + write!( + f, + "SPIR-V target `{SPIRV_TARGET_PREFIX}-{target_env}` is not supported" + ) + } + Self::CratePathDoesntExist(path) => { + write!(f, "crate path {} does not exist", path.display()) + } + Self::BuildFailed => f.write_str("build failed"), + Self::MultiModuleWithPrintMetadata => f.write_str( + "multi-module build cannot be used with print_metadata = MetadataPrintout::Full", + ), + Self::WatchWithPrintMetadata => { + f.write_str("watching within build scripts will prevent build completion") } - SpirvBuilderError::MetadataFileMalformed(_) => { - f.write_str("Unable to parse multi-module metadata file") + Self::MetadataFileMissing(_) => f.write_str("multi-module metadata file missing"), + Self::MetadataFileMalformed(_) => { + f.write_str("unable to parse multi-module metadata file") } } } @@ -453,6 +480,31 @@ impl SpirvBuilder { } pub(crate) fn validate_running_conditions(&mut self) -> Result<(), SpirvBuilderError> { + let target_env = self + .target + .strip_prefix(SPIRV_TARGET_PREFIX) + .ok_or_else(|| SpirvBuilderError::NonSpirvTarget { + target: self.target.clone(), + })?; + // HACK(eddyb) used only to split the full list into groups. + #[allow(clippy::match_same_arms)] + match target_env { + // HACK(eddyb) hardcoded list to avoid checking if the JSON file + // for a particular target exists (and sanitizing strings for paths). + // + // FIXME(eddyb) consider moving this list, or even `target-specs`, + // into `rustc_codegen_spirv_types`'s code/source. + "spv1.0" | "spv1.1" | "spv1.2" | "spv1.3" | "spv1.4" | "spv1.5" => {} + "opengl4.0" | "opengl4.1" | "opengl4.2" | "opengl4.3" | "opengl4.5" => {} + "vulkan1.0" | "vulkan1.1" | "vulkan1.1spv1.4" | "vulkan1.2" => {} + + _ => { + return Err(SpirvBuilderError::UnsupportedSpirvTargetEnv { + target_env: target_env.into(), + }); + } + } + if (self.print_metadata == MetadataPrintout::Full) && self.multimodule { return Err(SpirvBuilderError::MultiModuleWithPrintMetadata); } @@ -469,8 +521,10 @@ impl SpirvBuilder { at: &Path, ) -> Result { let metadata_contents = File::open(at).map_err(SpirvBuilderError::MetadataFileMissing)?; - let metadata: CompileResult = serde_json::from_reader(BufReader::new(metadata_contents)) - .map_err(SpirvBuilderError::MetadataFileMalformed)?; + // FIXME(eddyb) move this functionality into `rustc_codegen_spirv_types`. + let metadata: CompileResult = + rustc_codegen_spirv_types::serde_json::from_reader(BufReader::new(metadata_contents)) + .map_err(SpirvBuilderError::MetadataFileMalformed)?; match &metadata.module { ModuleResult::SingleModule(spirv_module) => { assert!(!self.multimodule); @@ -691,10 +745,16 @@ fn invoke_rustc(builder: &SpirvBuilder) -> Result { "-Zbuild-std-features=compiler-builtins-mem", "--profile", profile, - "--target", - &*builder.target, ]); + // FIXME(eddyb) consider moving `target-specs` into `rustc_codegen_spirv_types`. + // FIXME(eddyb) consider the `RUST_TARGET_PATH` env var alternative. + cargo.arg("--target").arg( + Path::new(env!("CARGO_MANIFEST_DIR")) + .join("target-specs") + .join(&format!("{}.json", builder.target)), + ); + // NOTE(eddyb) see above how this is computed and why it might be missing. if let Some(target_dir) = target_dir { cargo.arg("--target-dir").arg(target_dir); diff --git a/crates/spirv-builder/target-specs/spirv-unknown-opengl4.0.json b/crates/spirv-builder/target-specs/spirv-unknown-opengl4.0.json new file mode 100644 index 0000000000..89a643e501 --- /dev/null +++ b/crates/spirv-builder/target-specs/spirv-unknown-opengl4.0.json @@ -0,0 +1,21 @@ +{ + "allows-weak-linkage": false, + "arch": "spirv", + "crt-objects-fallback": "false", + "crt-static-allows-dylibs": true, + "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", + "description": null, + "dll-prefix": "", + "dll-suffix": ".spv.json", + "dynamic-linking": true, + "emit-debug-gdb-scripts": false, + "env": "opengl4.0", + "linker-flavor": "unix", + "linker-is-gnu": false, + "llvm-target": "spirv-unknown-opengl4.0", + "main-needs-argc-argv": false, + "os": "unknown", + "panic-strategy": "abort", + "simd-types-indirect": false, + "target-pointer-width": "32" +} diff --git a/crates/spirv-builder/target-specs/spirv-unknown-opengl4.1.json b/crates/spirv-builder/target-specs/spirv-unknown-opengl4.1.json new file mode 100644 index 0000000000..5ee77e88a5 --- /dev/null +++ b/crates/spirv-builder/target-specs/spirv-unknown-opengl4.1.json @@ -0,0 +1,21 @@ +{ + "allows-weak-linkage": false, + "arch": "spirv", + "crt-objects-fallback": "false", + "crt-static-allows-dylibs": true, + "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", + "description": null, + "dll-prefix": "", + "dll-suffix": ".spv.json", + "dynamic-linking": true, + "emit-debug-gdb-scripts": false, + "env": "opengl4.1", + "linker-flavor": "unix", + "linker-is-gnu": false, + "llvm-target": "spirv-unknown-opengl4.1", + "main-needs-argc-argv": false, + "os": "unknown", + "panic-strategy": "abort", + "simd-types-indirect": false, + "target-pointer-width": "32" +} diff --git a/crates/spirv-builder/target-specs/spirv-unknown-opengl4.2.json b/crates/spirv-builder/target-specs/spirv-unknown-opengl4.2.json new file mode 100644 index 0000000000..a781008000 --- /dev/null +++ b/crates/spirv-builder/target-specs/spirv-unknown-opengl4.2.json @@ -0,0 +1,21 @@ +{ + "allows-weak-linkage": false, + "arch": "spirv", + "crt-objects-fallback": "false", + "crt-static-allows-dylibs": true, + "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", + "description": null, + "dll-prefix": "", + "dll-suffix": ".spv.json", + "dynamic-linking": true, + "emit-debug-gdb-scripts": false, + "env": "opengl4.2", + "linker-flavor": "unix", + "linker-is-gnu": false, + "llvm-target": "spirv-unknown-opengl4.2", + "main-needs-argc-argv": false, + "os": "unknown", + "panic-strategy": "abort", + "simd-types-indirect": false, + "target-pointer-width": "32" +} diff --git a/crates/spirv-builder/target-specs/spirv-unknown-opengl4.3.json b/crates/spirv-builder/target-specs/spirv-unknown-opengl4.3.json new file mode 100644 index 0000000000..cdf7e1c0d3 --- /dev/null +++ b/crates/spirv-builder/target-specs/spirv-unknown-opengl4.3.json @@ -0,0 +1,21 @@ +{ + "allows-weak-linkage": false, + "arch": "spirv", + "crt-objects-fallback": "false", + "crt-static-allows-dylibs": true, + "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", + "description": null, + "dll-prefix": "", + "dll-suffix": ".spv.json", + "dynamic-linking": true, + "emit-debug-gdb-scripts": false, + "env": "opengl4.3", + "linker-flavor": "unix", + "linker-is-gnu": false, + "llvm-target": "spirv-unknown-opengl4.3", + "main-needs-argc-argv": false, + "os": "unknown", + "panic-strategy": "abort", + "simd-types-indirect": false, + "target-pointer-width": "32" +} diff --git a/crates/spirv-builder/target-specs/spirv-unknown-opengl4.5.json b/crates/spirv-builder/target-specs/spirv-unknown-opengl4.5.json new file mode 100644 index 0000000000..bb81ff34d1 --- /dev/null +++ b/crates/spirv-builder/target-specs/spirv-unknown-opengl4.5.json @@ -0,0 +1,21 @@ +{ + "allows-weak-linkage": false, + "arch": "spirv", + "crt-objects-fallback": "false", + "crt-static-allows-dylibs": true, + "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", + "description": null, + "dll-prefix": "", + "dll-suffix": ".spv.json", + "dynamic-linking": true, + "emit-debug-gdb-scripts": false, + "env": "opengl4.5", + "linker-flavor": "unix", + "linker-is-gnu": false, + "llvm-target": "spirv-unknown-opengl4.5", + "main-needs-argc-argv": false, + "os": "unknown", + "panic-strategy": "abort", + "simd-types-indirect": false, + "target-pointer-width": "32" +} diff --git a/crates/spirv-builder/target-specs/spirv-unknown-spv1.0.json b/crates/spirv-builder/target-specs/spirv-unknown-spv1.0.json new file mode 100644 index 0000000000..3b205422ca --- /dev/null +++ b/crates/spirv-builder/target-specs/spirv-unknown-spv1.0.json @@ -0,0 +1,21 @@ +{ + "allows-weak-linkage": false, + "arch": "spirv", + "crt-objects-fallback": "false", + "crt-static-allows-dylibs": true, + "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", + "description": null, + "dll-prefix": "", + "dll-suffix": ".spv.json", + "dynamic-linking": true, + "emit-debug-gdb-scripts": false, + "env": "spv1.0", + "linker-flavor": "unix", + "linker-is-gnu": false, + "llvm-target": "spirv-unknown-spv1.0", + "main-needs-argc-argv": false, + "os": "unknown", + "panic-strategy": "abort", + "simd-types-indirect": false, + "target-pointer-width": "32" +} diff --git a/crates/spirv-builder/target-specs/spirv-unknown-spv1.1.json b/crates/spirv-builder/target-specs/spirv-unknown-spv1.1.json new file mode 100644 index 0000000000..9096d23058 --- /dev/null +++ b/crates/spirv-builder/target-specs/spirv-unknown-spv1.1.json @@ -0,0 +1,21 @@ +{ + "allows-weak-linkage": false, + "arch": "spirv", + "crt-objects-fallback": "false", + "crt-static-allows-dylibs": true, + "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", + "description": null, + "dll-prefix": "", + "dll-suffix": ".spv.json", + "dynamic-linking": true, + "emit-debug-gdb-scripts": false, + "env": "spv1.1", + "linker-flavor": "unix", + "linker-is-gnu": false, + "llvm-target": "spirv-unknown-spv1.1", + "main-needs-argc-argv": false, + "os": "unknown", + "panic-strategy": "abort", + "simd-types-indirect": false, + "target-pointer-width": "32" +} diff --git a/crates/spirv-builder/target-specs/spirv-unknown-spv1.2.json b/crates/spirv-builder/target-specs/spirv-unknown-spv1.2.json new file mode 100644 index 0000000000..466ba0422e --- /dev/null +++ b/crates/spirv-builder/target-specs/spirv-unknown-spv1.2.json @@ -0,0 +1,21 @@ +{ + "allows-weak-linkage": false, + "arch": "spirv", + "crt-objects-fallback": "false", + "crt-static-allows-dylibs": true, + "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", + "description": null, + "dll-prefix": "", + "dll-suffix": ".spv.json", + "dynamic-linking": true, + "emit-debug-gdb-scripts": false, + "env": "spv1.2", + "linker-flavor": "unix", + "linker-is-gnu": false, + "llvm-target": "spirv-unknown-spv1.2", + "main-needs-argc-argv": false, + "os": "unknown", + "panic-strategy": "abort", + "simd-types-indirect": false, + "target-pointer-width": "32" +} diff --git a/crates/spirv-builder/target-specs/spirv-unknown-spv1.3.json b/crates/spirv-builder/target-specs/spirv-unknown-spv1.3.json new file mode 100644 index 0000000000..e334597dab --- /dev/null +++ b/crates/spirv-builder/target-specs/spirv-unknown-spv1.3.json @@ -0,0 +1,21 @@ +{ + "allows-weak-linkage": false, + "arch": "spirv", + "crt-objects-fallback": "false", + "crt-static-allows-dylibs": true, + "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", + "description": null, + "dll-prefix": "", + "dll-suffix": ".spv.json", + "dynamic-linking": true, + "emit-debug-gdb-scripts": false, + "env": "spv1.3", + "linker-flavor": "unix", + "linker-is-gnu": false, + "llvm-target": "spirv-unknown-spv1.3", + "main-needs-argc-argv": false, + "os": "unknown", + "panic-strategy": "abort", + "simd-types-indirect": false, + "target-pointer-width": "32" +} diff --git a/crates/spirv-builder/target-specs/spirv-unknown-spv1.4.json b/crates/spirv-builder/target-specs/spirv-unknown-spv1.4.json new file mode 100644 index 0000000000..749686270e --- /dev/null +++ b/crates/spirv-builder/target-specs/spirv-unknown-spv1.4.json @@ -0,0 +1,21 @@ +{ + "allows-weak-linkage": false, + "arch": "spirv", + "crt-objects-fallback": "false", + "crt-static-allows-dylibs": true, + "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", + "description": null, + "dll-prefix": "", + "dll-suffix": ".spv.json", + "dynamic-linking": true, + "emit-debug-gdb-scripts": false, + "env": "spv1.4", + "linker-flavor": "unix", + "linker-is-gnu": false, + "llvm-target": "spirv-unknown-spv1.4", + "main-needs-argc-argv": false, + "os": "unknown", + "panic-strategy": "abort", + "simd-types-indirect": false, + "target-pointer-width": "32" +} diff --git a/crates/spirv-builder/target-specs/spirv-unknown-spv1.5.json b/crates/spirv-builder/target-specs/spirv-unknown-spv1.5.json new file mode 100644 index 0000000000..5427149632 --- /dev/null +++ b/crates/spirv-builder/target-specs/spirv-unknown-spv1.5.json @@ -0,0 +1,21 @@ +{ + "allows-weak-linkage": false, + "arch": "spirv", + "crt-objects-fallback": "false", + "crt-static-allows-dylibs": true, + "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", + "description": null, + "dll-prefix": "", + "dll-suffix": ".spv.json", + "dynamic-linking": true, + "emit-debug-gdb-scripts": false, + "env": "spv1.5", + "linker-flavor": "unix", + "linker-is-gnu": false, + "llvm-target": "spirv-unknown-spv1.5", + "main-needs-argc-argv": false, + "os": "unknown", + "panic-strategy": "abort", + "simd-types-indirect": false, + "target-pointer-width": "32" +} diff --git a/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.0.json b/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.0.json new file mode 100644 index 0000000000..fca2db755e --- /dev/null +++ b/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.0.json @@ -0,0 +1,21 @@ +{ + "allows-weak-linkage": false, + "arch": "spirv", + "crt-objects-fallback": "false", + "crt-static-allows-dylibs": true, + "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", + "description": null, + "dll-prefix": "", + "dll-suffix": ".spv.json", + "dynamic-linking": true, + "emit-debug-gdb-scripts": false, + "env": "vulkan1.0", + "linker-flavor": "unix", + "linker-is-gnu": false, + "llvm-target": "spirv-unknown-vulkan1.0", + "main-needs-argc-argv": false, + "os": "unknown", + "panic-strategy": "abort", + "simd-types-indirect": false, + "target-pointer-width": "32" +} diff --git a/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.1.json b/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.1.json new file mode 100644 index 0000000000..1b0b8066bb --- /dev/null +++ b/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.1.json @@ -0,0 +1,21 @@ +{ + "allows-weak-linkage": false, + "arch": "spirv", + "crt-objects-fallback": "false", + "crt-static-allows-dylibs": true, + "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", + "description": null, + "dll-prefix": "", + "dll-suffix": ".spv.json", + "dynamic-linking": true, + "emit-debug-gdb-scripts": false, + "env": "vulkan1.1", + "linker-flavor": "unix", + "linker-is-gnu": false, + "llvm-target": "spirv-unknown-vulkan1.1", + "main-needs-argc-argv": false, + "os": "unknown", + "panic-strategy": "abort", + "simd-types-indirect": false, + "target-pointer-width": "32" +} diff --git a/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.1spv1.4.json b/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.1spv1.4.json new file mode 100644 index 0000000000..efa554fee0 --- /dev/null +++ b/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.1spv1.4.json @@ -0,0 +1,21 @@ +{ + "allows-weak-linkage": false, + "arch": "spirv", + "crt-objects-fallback": "false", + "crt-static-allows-dylibs": true, + "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", + "description": null, + "dll-prefix": "", + "dll-suffix": ".spv.json", + "dynamic-linking": true, + "emit-debug-gdb-scripts": false, + "env": "vulkan1.1spv1.4", + "linker-flavor": "unix", + "linker-is-gnu": false, + "llvm-target": "spirv-unknown-vulkan1.1spv1.4", + "main-needs-argc-argv": false, + "os": "unknown", + "panic-strategy": "abort", + "simd-types-indirect": false, + "target-pointer-width": "32" +} diff --git a/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.2.json b/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.2.json new file mode 100644 index 0000000000..a2b0e4827b --- /dev/null +++ b/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.2.json @@ -0,0 +1,21 @@ +{ + "allows-weak-linkage": false, + "arch": "spirv", + "crt-objects-fallback": "false", + "crt-static-allows-dylibs": true, + "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", + "description": null, + "dll-prefix": "", + "dll-suffix": ".spv.json", + "dynamic-linking": true, + "emit-debug-gdb-scripts": false, + "env": "vulkan1.2", + "linker-flavor": "unix", + "linker-is-gnu": false, + "llvm-target": "spirv-unknown-vulkan1.2", + "main-needs-argc-argv": false, + "os": "unknown", + "panic-strategy": "abort", + "simd-types-indirect": false, + "target-pointer-width": "32" +} diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 5b8589ff04..5189d76a0e 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -17,3 +17,4 @@ use-compiled-tools = ["rustc_codegen_spirv/use-compiled-tools"] compiletest = { version = "0.9.0", package = "compiletest_rs" } rustc_codegen_spirv.workspace = true clap = { version = "4", features = ["derive"] } +itertools = "0.10.5" diff --git a/tests/src/main.rs b/tests/src/main.rs index f7f58eaf9e..68f1b272d1 100644 --- a/tests/src/main.rs +++ b/tests/src/main.rs @@ -1,7 +1,7 @@ use clap::Parser; +use itertools::Itertools as _; use std::{ - env, - io::{Error, ErrorKind, Result}, + env, io, path::{Path, PathBuf}, }; @@ -27,7 +27,14 @@ impl Opt { } } -const TARGET_PREFIX: &str = "spirv-unknown-"; +const SPIRV_TARGET_PREFIX: &str = "spirv-unknown-"; + +fn target_spec_json(target: &str) -> String { + format!( + "{}/../crates/spirv-builder/target-specs/{target}.json", + env!("CARGO_MANIFEST_DIR") + ) +} #[derive(Copy, Clone)] enum DepKind { @@ -140,7 +147,7 @@ impl Runner { // which offer `// only-S` and `// ignore-S` for any stage ID `S`. let stage_id = variation.name; - let target = format!("{TARGET_PREFIX}{env}"); + let target = format!("{SPIRV_TARGET_PREFIX}{env}"); let libs = build_deps(&self.deps_target_dir, &self.codegen_backend_path, &target); let mut flags = test_rustc_flags( &self.codegen_backend_path, @@ -160,7 +167,7 @@ impl Runner { stage_id: stage_id.to_string(), target_rustcflags: Some(flags), mode: mode.parse().expect("Invalid mode"), - target, + target: target_spec_json(&target), src_base: self.tests_dir.join(mode), build_base: self.compiletest_build_dir.clone(), bless: self.opt.bless, @@ -185,7 +192,7 @@ fn build_deps(deps_target_dir: &Path, codegen_backend_path: &Path, target: &str) "compiletests-deps-helper", "-Zbuild-std=core", "-Zbuild-std-features=compiler-builtins-mem", - &*format!("--target={target}"), + &*format!("--target={}", target_spec_json(target)), ]) .arg("--target-dir") .arg(deps_target_dir) @@ -201,38 +208,48 @@ fn build_deps(deps_target_dir: &Path, codegen_backend_path: &Path, target: &str) "compiler_builtins", DepKind::SpirvLib, target, - ) - .unwrap(); - let core = find_lib(deps_target_dir, "core", DepKind::SpirvLib, target).unwrap(); - let spirv_std = find_lib(deps_target_dir, "spirv_std", DepKind::SpirvLib, target).unwrap(); - let glam = find_lib(deps_target_dir, "glam", DepKind::SpirvLib, target).unwrap(); + ); + let core = find_lib(deps_target_dir, "core", DepKind::SpirvLib, target); + let spirv_std = find_lib(deps_target_dir, "spirv_std", DepKind::SpirvLib, target); + let glam = find_lib(deps_target_dir, "glam", DepKind::SpirvLib, target); let spirv_std_macros = find_lib( deps_target_dir, "spirv_std_macros", DepKind::ProcMacro, target, - ) - .unwrap(); + ); - if [ + let all_libs = [ &compiler_builtins, &core, &spirv_std, &glam, &spirv_std_macros, - ] - .iter() - .any(|o| o.is_none()) - { + ]; + if all_libs.iter().any(|r| r.is_err()) { + // FIXME(eddyb) `missing_count` should always be `0` anyway. + // FIXME(eddyb) use `--message-format=json-render-diagnostics` to + // avoid caring about duplicates (or search within files at all). + let missing_count = all_libs + .iter() + .filter(|r| matches!(r, Err(FindLibError::Missing))) + .count(); + let duplicate_count = all_libs + .iter() + .filter(|r| matches!(r, Err(FindLibError::Duplicate))) + .count(); + eprintln!( + "warning: cleaning deps ({missing_count} missing libs, {duplicate_count} duplicated libs)" + ); clean_deps(deps_target_dir); build_deps(deps_target_dir, codegen_backend_path, target) } else { TestDeps { - core: core.unwrap(), - glam: glam.unwrap(), - compiler_builtins: compiler_builtins.unwrap(), - spirv_std: spirv_std.unwrap(), - spirv_std_macros: spirv_std_macros.unwrap(), + core: core.ok().unwrap(), + glam: glam.ok().unwrap(), + compiler_builtins: compiler_builtins.ok().unwrap(), + spirv_std: spirv_std.ok().unwrap(), + spirv_std_macros: spirv_std_macros.ok().unwrap(), } } } @@ -249,24 +266,29 @@ fn clean_deps(deps_target_dir: &Path) { .unwrap(); } -/// Attempt find the rlib that matches `base`, if multiple rlibs are found -/// then a clean build is required and `None` is returned. +enum FindLibError { + Missing, + Duplicate, +} + +/// Attempt find the rlib that matches `base`, if multiple rlibs are found then +/// a clean build is required and `Err(FindLibError::Duplicate)` is returned. fn find_lib( deps_target_dir: &Path, base: impl AsRef, dep_kind: DepKind, target: &str, -) -> Result> { +) -> Result { let base = base.as_ref(); let (expected_prefix, expected_extension) = dep_kind.prefix_and_extension(); let expected_name = format!("{}{}", expected_prefix, base.display()); let dir = deps_target_dir.join(dep_kind.target_dir_suffix(target)); - let paths = std::fs::read_dir(dir)? - .filter_map(Result::ok) - .map(|entry| entry.path()) - .filter(|path| { + std::fs::read_dir(dir) + .unwrap() + .map(|entry| entry.unwrap().path()) + .filter(move |path| { let name = { let name = path.file_stem(); if name.is_none() { @@ -284,13 +306,14 @@ fn find_lib( name_matches && extension_matches }) - .collect::>(); - - Ok(if paths.len() > 1 { - None - } else { - paths.into_iter().next() - }) + .exactly_one() + .map_err(|mut iter| { + if iter.next().is_none() { + FindLibError::Missing + } else { + FindLibError::Duplicate + } + }) } /// Returns whether this string ends with a dash ('-'), followed by 16 lowercase hexadecimal characters @@ -359,11 +382,11 @@ fn rust_flags(codegen_backend_path: &Path) -> String { } /// Convience function to map process failure to results in Rust. -fn map_status_to_result(status: std::process::ExitStatus) -> Result<()> { +fn map_status_to_result(status: std::process::ExitStatus) -> io::Result<()> { match status.success() { true => Ok(()), - false => Err(Error::new( - ErrorKind::Other, + false => Err(io::Error::new( + io::ErrorKind::Other, format!( "process terminated with non-zero code: {}", status.code().unwrap_or(0) From c7041f13b63bbe43c825015ba13db24601490e08 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sat, 3 Aug 2024 13:39:38 +0300 Subject: [PATCH 18/32] (TODO: for_range_signed broken, try fix?) rustup: update to `nightly-2024-03-21`. --- crates/rustc_codegen_spirv/build.rs | 4 +- crates/rustc_codegen_spirv/src/attr.rs | 2 +- .../src/codegen_cx/declare.rs | 2 +- crates/rustc_codegen_spirv/src/linker/test.rs | 4 + crates/rustc_codegen_spirv/src/target.rs | 2 +- crates/spirv-builder/src/lib.rs | 2 +- .../target-specs/spirv-unknown-opengl4.0.json | 7 +- .../target-specs/spirv-unknown-opengl4.1.json | 7 +- .../target-specs/spirv-unknown-opengl4.2.json | 7 +- .../target-specs/spirv-unknown-opengl4.3.json | 7 +- .../target-specs/spirv-unknown-opengl4.5.json | 7 +- .../target-specs/spirv-unknown-spv1.0.json | 7 +- .../target-specs/spirv-unknown-spv1.1.json | 7 +- .../target-specs/spirv-unknown-spv1.2.json | 7 +- .../target-specs/spirv-unknown-spv1.3.json | 7 +- .../target-specs/spirv-unknown-spv1.4.json | 7 +- .../target-specs/spirv-unknown-spv1.5.json | 7 +- .../target-specs/spirv-unknown-vulkan1.0.json | 7 +- .../target-specs/spirv-unknown-vulkan1.1.json | 7 +- .../spirv-unknown-vulkan1.1spv1.4.json | 7 +- .../target-specs/spirv-unknown-vulkan1.2.json | 7 +- rust-toolchain.toml | 4 +- .../ui/dis/panic_builtin_bounds_check.stderr | 4 +- tests/ui/dis/ptr_copy.normal.stderr | 8 +- tests/ui/dis/ptr_read.stderr | 2 +- tests/ui/dis/ptr_read_method.stderr | 2 +- tests/ui/dis/ptr_write.stderr | 2 +- tests/ui/dis/ptr_write_method.stderr | 2 +- tests/ui/lang/control_flow/for_range.rs | 2 +- .../control_flow/for_range_signed-broken.rs | 12 +++ .../for_range_signed-broken.stderr | 76 +++++++++++++++++++ 31 files changed, 201 insertions(+), 34 deletions(-) create mode 100644 tests/ui/lang/control_flow/for_range_signed-broken.rs create mode 100644 tests/ui/lang/control_flow/for_range_signed-broken.stderr diff --git a/crates/rustc_codegen_spirv/build.rs b/crates/rustc_codegen_spirv/build.rs index 76d0742c59..6f09d68745 100644 --- a/crates/rustc_codegen_spirv/build.rs +++ b/crates/rustc_codegen_spirv/build.rs @@ -10,9 +10,9 @@ use std::process::{Command, ExitCode}; /// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/ //const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml"); const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain] -channel = "nightly-2024-03-11" +channel = "nightly-2024-03-21" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = 3b1717c052de4a2dbdd3badb0e7a885f40a8ad9e"#; +# commit_hash = 1388d7a069d872bcfe5e5dd97ef61fa0a586fac0"#; fn get_rustc_commit_hash() -> Result> { let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc")); diff --git a/crates/rustc_codegen_spirv/src/attr.rs b/crates/rustc_codegen_spirv/src/attr.rs index 9f67a1320a..f47062f31f 100644 --- a/crates/rustc_codegen_spirv/src/attr.rs +++ b/crates/rustc_codegen_spirv/src/attr.rs @@ -455,7 +455,7 @@ impl<'tcx> Visitor<'tcx> for CheckSpirvAttrVisitor<'tcx> { fn visit_stmt(&mut self, stmt: &'tcx hir::Stmt<'tcx>) { // When checking statements ignore expressions, they will be checked later. - if let hir::StmtKind::Local(l) = stmt.kind { + if let hir::StmtKind::Let(l) = stmt.kind { self.check_spirv_attributes(l.hir_id, Target::Statement); } intravisit::walk_stmt(self, stmt); diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs b/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs index a927cc1259..8c7930a4b1 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs @@ -330,7 +330,7 @@ impl<'tcx> StaticMethods for CodegenCx<'tcx> { ) } - fn codegen_static(&self, def_id: DefId, _is_mutable: bool) { + fn codegen_static(&self, def_id: DefId) { let g = self.get_static(def_id); let alloc = match self.tcx.eval_static_initializer(def_id) { diff --git a/crates/rustc_codegen_spirv/src/linker/test.rs b/crates/rustc_codegen_spirv/src/linker/test.rs index f82010113b..bef0f06484 100644 --- a/crates/rustc_codegen_spirv/src/linker/test.rs +++ b/crates/rustc_codegen_spirv/src/linker/test.rs @@ -148,6 +148,10 @@ fn link_with_linker_opts( Default::default(), Default::default(), Default::default(), + "spirv-unknown-spv1.0" + .parse::() + .unwrap() + .rustc_target(), Default::default(), rustc_interface::util::rustc_version_str().unwrap_or("unknown"), Default::default(), diff --git a/crates/rustc_codegen_spirv/src/target.rs b/crates/rustc_codegen_spirv/src/target.rs index 1ca45d812b..2f319e611f 100644 --- a/crates/rustc_codegen_spirv/src/target.rs +++ b/crates/rustc_codegen_spirv/src/target.rs @@ -97,7 +97,7 @@ impl SpirvTarget { pub fn rustc_target(&self) -> Target { Target { llvm_target: self.to_string().into(), - description: None, + metadata: Default::default(), pointer_width: 32, data_layout: "e-m:e-p:32:32:32-i64:64-n8:16:32:64".into(), arch: ARCH.into(), diff --git a/crates/spirv-builder/src/lib.rs b/crates/spirv-builder/src/lib.rs index 0ab46600d2..572d437956 100644 --- a/crates/spirv-builder/src/lib.rs +++ b/crates/spirv-builder/src/lib.rs @@ -752,7 +752,7 @@ fn invoke_rustc(builder: &SpirvBuilder) -> Result { cargo.arg("--target").arg( Path::new(env!("CARGO_MANIFEST_DIR")) .join("target-specs") - .join(&format!("{}.json", builder.target)), + .join(format!("{}.json", builder.target)), ); // NOTE(eddyb) see above how this is computed and why it might be missing. diff --git a/crates/spirv-builder/target-specs/spirv-unknown-opengl4.0.json b/crates/spirv-builder/target-specs/spirv-unknown-opengl4.0.json index 89a643e501..9fa58d8558 100644 --- a/crates/spirv-builder/target-specs/spirv-unknown-opengl4.0.json +++ b/crates/spirv-builder/target-specs/spirv-unknown-opengl4.0.json @@ -4,7 +4,6 @@ "crt-objects-fallback": "false", "crt-static-allows-dylibs": true, "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", - "description": null, "dll-prefix": "", "dll-suffix": ".spv.json", "dynamic-linking": true, @@ -14,6 +13,12 @@ "linker-is-gnu": false, "llvm-target": "spirv-unknown-opengl4.0", "main-needs-argc-argv": false, + "metadata": { + "description": null, + "host_tools": null, + "std": null, + "tier": null + }, "os": "unknown", "panic-strategy": "abort", "simd-types-indirect": false, diff --git a/crates/spirv-builder/target-specs/spirv-unknown-opengl4.1.json b/crates/spirv-builder/target-specs/spirv-unknown-opengl4.1.json index 5ee77e88a5..13d687233c 100644 --- a/crates/spirv-builder/target-specs/spirv-unknown-opengl4.1.json +++ b/crates/spirv-builder/target-specs/spirv-unknown-opengl4.1.json @@ -4,7 +4,6 @@ "crt-objects-fallback": "false", "crt-static-allows-dylibs": true, "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", - "description": null, "dll-prefix": "", "dll-suffix": ".spv.json", "dynamic-linking": true, @@ -14,6 +13,12 @@ "linker-is-gnu": false, "llvm-target": "spirv-unknown-opengl4.1", "main-needs-argc-argv": false, + "metadata": { + "description": null, + "host_tools": null, + "std": null, + "tier": null + }, "os": "unknown", "panic-strategy": "abort", "simd-types-indirect": false, diff --git a/crates/spirv-builder/target-specs/spirv-unknown-opengl4.2.json b/crates/spirv-builder/target-specs/spirv-unknown-opengl4.2.json index a781008000..d1312620a2 100644 --- a/crates/spirv-builder/target-specs/spirv-unknown-opengl4.2.json +++ b/crates/spirv-builder/target-specs/spirv-unknown-opengl4.2.json @@ -4,7 +4,6 @@ "crt-objects-fallback": "false", "crt-static-allows-dylibs": true, "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", - "description": null, "dll-prefix": "", "dll-suffix": ".spv.json", "dynamic-linking": true, @@ -14,6 +13,12 @@ "linker-is-gnu": false, "llvm-target": "spirv-unknown-opengl4.2", "main-needs-argc-argv": false, + "metadata": { + "description": null, + "host_tools": null, + "std": null, + "tier": null + }, "os": "unknown", "panic-strategy": "abort", "simd-types-indirect": false, diff --git a/crates/spirv-builder/target-specs/spirv-unknown-opengl4.3.json b/crates/spirv-builder/target-specs/spirv-unknown-opengl4.3.json index cdf7e1c0d3..7a52159432 100644 --- a/crates/spirv-builder/target-specs/spirv-unknown-opengl4.3.json +++ b/crates/spirv-builder/target-specs/spirv-unknown-opengl4.3.json @@ -4,7 +4,6 @@ "crt-objects-fallback": "false", "crt-static-allows-dylibs": true, "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", - "description": null, "dll-prefix": "", "dll-suffix": ".spv.json", "dynamic-linking": true, @@ -14,6 +13,12 @@ "linker-is-gnu": false, "llvm-target": "spirv-unknown-opengl4.3", "main-needs-argc-argv": false, + "metadata": { + "description": null, + "host_tools": null, + "std": null, + "tier": null + }, "os": "unknown", "panic-strategy": "abort", "simd-types-indirect": false, diff --git a/crates/spirv-builder/target-specs/spirv-unknown-opengl4.5.json b/crates/spirv-builder/target-specs/spirv-unknown-opengl4.5.json index bb81ff34d1..ba509ed6dd 100644 --- a/crates/spirv-builder/target-specs/spirv-unknown-opengl4.5.json +++ b/crates/spirv-builder/target-specs/spirv-unknown-opengl4.5.json @@ -4,7 +4,6 @@ "crt-objects-fallback": "false", "crt-static-allows-dylibs": true, "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", - "description": null, "dll-prefix": "", "dll-suffix": ".spv.json", "dynamic-linking": true, @@ -14,6 +13,12 @@ "linker-is-gnu": false, "llvm-target": "spirv-unknown-opengl4.5", "main-needs-argc-argv": false, + "metadata": { + "description": null, + "host_tools": null, + "std": null, + "tier": null + }, "os": "unknown", "panic-strategy": "abort", "simd-types-indirect": false, diff --git a/crates/spirv-builder/target-specs/spirv-unknown-spv1.0.json b/crates/spirv-builder/target-specs/spirv-unknown-spv1.0.json index 3b205422ca..d9e2166f5c 100644 --- a/crates/spirv-builder/target-specs/spirv-unknown-spv1.0.json +++ b/crates/spirv-builder/target-specs/spirv-unknown-spv1.0.json @@ -4,7 +4,6 @@ "crt-objects-fallback": "false", "crt-static-allows-dylibs": true, "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", - "description": null, "dll-prefix": "", "dll-suffix": ".spv.json", "dynamic-linking": true, @@ -14,6 +13,12 @@ "linker-is-gnu": false, "llvm-target": "spirv-unknown-spv1.0", "main-needs-argc-argv": false, + "metadata": { + "description": null, + "host_tools": null, + "std": null, + "tier": null + }, "os": "unknown", "panic-strategy": "abort", "simd-types-indirect": false, diff --git a/crates/spirv-builder/target-specs/spirv-unknown-spv1.1.json b/crates/spirv-builder/target-specs/spirv-unknown-spv1.1.json index 9096d23058..8fc1bcaf38 100644 --- a/crates/spirv-builder/target-specs/spirv-unknown-spv1.1.json +++ b/crates/spirv-builder/target-specs/spirv-unknown-spv1.1.json @@ -4,7 +4,6 @@ "crt-objects-fallback": "false", "crt-static-allows-dylibs": true, "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", - "description": null, "dll-prefix": "", "dll-suffix": ".spv.json", "dynamic-linking": true, @@ -14,6 +13,12 @@ "linker-is-gnu": false, "llvm-target": "spirv-unknown-spv1.1", "main-needs-argc-argv": false, + "metadata": { + "description": null, + "host_tools": null, + "std": null, + "tier": null + }, "os": "unknown", "panic-strategy": "abort", "simd-types-indirect": false, diff --git a/crates/spirv-builder/target-specs/spirv-unknown-spv1.2.json b/crates/spirv-builder/target-specs/spirv-unknown-spv1.2.json index 466ba0422e..0037561bee 100644 --- a/crates/spirv-builder/target-specs/spirv-unknown-spv1.2.json +++ b/crates/spirv-builder/target-specs/spirv-unknown-spv1.2.json @@ -4,7 +4,6 @@ "crt-objects-fallback": "false", "crt-static-allows-dylibs": true, "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", - "description": null, "dll-prefix": "", "dll-suffix": ".spv.json", "dynamic-linking": true, @@ -14,6 +13,12 @@ "linker-is-gnu": false, "llvm-target": "spirv-unknown-spv1.2", "main-needs-argc-argv": false, + "metadata": { + "description": null, + "host_tools": null, + "std": null, + "tier": null + }, "os": "unknown", "panic-strategy": "abort", "simd-types-indirect": false, diff --git a/crates/spirv-builder/target-specs/spirv-unknown-spv1.3.json b/crates/spirv-builder/target-specs/spirv-unknown-spv1.3.json index e334597dab..645848caf5 100644 --- a/crates/spirv-builder/target-specs/spirv-unknown-spv1.3.json +++ b/crates/spirv-builder/target-specs/spirv-unknown-spv1.3.json @@ -4,7 +4,6 @@ "crt-objects-fallback": "false", "crt-static-allows-dylibs": true, "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", - "description": null, "dll-prefix": "", "dll-suffix": ".spv.json", "dynamic-linking": true, @@ -14,6 +13,12 @@ "linker-is-gnu": false, "llvm-target": "spirv-unknown-spv1.3", "main-needs-argc-argv": false, + "metadata": { + "description": null, + "host_tools": null, + "std": null, + "tier": null + }, "os": "unknown", "panic-strategy": "abort", "simd-types-indirect": false, diff --git a/crates/spirv-builder/target-specs/spirv-unknown-spv1.4.json b/crates/spirv-builder/target-specs/spirv-unknown-spv1.4.json index 749686270e..43ab248a65 100644 --- a/crates/spirv-builder/target-specs/spirv-unknown-spv1.4.json +++ b/crates/spirv-builder/target-specs/spirv-unknown-spv1.4.json @@ -4,7 +4,6 @@ "crt-objects-fallback": "false", "crt-static-allows-dylibs": true, "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", - "description": null, "dll-prefix": "", "dll-suffix": ".spv.json", "dynamic-linking": true, @@ -14,6 +13,12 @@ "linker-is-gnu": false, "llvm-target": "spirv-unknown-spv1.4", "main-needs-argc-argv": false, + "metadata": { + "description": null, + "host_tools": null, + "std": null, + "tier": null + }, "os": "unknown", "panic-strategy": "abort", "simd-types-indirect": false, diff --git a/crates/spirv-builder/target-specs/spirv-unknown-spv1.5.json b/crates/spirv-builder/target-specs/spirv-unknown-spv1.5.json index 5427149632..e339e11535 100644 --- a/crates/spirv-builder/target-specs/spirv-unknown-spv1.5.json +++ b/crates/spirv-builder/target-specs/spirv-unknown-spv1.5.json @@ -4,7 +4,6 @@ "crt-objects-fallback": "false", "crt-static-allows-dylibs": true, "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", - "description": null, "dll-prefix": "", "dll-suffix": ".spv.json", "dynamic-linking": true, @@ -14,6 +13,12 @@ "linker-is-gnu": false, "llvm-target": "spirv-unknown-spv1.5", "main-needs-argc-argv": false, + "metadata": { + "description": null, + "host_tools": null, + "std": null, + "tier": null + }, "os": "unknown", "panic-strategy": "abort", "simd-types-indirect": false, diff --git a/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.0.json b/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.0.json index fca2db755e..a15b45b6c6 100644 --- a/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.0.json +++ b/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.0.json @@ -4,7 +4,6 @@ "crt-objects-fallback": "false", "crt-static-allows-dylibs": true, "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", - "description": null, "dll-prefix": "", "dll-suffix": ".spv.json", "dynamic-linking": true, @@ -14,6 +13,12 @@ "linker-is-gnu": false, "llvm-target": "spirv-unknown-vulkan1.0", "main-needs-argc-argv": false, + "metadata": { + "description": null, + "host_tools": null, + "std": null, + "tier": null + }, "os": "unknown", "panic-strategy": "abort", "simd-types-indirect": false, diff --git a/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.1.json b/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.1.json index 1b0b8066bb..b71dd7b2fd 100644 --- a/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.1.json +++ b/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.1.json @@ -4,7 +4,6 @@ "crt-objects-fallback": "false", "crt-static-allows-dylibs": true, "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", - "description": null, "dll-prefix": "", "dll-suffix": ".spv.json", "dynamic-linking": true, @@ -14,6 +13,12 @@ "linker-is-gnu": false, "llvm-target": "spirv-unknown-vulkan1.1", "main-needs-argc-argv": false, + "metadata": { + "description": null, + "host_tools": null, + "std": null, + "tier": null + }, "os": "unknown", "panic-strategy": "abort", "simd-types-indirect": false, diff --git a/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.1spv1.4.json b/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.1spv1.4.json index efa554fee0..82634e6b85 100644 --- a/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.1spv1.4.json +++ b/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.1spv1.4.json @@ -4,7 +4,6 @@ "crt-objects-fallback": "false", "crt-static-allows-dylibs": true, "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", - "description": null, "dll-prefix": "", "dll-suffix": ".spv.json", "dynamic-linking": true, @@ -14,6 +13,12 @@ "linker-is-gnu": false, "llvm-target": "spirv-unknown-vulkan1.1spv1.4", "main-needs-argc-argv": false, + "metadata": { + "description": null, + "host_tools": null, + "std": null, + "tier": null + }, "os": "unknown", "panic-strategy": "abort", "simd-types-indirect": false, diff --git a/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.2.json b/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.2.json index a2b0e4827b..7952baed9d 100644 --- a/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.2.json +++ b/crates/spirv-builder/target-specs/spirv-unknown-vulkan1.2.json @@ -4,7 +4,6 @@ "crt-objects-fallback": "false", "crt-static-allows-dylibs": true, "data-layout": "e-m:e-p:32:32:32-i64:64-n8:16:32:64", - "description": null, "dll-prefix": "", "dll-suffix": ".spv.json", "dynamic-linking": true, @@ -14,6 +13,12 @@ "linker-is-gnu": false, "llvm-target": "spirv-unknown-vulkan1.2", "main-needs-argc-argv": false, + "metadata": { + "description": null, + "host_tools": null, + "std": null, + "tier": null + }, "os": "unknown", "panic-strategy": "abort", "simd-types-indirect": false, diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 30cc29967a..b03dcf4e42 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,7 +1,7 @@ [toolchain] -channel = "nightly-2024-03-11" +channel = "nightly-2024-03-21" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = 3b1717c052de4a2dbdd3badb0e7a885f40a8ad9e +# commit_hash = 1388d7a069d872bcfe5e5dd97ef61fa0a586fac0 # Whenever changing the nightly channel, update the commit hash above, and make # sure to change `REQUIRED_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` also. diff --git a/tests/ui/dis/panic_builtin_bounds_check.stderr b/tests/ui/dis/panic_builtin_bounds_check.stderr index 94ee4dc001..5d31113bae 100644 --- a/tests/ui/dis/panic_builtin_bounds_check.stderr +++ b/tests/ui/dis/panic_builtin_bounds_check.stderr @@ -10,7 +10,7 @@ OpExtension "SPV_KHR_shader_clock" OpMemoryModel Logical Simple OpEntryPoint Fragment %2 "main" OpExecutionMode %2 OriginUpperLeft -%3 = OpString "/n[Rust panicked at $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs:209:5]/n index out of bounds: the len is %u but the index is %u/n in main()/n" +%3 = OpString "/n[Rust panicked at $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs:205:5]/n index out of bounds: the len is %u but the index is %u/n in main()/n" %4 = OpString $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs" %5 = OpString "$DIR/panic_builtin_bounds_check.rs" %6 = OpTypeVoid @@ -29,7 +29,7 @@ OpBranchConditional %13 %15 %16 %15 = OpLabel OpBranch %14 %16 = OpLabel -OpLine %4 209 4 +OpLine %4 205 4 %17 = OpExtInst %6 %1 1 %3 %11 %10 OpNoLine OpBranch %14 diff --git a/tests/ui/dis/ptr_copy.normal.stderr b/tests/ui/dis/ptr_copy.normal.stderr index 7ec17563dc..b5f537dde4 100644 --- a/tests/ui/dis/ptr_copy.normal.stderr +++ b/tests/ui/dis/ptr_copy.normal.stderr @@ -1,13 +1,13 @@ error: cannot memcpy dynamically sized data - --> $CORE_SRC/intrinsics.rs:3085:9 + --> $CORE_SRC/intrinsics.rs:3076:9 | -3085 | copy(src, dst, count) +3076 | copy(src, dst, count) | ^^^^^^^^^^^^^^^^^^^^^ | note: used from within `core::intrinsics::copy::` - --> $CORE_SRC/intrinsics.rs:3064:21 + --> $CORE_SRC/intrinsics.rs:3055:21 | -3064 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { +3055 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { | ^^^^ note: called by `ptr_copy::copy_via_raw_ptr` --> $DIR/ptr_copy.rs:28:18 diff --git a/tests/ui/dis/ptr_read.stderr b/tests/ui/dis/ptr_read.stderr index 1c618431d0..f82d6dda3a 100644 --- a/tests/ui/dis/ptr_read.stderr +++ b/tests/ui/dis/ptr_read.stderr @@ -2,7 +2,7 @@ %4 = OpFunctionParameter %5 %6 = OpFunctionParameter %5 %7 = OpLabel -OpLine %8 1284 8 +OpLine %8 1283 8 %9 = OpLoad %10 %4 OpLine %11 7 13 OpStore %6 %9 diff --git a/tests/ui/dis/ptr_read_method.stderr b/tests/ui/dis/ptr_read_method.stderr index 1c618431d0..f82d6dda3a 100644 --- a/tests/ui/dis/ptr_read_method.stderr +++ b/tests/ui/dis/ptr_read_method.stderr @@ -2,7 +2,7 @@ %4 = OpFunctionParameter %5 %6 = OpFunctionParameter %5 %7 = OpLabel -OpLine %8 1284 8 +OpLine %8 1283 8 %9 = OpLoad %10 %4 OpLine %11 7 13 OpStore %6 %9 diff --git a/tests/ui/dis/ptr_write.stderr b/tests/ui/dis/ptr_write.stderr index c5df883cb0..7a2ed7f2b4 100644 --- a/tests/ui/dis/ptr_write.stderr +++ b/tests/ui/dis/ptr_write.stderr @@ -4,7 +4,7 @@ %7 = OpLabel OpLine %8 7 35 %9 = OpLoad %10 %4 -OpLine %11 1493 8 +OpLine %11 1492 8 OpStore %6 %9 OpNoLine OpReturn diff --git a/tests/ui/dis/ptr_write_method.stderr b/tests/ui/dis/ptr_write_method.stderr index fb09d4230c..e7c58f0b77 100644 --- a/tests/ui/dis/ptr_write_method.stderr +++ b/tests/ui/dis/ptr_write_method.stderr @@ -4,7 +4,7 @@ %7 = OpLabel OpLine %8 7 37 %9 = OpLoad %10 %4 -OpLine %11 1493 8 +OpLine %11 1492 8 OpStore %6 %9 OpNoLine OpReturn diff --git a/tests/ui/lang/control_flow/for_range.rs b/tests/ui/lang/control_flow/for_range.rs index bd868ba7a5..84cb95a7fb 100644 --- a/tests/ui/lang/control_flow/for_range.rs +++ b/tests/ui/lang/control_flow/for_range.rs @@ -3,6 +3,6 @@ use spirv_std::spirv; #[spirv(fragment)] -pub fn main(#[spirv(flat)] i: i32) { +pub fn main(#[spirv(flat)] i: u32) { for _ in 0..i {} } diff --git a/tests/ui/lang/control_flow/for_range_signed-broken.rs b/tests/ui/lang/control_flow/for_range_signed-broken.rs new file mode 100644 index 0000000000..10b5f173fb --- /dev/null +++ b/tests/ui/lang/control_flow/for_range_signed-broken.rs @@ -0,0 +1,12 @@ +// build-fail + +// FIXME(eddyb) this should work, but `unchecked_add_unsigned` doesn't exist, +// so range internals use `a.checked_add_unsigned(b).unwrap_unchecked()` instead, +// and that requires working `overflowing_add`, which we don't yet have. + +use spirv_std::spirv; + +#[spirv(fragment)] +pub fn main(#[spirv(flat)] i: i32) { + for _ in 0..i {} +} diff --git a/tests/ui/lang/control_flow/for_range_signed-broken.stderr b/tests/ui/lang/control_flow/for_range_signed-broken.stderr new file mode 100644 index 0000000000..3adfb8fb82 --- /dev/null +++ b/tests/ui/lang/control_flow/for_range_signed-broken.stderr @@ -0,0 +1,76 @@ +error: checked add is not supported yet + --> /home/eddy/.rustup/toolchains/nightly-2024-03-21-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:347:5 + | +347 | / int_impl! { +348 | | Self = i32, +349 | | ActualT = i32, +350 | | UnsignedT = u32, +... | +365 | | bound_condition = "", +366 | | } + | |_____^ + | +note: used from within `::overflowing_add` + --> /home/eddy/.rustup/toolchains/nightly-2024-03-21-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:347:5 + | +347 | / int_impl! { +348 | | Self = i32, +349 | | ActualT = i32, +350 | | UnsignedT = u32, +... | +365 | | bound_condition = "", +366 | | } + | |_____^ +note: called by `::overflowing_add_unsigned` + --> /home/eddy/.rustup/toolchains/nightly-2024-03-21-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:347:5 + | +347 | / int_impl! { +348 | | Self = i32, +349 | | ActualT = i32, +350 | | UnsignedT = u32, +... | +365 | | bound_condition = "", +366 | | } + | |_____^ +note: called by `::checked_add_unsigned` + --> /home/eddy/.rustup/toolchains/nightly-2024-03-21-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:347:5 + | +347 | / int_impl! { +348 | | Self = i32, +349 | | ActualT = i32, +350 | | UnsignedT = u32, +... | +365 | | bound_condition = "", +366 | | } + | |_____^ +note: called by `::forward_unchecked` + --> /home/eddy/.rustup/toolchains/nightly-2024-03-21-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/range.rs:424:1 + | +424 | / step_integer_impls! { +425 | | narrower than or same width as usize: [u8 i8], [u16 i16], [u32 i32], [usize isize]; +426 | | wider than usize: [u64 i64], [u128 i128]; +427 | | } + | |_^ +note: called by ` as core::iter::range::RangeIteratorImpl>::spec_next` + --> /home/eddy/.rustup/toolchains/nightly-2024-03-21-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/range.rs:757:35 + | +757 | self.start = unsafe { Step::forward_unchecked(old, 1) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: called by ` as core::iter::traits::iterator::Iterator>::next` + --> /home/eddy/.rustup/toolchains/nightly-2024-03-21-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/range.rs:845:9 + | +845 | self.spec_next() + | ^^^^^^^^^^^^^^^^ +note: called by `for_range_signed_broken::main` + --> $DIR/for_range_signed-broken.rs:11:14 + | +11 | for _ in 0..i {} + | ^^^^ +note: called by `main` + --> $DIR/for_range_signed-broken.rs:10:8 + | +10 | pub fn main(#[spirv(flat)] i: i32) { + | ^^^^ + +error: aborting due to 1 previous error + From 80d5648193d318ddd10f15527d1c4208619c8118 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sat, 3 Aug 2024 13:44:11 +0300 Subject: [PATCH 19/32] rustup: update to `nightly-2024-04-01`. --- crates/rustc_codegen_spirv/build.rs | 4 +- crates/rustc_codegen_spirv/src/abi.rs | 5 +- .../src/builder/builder_methods.rs | 32 ++++---- crates/rustc_codegen_spirv/src/builder/mod.rs | 4 +- .../src/codegen_cx/declare.rs | 37 +++++----- .../src/codegen_cx/entry.rs | 1 + .../rustc_codegen_spirv/src/codegen_cx/mod.rs | 31 ++++---- crates/rustc_codegen_spirv/src/linker/mod.rs | 8 +- crates/rustc_codegen_spirv/src/spirv_type.rs | 2 +- crates/rustc_codegen_spirv/src/symbols.rs | 4 - rust-toolchain.toml | 4 +- .../ui/arch/debug_printf_type_checking.stderr | 8 +- tests/ui/dis/issue-1062.stderr | 2 +- .../ui/dis/panic_builtin_bounds_check.stderr | 4 +- tests/ui/dis/ptr_copy.normal.stderr | 51 +++++++++++-- tests/ui/dis/ptr_read.stderr | 2 +- tests/ui/dis/ptr_read_method.stderr | 2 +- tests/ui/dis/ptr_write.stderr | 2 +- tests/ui/dis/ptr_write_method.stderr | 2 +- .../for_range_signed-broken.stderr | 74 +++++++++---------- tests/ui/lang/core/unwrap_or.stderr | 4 +- 21 files changed, 162 insertions(+), 121 deletions(-) diff --git a/crates/rustc_codegen_spirv/build.rs b/crates/rustc_codegen_spirv/build.rs index 6f09d68745..93b1d2ceda 100644 --- a/crates/rustc_codegen_spirv/build.rs +++ b/crates/rustc_codegen_spirv/build.rs @@ -10,9 +10,9 @@ use std::process::{Command, ExitCode}; /// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/ //const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml"); const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain] -channel = "nightly-2024-03-21" +channel = "nightly-2024-04-01" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = 1388d7a069d872bcfe5e5dd97ef61fa0a586fac0"#; +# commit_hash = 805813650248c1a2f6f271460d728d1bb852d2a7"#; fn get_rustc_commit_hash() -> Result> { let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc")); diff --git a/crates/rustc_codegen_spirv/src/abi.rs b/crates/rustc_codegen_spirv/src/abi.rs index b9d05636e8..0d3b8de664 100644 --- a/crates/rustc_codegen_spirv/src/abi.rs +++ b/crates/rustc_codegen_spirv/src/abi.rs @@ -12,8 +12,7 @@ use rustc_middle::query::Providers; use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout}; use rustc_middle::ty::GenericArgsRef; use rustc_middle::ty::{ - self, Const, CoroutineArgs, FloatTy, IntTy, ParamEnv, PolyFnSig, Ty, TyCtxt, TyKind, - TypeAndMut, UintTy, + self, Const, CoroutineArgs, FloatTy, IntTy, ParamEnv, PolyFnSig, Ty, TyCtxt, TyKind, UintTy, }; use rustc_middle::{bug, span_bug}; use rustc_span::def_id::DefId; @@ -547,7 +546,7 @@ fn dig_scalar_pointee<'tcx>( if let FieldsShape::Primitive = layout.fields { assert_eq!(offset, Size::ZERO); let pointee = match *layout.ty.kind() { - TyKind::Ref(_, pointee_ty, _) | TyKind::RawPtr(TypeAndMut { ty: pointee_ty, .. }) => { + TyKind::Ref(_, pointee_ty, _) | TyKind::RawPtr(pointee_ty, _) => { PointeeTy::Ty(cx.layout_of(pointee_ty)) } TyKind::FnPtr(sig) => PointeeTy::Fn(sig), diff --git a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs index b1d6bf18e8..55eb9d5513 100644 --- a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs +++ b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs @@ -21,7 +21,7 @@ use rustc_data_structures::fx::FxHashSet; use rustc_middle::bug; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs; use rustc_middle::ty::layout::LayoutOf; -use rustc_middle::ty::Ty; +use rustc_middle::ty::{self, Ty}; use rustc_span::Span; use rustc_target::abi::call::FnAbi; use rustc_target::abi::{Abi, Align, Scalar, Size, WrappingRange}; @@ -1175,9 +1175,10 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { then: Self::BasicBlock, _catch: Self::BasicBlock, funclet: Option<&Self::Funclet>, + instance: Option>, ) -> Self::Value { // Exceptions don't exist, jump directly to then block - let result = self.call(llty, fn_attrs, fn_abi, llfn, args, funclet); + let result = self.call(llty, fn_attrs, fn_abi, llfn, args, funclet, instance); self.emit().branch(then).unwrap(); result } @@ -2616,6 +2617,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { callee: Self::Value, args: &[Self::Value], funclet: Option<&Self::Funclet>, + instance: Option>, ) -> Self::Value { if funclet.is_some() { self.fatal("TODO: Funclets are not supported"); @@ -2674,17 +2676,19 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { .collect(); let args = &args[..]; - let libm_intrinsic = self.libm_intrinsics.borrow().get(&callee_val).copied(); - let buffer_load_intrinsic = self - .buffer_load_intrinsic_fn_id - .borrow() - .get(&callee_val) - .copied(); - let buffer_store_intrinsic = self - .buffer_store_intrinsic_fn_id - .borrow() - .get(&callee_val) - .copied(); + // FIXME(eddyb) should the maps exist at all, now that the `DefId` is known + // at `call` time, and presumably its high-level details can be looked up? + let instance_def_id = instance.map(|instance| instance.def_id()); + + let libm_intrinsic = + instance_def_id.and_then(|def_id| self.libm_intrinsics.borrow().get(&def_id).copied()); + let buffer_load_intrinsic = instance_def_id + .and_then(|def_id| self.buffer_load_intrinsics.borrow().get(&def_id).copied()); + let buffer_store_intrinsic = instance_def_id + .and_then(|def_id| self.buffer_store_intrinsics.borrow().get(&def_id).copied()); + let is_panic_entry_point = instance_def_id + .is_some_and(|def_id| self.panic_entry_points.borrow().contains(&def_id)); + if let Some(libm_intrinsic) = libm_intrinsic { let result = self.call_libm_intrinsic(libm_intrinsic, result_type, args); if result_type != result.ty { @@ -2696,7 +2700,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { ); } result - } else if self.panic_entry_point_ids.borrow().contains(&callee_val) { + } else if is_panic_entry_point { // HACK(eddyb) Rust 2021 `panic!` always uses `format_args!`, even // in the simple case that used to pass a `&str` constant, which // would not remain reachable in the SPIR-V - but `format_args!` is diff --git a/crates/rustc_codegen_spirv/src/builder/mod.rs b/crates/rustc_codegen_spirv/src/builder/mod.rs index 151b06a268..62c6d6dd32 100644 --- a/crates/rustc_codegen_spirv/src/builder/mod.rs +++ b/crates/rustc_codegen_spirv/src/builder/mod.rs @@ -21,7 +21,7 @@ use rustc_codegen_ssa::traits::{ DebugInfoBuilderMethods, HasCodegen, StaticBuilderMethods, TypeMembershipMethods, }; use rustc_errors::{Diag, DiagMessage}; -use rustc_middle::mir::Coverage; +use rustc_middle::mir::coverage::CoverageKind; use rustc_middle::span_bug; use rustc_middle::ty::layout::{ FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasParamEnv, HasTyCtxt, LayoutError, LayoutOfHelpers, @@ -147,7 +147,7 @@ impl<'a, 'tcx> Deref for Builder<'a, 'tcx> { } impl<'a, 'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'a, 'tcx> { - fn add_coverage(&mut self, _instance: Instance<'tcx>, _coverage: &Coverage) {} + fn add_coverage(&mut self, _instance: Instance<'tcx>, _kind: &CoverageKind) {} } impl<'a, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'tcx> { diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs b/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs index 8c7930a4b1..e509b5ee9a 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs @@ -59,9 +59,11 @@ impl<'tcx> CodegenCx<'tcx> { // MiscMethods::get_fn_addr -> get_fn_ext -> declare_fn_ext // PreDefineMethods::predefine_fn -> declare_fn_ext fn declare_fn_ext(&self, instance: Instance<'tcx>, linkage: Option) -> SpirvValue { - let control = attrs_to_spirv(self.tcx.codegen_fn_attrs(instance.def_id())); + let def_id = instance.def_id(); + + let control = attrs_to_spirv(self.tcx.codegen_fn_attrs(def_id)); let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty()); - let span = self.tcx.def_span(instance.def_id()); + let span = self.tcx.def_span(def_id); let function_type = fn_abi.spirv_type(span, self); let (return_type, argument_types) = match self.lookup_type(function_type) { SpirvType::Function { @@ -99,7 +101,7 @@ impl<'tcx> CodegenCx<'tcx> { // which prevents us from attaching `OpLine`s to `OpFunction` definitions, // but we can use our custom `SrcLocDecoration` instead. let src_loc_inst = SrcLocDecoration::from_rustc_span( - self.tcx.def_ident_span(instance.def_id()).unwrap_or(span), + self.tcx.def_ident_span(def_id).unwrap_or(span), &self.builder, ) .map(|src_loc| src_loc.encode_to_inst(fn_id)); @@ -128,12 +130,12 @@ impl<'tcx> CodegenCx<'tcx> { let attrs = AggregatedSpirvAttributes::parse( self, - match self.tcx.def_kind(instance.def_id()) { + match self.tcx.def_kind(def_id) { // This was made to ICE cross-crate at some point, but then got // reverted in https://github.com/rust-lang/rust/pull/111381. // FIXME(eddyb) remove this workaround once we rustup past that. DefKind::Closure => &[], - _ => self.tcx.get_attrs_unchecked(instance.def_id()), + _ => self.tcx.get_attrs_unchecked(def_id), }, ); if let Some(entry) = attrs.entry.map(|attr| attr.value) { @@ -143,28 +145,29 @@ impl<'tcx> CodegenCx<'tcx> { .map_or_else(|| instance.to_string(), ToString::to_string); self.entry_stub(&instance, fn_abi, declared, entry_name, entry); } + + // FIXME(eddyb) should the maps exist at all, now that the `DefId` is known + // at `call` time, and presumably its high-level details can be looked up? if attrs.buffer_load_intrinsic.is_some() { let mode = &fn_abi.ret.mode; - self.buffer_load_intrinsic_fn_id + self.buffer_load_intrinsics .borrow_mut() - .insert(fn_id, mode); + .insert(def_id, mode); } if attrs.buffer_store_intrinsic.is_some() { let mode = &fn_abi.args.last().unwrap().mode; - self.buffer_store_intrinsic_fn_id + self.buffer_store_intrinsics .borrow_mut() - .insert(fn_id, mode); + .insert(def_id, mode); } - let instance_def_id = instance.def_id(); - - if self.tcx.crate_name(instance_def_id.krate) == self.sym.libm { - let item_name = self.tcx.item_name(instance_def_id); + if self.tcx.crate_name(def_id.krate) == self.sym.libm { + let item_name = self.tcx.item_name(def_id); let intrinsic = self.sym.libm_intrinsics.get(&item_name); - if self.tcx.visibility(instance.def_id()) == ty::Visibility::Public { + if self.tcx.visibility(def_id) == ty::Visibility::Public { match intrinsic { Some(&intrinsic) => { - self.libm_intrinsics.borrow_mut().insert(fn_id, intrinsic); + self.libm_intrinsics.borrow_mut().insert(def_id, intrinsic); } None => { self.tcx.dcx().err(format!( @@ -179,9 +182,9 @@ impl<'tcx> CodegenCx<'tcx> { self.tcx.lang_items().panic_fn(), self.tcx.lang_items().panic_fmt(), ] - .contains(&Some(instance_def_id)) + .contains(&Some(def_id)) { - self.panic_entry_point_ids.borrow_mut().insert(fn_id); + self.panic_entry_points.borrow_mut().insert(def_id); } // HACK(eddyb) there is no good way to identify these definitions diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs b/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs index 0dc4815fe1..8979e9d9d5 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs @@ -199,6 +199,7 @@ impl<'tcx> CodegenCx<'tcx> { entry_func, &call_args, None, + None, ); bx.ret_void(); diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs index 91c79b1c07..7732d13ee2 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs @@ -19,6 +19,7 @@ use rustc_codegen_ssa::traits::{ AsmMethods, BackendTypes, DebugInfoMethods, GlobalAsmOperandRef, MiscMethods, }; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_hir::def_id::DefId; use rustc_middle::mir; use rustc_middle::mir::mono::CodegenUnit; use rustc_middle::ty::layout::{HasParamEnv, HasTyCtxt}; @@ -57,11 +58,14 @@ pub struct CodegenCx<'tcx> { /// Cache of all the builtin symbols we need pub sym: Rc, pub instruction_table: InstructionTable, - pub libm_intrinsics: RefCell>, + + // FIXME(eddyb) should the maps exist at all, now that the `DefId` is known + // at `call` time, and presumably its high-level details can be looked up? + pub libm_intrinsics: RefCell>, /// All `panic!(...)`s and builtin panics (from MIR `Assert`s) call into one /// of these lang items, which we always replace with an "abort". - pub panic_entry_point_ids: RefCell>, + pub panic_entry_points: RefCell>, /// `core::fmt::Arguments::new_{v1,const}` instances (for Rust 2021 panics). pub fmt_args_new_fn_ids: RefCell>, @@ -72,18 +76,15 @@ pub struct CodegenCx<'tcx> { pub fmt_rt_arg_new_fn_ids_to_ty_and_spec: RefCell, char)>>, /// Intrinsic for loading a `` from a `&[u32]`. The `PassMode` is the mode of the ``. - pub buffer_load_intrinsic_fn_id: RefCell>, + pub buffer_load_intrinsics: RefCell>, /// Intrinsic for storing a `` into a `&[u32]`. The `PassMode` is the mode of the ``. - pub buffer_store_intrinsic_fn_id: RefCell>, + pub buffer_store_intrinsics: RefCell>, /// Some runtimes (e.g. intel-compute-runtime) disallow atomics on i8 and i16, even though it's allowed by the spec. /// This enables/disables them. pub i8_i16_atomics_allowed: bool, pub codegen_args: CodegenArgs, - - /// Information about the SPIR-V target. - pub target: SpirvTarget, } impl<'tcx> CodegenCx<'tcx> { @@ -190,15 +191,14 @@ impl<'tcx> CodegenCx<'tcx> { vtables: Default::default(), ext_inst: Default::default(), zombie_decorations: Default::default(), - target, sym, instruction_table: InstructionTable::new(), libm_intrinsics: Default::default(), - panic_entry_point_ids: Default::default(), + panic_entry_points: Default::default(), fmt_args_new_fn_ids: Default::default(), fmt_rt_arg_new_fn_ids_to_ty_and_spec: Default::default(), - buffer_load_intrinsic_fn_id: Default::default(), - buffer_store_intrinsic_fn_id: Default::default(), + buffer_load_intrinsics: Default::default(), + buffer_store_intrinsics: Default::default(), i8_i16_atomics_allowed: false, codegen_args, } @@ -296,7 +296,6 @@ pub enum SpirvMetadata { } pub struct CodegenArgs { - pub module_output_type: ModuleOutputType, pub disassemble: bool, pub disassemble_fn: Option, pub disassemble_entry: Option, @@ -554,8 +553,6 @@ impl CodegenArgs { std::process::exit(1); } - let module_output_type = - matches.opt_get_default("module-output", ModuleOutputType::Single)?; let disassemble = matches.opt_present("disassemble"); let disassemble_fn = matches.opt_str("disassemble-fn"); let disassemble_entry = matches.opt_str("disassemble-entry"); @@ -617,9 +614,9 @@ impl CodegenArgs { .collect(), abort_strategy: matches.opt_str("abort-strategy"), + module_output_type: matches.opt_get_default("module-output", Default::default())?, // FIXME(eddyb) deduplicate between `CodegenArgs` and `linker::Options`. - emit_multiple_modules: module_output_type == ModuleOutputType::Multiple, spirv_metadata, keep_link_exports: false, @@ -639,7 +636,6 @@ impl CodegenArgs { }; Ok(Self { - module_output_type, disassemble, disassemble_fn, disassemble_entry, @@ -781,8 +777,9 @@ impl CodegenArgs { } } -#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum ModuleOutputType { + #[default] Single, Multiple, } diff --git a/crates/rustc_codegen_spirv/src/linker/mod.rs b/crates/rustc_codegen_spirv/src/linker/mod.rs index 37fdf0c497..baeb9d2815 100644 --- a/crates/rustc_codegen_spirv/src/linker/mod.rs +++ b/crates/rustc_codegen_spirv/src/linker/mod.rs @@ -18,7 +18,7 @@ mod zombies; use std::borrow::Cow; -use crate::codegen_cx::SpirvMetadata; +use crate::codegen_cx::{ModuleOutputType, SpirvMetadata}; use crate::custom_decorations::{CustomDecoration, SrcLocDecoration, ZombieDecoration}; use crate::custom_insts; use either::Either; @@ -45,8 +45,8 @@ pub struct Options { pub spirt_passes: Vec, pub abort_strategy: Option, + pub module_output_type: ModuleOutputType, - pub emit_multiple_modules: bool, pub spirv_metadata: SpirvMetadata, /// Whether to preserve `LinkageAttributes "..." Export` decorations, @@ -620,7 +620,7 @@ pub fn link( simple_passes::sort_globals(&mut output); } - let mut output = if opts.emit_multiple_modules { + let mut output = if opts.module_output_type == ModuleOutputType::Multiple { let mut file_stem_to_entry_name_and_module = BTreeMap::new(); for (i, entry) in output.entry_points.iter().enumerate() { let mut module = output.clone(); @@ -695,7 +695,7 @@ pub fn link( ) .unwrap(); } - // Run DCE again, even if emit_multiple_modules==false - the first DCE ran before + // Run DCE again, even if module_output_type == ModuleOutputType::Multiple - the first DCE ran before // structurization and mem2reg (for perf reasons), and mem2reg may remove references to // invalid types, so we need to DCE again. if opts.dce { diff --git a/crates/rustc_codegen_spirv/src/spirv_type.rs b/crates/rustc_codegen_spirv/src/spirv_type.rs index 226295958f..074783116e 100644 --- a/crates/rustc_codegen_spirv/src/spirv_type.rs +++ b/crates/rustc_codegen_spirv/src/spirv_type.rs @@ -22,7 +22,7 @@ use std::sync::{LazyLock, Mutex}; /// the `result_id` of the type declaration instruction, merely the contents. // // FIXME(eddyb) should `SpirvType`s be behind `&'tcx` from `tcx.arena.dropless`? -#[derive(Copy, Clone, Debug, PartialEq, Eq, Ord, PartialOrd, Hash)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] pub enum SpirvType<'tcx> { Void, Bool, diff --git a/crates/rustc_codegen_spirv/src/symbols.rs b/crates/rustc_codegen_spirv/src/symbols.rs index 242622fc93..b0dae13875 100644 --- a/crates/rustc_codegen_spirv/src/symbols.rs +++ b/crates/rustc_codegen_spirv/src/symbols.rs @@ -19,9 +19,7 @@ pub struct Symbols { pub discriminant: Symbol, pub rust_gpu: Symbol, pub spirv: Symbol, - pub spirv_std: Symbol, pub libm: Symbol, - pub num_traits: Symbol, pub entry_point_name: Symbol, pub spv_intel_shader_integer_functions2: Symbol, pub spv_khr_vulkan_memory_model: Symbol, @@ -383,9 +381,7 @@ impl Symbols { discriminant: Symbol::intern("discriminant"), rust_gpu: Symbol::intern("rust_gpu"), spirv: Symbol::intern("spirv"), - spirv_std: Symbol::intern("spirv_std"), libm: Symbol::intern("libm"), - num_traits: Symbol::intern("num_traits"), entry_point_name: Symbol::intern("entry_point_name"), spv_intel_shader_integer_functions2: Symbol::intern( "SPV_INTEL_shader_integer_functions2", diff --git a/rust-toolchain.toml b/rust-toolchain.toml index b03dcf4e42..7e64c0ac8f 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,7 +1,7 @@ [toolchain] -channel = "nightly-2024-03-21" +channel = "nightly-2024-04-01" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = 1388d7a069d872bcfe5e5dd97ef61fa0a586fac0 +# commit_hash = 805813650248c1a2f6f271460d728d1bb852d2a7 # Whenever changing the nightly channel, update the commit hash above, and make # sure to change `REQUIRED_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` also. diff --git a/tests/ui/arch/debug_printf_type_checking.stderr b/tests/ui/arch/debug_printf_type_checking.stderr index 0bd4cb7494..fcd2013a15 100644 --- a/tests/ui/arch/debug_printf_type_checking.stderr +++ b/tests/ui/arch/debug_printf_type_checking.stderr @@ -119,14 +119,14 @@ error[E0277]: the trait bound `{float}: Vector` is not satisfied | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Vector` is not implemented for `{float}` | = help: the following other types implement trait `Vector`: - > - > - > - > > > > > + > + > + > + > and 5 others note: required by a bound in `debug_printf_assert_is_vector` --> $SPIRV_STD_SRC/lib.rs:143:8 diff --git a/tests/ui/dis/issue-1062.stderr b/tests/ui/dis/issue-1062.stderr index 7b56b2e329..6177c07f78 100644 --- a/tests/ui/dis/issue-1062.stderr +++ b/tests/ui/dis/issue-1062.stderr @@ -4,7 +4,7 @@ OpLine %5 11 12 %6 = OpLoad %7 %8 OpLine %5 11 35 %9 = OpLoad %7 %10 -OpLine %11 1157 4 +OpLine %11 1156 4 %12 = OpBitwiseAnd %7 %9 %13 %14 = OpISub %7 %15 %12 %16 = OpShiftLeftLogical %7 %6 %12 diff --git a/tests/ui/dis/panic_builtin_bounds_check.stderr b/tests/ui/dis/panic_builtin_bounds_check.stderr index 5d31113bae..4affbb3e61 100644 --- a/tests/ui/dis/panic_builtin_bounds_check.stderr +++ b/tests/ui/dis/panic_builtin_bounds_check.stderr @@ -10,7 +10,7 @@ OpExtension "SPV_KHR_shader_clock" OpMemoryModel Logical Simple OpEntryPoint Fragment %2 "main" OpExecutionMode %2 OriginUpperLeft -%3 = OpString "/n[Rust panicked at $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs:205:5]/n index out of bounds: the len is %u but the index is %u/n in main()/n" +%3 = OpString "/n[Rust panicked at $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs:268:5]/n index out of bounds: the len is %u but the index is %u/n in main()/n" %4 = OpString $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs" %5 = OpString "$DIR/panic_builtin_bounds_check.rs" %6 = OpTypeVoid @@ -29,7 +29,7 @@ OpBranchConditional %13 %15 %16 %15 = OpLabel OpBranch %14 %16 = OpLabel -OpLine %4 205 4 +OpLine %4 268 4 %17 = OpExtInst %6 %1 1 %3 %11 %10 OpNoLine OpBranch %14 diff --git a/tests/ui/dis/ptr_copy.normal.stderr b/tests/ui/dis/ptr_copy.normal.stderr index b5f537dde4..5079309cc0 100644 --- a/tests/ui/dis/ptr_copy.normal.stderr +++ b/tests/ui/dis/ptr_copy.normal.stderr @@ -1,13 +1,13 @@ error: cannot memcpy dynamically sized data - --> $CORE_SRC/intrinsics.rs:3076:9 + --> $CORE_SRC/intrinsics.rs:2987:9 | -3076 | copy(src, dst, count) +2987 | copy(src, dst, count) | ^^^^^^^^^^^^^^^^^^^^^ | note: used from within `core::intrinsics::copy::` - --> $CORE_SRC/intrinsics.rs:3055:21 + --> $CORE_SRC/intrinsics.rs:2966:21 | -3055 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { +2966 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { | ^^^^ note: called by `ptr_copy::copy_via_raw_ptr` --> $DIR/ptr_copy.rs:28:18 @@ -25,5 +25,46 @@ note: called by `main` 32 | pub fn main(i: f32, o: &mut f32) { | ^^^^ -error: aborting due to 1 previous error +error: cannot cast between pointer types + from `*f32` + to `*struct () { }` + --> $CORE_SRC/intrinsics.rs:2975:9 + | +2975 | / ub_checks::assert_unsafe_precondition!( +2976 | | check_language_ub, +2977 | | "ptr::copy_nonoverlapping requires that both pointer arguments are aligned and non-null / +2978 | | and the specified memory ranges do not overlap", +... | +2985 | | && ub_checks::is_aligned_and_not_null(dst, align) +2986 | | ); + | |_________^ + | +note: used from within `core::intrinsics::copy::` + --> $CORE_SRC/intrinsics.rs:2975:9 + | +2975 | / ub_checks::assert_unsafe_precondition!( +2976 | | check_language_ub, +2977 | | "ptr::copy_nonoverlapping requires that both pointer arguments are aligned and non-null / +2978 | | and the specified memory ranges do not overlap", +... | +2985 | | && ub_checks::is_aligned_and_not_null(dst, align) +2986 | | ); + | |_________^ +note: called by `ptr_copy::copy_via_raw_ptr` + --> $DIR/ptr_copy.rs:28:18 + | +28 | unsafe { core::ptr::copy(src, dst, 1) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: called by `ptr_copy::main` + --> $DIR/ptr_copy.rs:33:5 + | +33 | copy_via_raw_ptr(&i, o); + | ^^^^^^^^^^^^^^^^^^^^^^^ +note: called by `main` + --> $DIR/ptr_copy.rs:32:8 + | +32 | pub fn main(i: f32, o: &mut f32) { + | ^^^^ + +error: aborting due to 2 previous errors diff --git a/tests/ui/dis/ptr_read.stderr b/tests/ui/dis/ptr_read.stderr index f82d6dda3a..24e9eb7fc8 100644 --- a/tests/ui/dis/ptr_read.stderr +++ b/tests/ui/dis/ptr_read.stderr @@ -2,7 +2,7 @@ %4 = OpFunctionParameter %5 %6 = OpFunctionParameter %5 %7 = OpLabel -OpLine %8 1283 8 +OpLine %8 1297 8 %9 = OpLoad %10 %4 OpLine %11 7 13 OpStore %6 %9 diff --git a/tests/ui/dis/ptr_read_method.stderr b/tests/ui/dis/ptr_read_method.stderr index f82d6dda3a..24e9eb7fc8 100644 --- a/tests/ui/dis/ptr_read_method.stderr +++ b/tests/ui/dis/ptr_read_method.stderr @@ -2,7 +2,7 @@ %4 = OpFunctionParameter %5 %6 = OpFunctionParameter %5 %7 = OpLabel -OpLine %8 1283 8 +OpLine %8 1297 8 %9 = OpLoad %10 %4 OpLine %11 7 13 OpStore %6 %9 diff --git a/tests/ui/dis/ptr_write.stderr b/tests/ui/dis/ptr_write.stderr index 7a2ed7f2b4..cdeee70f1f 100644 --- a/tests/ui/dis/ptr_write.stderr +++ b/tests/ui/dis/ptr_write.stderr @@ -4,7 +4,7 @@ %7 = OpLabel OpLine %8 7 35 %9 = OpLoad %10 %4 -OpLine %11 1492 8 +OpLine %11 1506 8 OpStore %6 %9 OpNoLine OpReturn diff --git a/tests/ui/dis/ptr_write_method.stderr b/tests/ui/dis/ptr_write_method.stderr index e7c58f0b77..2aa446920a 100644 --- a/tests/ui/dis/ptr_write_method.stderr +++ b/tests/ui/dis/ptr_write_method.stderr @@ -4,7 +4,7 @@ %7 = OpLabel OpLine %8 7 37 %9 = OpLoad %10 %4 -OpLine %11 1492 8 +OpLine %11 1506 8 OpStore %6 %9 OpNoLine OpReturn diff --git a/tests/ui/lang/control_flow/for_range_signed-broken.stderr b/tests/ui/lang/control_flow/for_range_signed-broken.stderr index 3adfb8fb82..015754b390 100644 --- a/tests/ui/lang/control_flow/for_range_signed-broken.stderr +++ b/tests/ui/lang/control_flow/for_range_signed-broken.stderr @@ -1,65 +1,65 @@ error: checked add is not supported yet - --> /home/eddy/.rustup/toolchains/nightly-2024-03-21-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:347:5 + --> /home/eddy/.rustup/toolchains/nightly-2024-04-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:346:5 | -347 | / int_impl! { -348 | | Self = i32, -349 | | ActualT = i32, -350 | | UnsignedT = u32, +346 | / int_impl! { +347 | | Self = i32, +348 | | ActualT = i32, +349 | | UnsignedT = u32, ... | -365 | | bound_condition = "", -366 | | } +364 | | bound_condition = "", +365 | | } | |_____^ | note: used from within `::overflowing_add` - --> /home/eddy/.rustup/toolchains/nightly-2024-03-21-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:347:5 + --> /home/eddy/.rustup/toolchains/nightly-2024-04-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:346:5 | -347 | / int_impl! { -348 | | Self = i32, -349 | | ActualT = i32, -350 | | UnsignedT = u32, +346 | / int_impl! { +347 | | Self = i32, +348 | | ActualT = i32, +349 | | UnsignedT = u32, ... | -365 | | bound_condition = "", -366 | | } +364 | | bound_condition = "", +365 | | } | |_____^ note: called by `::overflowing_add_unsigned` - --> /home/eddy/.rustup/toolchains/nightly-2024-03-21-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:347:5 + --> /home/eddy/.rustup/toolchains/nightly-2024-04-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:346:5 | -347 | / int_impl! { -348 | | Self = i32, -349 | | ActualT = i32, -350 | | UnsignedT = u32, +346 | / int_impl! { +347 | | Self = i32, +348 | | ActualT = i32, +349 | | UnsignedT = u32, ... | -365 | | bound_condition = "", -366 | | } +364 | | bound_condition = "", +365 | | } | |_____^ note: called by `::checked_add_unsigned` - --> /home/eddy/.rustup/toolchains/nightly-2024-03-21-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:347:5 + --> /home/eddy/.rustup/toolchains/nightly-2024-04-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:346:5 | -347 | / int_impl! { -348 | | Self = i32, -349 | | ActualT = i32, -350 | | UnsignedT = u32, +346 | / int_impl! { +347 | | Self = i32, +348 | | ActualT = i32, +349 | | UnsignedT = u32, ... | -365 | | bound_condition = "", -366 | | } +364 | | bound_condition = "", +365 | | } | |_____^ note: called by `::forward_unchecked` - --> /home/eddy/.rustup/toolchains/nightly-2024-03-21-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/range.rs:424:1 + --> /home/eddy/.rustup/toolchains/nightly-2024-04-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/range.rs:423:1 | -424 | / step_integer_impls! { -425 | | narrower than or same width as usize: [u8 i8], [u16 i16], [u32 i32], [usize isize]; -426 | | wider than usize: [u64 i64], [u128 i128]; -427 | | } +423 | / step_integer_impls! { +424 | | narrower than or same width as usize: [u8 i8], [u16 i16], [u32 i32], [usize isize]; +425 | | wider than usize: [u64 i64], [u128 i128]; +426 | | } | |_^ note: called by ` as core::iter::range::RangeIteratorImpl>::spec_next` - --> /home/eddy/.rustup/toolchains/nightly-2024-03-21-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/range.rs:757:35 + --> /home/eddy/.rustup/toolchains/nightly-2024-04-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/range.rs:756:35 | -757 | self.start = unsafe { Step::forward_unchecked(old, 1) }; +756 | self.start = unsafe { Step::forward_unchecked(old, 1) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: called by ` as core::iter::traits::iterator::Iterator>::next` - --> /home/eddy/.rustup/toolchains/nightly-2024-03-21-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/range.rs:845:9 + --> /home/eddy/.rustup/toolchains/nightly-2024-04-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/range.rs:844:9 | -845 | self.spec_next() +844 | self.spec_next() | ^^^^^^^^^^^^^^^^ note: called by `for_range_signed_broken::main` --> $DIR/for_range_signed-broken.rs:11:14 diff --git a/tests/ui/lang/core/unwrap_or.stderr b/tests/ui/lang/core/unwrap_or.stderr index cabe9e3131..7349d6eb0e 100644 --- a/tests/ui/lang/core/unwrap_or.stderr +++ b/tests/ui/lang/core/unwrap_or.stderr @@ -3,9 +3,9 @@ OpLine %5 13 11 %6 = OpCompositeInsert %7 %8 %9 0 %10 = OpCompositeExtract %11 %6 1 -OpLine %12 954 14 +OpLine %12 953 14 %13 = OpBitcast %14 %8 -OpLine %12 954 8 +OpLine %12 953 8 %15 = OpIEqual %16 %13 %17 OpNoLine OpSelectionMerge %18 None From 629c23cfb5892e15d024b886d6b15608143a4cfb Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sun, 4 Aug 2024 19:30:22 +0300 Subject: [PATCH 20/32] rustup: update to `nightly-2024-04-24`. --- crates/rustc_codegen_spirv/build.rs | 4 +- .../src/builder/builder_methods.rs | 125 +++++++++--------- .../src/builder/intrinsics.rs | 6 +- .../src/builder/spirv_asm.rs | 6 +- .../src/codegen_cx/constant.rs | 10 +- crates/rustc_codegen_spirv/src/lib.rs | 2 + crates/rustc_codegen_spirv/src/linker/test.rs | 22 ++- examples/runners/ash/src/main.rs | 4 +- rust-toolchain.toml | 4 +- tests/ui/dis/issue-1062.stderr | 2 +- .../ui/dis/panic_builtin_bounds_check.stderr | 4 +- tests/ui/dis/ptr_copy.normal.stderr | 36 ++--- .../for_range_signed-broken.stderr | 62 ++++----- 13 files changed, 154 insertions(+), 133 deletions(-) diff --git a/crates/rustc_codegen_spirv/build.rs b/crates/rustc_codegen_spirv/build.rs index 93b1d2ceda..b0cd95db81 100644 --- a/crates/rustc_codegen_spirv/build.rs +++ b/crates/rustc_codegen_spirv/build.rs @@ -10,9 +10,9 @@ use std::process::{Command, ExitCode}; /// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/ //const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml"); const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain] -channel = "nightly-2024-04-01" +channel = "nightly-2024-04-24" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = 805813650248c1a2f6f271460d728d1bb852d2a7"#; +# commit_hash = 244da22fabd9fa677bbd0ac601a88e5ca6917526"#; fn get_rustc_commit_hash() -> Result> { let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc")); diff --git a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs index 55eb9d5513..af77eafac9 100644 --- a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs +++ b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs @@ -1451,13 +1451,13 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { return OperandRef::zero_sized(place.layout); } - let val = if let Some(llextra) = place.llextra { - OperandValue::Ref(place.llval, Some(llextra), place.align) + let val = if place.val.llextra.is_some() { + OperandValue::Ref(place.val) } else if self.cx.is_backend_immediate(place.layout) { let llval = self.load( place.layout.spirv_type(self.span(), self), - place.llval, - place.align, + place.val.llval, + place.val.align, ); OperandValue::Immediate(self.to_immediate(llval, place.layout)) } else if let Abi::ScalarPair(a, b) = place.layout.abi { @@ -1468,9 +1468,9 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { let mut load = |i, scalar: Scalar, align| { let llptr = if i == 0 { - place.llval + place.val.llval } else { - self.inbounds_ptradd(place.llval, self.const_usize(b_offset.bytes())) + self.inbounds_ptradd(place.val.llval, self.const_usize(b_offset.bytes())) }; let load = self.load( self.scalar_pair_element_backend_type(place.layout, i, false), @@ -1481,11 +1481,11 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { }; OperandValue::Pair( - load(0, a, place.align), - load(1, b, place.align.restrict_for_offset(b_offset)), + load(0, a, place.val.align), + load(1, b, place.val.align.restrict_for_offset(b_offset)), ) } else { - OperandValue::Ref(place.llval, None, place.align) + OperandValue::Ref(place.val) }; OperandRef { val, @@ -1501,11 +1501,11 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { dest: PlaceRef<'tcx, Self::Value>, ) { let zero = self.const_usize(0); - let start = dest.project_index(self, zero).llval; + let start = dest.project_index(self, zero).val.llval; let elem_layout = dest.layout.field(self.cx(), 0); let elem_ty = elem_layout.spirv_type(self.span(), self); - let align = dest.align.restrict_for_offset(elem_layout.size); + let align = dest.val.align.restrict_for_offset(elem_layout.size); for i in 0..count { 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> { // are decoded to values of this `enum`. For instructions that // produce results, the result ID is the first `ID` value. #[derive(Debug)] - enum Inst<'tcx, ID> { + enum Inst { Bitcast(ID, ID), CompositeExtract(ID, ID, u32), - InBoundsAccessChain(ID, ID, SpirvConst<'tcx, 'tcx>), + InBoundsAccessChain(ID, ID, u32), Store(ID, ID), Load(ID, ID), + CopyMemory(ID, ID), Call(ID, ID, SmallVec<[ID; 4]>), // HACK(eddyb) this only exists for better error reporting, @@ -2882,14 +2883,17 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { match (inst.class.opcode, inst.result_id, &id_operands[..]) { (Op::Bitcast, Some(r), &[x]) => Inst::Bitcast(r, x), (Op::InBoundsAccessChain, Some(r), &[p, i]) => { - Inst::InBoundsAccessChain( - r, - p, - self.builder.lookup_const_by_id(i)?, - ) + if let Some(SpirvConst::U32(i)) = + self.builder.lookup_const_by_id(i) + { + Inst::InBoundsAccessChain(r, p, i) + } else { + Inst::Unsupported(inst.class.opcode) + } } (Op::Store, None, &[p, v]) => Inst::Store(p, v), (Op::Load, Some(r), &[p]) => Inst::Load(r, p), + (Op::CopyMemory, None, &[a, b]) => Inst::CopyMemory(a, b), (Op::FunctionCall, Some(r), [f, args @ ..]) => { Inst::Call(r, *f, args.iter().copied().collect()) } @@ -2989,46 +2993,50 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { }; require_local_var(rt_args_array_ptr_id, "[fmt::rt::Argument; N]")?; - // Each runtime argument has 3 instructions to call one of - // the `fmt::rt::Argument::new_*` functions (and split its - // scalar pair result), and 5 instructions to store it into - // the appropriate slot in the array. The groups of 3 and 5 + // Each runtime argument has 4 instructions to call one of + // the `fmt::rt::Argument::new_*` functions (and temporarily + // store its result), and 4 instructions to copy it into + // the appropriate slot in the array. The groups of 4 and 4 // instructions, for all runtime args, are each separate. - let stores_to_rt_args_array = - try_rev_take(rt_args_count * 5).ok_or_else(|| { + let copies_to_rt_args_array = + try_rev_take(rt_args_count * 4).ok_or_else(|| { FormatArgsNotRecognized( - "[fmt::rt::Argument; N] stores: ran out of instructions".into(), + "[fmt::rt::Argument; N] copies: ran out of instructions".into(), ) })?; - let stores_to_rt_args_array = stores_to_rt_args_array.chunks(5); - let rt_arg_new_calls = try_rev_take(rt_args_count * 3).ok_or_else(|| { + let copies_to_rt_args_array = copies_to_rt_args_array.chunks(4); + let rt_arg_new_calls = try_rev_take(rt_args_count * 4).ok_or_else(|| { FormatArgsNotRecognized( "fmt::rt::Argument::new calls: ran out of instructions".into(), ) })?; - let rt_arg_new_calls = rt_arg_new_calls.chunks(3); + let rt_arg_new_calls = rt_arg_new_calls.chunks(4); - for (rt_arg_idx, (rt_arg_new_call_insts, store_to_rt_args_array_insts)) in - rt_arg_new_calls.zip(stores_to_rt_args_array).enumerate() + for (rt_arg_idx, (rt_arg_new_call_insts, copy_to_rt_args_array_insts)) in + rt_arg_new_calls.zip(copies_to_rt_args_array).enumerate() { - let (a, b) = match rt_arg_new_call_insts[..] { + let call_ret_slot_ptr = match rt_arg_new_call_insts[..] { [ Inst::Call(call_ret_id, callee_id, ref call_args), - Inst::CompositeExtract(a, a_parent_pair, 0), - Inst::CompositeExtract(b, b_parent_pair, 1), - ] if [a_parent_pair, b_parent_pair] == [call_ret_id; 2] => self - .fmt_rt_arg_new_fn_ids_to_ty_and_spec - .borrow() - .get(&callee_id) - .and_then(|&(ty, spec)| match call_args[..] { - [x] => { - decoded_format_args - .ref_arg_ids_with_ty_and_spec - .push((x, ty, spec)); - Some((a, b)) - } - _ => None, - }), + Inst::InBoundsAccessChain(tmp_slot_field_ptr, tmp_slot_ptr, 0), + Inst::CompositeExtract(field, wrapper_newtype, 0), + Inst::Store(st_dst_ptr, st_val), + ] if wrapper_newtype == call_ret_id + && (st_dst_ptr, st_val) == (tmp_slot_field_ptr, field) => + { + self.fmt_rt_arg_new_fn_ids_to_ty_and_spec + .borrow() + .get(&callee_id) + .and_then(|&(ty, spec)| match call_args[..] { + [x] => { + decoded_format_args + .ref_arg_ids_with_ty_and_spec + .push((x, ty, spec)); + Some(tmp_slot_ptr) + } + _ => None, + }) + } _ => None, } .ok_or_else(|| { @@ -3037,25 +3045,20 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { )) })?; - match store_to_rt_args_array_insts[..] { + match copy_to_rt_args_array_insts[..] { [ - Inst::InBoundsAccessChain( - array_slot_ptr, - array_base_ptr, - SpirvConst::U32(array_idx), - ), - Inst::InBoundsAccessChain(a_ptr, a_base_ptr, SpirvConst::U32(0)), - Inst::Store(a_st_dst, a_st_val), - Inst::InBoundsAccessChain(b_ptr, b_base_ptr, SpirvConst::U32(1)), - Inst::Store(b_st_dst, b_st_val), - ] if array_base_ptr == rt_args_array_ptr_id + Inst::InBoundsAccessChain(array_slot, array_base, array_idx), + Inst::InBoundsAccessChain(dst_field_ptr, dst_base_ptr, 0), + Inst::InBoundsAccessChain(src_field_ptr, src_base_ptr, 0), + Inst::CopyMemory(copy_dst, copy_src), + ] if array_base == rt_args_array_ptr_id && array_idx as usize == rt_arg_idx - && [a_base_ptr, b_base_ptr] == [array_slot_ptr; 2] - && (a, b) == (a_st_val, b_st_val) - && (a_ptr, b_ptr) == (a_st_dst, b_st_dst) => {} + && dst_base_ptr == array_slot + && src_base_ptr == call_ret_slot_ptr + && (copy_dst, copy_src) == (dst_field_ptr, src_field_ptr) => {} _ => { return Err(FormatArgsNotRecognized(format!( - "[fmt::rt::Argument; N] stores sequence ({store_to_rt_args_array_insts:?})" + "[fmt::rt::Argument; N] copies sequence ({copy_to_rt_args_array_insts:?})" ))); } } diff --git a/crates/rustc_codegen_spirv/src/builder/intrinsics.rs b/crates/rustc_codegen_spirv/src/builder/intrinsics.rs index 4a7471ef73..5b2091ecce 100644 --- a/crates/rustc_codegen_spirv/src/builder/intrinsics.rs +++ b/crates/rustc_codegen_spirv/src/builder/intrinsics.rs @@ -46,11 +46,11 @@ impl Builder<'_, '_> { let (mask_sign, mask_value) = match width { 32 => ( self.constant_u32(self.span(), 1 << 31), - self.constant_u32(self.span(), u32::max_value() >> 1), + self.constant_u32(self.span(), u32::MAX >> 1), ), 64 => ( self.constant_u64(self.span(), 1 << 63), - self.constant_u64(self.span(), u64::max_value() >> 1), + self.constant_u64(self.span(), u64::MAX >> 1), ), _ => bug!("copysign must have width 32 or 64, not {}", width), }; @@ -106,7 +106,7 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> { let layout = self.layout_of(fn_args.type_at(0)); let load = self.volatile_load(layout.spirv_type(self.span(), self), ptr); if !result.layout.is_zst() { - self.store(load, result.llval, result.align); + self.store(load, result.val.llval, result.val.align); } return Ok(()); } diff --git a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs index 31c35f363d..623893e465 100644 --- a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs +++ b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs @@ -488,7 +488,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { if let Some(OutRegister::Place(place)) = out_register { self.emit() .store( - place.llval.def(self), + place.val.llval.def(self), result_id.unwrap(), None, std::iter::empty(), @@ -946,14 +946,14 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { } => { self.check_reg(span, reg); match place { - Some(place) => match self.lookup_type(place.llval.ty) { + Some(place) => match self.lookup_type(place.val.llval.ty) { SpirvType::Pointer { pointee } => Some(pointee), other => { self.tcx.dcx().span_err( span, format!( "out register type not pointer: {}", - other.debug(place.llval.ty, self) + other.debug(place.val.llval.ty, self) ), ); None diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs b/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs index e5d0898dd8..a0c9efb394 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs @@ -20,6 +20,11 @@ impl<'tcx> CodegenCx<'tcx> { self.def_constant(ty, SpirvConst::U32(val as u32)) } + pub fn constant_i8(&self, span: Span, val: i8) -> SpirvValue { + let ty = SpirvType::Integer(8, true).def(span, self); + self.def_constant(ty, SpirvConst::U32(val as u32)) + } + pub fn constant_i16(&self, span: Span, val: i16) -> SpirvValue { let ty = SpirvType::Integer(16, true).def(span, self); self.def_constant(ty, SpirvConst::U32(val as u32)) @@ -156,6 +161,9 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> { fn const_bool(&self, val: bool) -> Self::Value { self.constant_bool(DUMMY_SP, val) } + fn const_i8(&self, i: i8) -> Self::Value { + self.constant_i8(DUMMY_SP, i) + } fn const_i16(&self, i: i16) -> Self::Value { self.constant_i16(DUMMY_SP, i) } @@ -243,7 +251,7 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> { match scalar { Scalar::Int(int) => { assert_eq!(int.size(), layout.primitive().size(self)); - let data = int.to_bits(int.size()).unwrap(); + let data = int.assert_uint(int.size()); match layout.primitive() { Primitive::Int(int_size, int_signedness) => match self.lookup_type(ty) { diff --git a/crates/rustc_codegen_spirv/src/lib.rs b/crates/rustc_codegen_spirv/src/lib.rs index 0ada0703bc..cf6633fbaf 100644 --- a/crates/rustc_codegen_spirv/src/lib.rs +++ b/crates/rustc_codegen_spirv/src/lib.rs @@ -359,6 +359,8 @@ impl WriteBackendMethods for SpirvCodegenBackend { object: Some(path), dwarf_object: None, bytecode: None, + assembly: None, + llvm_ir: None, }) } diff --git a/crates/rustc_codegen_spirv/src/linker/test.rs b/crates/rustc_codegen_spirv/src/linker/test.rs index bef0f06484..55750bf264 100644 --- a/crates/rustc_codegen_spirv/src/linker/test.rs +++ b/crates/rustc_codegen_spirv/src/linker/test.rs @@ -122,15 +122,27 @@ fn link_with_linker_opts( // is really a silent unwinding device, that should be treated the same as // `Err(ErrorGuaranteed)` returns from `link`). rustc_driver::catch_fatal_errors(|| { + rustc_data_structures::jobserver::initialize_checked(|err| { + unreachable!("jobserver error: {err}"); + }); + let mut early_dcx = rustc_session::EarlyDiagCtxt::new(rustc_session::config::ErrorOutputType::default()); - early_dcx.initialize_checked_jobserver(); let matches = rustc_driver::handle_options(&early_dcx, &["".to_string(), "x.rs".to_string()]) .unwrap(); let sopts = rustc_session::config::build_session_options(&mut early_dcx, &matches); - rustc_span::create_session_globals_then(sopts.edition, || { + let target = "spirv-unknown-spv1.0" + .parse::() + .unwrap() + .rustc_target(); + let sm_inputs = rustc_span::source_map::SourceMapInputs { + file_loader: Box::new(rustc_span::source_map::RealFileLoader), + path_mapping: sopts.file_path_mapping(), + hash_kind: sopts.unstable_opts.src_hash_algorithm(&target), + }; + rustc_span::create_session_globals_then(sopts.edition, Some(sm_inputs), || { let mut sess = rustc_session::build_session( early_dcx, sopts, @@ -147,11 +159,7 @@ fn link_with_linker_opts( Registry::new(&[]), Default::default(), Default::default(), - Default::default(), - "spirv-unknown-spv1.0" - .parse::() - .unwrap() - .rustc_target(), + target, Default::default(), rustc_interface::util::rustc_version_str().unwrap_or("unknown"), Default::default(), diff --git a/examples/runners/ash/src/main.rs b/examples/runners/ash/src/main.rs index 4214e649a3..6c9180da4e 100644 --- a/examples/runners/ash/src/main.rs +++ b/examples/runners/ash/src/main.rs @@ -941,7 +941,7 @@ impl RenderCtx { let present_index = unsafe { match self.base.swapchain_loader.acquire_next_image( self.swapchain, - std::u64::MAX, + u64::MAX, self.sync.present_complete_semaphore, vk::Fence::null(), ) { @@ -1058,7 +1058,7 @@ impl RenderCtx { unsafe { self.base .device - .wait_for_fences(&[self.sync.draw_commands_reuse_fence], true, std::u64::MAX) + .wait_for_fences(&[self.sync.draw_commands_reuse_fence], true, u64::MAX) .expect("Wait for fence failed."); self.base diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 7e64c0ac8f..e31153b5c2 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,7 +1,7 @@ [toolchain] -channel = "nightly-2024-04-01" +channel = "nightly-2024-04-24" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = 805813650248c1a2f6f271460d728d1bb852d2a7 +# commit_hash = 244da22fabd9fa677bbd0ac601a88e5ca6917526 # Whenever changing the nightly channel, update the commit hash above, and make # sure to change `REQUIRED_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` also. diff --git a/tests/ui/dis/issue-1062.stderr b/tests/ui/dis/issue-1062.stderr index 6177c07f78..3a056d9326 100644 --- a/tests/ui/dis/issue-1062.stderr +++ b/tests/ui/dis/issue-1062.stderr @@ -4,7 +4,7 @@ OpLine %5 11 12 %6 = OpLoad %7 %8 OpLine %5 11 35 %9 = OpLoad %7 %10 -OpLine %11 1156 4 +OpLine %11 1145 4 %12 = OpBitwiseAnd %7 %9 %13 %14 = OpISub %7 %15 %12 %16 = OpShiftLeftLogical %7 %6 %12 diff --git a/tests/ui/dis/panic_builtin_bounds_check.stderr b/tests/ui/dis/panic_builtin_bounds_check.stderr index 4affbb3e61..279553b922 100644 --- a/tests/ui/dis/panic_builtin_bounds_check.stderr +++ b/tests/ui/dis/panic_builtin_bounds_check.stderr @@ -10,7 +10,7 @@ OpExtension "SPV_KHR_shader_clock" OpMemoryModel Logical Simple OpEntryPoint Fragment %2 "main" OpExecutionMode %2 OriginUpperLeft -%3 = OpString "/n[Rust panicked at $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs:268:5]/n index out of bounds: the len is %u but the index is %u/n in main()/n" +%3 = OpString "/n[Rust panicked at $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs:275:5]/n index out of bounds: the len is %u but the index is %u/n in main()/n" %4 = OpString $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs" %5 = OpString "$DIR/panic_builtin_bounds_check.rs" %6 = OpTypeVoid @@ -29,7 +29,7 @@ OpBranchConditional %13 %15 %16 %15 = OpLabel OpBranch %14 %16 = OpLabel -OpLine %4 268 4 +OpLine %4 275 4 %17 = OpExtInst %6 %1 1 %3 %11 %10 OpNoLine OpBranch %14 diff --git a/tests/ui/dis/ptr_copy.normal.stderr b/tests/ui/dis/ptr_copy.normal.stderr index 5079309cc0..9dacf13e91 100644 --- a/tests/ui/dis/ptr_copy.normal.stderr +++ b/tests/ui/dis/ptr_copy.normal.stderr @@ -1,13 +1,13 @@ error: cannot memcpy dynamically sized data - --> $CORE_SRC/intrinsics.rs:2987:9 + --> $CORE_SRC/intrinsics.rs:3076:9 | -2987 | copy(src, dst, count) +3076 | copy(src, dst, count) | ^^^^^^^^^^^^^^^^^^^^^ | note: used from within `core::intrinsics::copy::` - --> $CORE_SRC/intrinsics.rs:2966:21 + --> $CORE_SRC/intrinsics.rs:3055:21 | -2966 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { +3055 | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { | ^^^^ note: called by `ptr_copy::copy_via_raw_ptr` --> $DIR/ptr_copy.rs:28:18 @@ -28,27 +28,27 @@ note: called by `main` error: cannot cast between pointer types from `*f32` to `*struct () { }` - --> $CORE_SRC/intrinsics.rs:2975:9 + --> $CORE_SRC/intrinsics.rs:3064:9 | -2975 | / ub_checks::assert_unsafe_precondition!( -2976 | | check_language_ub, -2977 | | "ptr::copy_nonoverlapping requires that both pointer arguments are aligned and non-null / -2978 | | and the specified memory ranges do not overlap", +3064 | / ub_checks::assert_unsafe_precondition!( +3065 | | check_language_ub, +3066 | | "ptr::copy_nonoverlapping requires that both pointer arguments are aligned and non-null / +3067 | | and the specified memory ranges do not overlap", ... | -2985 | | && ub_checks::is_aligned_and_not_null(dst, align) -2986 | | ); +3074 | | && ub_checks::is_aligned_and_not_null(dst, align) +3075 | | ); | |_________^ | note: used from within `core::intrinsics::copy::` - --> $CORE_SRC/intrinsics.rs:2975:9 + --> $CORE_SRC/intrinsics.rs:3064:9 | -2975 | / ub_checks::assert_unsafe_precondition!( -2976 | | check_language_ub, -2977 | | "ptr::copy_nonoverlapping requires that both pointer arguments are aligned and non-null / -2978 | | and the specified memory ranges do not overlap", +3064 | / ub_checks::assert_unsafe_precondition!( +3065 | | check_language_ub, +3066 | | "ptr::copy_nonoverlapping requires that both pointer arguments are aligned and non-null / +3067 | | and the specified memory ranges do not overlap", ... | -2985 | | && ub_checks::is_aligned_and_not_null(dst, align) -2986 | | ); +3074 | | && ub_checks::is_aligned_and_not_null(dst, align) +3075 | | ); | |_________^ note: called by `ptr_copy::copy_via_raw_ptr` --> $DIR/ptr_copy.rs:28:18 diff --git a/tests/ui/lang/control_flow/for_range_signed-broken.stderr b/tests/ui/lang/control_flow/for_range_signed-broken.stderr index 015754b390..c2368efc13 100644 --- a/tests/ui/lang/control_flow/for_range_signed-broken.stderr +++ b/tests/ui/lang/control_flow/for_range_signed-broken.stderr @@ -1,50 +1,50 @@ error: checked add is not supported yet - --> /home/eddy/.rustup/toolchains/nightly-2024-04-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:346:5 + --> /home/eddy/.rustup/toolchains/nightly-2024-04-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:335:5 | -346 | / int_impl! { -347 | | Self = i32, -348 | | ActualT = i32, -349 | | UnsignedT = u32, +335 | / int_impl! { +336 | | Self = i32, +337 | | ActualT = i32, +338 | | UnsignedT = u32, ... | -364 | | bound_condition = "", -365 | | } +353 | | bound_condition = "", +354 | | } | |_____^ | note: used from within `::overflowing_add` - --> /home/eddy/.rustup/toolchains/nightly-2024-04-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:346:5 + --> /home/eddy/.rustup/toolchains/nightly-2024-04-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:335:5 | -346 | / int_impl! { -347 | | Self = i32, -348 | | ActualT = i32, -349 | | UnsignedT = u32, +335 | / int_impl! { +336 | | Self = i32, +337 | | ActualT = i32, +338 | | UnsignedT = u32, ... | -364 | | bound_condition = "", -365 | | } +353 | | bound_condition = "", +354 | | } | |_____^ note: called by `::overflowing_add_unsigned` - --> /home/eddy/.rustup/toolchains/nightly-2024-04-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:346:5 + --> /home/eddy/.rustup/toolchains/nightly-2024-04-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:335:5 | -346 | / int_impl! { -347 | | Self = i32, -348 | | ActualT = i32, -349 | | UnsignedT = u32, +335 | / int_impl! { +336 | | Self = i32, +337 | | ActualT = i32, +338 | | UnsignedT = u32, ... | -364 | | bound_condition = "", -365 | | } +353 | | bound_condition = "", +354 | | } | |_____^ note: called by `::checked_add_unsigned` - --> /home/eddy/.rustup/toolchains/nightly-2024-04-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:346:5 + --> /home/eddy/.rustup/toolchains/nightly-2024-04-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/mod.rs:335:5 | -346 | / int_impl! { -347 | | Self = i32, -348 | | ActualT = i32, -349 | | UnsignedT = u32, +335 | / int_impl! { +336 | | Self = i32, +337 | | ActualT = i32, +338 | | UnsignedT = u32, ... | -364 | | bound_condition = "", -365 | | } +353 | | bound_condition = "", +354 | | } | |_____^ note: called by `::forward_unchecked` - --> /home/eddy/.rustup/toolchains/nightly-2024-04-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/range.rs:423:1 + --> /home/eddy/.rustup/toolchains/nightly-2024-04-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/range.rs:423:1 | 423 | / step_integer_impls! { 424 | | narrower than or same width as usize: [u8 i8], [u16 i16], [u32 i32], [usize isize]; @@ -52,12 +52,12 @@ note: called by `::forward_unchecked` 426 | | } | |_^ note: called by ` as core::iter::range::RangeIteratorImpl>::spec_next` - --> /home/eddy/.rustup/toolchains/nightly-2024-04-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/range.rs:756:35 + --> /home/eddy/.rustup/toolchains/nightly-2024-04-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/range.rs:756:35 | 756 | self.start = unsafe { Step::forward_unchecked(old, 1) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: called by ` as core::iter::traits::iterator::Iterator>::next` - --> /home/eddy/.rustup/toolchains/nightly-2024-04-01-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/range.rs:844:9 + --> /home/eddy/.rustup/toolchains/nightly-2024-04-24-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/range.rs:844:9 | 844 | self.spec_next() | ^^^^^^^^^^^^^^^^ From e1974d8260129c1a815880288c3c0ce60cdb8c5b Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sun, 4 Aug 2024 22:14:05 +0300 Subject: [PATCH 21/32] Massive `cargo update`. --- Cargo.lock | 901 +++++++++++++++++++++++++++-------------------------- 1 file changed, 459 insertions(+), 442 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 93e2e36a75..14f04b5512 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "ab_glyph" -version = "0.2.23" +version = "0.2.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80179d7dd5d7e8c285d67c4a1e652972a92de7475beddfb92028c76463b13225" +checksum = "79faae4620f45232f599d9bc7b290f88247a0834162c4495ab2f02d60004adfb" dependencies = [ "ab_glyph_rasterizer", "owned_ttf_parser", @@ -31,9 +31,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.7" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", "getrandom", @@ -44,27 +44,27 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] [[package]] name = "allocator-api2" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "android-activity" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39b801912a977c3fd52d80511fe1c0c8480c6f957f21ae2ce1b92ffe970cf4b9" +checksum = "ee91c0c2905bae44f84bfa4e044536541df26b7703fd0888deeb9060fcc44289" dependencies = [ "android-properties", - "bitflags 2.4.2", + "bitflags 2.6.0", "cc", "cesu8", "jni", @@ -113,47 +113,48 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.11" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" -version = "0.2.3" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.2" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.2" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -161,9 +162,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.79" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "ar" @@ -173,9 +174,9 @@ checksum = "d67af77d68a931ecd5cbd8a3b5987d63a1d1d1278f7f6a60ae33db485cdebb69" [[package]] name = "arrayref" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" +checksum = "9d151e35f61089500b617991b791fc8bfd237ae50cd5950803758a179b41e67a" [[package]] name = "arrayvec" @@ -229,15 +230,15 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "base64" -version = "0.21.7" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bit-set" @@ -262,9 +263,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "block" @@ -293,28 +294,28 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytemuck" -version = "1.14.0" +version = "1.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" +checksum = "102087e286b4677862ea56cf8fc58bb2cdfa8725c40ffb80fe3a008eb7f2fc83" dependencies = [ "bytemuck_derive", ] [[package]] name = "bytemuck_derive" -version = "1.5.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "965ab7eb5f8f97d2a083c799f3a1b994fc397b2fe2da5d1da1626ce15a39f2b1" +checksum = "1ee891b04274a59bd38b412188e24b849617b2e45a0fd8d057deb63e7403761b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.72", ] [[package]] @@ -325,9 +326,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] name = "calloop" @@ -335,7 +336,7 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fba7adb4dd5aa98e5553510223000e7148f621165ec5f9acd7113f6ca4995298" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "log", "polling", "rustix", @@ -352,14 +353,14 @@ dependencies = [ "calloop", "rustix", "wayland-backend", - "wayland-client 0.31.1", + "wayland-client 0.31.5", ] [[package]] name = "cc" -version = "1.0.83" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" dependencies = [ "jobserver", "libc", @@ -385,9 +386,9 @@ checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" [[package]] name = "clap" -version = "4.4.18" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" +checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc" dependencies = [ "clap_builder", "clap_derive", @@ -395,9 +396,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.18" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" +checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99" dependencies = [ "anstream", "anstyle", @@ -407,21 +408,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.7" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.72", ] [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "cocoa" @@ -465,9 +466,9 @@ dependencies = [ [[package]] name = "colorchoice" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "com" @@ -502,9 +503,9 @@ dependencies = [ [[package]] name = "combine" -version = "4.6.6" +version = "4.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" dependencies = [ "bytes", "memchr", @@ -559,9 +560,9 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" dependencies = [ "crossbeam-utils", ] @@ -610,9 +611,9 @@ checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "core-graphics" -version = "0.23.1" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "970a29baf4110c26fedbc7f82107d42c23f7e88e404c4577ed73fe99ff85a212" +checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" dependencies = [ "bitflags 1.3.2", "core-foundation", @@ -634,9 +635,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.11" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176dc175b78f56c0f321911d9c8eb2b77a78a4860b9c19db83835fea1a46649b" +checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" dependencies = [ "crossbeam-utils", ] @@ -662,9 +663,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "cty" @@ -684,8 +685,8 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e3d747f100290a1ca24b752186f61f6637e1deffe3bf6320de6fcb29510a307" dependencies = [ - "bitflags 2.4.2", - "libloading 0.8.1", + "bitflags 2.6.0", + "libloading 0.8.5", "winapi", ] @@ -700,15 +701,15 @@ dependencies = [ [[package]] name = "derive_more" -version = "0.99.17" +version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "convert_case", "proc-macro2", "quote", "rustc_version", - "syn 1.0.109", + "syn 2.0.72", ] [[package]] @@ -750,20 +751,20 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412" dependencies = [ - "libloading 0.8.1", + "libloading 0.8.5", ] [[package]] name = "downcast-rs" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" [[package]] name = "either" -version = "1.9.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "elsa" @@ -771,15 +772,15 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d98e71ae4df57d214182a2e5cb90230c0192c6ddfcaa05c36453d46a54713e10" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.3.0", "stable_deref_trait", ] [[package]] name = "env_filter" -version = "0.1.0" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" +checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" dependencies = [ "log", "regex", @@ -797,9 +798,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.11.0" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eeb342678d785662fd2514be38c459bb925f02b68dd2a3e0f21d7ef82d979dd" +checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" dependencies = [ "anstream", "anstyle", @@ -816,9 +817,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys 0.52.0", @@ -859,7 +860,7 @@ dependencies = [ "clap", "console_error_panic_hook", "console_log", - "env_logger 0.11.0", + "env_logger 0.11.5", "futures", "shared", "spirv-builder", @@ -879,9 +880,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "filetime" @@ -919,7 +920,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.72", ] [[package]] @@ -993,7 +994,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.72", ] [[package]] @@ -1056,9 +1057,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -1078,9 +1079,9 @@ dependencies = [ [[package]] name = "glam" -version = "0.24.2" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5418c17512bdf42730f9032c74e1ae39afc408745ebb2acf72fbc4691c17945" +checksum = "151665d9be52f9bb40fc7966565d39666f2d1e69233571b71b87791c7e0528b3" dependencies = [ "libm", ] @@ -1112,7 +1113,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbcd2dba93594b227a1f57ee09b8b9da8892c34d55aa332e034a228d0fe6a171" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "gpu-alloc-types", ] @@ -1122,7 +1123,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98ff03b468aa837d70984d55f5d3f846f6ec31fe34bbb97c4f85219caeee1ca4" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", ] [[package]] @@ -1144,9 +1145,9 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc11df1ace8e7e564511f53af41f3e42ddc95b56fd07b3f4445d2a6048bc682c" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "gpu-descriptor-types", - "hashbrown 0.14.3", + "hashbrown 0.14.5", ] [[package]] @@ -1155,7 +1156,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bf0b36e6f090b7e1d8a4b49c0cb81c1f8376f72198c65dd3ad9ff3556b8b78c" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", ] [[package]] @@ -1175,11 +1176,11 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ - "ahash 0.8.7", + "ahash 0.8.11", "allocator-api2", ] @@ -1189,10 +1190,10 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af2a7e73e1f34c48da31fb668a907f250794837e08faa144fd24f0b8b741e890" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "com", "libc", - "libloading 0.8.1", + "libloading 0.8.5", "thiserror", "widestring", "winapi", @@ -1204,11 +1205,23 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" -version = "0.3.4" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" [[package]] name = "hexf-parse" @@ -1245,12 +1258,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.1.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown 0.14.5", ] [[package]] @@ -1275,9 +1288,9 @@ dependencies = [ [[package]] name = "instant" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" dependencies = [ "cfg-if", "js-sys", @@ -1291,6 +1304,12 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "969ee3fc68ec2e88eb21434ce4d9b7e1600d1ce92ff974560a6c4a304f5124b9" +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itertools" version = "0.10.5" @@ -1302,9 +1321,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jni" @@ -1330,18 +1349,18 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "jobserver" -version = "0.1.27" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] @@ -1353,7 +1372,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76" dependencies = [ "libc", - "libloading 0.8.1", + "libloading 0.8.5", "pkg-config", ] @@ -1385,15 +1404,15 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.152" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libloading" @@ -1407,12 +1426,12 @@ dependencies = [ [[package]] name = "libloading" -version = "0.8.1" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" +checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", - "windows-sys 0.48.0", + "windows-targets 0.52.6", ] [[package]] @@ -1421,48 +1440,38 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" -[[package]] -name = "libredox" -version = "0.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" -dependencies = [ - "bitflags 2.4.2", - "libc", - "redox_syscall 0.4.1", -] - [[package]] name = "libredox" version = "0.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3af92c55d7d839293953fcd0fda5ecfe93297cfde6ffbdec13b41d99c0ba6607" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "libc", "redox_syscall 0.4.1", ] [[package]] -name = "line-wrap" -version = "0.1.1" +name = "libredox" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "safemem", + "bitflags 2.6.0", + "libc", ] [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -1470,9 +1479,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.20" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "longest-increasing-subsequence" @@ -1491,15 +1500,15 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memmap2" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45fd3a57831bf88bc63f8cebc0cf956116276e97fef3966103e96416209f7c92" +checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" dependencies = [ "libc", ] @@ -1513,22 +1522,13 @@ dependencies = [ "autocfg", ] -[[package]] -name = "memoffset" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" -dependencies = [ - "autocfg", -] - [[package]] name = "metal" version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c43f73953f8cbe511f021b58f18c3ce1c3d1ae13fe953293e13345bf83217f25" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "block", "core-graphics-types", "foreign-types", @@ -1565,9 +1565,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", @@ -1601,15 +1601,15 @@ dependencies = [ [[package]] name = "naga" -version = "0.19.0" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8878eb410fc90853da3908aebfe61d73d26d4437ef850b70050461f939509899" +checksum = "50e3524642f53d9af419ab5e8dd29d3ba155708267667c2f3f06c88c9e130843" dependencies = [ "bit-set", - "bitflags 2.4.2", + "bitflags 2.6.0", "codespan-reporting", "hexf-parse", - "indexmap 2.1.0", + "indexmap 2.3.0", "log", "num-traits", "petgraph", @@ -1626,13 +1626,13 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "jni-sys", "log", "ndk-sys", "num_enum", "raw-window-handle 0.5.2", - "raw-window-handle 0.6.0", + "raw-window-handle 0.6.2", "thiserror", ] @@ -1660,19 +1660,7 @@ dependencies = [ "bitflags 1.3.2", "cfg-if", "libc", - "memoffset 0.6.5", -] - -[[package]] -name = "nix" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" -dependencies = [ - "bitflags 1.3.2", - "cfg-if", - "libc", - "memoffset 0.7.1", + "memoffset", ] [[package]] @@ -1693,11 +1681,17 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", "libm", @@ -1709,29 +1703,29 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", ] [[package]] name = "num_enum" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" +checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179" dependencies = [ "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" +checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.72", ] [[package]] @@ -1746,9 +1740,9 @@ dependencies = [ [[package]] name = "objc-sys" -version = "0.3.2" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7c71324e4180d0899963fc83d9d241ac39e699609fc1025a850aadac8257459" +checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" [[package]] name = "objc2" @@ -1795,18 +1789,18 @@ dependencies = [ [[package]] name = "owned_ttf_parser" -version = "0.20.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4586edfe4c648c71797a74c84bacb32b52b212eff5dfe2bb9f2c599844023e7" +checksum = "490d3a563d3122bf7c911a59b0add9389e5ec0f5f0c3ac6b91ff235a0e6a7f90" dependencies = [ "ttf-parser", ] [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", @@ -1814,22 +1808,22 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.4.1", + "redox_syscall 0.5.3", "smallvec", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] name = "paste" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "percent-encoding" @@ -1839,19 +1833,19 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "petgraph" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.1.0", + "indexmap 2.3.0", ] [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -1870,32 +1864,32 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "plist" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5699cc8a63d1aa2b1ee8e12b9ad70ac790d65788cd36101fa37f87ea46c4cef" +checksum = "42cf17e9a1800f5f396bc67d193dc9411b59012a5876445ef450d449881e1016" dependencies = [ "base64", - "indexmap 2.1.0", - "line-wrap", - "quick-xml 0.31.0", + "indexmap 2.3.0", + "quick-xml 0.32.0", "serde", "time", ] [[package]] name = "polling" -version = "3.3.2" +version = "3.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "545c980a3880efd47b2e262f6a4bb6daad6555cf3367aa9c4e52895f69537a41" +checksum = "a3ed00ed3fbf728b5816498ecd316d1716eecaced9c0c8d2c5a6740ca214985b" dependencies = [ "cfg-if", "concurrent-queue", + "hermit-abi 0.4.0", "pin-project-lite", "rustix", "tracing", @@ -1935,42 +1929,42 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "profiling" -version = "1.0.13" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d135ede8821cf6376eb7a64148901e1690b788c11ae94dc297ae917dbc91dc0e" +checksum = "43d84d1d7a6ac92673717f9f6d1518374ef257669c24ebc5ac25d5033828be58" [[package]] name = "quick-xml" -version = "0.30.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eff6510e86862b57b210fd8cbe8ed3f0d7d600b9c2863cd4549a2e033c66e956" +checksum = "1d3a6e5838b60e0e8fa7a43f22ade549a37d61f8bdbe636d0d7816191de969c2" dependencies = [ "memchr", ] [[package]] name = "quick-xml" -version = "0.31.0" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" +checksum = "6f24d770aeca0eacb81ac29dfbc55ebcc09312fdd1f8bbecdc7e4a84e000e3b4" dependencies = [ "memchr", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -2004,9 +1998,9 @@ checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" [[package]] name = "raw-window-handle" -version = "0.6.0" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a9830a0e1b9fb145ebb365b8bc4ccd75f290f98c0247deafbbe2c75cefb544" +checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" [[package]] name = "raw-window-metal" @@ -2022,9 +2016,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.8.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" dependencies = [ "either", "rayon-core", @@ -2058,14 +2052,23 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_syscall" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +dependencies = [ + "bitflags 2.6.0", +] + [[package]] name = "redox_users" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ "getrandom", - "libredox 0.0.1", + "libredox 0.1.3", "thiserror", ] @@ -2078,9 +2081,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.3" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", @@ -2090,9 +2093,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.4" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b7fa1134405e2ec9353fd416b17f8dacd46c473d7d3fd1cf202706a14eb792a" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", @@ -2101,15 +2104,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "renderdoc-sys" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216080ab382b992234dda86873c18d4c48358f5cfcb70fd693d7f6f2131b628b" +checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" [[package]] name = "rspirv" @@ -2124,9 +2127,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" @@ -2193,11 +2196,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.30" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", @@ -2206,21 +2209,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.14" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" - -[[package]] -name = "safemem" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "same-file" @@ -2255,9 +2252,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sctk-adwaita" -version = "0.8.1" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82b2eaf3a5b264a521b988b2e73042e742df700c4f962cde845d1541adb46550" +checksum = "70b31447ca297092c5a9916fc3b955203157b37c19ca8edde4f52e9843e602c7" dependencies = [ "ab_glyph", "log", @@ -2291,37 +2288,38 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.21" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.195" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.195" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.72", ] [[package]] name = "serde_json" -version = "1.0.111" +version = "1.0.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -2370,20 +2368,20 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" dependencies = [ "serde", ] [[package]] name = "smithay-client-toolkit" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60e3d9941fa3bacf7c2bf4b065304faa14164151254cd16ce1b1bc8fc381600f" +checksum = "922fd3eeab3bd820d76537ce8f582b1cf951eceb5475c28500c7457d9d17f53a" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "calloop", "calloop-wayland-source", "cursor-icon", @@ -2393,20 +2391,20 @@ dependencies = [ "rustix", "thiserror", "wayland-backend", - "wayland-client 0.31.1", + "wayland-client 0.31.5", "wayland-csd-frame", - "wayland-cursor 0.31.0", - "wayland-protocols 0.31.0", + "wayland-cursor 0.31.5", + "wayland-protocols 0.31.2", "wayland-protocols-wlr", - "wayland-scanner 0.31.0", + "wayland-scanner 0.31.4", "xkeysym", ] [[package]] name = "smol_str" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6845563ada680337a52d43bb0b29f396f2d911616f6573012645b9e3d048a49" +checksum = "dd538fb6910ac1099850255cf94a94df6551fbdd602454387d0adb2d1ca6dead" dependencies = [ "serde", ] @@ -2448,7 +2446,7 @@ version = "0.3.0+sdk-1.3.268.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", ] [[package]] @@ -2529,9 +2527,9 @@ checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "strum" @@ -2548,11 +2546,11 @@ version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2", "quote", "rustversion", - "syn 2.0.48", + "syn 2.0.72", ] [[package]] @@ -2568,9 +2566,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" dependencies = [ "proc-macro2", "quote", @@ -2579,13 +2577,13 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.9.0" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53" dependencies = [ "cfg-if", "fastrand", - "redox_syscall 0.4.1", + "once_cell", "rustix", "windows-sys 0.52.0", ] @@ -2625,32 +2623,33 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.56" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.72", ] [[package]] name = "time" -version = "0.3.31" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", + "num-conv", "powerfmt", "serde", "time-core", @@ -2665,18 +2664,19 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ + "num-conv", "time-core", ] [[package]] name = "tiny-skia" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a067b809476893fce6a254cf285850ff69c847e6cfbade6a20b655b6c7e80d" +checksum = "83d13394d44dae3207b52a326c0c85a8bf87f1541f23b0d143811088497b09ab" dependencies = [ "arrayref", "arrayvec", @@ -2688,9 +2688,9 @@ dependencies = [ [[package]] name = "tiny-skia-path" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de35e8a90052baaaf61f171680ac2f8e925a1e43ea9d2e3a00514772250e541" +checksum = "9c9e7fc0c2e86a30b117d0462aa261b72b7a99b7ebd7deb3a14ceda95c5bdc93" dependencies = [ "arrayref", "bytemuck", @@ -2699,17 +2699,17 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" [[package]] name = "toml_edit" -version = "0.21.0" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.3.0", "toml_datetime", "winnow", ] @@ -2732,9 +2732,9 @@ checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" [[package]] name = "ttf-parser" -version = "0.20.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f77d76d837a7830fe1d4f12b7b4ba4192c1888001c7164257e4bc6d21d96b4" +checksum = "8686b91785aff82828ed725225925b33b4fde44c4bb15876e5f7c832724c420a" [[package]] name = "unicode-ident" @@ -2744,15 +2744,15 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-segmentation" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "unicode-xid" @@ -2762,9 +2762,9 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "utf8parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "version-compare" @@ -2774,15 +2774,15 @@ checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "walkdir" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", @@ -2796,9 +2796,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -2806,24 +2806,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.72", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.40" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" dependencies = [ "cfg-if", "js-sys", @@ -2833,9 +2833,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2843,35 +2843,35 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.72", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wayland-backend" -version = "0.3.2" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19152ddd73f45f024ed4534d9ca2594e0ef252c1847695255dae47f34df9fbe4" +checksum = "f90e11ce2ca99c97b940ee83edbae9da2d56a08f9ea8158550fd77fa31722993" dependencies = [ "cc", "downcast-rs", - "nix 0.26.4", + "rustix", "scoped-tls", "smallvec", - "wayland-sys 0.31.1", + "wayland-sys 0.31.4", ] [[package]] @@ -2883,7 +2883,7 @@ dependencies = [ "bitflags 1.3.2", "downcast-rs", "libc", - "nix 0.24.3", + "nix", "scoped-tls", "wayland-commons", "wayland-scanner 0.29.5", @@ -2892,14 +2892,14 @@ dependencies = [ [[package]] name = "wayland-client" -version = "0.31.1" +version = "0.31.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ca7d52347346f5473bf2f56705f360e8440873052e575e55890c4fa57843ed3" +checksum = "7e321577a0a165911bdcfb39cf029302479d7527b517ee58ab0f6ad09edf0943" dependencies = [ - "bitflags 2.4.2", - "nix 0.26.4", + "bitflags 2.6.0", + "rustix", "wayland-backend", - "wayland-scanner 0.31.0", + "wayland-scanner 0.31.4", ] [[package]] @@ -2908,7 +2908,7 @@ version = "0.29.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8691f134d584a33a6606d9d717b95c4fa20065605f798a3f350d78dced02a902" dependencies = [ - "nix 0.24.3", + "nix", "once_cell", "smallvec", "wayland-sys 0.29.5", @@ -2920,7 +2920,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "cursor-icon", "wayland-backend", ] @@ -2931,19 +2931,19 @@ version = "0.29.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6865c6b66f13d6257bef1cd40cbfe8ef2f150fb8ebbdb1e8e873455931377661" dependencies = [ - "nix 0.24.3", + "nix", "wayland-client 0.29.5", "xcursor", ] [[package]] name = "wayland-cursor" -version = "0.31.0" +version = "0.31.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44aa20ae986659d6c77d64d808a046996a932aa763913864dc40c359ef7ad5b" +checksum = "6ef9489a8df197ebf3a8ce8a7a7f0a2320035c3743f3c1bd0bdbccf07ce64f95" dependencies = [ - "nix 0.26.4", - "wayland-client 0.31.1", + "rustix", + "wayland-client 0.31.5", "xcursor", ] @@ -2961,14 +2961,14 @@ dependencies = [ [[package]] name = "wayland-protocols" -version = "0.31.0" +version = "0.31.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e253d7107ba913923dc253967f35e8561a3c65f914543e46843c88ddd729e21c" +checksum = "8f81f365b8b4a97f422ac0e8737c438024b5951734506b0e1d775c73030561f4" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "wayland-backend", - "wayland-client 0.31.1", - "wayland-scanner 0.31.0", + "wayland-client 0.31.5", + "wayland-scanner 0.31.4", ] [[package]] @@ -2977,11 +2977,11 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23803551115ff9ea9bce586860c5c5a971e360825a0309264102a9495a5ff479" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "wayland-backend", - "wayland-client 0.31.1", - "wayland-protocols 0.31.0", - "wayland-scanner 0.31.0", + "wayland-client 0.31.5", + "wayland-protocols 0.31.2", + "wayland-scanner 0.31.4", ] [[package]] @@ -2990,11 +2990,11 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad1f61b76b6c2d8742e10f9ba5c3737f6530b4c243132c2a2ccc8aa96fe25cd6" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "wayland-backend", - "wayland-client 0.31.1", - "wayland-protocols 0.31.0", - "wayland-scanner 0.31.0", + "wayland-client 0.31.5", + "wayland-protocols 0.31.2", + "wayland-scanner 0.31.4", ] [[package]] @@ -3010,12 +3010,12 @@ dependencies = [ [[package]] name = "wayland-scanner" -version = "0.31.0" +version = "0.31.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb8e28403665c9f9513202b7e1ed71ec56fde5c107816843fb14057910b2c09c" +checksum = "d7b56f89937f1cf2ee1f1259cf2936a17a1f45d8f0aa1019fae6d470d304cfa6" dependencies = [ "proc-macro2", - "quick-xml 0.30.0", + "quick-xml 0.34.0", "quote", ] @@ -3032,9 +3032,9 @@ dependencies = [ [[package]] name = "wayland-sys" -version = "0.31.1" +version = "0.31.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15a0c8eaff5216d07f226cb7a549159267f3467b289d9a2e52fd3ef5aae2b7af" +checksum = "43676fe2daf68754ecf1d72026e4e6c15483198b5d24e888b74d3f22f887a148" dependencies = [ "dlib", "log", @@ -3044,9 +3044,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ "js-sys", "wasm-bindgen", @@ -3064,9 +3064,9 @@ dependencies = [ [[package]] name = "wgpu" -version = "0.19.1" +version = "0.19.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfe9a310dcf2e6b85f00c46059aaeaf4184caa8e29a1ecd4b7a704c3482332d" +checksum = "cbd7311dbd2abcfebaabf1841a2824ed7c8be443a0f29166e5d3c6a53a762c01" dependencies = [ "arrayvec", "cfg-if", @@ -3076,7 +3076,7 @@ dependencies = [ "naga", "parking_lot", "profiling", - "raw-window-handle 0.6.0", + "raw-window-handle 0.6.2", "smallvec", "static_assertions", "wasm-bindgen", @@ -3089,22 +3089,22 @@ dependencies = [ [[package]] name = "wgpu-core" -version = "0.19.0" +version = "0.19.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b15e451d4060ada0d99a64df44e4d590213496da7c4f245572d51071e8e30ed" +checksum = "28b94525fc99ba9e5c9a9e24764f2bc29bad0911a7446c12f446a8277369bf3a" dependencies = [ "arrayvec", "bit-vec", - "bitflags 2.4.2", + "bitflags 2.6.0", "cfg_aliases", "codespan-reporting", - "indexmap 2.1.0", + "indexmap 2.3.0", "log", "naga", "once_cell", "parking_lot", "profiling", - "raw-window-handle 0.6.0", + "raw-window-handle 0.6.2", "rustc-hash", "smallvec", "thiserror", @@ -3115,15 +3115,15 @@ dependencies = [ [[package]] name = "wgpu-hal" -version = "0.19.1" +version = "0.19.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bb47856236bfafc0bc591a925eb036ac19cd987624a447ff353e7a7e7e6f72" +checksum = "bfabcfc55fd86611a855816326b2d54c3b2fd7972c27ce414291562650552703" dependencies = [ "android_system_properties", "arrayvec", "ash", "bit-set", - "bitflags 2.4.2", + "bitflags 2.6.0", "block", "cfg_aliases", "core-graphics-types", @@ -3137,16 +3137,17 @@ dependencies = [ "js-sys", "khronos-egl", "libc", - "libloading 0.8.1", + "libloading 0.8.5", "log", "metal", "naga", + "ndk-sys", "objc", "once_cell", "parking_lot", "profiling", "range-alloc", - "raw-window-handle 0.6.0", + "raw-window-handle 0.6.2", "renderdoc-sys", "rustc-hash", "smallvec", @@ -3159,20 +3160,20 @@ dependencies = [ [[package]] name = "wgpu-types" -version = "0.19.0" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "895fcbeb772bfb049eb80b2d6e47f6c9af235284e9703c96fc0218a42ffd5af2" +checksum = "b671ff9fb03f78b46ff176494ee1ebe7d603393f42664be55b64dc8d53969805" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "js-sys", "web-sys", ] [[package]] name = "widestring" -version = "1.0.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" +checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311" [[package]] name = "winapi" @@ -3192,11 +3193,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "winapi", + "windows-sys 0.59.0", ] [[package]] @@ -3212,7 +3213,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" dependencies = [ "windows-core", - "windows-targets 0.52.0", + "windows-targets 0.52.6", ] [[package]] @@ -3221,7 +3222,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.6", ] [[package]] @@ -3248,7 +3249,16 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", ] [[package]] @@ -3283,17 +3293,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -3310,9 +3321,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -3328,9 +3339,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -3346,9 +3357,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -3364,9 +3381,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -3382,9 +3399,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -3400,9 +3417,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -3418,20 +3435,20 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winit" -version = "0.29.10" +version = "0.29.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c824f11941eeae66ec71111cc2674373c772f482b58939bb4066b642aa2ffcf" +checksum = "0d59ad965a635657faf09c8f062badd885748428933dad8e8bdd64064d92e5ca" dependencies = [ - "ahash 0.8.7", + "ahash 0.8.11", "android-activity", "atomic-waker", - "bitflags 2.4.2", + "bitflags 2.6.0", "bytemuck", "calloop", "cfg_aliases", @@ -3450,7 +3467,7 @@ dependencies = [ "orbclient", "percent-encoding", "raw-window-handle 0.5.2", - "raw-window-handle 0.6.0", + "raw-window-handle 0.6.2", "redox_syscall 0.3.5", "rustix", "sctk-adwaita", @@ -3460,8 +3477,8 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "wayland-backend", - "wayland-client 0.31.1", - "wayland-protocols 0.31.0", + "wayland-client 0.31.5", + "wayland-protocols 0.31.2", "wayland-protocols-plasma", "web-sys", "web-time", @@ -3473,9 +3490,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.5.34" +version = "0.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7cf47b659b318dccbd69cc4797a39ae128f533dce7902a1096044d1967b9c16" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" dependencies = [ "memchr", ] @@ -3493,14 +3510,14 @@ dependencies = [ [[package]] name = "x11rb" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8f25ead8c7e4cba123243a6367da5d3990e0d3affa708ea19dce96356bd9f1a" +checksum = "5d91ffca73ee7f68ce055750bf9f6eca0780b8c85eff9bc046a3b0da41755e12" dependencies = [ "as-raw-xcb-connection", "gethostname", "libc", - "libloading 0.8.1", + "libloading 0.8.5", "once_cell", "rustix", "x11rb-protocol", @@ -3508,23 +3525,23 @@ dependencies = [ [[package]] name = "x11rb-protocol" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e63e71c4b8bd9ffec2c963173a4dc4cbde9ee96961d4fcb4429db9929b606c34" +checksum = "ec107c4503ea0b4a98ef47356329af139c0a4f7750e621cf2973cd3385ebcb3d" [[package]] name = "xcursor" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a0ccd7b4a5345edfcd0c3535718a4e9ff7798ffc536bb5b5a0e26ff84732911" +checksum = "d491ee231a51ae64a5b762114c3ac2104b967aadba1de45c86ca42cf051513b7" [[package]] name = "xkbcommon-dl" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6924668544c48c0133152e7eec86d644a056ca3d09275eb8d5cdb9855f9d8699" +checksum = "d039de8032a9a8856a6be89cea3e5d12fdd82306ab7c94d74e6deab2460651c5" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.6.0", "dlib", "log", "once_cell", @@ -3533,15 +3550,15 @@ dependencies = [ [[package]] name = "xkeysym" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "054a8e68b76250b253f671d1268cb7f1ae089ec35e195b2efb2a4e9a836d0621" +checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56" [[package]] name = "xml-rs" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a" +checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193" [[package]] name = "yansi" @@ -3551,20 +3568,20 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.72", ] From 32cc080809ed09b055cc6e3506dd71cbc08f971c Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Fri, 23 Feb 2024 16:47:26 +0200 Subject: [PATCH 22/32] linker: centralize dumping SPIR-V and SPIR-T together. --- crates/rustc_codegen_spirv/src/linker/mod.rs | 174 +++++++++++-------- 1 file changed, 106 insertions(+), 68 deletions(-) diff --git a/crates/rustc_codegen_spirv/src/linker/mod.rs b/crates/rustc_codegen_spirv/src/linker/mod.rs index 96ad90a4d8..08d9ab17a2 100644 --- a/crates/rustc_codegen_spirv/src/linker/mod.rs +++ b/crates/rustc_codegen_spirv/src/linker/mod.rs @@ -150,6 +150,31 @@ fn get_name<'a>(names: &FxHashMap, id: Word) -> Cow<'a, str> { ) } +impl Options { + // FIXME(eddyb) using a method on this type seems a bit sketchy. + fn spirt_cleanup_for_dumping(&self, module: &mut spirt::Module) { + if self.spirt_strip_custom_debuginfo_from_dumps { + spirt_passes::debuginfo::convert_custom_debuginfo_to_spv(module); + } + if !self.spirt_keep_debug_sources_in_dumps { + const DOTS: &str = "⋯"; + let dots_interned_str = module.cx().intern(DOTS); + let spirt::ModuleDebugInfo::Spv(debuginfo) = &mut module.debug_info; + for sources in debuginfo.source_languages.values_mut() { + for file in sources.file_contents.values_mut() { + *file = DOTS.into(); + } + sources.file_contents.insert( + dots_interned_str, + "sources hidden, to show them use \ + `RUSTGPU_CODEGEN_ARGS=--spirt-keep-debug-sources-in-dumps`" + .into(), + ); + } + } + } +} + pub fn link( sess: &Session, mut inputs: Vec, @@ -157,6 +182,66 @@ pub fn link( outputs: &OutputFilenames, disambiguated_crate_name_for_dumps: &OsStr, ) -> Result { + // HACK(eddyb) this is defined here to allow SPIR-T pretty-printing to apply + // to SPIR-V being dumped, outside of e.g. `--dump-spirt-passes`. + // FIXME(eddyb) this isn't used everywhere, sadly - to find those, search + // elsewhere for `.assemble()` and/or `spirv_tools::binary::from_binary`. + let spv_module_to_spv_words_and_spirt_module = |spv_module: &Module| { + let spv_words; + let spv_bytes = { + let _timer = sess.timer("assemble-to-spv_bytes-for-spirt"); + spv_words = spv_module.assemble(); + // FIXME(eddyb) this is wastefully cloning all the bytes, but also + // `spirt::Module` should have a method that takes `Vec`. + spirv_tools::binary::from_binary(&spv_words).to_vec() + }; + + // FIXME(eddyb) should've really been "spirt::Module::lower_from_spv_bytes". + let _timer = sess.timer("spirt::Module::lower_from_spv_file"); + let cx = std::rc::Rc::new(spirt::Context::new()); + crate::custom_insts::register_to_spirt_context(&cx); + ( + spv_words, + spirt::Module::lower_from_spv_bytes(cx, spv_bytes), + ) + }; + + let dump_spv_and_spirt = |spv_module: &Module, dump_file_path_stem: PathBuf| { + let (spv_words, spirt_module_or_err) = spv_module_to_spv_words_and_spirt_module(spv_module); + std::fs::write( + dump_file_path_stem.with_extension("spv"), + spirv_tools::binary::from_binary(&spv_words), + ) + .unwrap(); + + // FIXME(eddyb) reify SPIR-V -> SPIR-T errors so they're easier to debug. + if let Ok(mut module) = spirt_module_or_err { + // HACK(eddyb) avoid pretty-printing massive amounts of unused SPIR-T. + spirt::passes::link::minimize_exports(&mut module, |export_key| { + matches!(export_key, spirt::ExportKey::SpvEntryPoint { .. }) + }); + + opts.spirt_cleanup_for_dumping(&mut module); + + let pretty = spirt::print::Plan::for_module(&module).pretty_print(); + + // FIXME(eddyb) don't allocate whole `String`s here. + std::fs::write( + dump_file_path_stem.with_extension("spirt"), + pretty.to_string(), + ) + .unwrap(); + std::fs::write( + dump_file_path_stem.with_extension("spirt.html"), + pretty + .render_to_html() + .with_dark_mode_support() + .to_html_doc(), + ) + .unwrap(); + } + }; + let mut output = { let _timer = sess.timer("link_merge"); // shift all the ids @@ -193,12 +278,7 @@ pub fn link( }; if let Some(dir) = &opts.dump_post_merge { - std::fs::write( - dir.join(disambiguated_crate_name_for_dumps) - .with_extension("spv"), - spirv_tools::binary::from_binary(&output.assemble()), - ) - .unwrap(); + dump_spv_and_spirt(&output, dir.join(disambiguated_crate_name_for_dumps)); } // remove duplicates (https://github.com/KhronosGroup/SPIRV-Tools/blob/e7866de4b1dc2a7e8672867caeb0bdca49f458d3/source/opt/remove_duplicates_pass.cpp) @@ -401,40 +481,22 @@ pub fn link( } }; - let spv_words; - let spv_bytes = { - let _timer = sess.timer("assemble-to-spv_bytes-for-spirt"); - spv_words = output.assemble(); - // FIXME(eddyb) this is wastefully cloning all the bytes, but also - // `spirt::Module` should have a method that takes `Vec`. - spirv_tools::binary::from_binary(&spv_words).to_vec() - }; - let cx = std::rc::Rc::new(spirt::Context::new()); - crate::custom_insts::register_to_spirt_context(&cx); - let mut module = { - let _timer = sess.timer("spirt::Module::lower_from_spv_file"); - match spirt::Module::lower_from_spv_bytes(cx.clone(), spv_bytes) { - Ok(module) => module, - Err(e) => { - let spv_path = outputs.temp_path_ext("spirt-lower-from-spv-input.spv", None); - - let was_saved_msg = match std::fs::write( - &spv_path, - spirv_tools::binary::from_binary(&spv_words), - ) { - Ok(()) => format!("was saved to {}", spv_path.display()), - Err(e) => format!("could not be saved: {e}"), - }; - - return Err(sess - .dcx() - .struct_err(format!("{e}")) - .with_note("while lowering SPIR-V module to SPIR-T (spirt::spv::lower)") - .with_note(format!("input SPIR-V module {was_saved_msg}")) - .emit()); - } - } - }; + let (spv_words, module_or_err) = spv_module_to_spv_words_and_spirt_module(&output); + let mut module = module_or_err.map_err(|e| { + let spv_path = outputs.temp_path_ext("spirt-lower-from-spv-input.spv", None); + + let was_saved_msg = + match std::fs::write(&spv_path, spirv_tools::binary::from_binary(&spv_words)) { + Ok(()) => format!("was saved to {}", spv_path.display()), + Err(e) => format!("could not be saved: {e}"), + }; + + sess.dcx() + .struct_err(format!("{e}")) + .with_note("while lowering SPIR-V module to SPIR-T (spirt::spv::lower)") + .with_note(format!("input SPIR-V module {was_saved_msg}")) + .emit() + })?; // HACK(eddyb) don't dump the unstructured state if not requested, as // after SPIR-T 0.4.0 it's extremely verbose (due to def-use hermeticity). if opts.spirt_keep_unstructured_cfg_in_dumps || !opts.structurize { @@ -499,31 +561,12 @@ pub fn link( // NOTE(eddyb) this should be *before* `lift_to_spv` below, // so if that fails, the dump could be used to debug it. if let Some(dump_spirt_file_path) = &dump_spirt_file_path { - if opts.spirt_strip_custom_debuginfo_from_dumps { - for (_, module) in &mut per_pass_module_for_dumping { - spirt_passes::debuginfo::convert_custom_debuginfo_to_spv(module); - } - } - if !opts.spirt_keep_debug_sources_in_dumps { - for (_, module) in &mut per_pass_module_for_dumping { - let spirt::ModuleDebugInfo::Spv(debuginfo) = &mut module.debug_info; - for sources in debuginfo.source_languages.values_mut() { - const DOTS: &str = "⋯"; - for file in sources.file_contents.values_mut() { - *file = DOTS.into(); - } - sources.file_contents.insert( - cx.intern(DOTS), - "sources hidden, to show them use \ - `RUSTGPU_CODEGEN_ARGS=--spirt-keep-debug-sources-in-dumps`" - .into(), - ); - } - } + for (_, module) in &mut per_pass_module_for_dumping { + opts.spirt_cleanup_for_dumping(module); } let plan = spirt::print::Plan::for_versions( - &cx, + module.cx_ref(), per_pass_module_for_dumping .iter() .map(|(pass, module)| (format!("after {pass}"), module)), @@ -695,13 +738,8 @@ pub fn link( file_name.push("."); file_name.push(file_stem); } - file_name.push(".spv"); - std::fs::write( - dir.join(file_name), - spirv_tools::binary::from_binary(&output.assemble()), - ) - .unwrap(); + dump_spv_and_spirt(output, dir.join(file_name)); } // Run DCE again, even if module_output_type == ModuleOutputType::Multiple - the first DCE ran before // structurization and mem2reg (for perf reasons), and mem2reg may remove references to From 4eefe803ba0ad65bfcd10039db535750a36528fe Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Mon, 26 Feb 2024 23:36:39 +0200 Subject: [PATCH 23/32] linker: add `--dump-{pre,post}-inline` to be able to debug the inliner. --- crates/rustc_codegen_spirv/src/codegen_cx/mod.rs | 14 ++++++++++++++ crates/rustc_codegen_spirv/src/linker/mod.rs | 11 +++++++++++ docs/src/codegen-args.md | 8 ++++++++ 3 files changed, 33 insertions(+) diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs index c3175155df..9db238d7df 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs @@ -438,6 +438,18 @@ impl CodegenArgs { "dump the merged module immediately after merging, to a file in DIR", "DIR", ); + opts.optopt( + "", + "dump-pre-inline", + "dump the module immediately before inlining, to a file in DIR", + "DIR", + ); + opts.optopt( + "", + "dump-post-inline", + "dump the module immediately after inlining, to a file in DIR", + "DIR", + ); opts.optopt( "", "dump-post-split", @@ -628,6 +640,8 @@ impl CodegenArgs { // NOTE(eddyb) these are debugging options that used to be env vars // (for more information see `docs/src/codegen-args.md`). dump_post_merge: matches_opt_dump_dir_path("dump-post-merge"), + dump_pre_inline: matches_opt_dump_dir_path("dump-pre-inline"), + dump_post_inline: matches_opt_dump_dir_path("dump-post-inline"), dump_post_split: matches_opt_dump_dir_path("dump-post-split"), dump_spirt_passes: matches_opt_dump_dir_path("dump-spirt-passes"), spirt_strip_custom_debuginfo_from_dumps: matches diff --git a/crates/rustc_codegen_spirv/src/linker/mod.rs b/crates/rustc_codegen_spirv/src/linker/mod.rs index 08d9ab17a2..9904e44a3c 100644 --- a/crates/rustc_codegen_spirv/src/linker/mod.rs +++ b/crates/rustc_codegen_spirv/src/linker/mod.rs @@ -58,6 +58,8 @@ pub struct Options { // NOTE(eddyb) these are debugging options that used to be env vars // (for more information see `docs/src/codegen-args.md`). pub dump_post_merge: Option, + pub dump_pre_inline: Option, + pub dump_post_inline: Option, pub dump_post_split: Option, pub dump_spirt_passes: Option, pub spirt_strip_custom_debuginfo_from_dumps: bool, @@ -416,6 +418,10 @@ pub fn link( duplicates::remove_duplicate_debuginfo(&mut output); } + if let Some(dir) = &opts.dump_pre_inline { + dump_spv_and_spirt(&output, dir.join(disambiguated_crate_name_for_dumps)); + } + { let _timer = sess.timer("link_inline"); inline::inline(sess, &mut output)?; @@ -426,6 +432,11 @@ pub fn link( dce::dce(&mut output); } + // HACK(eddyb) this has to be after DCE, to not break SPIR-T w/ dead decorations. + if let Some(dir) = &opts.dump_post_inline { + dump_spv_and_spirt(&output, dir.join(disambiguated_crate_name_for_dumps)); + } + { let _timer = sess.timer("link_block_ordering_pass_and_mem2reg-after-inlining"); let mut pointer_to_pointee = FxHashMap::default(); diff --git a/docs/src/codegen-args.md b/docs/src/codegen-args.md index 4a08ca5e37..254894918a 100644 --- a/docs/src/codegen-args.md +++ b/docs/src/codegen-args.md @@ -79,6 +79,14 @@ Dumps the merged module, to a file in `DIR`, immediately after merging, but befo similar to `--dump-pre-link`, except it outputs only a single file, which might make grepping through for stuff easier. +### `--dump-pre-inline DIR` + +Dumps the module, to a file in `DIR`, immediately before the inliner pass runs. + +### `--dump-post-inline DIR` + +Dumps the module, to a file in `DIR`, immediately after the inliner pass runs. + ### `--dump-post-split DIR` Dumps the modules, to files in `DIR`, immediately after multimodule splitting, but before final cleanup passes (e.g. From d7ac3ed940748db1ab25fb9543f61a1263239393 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Mon, 26 Feb 2024 21:19:54 +0200 Subject: [PATCH 24/32] linker/inline: fix `OpVariable` debuginfo collection and insertion. --- .../rustc_codegen_spirv/src/linker/inline.rs | 202 +++++++++++++----- 1 file changed, 150 insertions(+), 52 deletions(-) diff --git a/crates/rustc_codegen_spirv/src/linker/inline.rs b/crates/rustc_codegen_spirv/src/linker/inline.rs index 717a73f85b..5e53215af7 100644 --- a/crates/rustc_codegen_spirv/src/linker/inline.rs +++ b/crates/rustc_codegen_spirv/src/linker/inline.rs @@ -15,7 +15,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::ErrorGuaranteed; use rustc_session::Session; use smallvec::SmallVec; -use std::mem::{self, take}; +use std::mem; type FunctionMap = FxHashMap; @@ -658,15 +658,13 @@ impl Inliner<'_, '_> { if let Some(call_result_type) = call_result_type { // Generate the storage space for the return value: Do this *after* the split above, // because if block_idx=0, inserting a variable here shifts call_index. - insert_opvariables( - &mut caller.blocks[0], - [Instruction::new( - Op::Variable, - Some(self.ptr_ty(call_result_type)), - Some(return_variable.unwrap()), - vec![Operand::StorageClass(StorageClass::Function)], - )], + let ret_var_inst = Instruction::new( + Op::Variable, + Some(self.ptr_ty(call_result_type)), + Some(return_variable.unwrap()), + vec![Operand::StorageClass(StorageClass::Function)], ); + self.insert_opvariables(&mut caller.blocks[0], [ret_var_inst]); } // Insert non-entry inlined callee blocks just after the pre-call block. @@ -712,52 +710,115 @@ impl Inliner<'_, '_> { // Fuse the inlined callee entry block into the pre-call block. // This is okay because it's illegal to branch to the first BB in a function. { + // NOTE(eddyb) `OpExtInst`s have a result ID, even if unused, and + // it has to be unique, so this allocates new IDs as-needed. + let instantiate_debuginfo = |this: &mut Self, inst: &Instruction| { + let mut inst = inst.clone(); + if let Some(id) = &mut inst.result_id { + *id = this.id(); + } + inst + }; + + let custom_inst_to_inst = |this: &mut Self, inst: CustomInst<_>| { + Instruction::new( + Op::ExtInst, + Some(this.op_type_void_id), + Some(this.id()), + [ + Operand::IdRef(this.custom_ext_inst_set_import), + Operand::LiteralExtInstInteger(inst.op() as u32), + ] + .into_iter() + .chain(inst.into_operands()) + .collect(), + ) + }; + // Return the subsequence of `insts` made from `OpVariable`s, and any // debuginfo instructions (which may apply to them), while removing // *only* `OpVariable`s from `insts` (and keeping debuginfo in both). let mut steal_vars = |insts: &mut Vec| { - let mut vars_and_debuginfo = vec![]; - insts.retain_mut(|inst| { - let is_debuginfo = match inst.class.opcode { - Op::Line | Op::NoLine => true, - Op::ExtInst => { - inst.operands[0].unwrap_id_ref() == self.custom_ext_inst_set_import - && CustomOp::decode_from_ext_inst(inst).is_debuginfo() - } - _ => false, - }; - if is_debuginfo { - // NOTE(eddyb) `OpExtInst`s have a result ID, - // even if unused, and it has to be unique. - let mut inst = inst.clone(); - if let Some(id) = &mut inst.result_id { - *id = self.id(); + // HACK(eddyb) this duplicates some code from `get_inlined_blocks`, + // but that will be removed once the inliner is refactored to be + // inside-out instead of outside-in (already finished in a branch). + let mut enclosing_inlined_frames = SmallVec::<[_; 8]>::new(); + let mut current_debug_src_loc_inst = None; + let mut vars_and_debuginfo_range = 0..0; + while vars_and_debuginfo_range.end < insts.len() { + let inst = &insts[vars_and_debuginfo_range.end]; + match inst.class.opcode { + Op::Line => current_debug_src_loc_inst = Some(inst), + Op::NoLine => current_debug_src_loc_inst = None, + Op::ExtInst + if inst.operands[0].unwrap_id_ref() + == self.custom_ext_inst_set_import => + { + match CustomOp::decode_from_ext_inst(inst) { + CustomOp::SetDebugSrcLoc => current_debug_src_loc_inst = Some(inst), + CustomOp::ClearDebugSrcLoc => current_debug_src_loc_inst = None, + CustomOp::PushInlinedCallFrame => { + enclosing_inlined_frames + .push((current_debug_src_loc_inst.take(), inst)); + } + CustomOp::PopInlinedCallFrame => { + if let Some((callsite_debug_src_loc_inst, _)) = + enclosing_inlined_frames.pop() + { + current_debug_src_loc_inst = callsite_debug_src_loc_inst; + } + } + CustomOp::Abort => break, + } } - vars_and_debuginfo.push(inst); - true - } else if inst.class.opcode == Op::Variable { - // HACK(eddyb) we're removing this `Instruction` from - // `inst`, so it doesn't really matter what we use here. - vars_and_debuginfo.push(mem::replace( - inst, - Instruction::new(Op::Nop, None, None, vec![]), - )); - false - } else { - true + Op::Variable => {} + _ => break, } - }); - vars_and_debuginfo + vars_and_debuginfo_range.end += 1; + } + + // `vars_and_debuginfo_range.end` indicates where `OpVariable`s + // end and other instructions start (module debuginfo), but to + // split the block in two, both sides of the "cut" need "repair": + // - the variables are missing "inlined call frames" pops, that + // may happen later in the block, and have to be synthesized + // - the non-variables are missing "inlined call frames" pushes, + // that must be recreated to avoid ending up with dangling pops + // + // FIXME(eddyb) this only collects to avoid borrow conflicts, + // between e.g. `enclosing_inlined_frames` and mutating `insts`, + // but also between different uses of `self`. + let all_pops_after_vars: SmallVec<[_; 8]> = enclosing_inlined_frames + .iter() + .map(|_| custom_inst_to_inst(self, CustomInst::PopInlinedCallFrame)) + .collect(); + let all_repushes_before_non_vars: SmallVec<[_; 8]> = + (enclosing_inlined_frames.into_iter().flat_map( + |(callsite_debug_src_loc_inst, push_inlined_call_frame_inst)| { + (callsite_debug_src_loc_inst.into_iter()) + .chain([push_inlined_call_frame_inst]) + }, + )) + .chain(current_debug_src_loc_inst) + .map(|inst| instantiate_debuginfo(self, inst)) + .collect(); + + let vars_and_debuginfo = + insts.splice(vars_and_debuginfo_range, all_repushes_before_non_vars); + let repaired_vars_and_debuginfo = vars_and_debuginfo.chain(all_pops_after_vars); + + // FIXME(eddyb) collecting shouldn't be necessary but this is + // nested in a closure, and `splice` borrows the original `Vec`. + repaired_vars_and_debuginfo.collect::>() }; let [mut inlined_callee_entry_block]: [_; 1] = inlined_callee_blocks.try_into().unwrap(); // Move the `OpVariable`s of the callee to the caller. - insert_opvariables( - &mut caller.blocks[0], - steal_vars(&mut inlined_callee_entry_block.instructions), - ); + let callee_vars_and_debuginfo = + steal_vars(&mut inlined_callee_entry_block.instructions); + self.insert_opvariables(&mut caller.blocks[0], callee_vars_and_debuginfo); caller.blocks[pre_call_block_idx] .instructions @@ -990,15 +1051,52 @@ impl Inliner<'_, '_> { caller_restore_debuginfo_after_call, ) } -} -fn insert_opvariables(block: &mut Block, insts: impl IntoIterator) { - let first_non_variable = block - .instructions - .iter() - .position(|inst| inst.class.opcode != Op::Variable); - let i = first_non_variable.unwrap_or(block.instructions.len()); - block.instructions.splice(i..i, insts); + fn insert_opvariables(&self, block: &mut Block, insts: impl IntoIterator) { + // HACK(eddyb) this isn't as efficient as it could be in theory, but it's + // very important to make sure sure to never insert new instructions in + // the middle of debuginfo (as it would be affected by it). + let mut inlined_frames_depth = 0usize; + let mut outermost_has_debug_src_loc = false; + let mut last_debugless_var_insertion_point_candidate = None; + for (i, inst) in block.instructions.iter().enumerate() { + last_debugless_var_insertion_point_candidate = + (inlined_frames_depth == 0 && !outermost_has_debug_src_loc).then_some(i); + + let changed_has_debug_src_loc = match inst.class.opcode { + Op::Line => true, + Op::NoLine => false, + Op::ExtInst + if inst.operands[0].unwrap_id_ref() == self.custom_ext_inst_set_import => + { + match CustomOp::decode_from_ext_inst(inst) { + CustomOp::SetDebugSrcLoc => true, + CustomOp::ClearDebugSrcLoc => false, + CustomOp::PushInlinedCallFrame => { + inlined_frames_depth += 1; + continue; + } + CustomOp::PopInlinedCallFrame => { + inlined_frames_depth = inlined_frames_depth.saturating_sub(1); + continue; + } + CustomOp::Abort => break, + } + } + Op::Variable => continue, + _ => break, + }; + + if inlined_frames_depth == 0 { + outermost_has_debug_src_loc = changed_has_debug_src_loc; + } + } + + // HACK(eddyb) fallback to inserting at the start, which should be correct. + // FIXME(eddyb) some level of debuginfo repair could prevent needing this. + let i = last_debugless_var_insertion_point_candidate.unwrap_or(0); + block.instructions.splice(i..i, insts); + } } fn fuse_trivial_branches(function: &mut Function) { @@ -1033,7 +1131,7 @@ fn fuse_trivial_branches(function: &mut Function) { }; let pred_insts = &function.blocks[pred].instructions; if pred_insts.last().unwrap().class.opcode == Op::Branch { - let mut dest_insts = take(&mut function.blocks[dest_block].instructions); + let mut dest_insts = mem::take(&mut function.blocks[dest_block].instructions); let pred_insts = &mut function.blocks[pred].instructions; pred_insts.pop(); // pop the branch pred_insts.append(&mut dest_insts); From 338f51258a66989393f75062a0a9080222044ed6 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Fri, 23 Feb 2024 17:38:45 +0200 Subject: [PATCH 25/32] WIP: (TODO: finish bottom-up cleanups) bottom-up inlining --- .../rustc_codegen_spirv/src/linker/inline.rs | 173 ++++++++++-------- crates/rustc_codegen_spirv/src/linker/ipo.rs | 16 +- 2 files changed, 107 insertions(+), 82 deletions(-) diff --git a/crates/rustc_codegen_spirv/src/linker/inline.rs b/crates/rustc_codegen_spirv/src/linker/inline.rs index 5e53215af7..6b3992eac7 100644 --- a/crates/rustc_codegen_spirv/src/linker/inline.rs +++ b/crates/rustc_codegen_spirv/src/linker/inline.rs @@ -17,8 +17,6 @@ use rustc_session::Session; use smallvec::SmallVec; use std::mem; -type FunctionMap = FxHashMap; - // FIXME(eddyb) this is a bit silly, but this keeps being repeated everywhere. fn next_id(header: &mut ModuleHeader) -> Word { let result = header.bound; @@ -30,6 +28,9 @@ pub fn inline(sess: &Session, module: &mut Module) -> super::Result<()> { // This algorithm gets real sad if there's recursion - but, good news, SPIR-V bans recursion deny_recursion_in_module(sess, module)?; + // Compute the call-graph that will drive (inside-out, aka bottom-up) inlining. + let (call_graph, func_id_to_idx) = CallGraph::collect_with_func_id_to_idx(module); + let custom_ext_inst_set_import = module .ext_inst_imports .iter() @@ -39,62 +40,7 @@ pub fn inline(sess: &Session, module: &mut Module) -> super::Result<()> { }) .map(|inst| inst.result_id.unwrap()); - // HACK(eddyb) compute the set of functions that may `Abort` *transitively*, - // which is only needed because of how we inline (sometimes it's outside-in, - // aka top-down, instead of always being inside-out, aka bottom-up). - // - // (inlining is needed in the first place because our custom `Abort` - // instructions get lowered to a simple `OpReturn` in entry-points, but - // that requires that they get inlined all the way up to the entry-points) - let functions_that_may_abort = custom_ext_inst_set_import - .map(|custom_ext_inst_set_import| { - let mut may_abort_by_id = FxHashSet::default(); - - // FIXME(eddyb) use this `CallGraph` abstraction more during inlining. - let call_graph = CallGraph::collect(module); - for func_idx in call_graph.post_order() { - let func_id = module.functions[func_idx].def_id().unwrap(); - - let any_callee_may_abort = call_graph.callees[func_idx].iter().any(|&callee_idx| { - may_abort_by_id.contains(&module.functions[callee_idx].def_id().unwrap()) - }); - if any_callee_may_abort { - may_abort_by_id.insert(func_id); - continue; - } - - let may_abort_directly = module.functions[func_idx].blocks.iter().any(|block| { - match &block.instructions[..] { - [.., last_normal_inst, terminator_inst] - if last_normal_inst.class.opcode == Op::ExtInst - && last_normal_inst.operands[0].unwrap_id_ref() - == custom_ext_inst_set_import - && CustomOp::decode_from_ext_inst(last_normal_inst) - == CustomOp::Abort => - { - assert_eq!(terminator_inst.class.opcode, Op::Unreachable); - true - } - - _ => false, - } - }); - if may_abort_directly { - may_abort_by_id.insert(func_id); - } - } - - may_abort_by_id - }) - .unwrap_or_default(); - - let functions = module - .functions - .iter() - .map(|f| (f.def_id().unwrap(), f.clone())) - .collect(); - let legal_globals = LegalGlobal::gather_from_module(module); - + /* // Drop all the functions we'll be inlining. (This also means we won't waste time processing // inlines in functions that will get inlined) let mut dropped_ids = FxHashSet::default(); @@ -123,6 +69,9 @@ pub fn inline(sess: &Session, module: &mut Module) -> super::Result<()> { )); } } + */ + + let legal_globals = LegalGlobal::gather_from_module(module); let header = module.header.as_mut().unwrap(); // FIXME(eddyb) clippy false positive (seperate `map` required for borrowck). @@ -154,6 +103,8 @@ pub fn inline(sess: &Session, module: &mut Module) -> super::Result<()> { id }), + func_id_to_idx, + id_to_name: module .debug_names .iter() @@ -173,22 +124,61 @@ pub fn inline(sess: &Session, module: &mut Module) -> super::Result<()> { annotations: &mut module.annotations, types_global_values: &mut module.types_global_values, - functions: &functions, - legal_globals: &legal_globals, - functions_that_may_abort: &functions_that_may_abort, + legal_globals, + + // NOTE(eddyb) this is needed because our custom `Abort` instructions get + // lowered to a simple `OpReturn` in entry-points, but that requires that + // they get inlined all the way up to the entry-points in the first place. + functions_that_may_abort: module + .functions + .iter() + .filter_map(|func| { + let custom_ext_inst_set_import = custom_ext_inst_set_import?; + func.blocks + .iter() + .any(|block| match &block.instructions[..] { + [.., last_normal_inst, terminator_inst] + if last_normal_inst.class.opcode == Op::ExtInst + && last_normal_inst.operands[0].unwrap_id_ref() + == custom_ext_inst_set_import + && CustomOp::decode_from_ext_inst(last_normal_inst) + == CustomOp::Abort => + { + assert_eq!(terminator_inst.class.opcode, Op::Unreachable); + true + } + + _ => false, + }) + .then_some(func.def_id().unwrap()) + }) + .collect(), }; - for function in &mut module.functions { - inliner.inline_fn(function); - fuse_trivial_branches(function); + + let mut functions: Vec<_> = mem::take(&mut module.functions) + .into_iter() + .map(Ok) + .collect(); + + // Inline functions in post-order (aka inside-out aka bottom-out) - that is, + // callees are processed before their callers, to avoid duplicating work. + for func_idx in call_graph.post_order() { + let mut function = mem::replace(&mut functions[func_idx], Err(FuncIsBeingInlined)).unwrap(); + inliner.inline_fn(&mut function, &functions); + fuse_trivial_branches(&mut function); + functions[func_idx] = Ok(function); } + module.functions = functions.into_iter().map(|func| func.unwrap()).collect(); + + /* // Drop OpName etc. for inlined functions module.debug_names.retain(|inst| { !inst.operands.iter().any(|op| { op.id_ref_any() .map_or(false, |id| dropped_ids.contains(&id)) }) - }); + });*/ Ok(()) } @@ -456,19 +446,27 @@ fn should_inline( Ok(callee_control.contains(FunctionControl::INLINE)) } +/// Helper error type for `Inliner`'s `functions` field, indicating a `Function` +/// was taken out of its slot because it's being inlined. +#[derive(Debug)] +struct FuncIsBeingInlined; + // Steps: // Move OpVariable decls // Rewrite return // Renumber IDs // Insert blocks -struct Inliner<'m, 'map> { +struct Inliner<'m> { /// ID of `OpExtInstImport` for our custom "extended instruction set" /// (see `crate::custom_insts` for more details). custom_ext_inst_set_import: Word, op_type_void_id: Word, + /// Map from each function's ID to its index in `functions`. + func_id_to_idx: FxHashMap, + /// Pre-collected `OpName`s, that can be used to find any function's name /// during inlining (to be able to generate debuginfo that uses names). id_to_name: FxHashMap, @@ -485,13 +483,12 @@ struct Inliner<'m, 'map> { annotations: &'m mut Vec, types_global_values: &'m mut Vec, - functions: &'map FunctionMap, - legal_globals: &'map FxHashMap, - functions_that_may_abort: &'map FxHashSet, + legal_globals: FxHashMap, + functions_that_may_abort: FxHashSet, // rewrite_rules: FxHashMap, } -impl Inliner<'_, '_> { +impl Inliner<'_> { fn id(&mut self) -> Word { next_id(self.header) } @@ -536,19 +533,29 @@ impl Inliner<'_, '_> { inst_id } - fn inline_fn(&mut self, function: &mut Function) { + fn inline_fn( + &mut self, + function: &mut Function, + functions: &[Result], + ) { let mut block_idx = 0; while block_idx < function.blocks.len() { // If we successfully inlined a block, then repeat processing on the same block, in // case the newly inlined block has more inlined calls. // TODO: This is quadratic - if !self.inline_block(function, block_idx) { + if !self.inline_block(function, block_idx, functions) { + // TODO(eddyb) skip past the inlined callee without rescanning it. block_idx += 1; } } } - fn inline_block(&mut self, caller: &mut Function, block_idx: usize) -> bool { + fn inline_block( + &mut self, + caller: &mut Function, + block_idx: usize, + functions: &[Result], + ) -> bool { // Find the first inlined OpFunctionCall let call = caller.blocks[block_idx] .instructions @@ -559,8 +566,8 @@ impl Inliner<'_, '_> { ( index, inst, - self.functions - .get(&inst.operands[0].id_ref_any().unwrap()) + functions[self.func_id_to_idx[&inst.operands[0].id_ref_any().unwrap()]] + .as_ref() .unwrap(), ) }) @@ -570,8 +577,8 @@ impl Inliner<'_, '_> { call_inst: inst, }; match should_inline( - self.legal_globals, - self.functions_that_may_abort, + &self.legal_globals, + &self.functions_that_may_abort, f, Some(call_site), ) { @@ -583,6 +590,16 @@ impl Inliner<'_, '_> { None => return false, Some(call) => call, }; + + // Propagate "may abort" from callee to caller (i.e. as aborts get inlined). + if self + .functions_that_may_abort + .contains(&callee.def_id().unwrap()) + { + self.functions_that_may_abort + .insert(caller.def_id().unwrap()); + } + let call_result_type = { let ty = call_inst.result_type.unwrap(); if ty == self.op_type_void_id { @@ -594,6 +611,7 @@ impl Inliner<'_, '_> { let call_result_id = call_inst.result_id.unwrap(); // Get the debuginfo instructions that apply to the call. + // TODO(eddyb) only one instruction should be necessary here w/ bottom-up. let custom_ext_inst_set_import = self.custom_ext_inst_set_import; let call_debug_insts = caller.blocks[block_idx].instructions[..call_index] .iter() @@ -868,6 +886,7 @@ impl Inliner<'_, '_> { .. } = *self; + // TODO(eddyb) kill this as it shouldn't be needed for bottom-up inline. // HACK(eddyb) this is terrible, but we have to deal with it becasue of // how this inliner is outside-in, instead of inside-out, meaning that // context builds up "outside" of the callee blocks, inside the caller. diff --git a/crates/rustc_codegen_spirv/src/linker/ipo.rs b/crates/rustc_codegen_spirv/src/linker/ipo.rs index 475f5c50c1..96c7bbe6ae 100644 --- a/crates/rustc_codegen_spirv/src/linker/ipo.rs +++ b/crates/rustc_codegen_spirv/src/linker/ipo.rs @@ -4,7 +4,7 @@ use indexmap::IndexSet; use rspirv::dr::Module; -use rspirv::spirv::Op; +use rspirv::spirv::{Op, Word}; use rustc_data_structures::fx::FxHashMap; // FIXME(eddyb) use newtyped indices and `IndexVec`. @@ -19,6 +19,9 @@ pub struct CallGraph { impl CallGraph { pub fn collect(module: &Module) -> Self { + Self::collect_with_func_id_to_idx(module).0 + } + pub fn collect_with_func_id_to_idx(module: &Module) -> (Self, FxHashMap) { let func_id_to_idx: FxHashMap<_, _> = module .functions .iter() @@ -51,10 +54,13 @@ impl CallGraph { .collect() }) .collect(); - Self { - entry_points, - callees, - } + ( + Self { + entry_points, + callees, + }, + func_id_to_idx, + ) } /// Order functions using a post-order traversal, i.e. callees before callers. From 46ef3472f0bced07fec404c2e1fd9435134cfd82 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Wed, 31 Jan 2024 17:52:07 +0200 Subject: [PATCH 26/32] WIP: update for spirt 0.4.0 --- Cargo.lock | 7 +- crates/rustc_codegen_spirv/Cargo.toml | 4 +- .../rustc_codegen_spirv/src/codegen_cx/mod.rs | 7 ++ crates/rustc_codegen_spirv/src/linker/mod.rs | 7 +- .../src/linker/spirt_passes/controlflow.rs | 53 ++++---- .../src/linker/spirt_passes/debuginfo.rs | 18 +-- .../src/linker/spirt_passes/diagnostics.rs | 29 +++-- .../src/linker/spirt_passes/mod.rs | 118 ++++-------------- .../src/linker/spirt_passes/reduce.rs | 117 +++++++++-------- docs/src/codegen-args.md | 8 ++ tests/ui/lang/core/unwrap_or.stderr | 12 +- 11 files changed, 177 insertions(+), 203 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 14f04b5512..62873c1afa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2411,15 +2411,14 @@ dependencies = [ [[package]] name = "spirt" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e1f7903720ff818d6da824edf2c4082c6e7a029a99317fd10c39dd7c40c7ff" +version = "0.4.0" +source = "git+https://github.com/LykenSol/spirt?branch=ephemera/0.4.0#c346ed1422cd911e902c60741f6413b117a214b7" dependencies = [ "arrayvec", "bytemuck", "derive_more", "elsa", - "indexmap 1.9.3", + "indexmap 2.3.0", "internal-iterator", "itertools", "lazy_static", diff --git a/crates/rustc_codegen_spirv/Cargo.toml b/crates/rustc_codegen_spirv/Cargo.toml index c1c469c645..ae11caee07 100644 --- a/crates/rustc_codegen_spirv/Cargo.toml +++ b/crates/rustc_codegen_spirv/Cargo.toml @@ -55,7 +55,9 @@ rustc_codegen_spirv-types.workspace = true rustc-demangle = "0.1.21" sanitize-filename = "0.4" smallvec = { version = "1.6.1", features = ["union"] } -spirt = "0.3.0" +# FIXME(eddyb) release 0.4.0 +# spirt = "0.4.0" +spirt = { version = "0.4.0", git = "https://github.com/LykenSol/spirt", branch = "ephemera/0.4.0" } spirv-tools.workspace = true lazy_static = "1.4.0" itertools = "0.10.5" diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs index 7732d13ee2..c3175155df 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs @@ -460,6 +460,11 @@ impl CodegenArgs { "spirt-keep-debug-sources-in-dumps", "keep file contents debuginfo when dumping SPIR-T", ); + opts.optflag( + "", + "spirt-keep-unstructured-cfg-in-dumps", + "include initial unstructured CFG when dumping SPIR-T", + ); opts.optflag( "", "specializer-debug", @@ -629,6 +634,8 @@ impl CodegenArgs { .opt_present("spirt-strip-custom-debuginfo-from-dumps"), spirt_keep_debug_sources_in_dumps: matches .opt_present("spirt-keep-debug-sources-in-dumps"), + spirt_keep_unstructured_cfg_in_dumps: matches + .opt_present("spirt-keep-unstructured-cfg-in-dumps"), specializer_debug: matches.opt_present("specializer-debug"), specializer_dump_instances: matches_opt_path("specializer-dump-instances"), print_all_zombie: matches.opt_present("print-all-zombie"), diff --git a/crates/rustc_codegen_spirv/src/linker/mod.rs b/crates/rustc_codegen_spirv/src/linker/mod.rs index baeb9d2815..b0548e679a 100644 --- a/crates/rustc_codegen_spirv/src/linker/mod.rs +++ b/crates/rustc_codegen_spirv/src/linker/mod.rs @@ -62,6 +62,7 @@ pub struct Options { pub dump_spirt_passes: Option, pub spirt_strip_custom_debuginfo_from_dumps: bool, pub spirt_keep_debug_sources_in_dumps: bool, + pub spirt_keep_unstructured_cfg_in_dumps: bool, pub specializer_debug: bool, pub specializer_dump_instances: Option, pub print_all_zombie: bool, @@ -434,7 +435,11 @@ pub fn link( } } }; - after_pass("lower_from_spv", &module); + // HACK(eddyb) don't dump the unstructured state if not requested, as + // after SPIR-T 0.4.0 it's extremely verbose (due to def-use hermeticity). + if opts.spirt_keep_unstructured_cfg_in_dumps || !opts.structurize { + after_pass("lower_from_spv", &module); + } // NOTE(eddyb) this *must* run on unstructured CFGs, to do its job. { diff --git a/crates/rustc_codegen_spirv/src/linker/spirt_passes/controlflow.rs b/crates/rustc_codegen_spirv/src/linker/spirt_passes/controlflow.rs index 5a173e43a4..2ac40b6d5a 100644 --- a/crates/rustc_codegen_spirv/src/linker/spirt_passes/controlflow.rs +++ b/crates/rustc_codegen_spirv/src/linker/spirt_passes/controlflow.rs @@ -4,8 +4,8 @@ use crate::custom_insts::{self, CustomInst, CustomOp}; use smallvec::SmallVec; use spirt::func_at::FuncAt; use spirt::{ - cfg, spv, Attr, AttrSet, ConstCtor, ConstDef, ControlNodeKind, DataInstFormDef, DataInstKind, - DeclDef, EntityDefs, ExportKey, Exportee, Module, Type, TypeCtor, TypeCtorArg, TypeDef, Value, + cfg, spv, Attr, AttrSet, ConstDef, ConstKind, ControlNodeKind, DataInstFormDef, DataInstKind, + DeclDef, EntityDefs, ExportKey, Exportee, Module, Type, TypeDef, TypeKind, TypeOrConst, Value, }; use std::fmt::Write as _; @@ -66,8 +66,8 @@ pub fn convert_custom_aborts_to_unstructured_returns_in_entry_points( }; let func_decl = &mut module.funcs[func]; - assert!(match &cx[func_decl.ret_type].ctor { - TypeCtor::SpvInst(spv_inst) => spv_inst.opcode == wk.OpTypeVoid, + assert!(match &cx[func_decl.ret_type].kind { + TypeKind::SpvInst { spv_inst, .. } => spv_inst.opcode == wk.OpTypeVoid, _ => false, }); @@ -112,7 +112,7 @@ pub fn convert_custom_aborts_to_unstructured_returns_in_entry_points( if let DataInstKind::SpvInst(spv_inst) = &data_inst_form_def.kind { if spv_inst.opcode == wk.OpLoad { if let Value::Const(ct) = data_inst_def.inputs[0] { - if let ConstCtor::PtrToGlobalVar(gv) = cx[ct].ctor { + if let ConstKind::PtrToGlobalVar(gv) = cx[ct].kind { if interface_global_vars.contains(&gv) { return Some(( gv, @@ -129,8 +129,8 @@ pub fn convert_custom_aborts_to_unstructured_returns_in_entry_points( if inputs { let mut first_input = true; for (gv, ty, value) in loaded_inputs { - let scalar_type = |ty: Type| match &cx[ty].ctor { - TypeCtor::SpvInst(spv_inst) => match spv_inst.imms[..] { + let scalar_type = |ty: Type| match &cx[ty].kind { + TypeKind::SpvInst { spv_inst, .. } => match spv_inst.imms[..] { [spv::Imm::Short(_, 32), spv::Imm::Short(_, signedness)] if spv_inst.opcode == wk.OpTypeInt => { @@ -145,14 +145,16 @@ pub fn convert_custom_aborts_to_unstructured_returns_in_entry_points( }; let vector_or_scalar_type = |ty: Type| { let ty_def = &cx[ty]; - match (&ty_def.ctor, &ty_def.ctor_args[..]) { - (TypeCtor::SpvInst(spv_inst), &[TypeCtorArg::Type(elem)]) - if spv_inst.opcode == wk.OpTypeVector => - { - match spv_inst.imms[..] { - [spv::Imm::Short(_, vlen @ 2..=4)] => { - Some((scalar_type(elem)?, Some(vlen))) - } + match &ty_def.kind { + TypeKind::SpvInst { + spv_inst, + type_and_const_inputs, + } if spv_inst.opcode == wk.OpTypeVector => { + match (&type_and_const_inputs[..], &spv_inst.imms[..]) { + ( + &[TypeOrConst::Type(elem)], + &[spv::Imm::Short(_, vlen @ 2..=4)], + ) => Some((scalar_type(elem)?, Some(vlen))), _ => None, } } @@ -260,16 +262,19 @@ pub fn convert_custom_aborts_to_unstructured_returns_in_entry_points( inputs: _, backtrace, }) => { - let const_ctor = |v: Value| match v { - Value::Const(ct) => &cx[ct].ctor, + let const_kind = |v: Value| match v { + Value::Const(ct) => &cx[ct].kind, _ => unreachable!(), }; - let const_str = |v: Value| match const_ctor(v) { - &ConstCtor::SpvStringLiteralForExtInst(s) => s, + let const_str = |v: Value| match const_kind(v) { + &ConstKind::SpvStringLiteralForExtInst(s) => s, _ => unreachable!(), }; - let const_u32 = |v: Value| match const_ctor(v) { - ConstCtor::SpvInst(spv_inst) => { + let const_u32 = |v: Value| match const_kind(v) { + ConstKind::SpvInst { + spv_inst_and_const_inputs, + } => { + let (spv_inst, _const_inputs) = &**spv_inst_and_const_inputs; assert!(spv_inst.opcode == wk.OpConstant); match spv_inst.imms[..] { [spv::Imm::Short(_, x)] => x, @@ -283,11 +288,9 @@ pub fn convert_custom_aborts_to_unstructured_returns_in_entry_points( attrs: Default::default(), ty: cx.intern(TypeDef { attrs: Default::default(), - ctor: TypeCtor::SpvStringLiteralForExtInst, - ctor_args: Default::default(), + kind: TypeKind::SpvStringLiteralForExtInst, }), - ctor: ConstCtor::SpvStringLiteralForExtInst(s), - ctor_args: Default::default(), + kind: ConstKind::SpvStringLiteralForExtInst(s), }) }; diff --git a/crates/rustc_codegen_spirv/src/linker/spirt_passes/debuginfo.rs b/crates/rustc_codegen_spirv/src/linker/spirt_passes/debuginfo.rs index 6121d01122..9d1944ced8 100644 --- a/crates/rustc_codegen_spirv/src/linker/spirt_passes/debuginfo.rs +++ b/crates/rustc_codegen_spirv/src/linker/spirt_passes/debuginfo.rs @@ -6,7 +6,7 @@ use smallvec::SmallVec; use spirt::transform::{InnerInPlaceTransform, Transformer}; use spirt::visit::InnerVisit; use spirt::{ - spv, Attr, AttrSetDef, ConstCtor, Context, ControlNode, ControlNodeKind, DataInstKind, + spv, Attr, AttrSetDef, ConstKind, Context, ControlNode, ControlNodeKind, DataInstKind, InternedStr, Module, OrdAssertEq, Value, }; @@ -95,16 +95,20 @@ impl Transformer for CustomDebuginfoToSpv<'_> { col_start: col, col_end: _, } => { - let const_ctor = |v: Value| match v { - Value::Const(ct) => &self.cx[ct].ctor, + let const_kind = |v: Value| match v { + Value::Const(ct) => &self.cx[ct].kind, _ => unreachable!(), }; - let const_str = |v: Value| match const_ctor(v) { - &ConstCtor::SpvStringLiteralForExtInst(s) => s, + let const_str = |v: Value| match const_kind(v) { + &ConstKind::SpvStringLiteralForExtInst(s) => s, _ => unreachable!(), }; - let const_u32 = |v: Value| match const_ctor(v) { - ConstCtor::SpvInst(spv_inst) => { + let const_u32 = |v: Value| match const_kind(v) { + ConstKind::SpvInst { + spv_inst_and_const_inputs, + } => { + let (spv_inst, _const_inputs) = + &**spv_inst_and_const_inputs; assert!(spv_inst.opcode == self.wk.OpConstant); match spv_inst.imms[..] { [spv::Imm::Short(_, x)] => x, diff --git a/crates/rustc_codegen_spirv/src/linker/spirt_passes/diagnostics.rs b/crates/rustc_codegen_spirv/src/linker/spirt_passes/diagnostics.rs index 4c4cbbc4bb..1c5083aae9 100644 --- a/crates/rustc_codegen_spirv/src/linker/spirt_passes/diagnostics.rs +++ b/crates/rustc_codegen_spirv/src/linker/spirt_passes/diagnostics.rs @@ -10,7 +10,7 @@ use smallvec::SmallVec; use spirt::func_at::FuncAt; use spirt::visit::{InnerVisit, Visitor}; use spirt::{ - spv, Attr, AttrSet, AttrSetDef, Const, ConstCtor, Context, ControlNode, ControlNodeKind, + spv, Attr, AttrSet, AttrSetDef, Const, ConstKind, Context, ControlNode, ControlNodeKind, DataInstDef, DataInstForm, DataInstKind, Diag, DiagLevel, ExportKey, Exportee, Func, FuncDecl, GlobalVar, InternedStr, Module, Type, Value, }; @@ -275,16 +275,19 @@ impl UseOrigin<'_> { } => (file, line_start, line_end, col_start, col_end), _ => unreachable!(), }; - let const_ctor = |v: Value| match v { - Value::Const(ct) => &cx[ct].ctor, + let const_kind = |v: Value| match v { + Value::Const(ct) => &cx[ct].kind, _ => unreachable!(), }; - let const_str = |v: Value| match const_ctor(v) { - &ConstCtor::SpvStringLiteralForExtInst(s) => s, + let const_str = |v: Value| match const_kind(v) { + &ConstKind::SpvStringLiteralForExtInst(s) => s, _ => unreachable!(), }; - let const_u32 = |v: Value| match const_ctor(v) { - ConstCtor::SpvInst(spv_inst) => { + let const_u32 = |v: Value| match const_kind(v) { + ConstKind::SpvInst { + spv_inst_and_const_inputs, + } => { + let (spv_inst, _const_inputs) = &**spv_inst_and_const_inputs; assert!(spv_inst.opcode == wk.OpConstant); match spv_inst.imms[..] { [spv::Imm::Short(_, x)] => x, @@ -505,9 +508,9 @@ impl<'a> Visitor<'a> for DiagnosticReporter<'a> { fn visit_const_use(&mut self, ct: Const) { if self.seen_consts.insert(ct) { let ct_def = &self.cx[ct]; - match ct_def.ctor { + match ct_def.kind { // HACK(eddyb) don't push an `UseOrigin` for `GlobalVar` pointers. - ConstCtor::PtrToGlobalVar(_) if ct_def.attrs == AttrSet::default() => { + ConstKind::PtrToGlobalVar(_) if ct_def.attrs == AttrSet::default() => { self.visit_const_def(ct_def); } _ => { @@ -642,12 +645,12 @@ impl<'a> Visitor<'a> for DiagnosticReporter<'a> { // Treat this like a call, in the caller. replace_origin(self, IntraFuncUseOrigin::CallCallee); - let const_ctor = |v: Value| match v { - Value::Const(ct) => &self.cx[ct].ctor, + let const_kind = |v: Value| match v { + Value::Const(ct) => &self.cx[ct].kind, _ => unreachable!(), }; - let const_str = |v: Value| match const_ctor(v) { - &ConstCtor::SpvStringLiteralForExtInst(s) => s, + let const_str = |v: Value| match const_kind(v) { + &ConstKind::SpvStringLiteralForExtInst(s) => s, _ => unreachable!(), }; self.use_stack.push(UseOrigin::IntraFunc { diff --git a/crates/rustc_codegen_spirv/src/linker/spirt_passes/mod.rs b/crates/rustc_codegen_spirv/src/linker/spirt_passes/mod.rs index 78ef09725a..e2e3d4f972 100644 --- a/crates/rustc_codegen_spirv/src/linker/spirt_passes/mod.rs +++ b/crates/rustc_codegen_spirv/src/linker/spirt_passes/mod.rs @@ -17,7 +17,6 @@ use spirt::{ FuncDefBody, GlobalVar, Module, Type, Value, }; use std::collections::VecDeque; -use std::hash::Hash; use std::iter; // HACK(eddyb) `spv::spec::Spec` with extra `WellKnown`s (that should be upstreamed). @@ -264,88 +263,11 @@ const _: () = { } fn visit_control_node_def(&mut self, func_at_control_node: FuncAt<'a, ControlNode>) { (self.visit_control_node)(&mut self.state, func_at_control_node); - // HACK(eddyb) accidentally private `inner_visit_with` method. - fn control_node_inner_visit_with<'a>( - self_: FuncAt<'a, ControlNode>, - visitor: &mut impl Visitor<'a>, - ) { - let ControlNodeDef { kind, outputs } = self_.def(); - - match kind { - ControlNodeKind::Block { insts } => { - for func_at_inst in self_.at(*insts) { - visitor.visit_data_inst_def(func_at_inst.def()); - } - } - ControlNodeKind::Select { - kind: SelectionKind::BoolCond | SelectionKind::SpvInst(_), - scrutinee, - cases, - } => { - visitor.visit_value_use(scrutinee); - for &case in cases { - visitor.visit_control_region_def(self_.at(case)); - } - } - ControlNodeKind::Loop { - initial_inputs, - body, - repeat_condition, - } => { - for v in initial_inputs { - visitor.visit_value_use(v); - } - visitor.visit_control_region_def(self_.at(*body)); - visitor.visit_value_use(repeat_condition); - } - } - for output in outputs { - output.inner_visit_with(visitor); - } - } - control_node_inner_visit_with(func_at_control_node, self); + func_at_control_node.inner_visit_with(self); } } }; -// HACK(eddyb) this works around the accidental lack of `spirt::Value: Hash`. -#[derive(Copy, Clone, PartialEq, Eq)] -struct HashableValue(Value); -#[allow(clippy::derived_hash_with_manual_eq)] -impl Hash for HashableValue { - fn hash(&self, state: &mut H) { - use spirt::*; - #[derive(Hash)] - enum ValueH { - Const(Const), - ControlRegionInput { - region: ControlRegion, - input_idx: u32, - }, - ControlNodeOutput { - control_node: ControlNode, - output_idx: u32, - }, - DataInstOutput(DataInst), - } - match self.0 { - Value::Const(ct) => ValueH::Const(ct), - Value::ControlRegionInput { region, input_idx } => { - ValueH::ControlRegionInput { region, input_idx } - } - Value::ControlNodeOutput { - control_node, - output_idx, - } => ValueH::ControlNodeOutput { - control_node, - output_idx, - }, - Value::DataInstOutput(inst) => ValueH::DataInstOutput(inst), - } - .hash(state); - } -} - // FIXME(eddyb) maybe this should be provided by `spirt::transform`. struct ReplaceValueWith(F); const _: () = { @@ -378,7 +300,7 @@ fn remove_unused_values_in_func(cx: &Context, func_def_body: &mut FuncDefBody) { // FIXME(eddyb) entity-keyed dense sets might be better for performance, // but would require separate sets/maps for separate `Value` cases. - used: FxHashSet, + used: FxHashSet, queue: VecDeque, } @@ -396,7 +318,7 @@ fn remove_unused_values_in_func(cx: &Context, func_def_body: &mut FuncDefBody) { return; } } - if self.used.insert(HashableValue(v)) { + if self.used.insert(v) { self.queue.push_back(v); } } @@ -476,8 +398,8 @@ fn remove_unused_values_in_func(cx: &Context, func_def_body: &mut FuncDefBody) { propagator.mark_used(v); propagator.propagate_used(func_at_control_node.at(())); }; - match func_at_control_node.def().kind { - ControlNodeKind::Block { insts } => { + match &func_at_control_node.def().kind { + &ControlNodeKind::Block { insts } => { for func_at_inst in func_at_control_node.at(insts) { // Ignore pure instructions (i.e. they're only used // if their output value is used, from somewhere else). @@ -496,11 +418,20 @@ fn remove_unused_values_in_func(cx: &Context, func_def_body: &mut FuncDefBody) { } } - ControlNodeKind::Select { scrutinee: v, .. } - | ControlNodeKind::Loop { + &ControlNodeKind::Select { scrutinee: v, .. } + | &ControlNodeKind::Loop { repeat_condition: v, .. } => mark_used_and_propagate(v), + + ControlNodeKind::ExitInvocation { + kind: spirt::cfg::ExitInvocationKind::SpvInst(_), + inputs, + } => { + for &v in inputs { + mark_used_and_propagate(v); + } + } } }, }; @@ -535,9 +466,7 @@ fn remove_unused_values_in_func(cx: &Context, func_def_body: &mut FuncDefBody) { continue; } } - if !used_values - .contains(&HashableValue(Value::DataInstOutput(func_at_inst.position))) - { + if !used_values.contains(&Value::DataInstOutput(func_at_inst.position)) { // Replace the removed `DataInstDef` itself with `OpNop`, // removing the ability to use its "name" as a value. // @@ -574,7 +503,7 @@ fn remove_unused_values_in_func(cx: &Context, func_def_body: &mut FuncDefBody) { output_idx: original_idx as u32, }; - if !used_values.contains(&HashableValue(original_output)) { + if !used_values.contains(&original_output) { // Remove the output definition and corresponding value from all cases. func_def_body .at_mut(control_node) @@ -593,11 +522,12 @@ fn remove_unused_values_in_func(cx: &Context, func_def_body: &mut FuncDefBody) { control_node, output_idx: new_idx as u32, }; - value_replacements.insert(HashableValue(original_output), new_output); + value_replacements.insert(original_output, new_output); } new_idx += 1; } } + ControlNodeKind::Loop { body, initial_inputs, @@ -612,7 +542,7 @@ fn remove_unused_values_in_func(cx: &Context, func_def_body: &mut FuncDefBody) { input_idx: original_idx as u32, }; - if !used_values.contains(&HashableValue(original_input)) { + if !used_values.contains(&original_input) { // Remove the input definition and corresponding values. match &mut func_def_body.at_mut(control_node).def().kind { ControlNodeKind::Loop { initial_inputs, .. } => { @@ -632,18 +562,20 @@ fn remove_unused_values_in_func(cx: &Context, func_def_body: &mut FuncDefBody) { region: body, input_idx: new_idx as u32, }; - value_replacements.insert(HashableValue(original_input), new_input); + value_replacements.insert(original_input, new_input); } new_idx += 1; } } + + ControlNodeKind::ExitInvocation { .. } => {} } } if !value_replacements.is_empty() { func_def_body.inner_in_place_transform_with(&mut ReplaceValueWith(|v| match v { Value::Const(_) => None, - _ => value_replacements.get(&HashableValue(v)).copied(), + _ => value_replacements.get(&v).copied(), })); } } diff --git a/crates/rustc_codegen_spirv/src/linker/spirt_passes/reduce.rs b/crates/rustc_codegen_spirv/src/linker/spirt_passes/reduce.rs index a4750586e7..aa1b96b2cb 100644 --- a/crates/rustc_codegen_spirv/src/linker/spirt_passes/reduce.rs +++ b/crates/rustc_codegen_spirv/src/linker/spirt_passes/reduce.rs @@ -4,16 +4,16 @@ use spirt::func_at::{FuncAt, FuncAtMut}; use spirt::transform::InnerInPlaceTransform; use spirt::visit::InnerVisit; use spirt::{ - spv, Const, ConstCtor, ConstDef, Context, ControlNode, ControlNodeDef, ControlNodeKind, + spv, Const, ConstDef, ConstKind, Context, ControlNode, ControlNodeDef, ControlNodeKind, ControlNodeOutputDecl, ControlRegion, ControlRegionInputDecl, DataInst, DataInstDef, DataInstFormDef, DataInstKind, EntityOrientedDenseMap, FuncDefBody, SelectionKind, Type, - TypeCtor, TypeDef, Value, + TypeDef, TypeKind, Value, }; use std::collections::hash_map::Entry; -use std::hash::Hash; use std::{iter, slice}; -use super::{HashableValue, ReplaceValueWith, VisitAllControlRegionsAndNodes}; +use super::{ReplaceValueWith, VisitAllControlRegionsAndNodes}; +use std::rc::Rc; /// Apply "reduction rules" to `func_def_body`, replacing (pure) computations /// with one of their inputs or a constant (e.g. `x + 0 => x` or `1 + 2 => 3`), @@ -87,9 +87,7 @@ pub(crate) fn reduce_in_func(cx: &Context, func_def_body: &mut FuncDefBody) { control_node: func_at_control_node.position, output_idx: i, }; - if let Entry::Vacant(entry) = - value_replacements.entry(HashableValue(output)) - { + if let Entry::Vacant(entry) = value_replacements.entry(output) { let per_case_value = cases.iter().map(|&case| { func_at_control_node.at(case).def().outputs[i as usize] }); @@ -132,8 +130,10 @@ pub(crate) fn reduce_in_func(cx: &Context, func_def_body: &mut FuncDefBody) { op: PureOp::IntToBool, output_type: cx.intern(TypeDef { attrs: Default::default(), - ctor: TypeCtor::SpvInst(wk.OpTypeBool.into()), - ctor_args: iter::empty().collect(), + kind: TypeKind::SpvInst { + spv_inst: wk.OpTypeBool.into(), + type_and_const_inputs: iter::empty().collect(), + }, }), input: *scrutinee, }; @@ -166,11 +166,16 @@ pub(crate) fn reduce_in_func(cx: &Context, func_def_body: &mut FuncDefBody) { }; if body_output == body_input { value_replacements - .entry(HashableValue(body_input)) + .entry(body_input) .or_insert(initial_input); } } } + + &ControlNodeDef { + kind: ControlNodeKind::ExitInvocation { .. }, + .. + } => {} }; func_def_body.inner_visit_with(&mut VisitAllControlRegionsAndNodes { state: (), @@ -197,7 +202,7 @@ pub(crate) fn reduce_in_func(cx: &Context, func_def_body: &mut FuncDefBody) { any_changes = true; match redu_target { ReductionTarget::DataInst(inst) => { - value_replacements.insert(HashableValue(Value::DataInstOutput(inst)), v); + value_replacements.insert(Value::DataInstOutput(inst), v); // Replace the reduced `DataInstDef` itself with `OpNop`, // removing the ability to use its "name" as a value. @@ -243,7 +248,7 @@ pub(crate) fn reduce_in_func(cx: &Context, func_def_body: &mut FuncDefBody) { loop { match v { Value::Const(_) => break, - _ => match value_replacements.get(&HashableValue(v)) { + _ => match value_replacements.get(&v) { Some(&new) => v = new, None => break, }, @@ -292,6 +297,7 @@ impl ParentMap { ControlNodeKind::Select { cases, .. } => cases, ControlNodeKind::Loop { body, .. } => slice::from_ref(body), + ControlNodeKind::ExitInvocation { .. } => &[][..], }; for &child_region in child_regions { this.control_region_parent @@ -319,8 +325,13 @@ fn try_reduce_select( let wk = &super::SpvSpecWithExtras::get().well_known; let as_spv_const = |v: Value| match v { - Value::Const(ct) => match &cx[ct].ctor { - ConstCtor::SpvInst(spv_inst) => Some(spv_inst.opcode), + Value::Const(ct) => match &cx[ct].kind { + ConstKind::SpvInst { + spv_inst_and_const_inputs, + } => { + let (spv_inst, _const_inputs) = &**spv_inst_and_const_inputs; + Some(spv_inst.opcode) + } _ => None, }, _ => None, @@ -476,22 +487,13 @@ impl TryFrom for spv::Inst { } /// Potentially-reducible application of a `PureOp` (`op`) to `input`. -#[derive(Copy, Clone, PartialEq, Eq)] +#[derive(Copy, Clone, PartialEq, Eq, Hash)] struct Reducible { op: PureOp, output_type: Type, input: V, } -// HACK(eddyb) this works around the accidental lack of `spirt::Value: Hash`. -impl Hash for Reducible { - fn hash(&self, state: &mut H) { - self.op.hash(state); - self.output_type.hash(state); - HashableValue(self.input).hash(state); - } -} - impl Reducible { fn with_input(self, new_input: V2) -> Reducible { Reducible { @@ -565,20 +567,27 @@ impl Reducible { let wk = &super::SpvSpecWithExtras::get().well_known; let ct_def = &cx[self.input]; - match (self.op, &ct_def.ctor) { - (_, ConstCtor::SpvInst(spv_inst)) if spv_inst.opcode == wk.OpUndef => { - Some(cx.intern(ConstDef { - attrs: ct_def.attrs, - ty: self.output_type, - ctor: ct_def.ctor.clone(), - ctor_args: iter::empty().collect(), - })) - } + match (self.op, &ct_def.kind) { + ( + _, + ConstKind::SpvInst { + spv_inst_and_const_inputs, + }, + ) if spv_inst_and_const_inputs.0.opcode == wk.OpUndef => Some(cx.intern(ConstDef { + attrs: ct_def.attrs, + ty: self.output_type, + kind: ct_def.kind.clone(), + })), - (PureOp::BitCast, ConstCtor::SpvInst(spv_inst)) if spv_inst.opcode == wk.OpConstant => { + ( + PureOp::BitCast, + ConstKind::SpvInst { + spv_inst_and_const_inputs, + }, + ) if spv_inst_and_const_inputs.0.opcode == wk.OpConstant => { // `OpTypeInt`/`OpTypeFloat` bit width. - let scalar_width = |ty: Type| match &cx[ty].ctor { - TypeCtor::SpvInst(spv_inst) + let scalar_width = |ty: Type| match &cx[ty].kind { + TypeKind::SpvInst { spv_inst, .. } if [wk.OpTypeInt, wk.OpTypeFloat].contains(&spv_inst.opcode) => { Some(spv_inst.imms[0]) @@ -590,8 +599,7 @@ impl Reducible { (Some(from), Some(to)) if from == to => Some(cx.intern(ConstDef { attrs: ct_def.attrs, ty: self.output_type, - ctor: ct_def.ctor.clone(), - ctor_args: ct_def.ctor_args.clone(), + kind: ct_def.kind.clone(), })), _ => None, } @@ -601,14 +609,21 @@ impl Reducible { PureOp::CompositeExtract { elem_idx: spv::Imm::Short(_, elem_idx), }, - ConstCtor::SpvInst(spv_inst), - ) if spv_inst.opcode == wk.OpConstantComposite => { - Some(ct_def.ctor_args[elem_idx as usize]) + ConstKind::SpvInst { + spv_inst_and_const_inputs, + }, + ) if spv_inst_and_const_inputs.0.opcode == wk.OpConstantComposite => { + let (_spv_inst, const_inputs) = &**spv_inst_and_const_inputs; + Some(const_inputs[elem_idx as usize]) } - (PureOp::IntToBool, ConstCtor::SpvInst(spv_inst)) - if spv_inst.opcode == wk.OpConstant => - { + ( + PureOp::IntToBool, + ConstKind::SpvInst { + spv_inst_and_const_inputs, + }, + ) if spv_inst_and_const_inputs.0.opcode == wk.OpConstant => { + let (spv_inst, _const_inputs) = &**spv_inst_and_const_inputs; let bool_const_op = match spv_imm_checked_trunc32(&spv_inst.imms[..]) { Some(0) => wk.OpConstantFalse, Some(1) => wk.OpConstantTrue, @@ -617,8 +632,12 @@ impl Reducible { Some(cx.intern(ConstDef { attrs: Default::default(), ty: self.output_type, - ctor: ConstCtor::SpvInst(bool_const_op.into()), - ctor_args: iter::empty().collect(), + kind: ConstKind::SpvInst { + spv_inst_and_const_inputs: Rc::new(( + bool_const_op.into(), + iter::empty().collect(), + )), + }, })) } @@ -680,7 +699,7 @@ impl Reducible { // FIXME(eddyb) come up with a better convention for this! func: FuncAtMut<'_, ()>, - value_replacements: &FxHashMap, + value_replacements: &FxHashMap, parent_map: &ParentMap, @@ -693,7 +712,7 @@ impl Reducible { // the first time they're encountered, but also, if this process was more // "demand-driven" (recursing into use->def, instead of processing defs), // it might not require any of this complication. - while let Some(&replacement) = value_replacements.get(&HashableValue(self.input)) { + while let Some(&replacement) = value_replacements.get(&self.input) { self.input = replacement; } @@ -715,7 +734,7 @@ impl Reducible { // FIXME(eddyb) come up with a better convention for this! mut func: FuncAtMut<'_, ()>, - value_replacements: &FxHashMap, + value_replacements: &FxHashMap, parent_map: &ParentMap, diff --git a/docs/src/codegen-args.md b/docs/src/codegen-args.md index 2dda3864b9..4a08ca5e37 100644 --- a/docs/src/codegen-args.md +++ b/docs/src/codegen-args.md @@ -208,3 +208,11 @@ all the "file contents debuginfo" (i.e. from SPIR-V `OpSource` instructions), which will end up being included, in full, at the start of the dump. The default (of hiding the file contents) is less verbose, but (arguably) lossier. + +### `--spirt-keep-unstructured-cfg-in-dumps` + +When dumping (pretty-printed) `SPIR-🇹` (e.g. with `--dump-spirt-passes`), include +the initial unstructured state, as well (i.e. just after lowering from SPIR-V). + +The default (of only dumping structured SPIR-T) can have far less noisy dataflow, +but unstructured SPIR-T may be needed for e.g. debugging the structurizer itself. diff --git a/tests/ui/lang/core/unwrap_or.stderr b/tests/ui/lang/core/unwrap_or.stderr index 7349d6eb0e..0b39d5b926 100644 --- a/tests/ui/lang/core/unwrap_or.stderr +++ b/tests/ui/lang/core/unwrap_or.stderr @@ -15,17 +15,9 @@ OpBranch %18 %20 = OpLabel OpBranch %18 %18 = OpLabel -%21 = OpPhi %16 %22 %19 %23 %20 -%24 = OpPhi %11 %25 %19 %10 %20 -OpSelectionMerge %26 None -OpBranchConditional %21 %27 %28 -%27 = OpLabel -OpBranch %26 -%28 = OpLabel -OpBranch %26 -%26 = OpLabel +%21 = OpPhi %11 %22 %19 %10 %20 OpLine %5 13 4 -OpStore %29 %24 +OpStore %23 %21 OpNoLine OpReturn OpFunctionEnd From d3b47d6da9a8c9e3fe2cccbb2ea285d5b7220ef7 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Thu, 22 Feb 2024 02:08:10 +0200 Subject: [PATCH 27/32] WIP: mem2reg speedup --- crates/rustc_codegen_spirv/src/linker/dce.rs | 11 ++- .../rustc_codegen_spirv/src/linker/mem2reg.rs | 91 +++++++++++-------- crates/rustc_codegen_spirv/src/linker/mod.rs | 5 +- 3 files changed, 62 insertions(+), 45 deletions(-) diff --git a/crates/rustc_codegen_spirv/src/linker/dce.rs b/crates/rustc_codegen_spirv/src/linker/dce.rs index 3cc865a741..896406c4e9 100644 --- a/crates/rustc_codegen_spirv/src/linker/dce.rs +++ b/crates/rustc_codegen_spirv/src/linker/dce.rs @@ -7,9 +7,10 @@ //! *references* a rooted thing is also rooted, not the other way around - but that's the basic //! concept. -use rspirv::dr::{Function, Instruction, Module, Operand}; +use rspirv::dr::{Block, Function, Instruction, Module, Operand}; use rspirv::spirv::{Decoration, LinkageType, Op, StorageClass, Word}; -use rustc_data_structures::fx::FxIndexSet; +use rustc_data_structures::fx::{FxIndexMap, FxIndexSet}; +use std::hash::Hash; pub fn dce(module: &mut Module) { let mut rooted = collect_roots(module); @@ -137,11 +138,11 @@ fn kill_unrooted(module: &mut Module, rooted: &FxIndexSet) { } } -pub fn dce_phi(func: &mut Function) { +pub fn dce_phi(blocks: &mut FxIndexMap) { let mut used = FxIndexSet::default(); loop { let mut changed = false; - for inst in func.all_inst_iter() { + for inst in blocks.values().flat_map(|block| &block.instructions) { if inst.class.opcode != Op::Phi || used.contains(&inst.result_id.unwrap()) { for op in &inst.operands { if let Some(id) = op.id_ref_any() { @@ -154,7 +155,7 @@ pub fn dce_phi(func: &mut Function) { break; } } - for block in &mut func.blocks { + for block in blocks.values_mut() { block .instructions .retain(|inst| inst.class.opcode != Op::Phi || used.contains(&inst.result_id.unwrap())); diff --git a/crates/rustc_codegen_spirv/src/linker/mem2reg.rs b/crates/rustc_codegen_spirv/src/linker/mem2reg.rs index 2f93e2b340..9f203084da 100644 --- a/crates/rustc_codegen_spirv/src/linker/mem2reg.rs +++ b/crates/rustc_codegen_spirv/src/linker/mem2reg.rs @@ -13,10 +13,14 @@ use super::simple_passes::outgoing_edges; use super::{apply_rewrite_rules, id}; use rspirv::dr::{Block, Function, Instruction, ModuleHeader, Operand}; use rspirv::spirv::{Op, Word}; -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; use rustc_middle::bug; use std::collections::hash_map; +// HACK(eddyb) newtype instead of type alias to avoid mistakes. +#[derive(Copy, Clone, PartialEq, Eq, Hash)] +struct LabelId(Word); + pub fn mem2reg( header: &mut ModuleHeader, types_global_values: &mut Vec, @@ -24,8 +28,16 @@ pub fn mem2reg( constants: &FxHashMap, func: &mut Function, ) { - let reachable = compute_reachable(&func.blocks); - let preds = compute_preds(&func.blocks, &reachable); + // HACK(eddyb) this ad-hoc indexing might be useful elsewhere as well, but + // it's made completely irrelevant by SPIR-T so only applies to legacy code. + let mut blocks: FxIndexMap<_, _> = func + .blocks + .iter_mut() + .map(|block| (LabelId(block.label_id().unwrap()), block)) + .collect(); + + let reachable = compute_reachable(&blocks); + let preds = compute_preds(&blocks, &reachable); let idom = compute_idom(&preds, &reachable); let dominance_frontier = compute_dominance_frontier(&preds, &idom); loop { @@ -34,31 +46,27 @@ pub fn mem2reg( types_global_values, pointer_to_pointee, constants, - &mut func.blocks, + &mut blocks, &dominance_frontier, ); if !changed { break; } // mem2reg produces minimal SSA form, not pruned, so DCE the dead ones - super::dce::dce_phi(func); + super::dce::dce_phi(&mut blocks); } } -fn label_to_index(blocks: &[Block], id: Word) -> usize { - blocks - .iter() - .position(|b| b.label_id().unwrap() == id) - .unwrap() -} - -fn compute_reachable(blocks: &[Block]) -> Vec { - fn recurse(blocks: &[Block], reachable: &mut [bool], block: usize) { +fn compute_reachable(blocks: &FxIndexMap) -> Vec { + fn recurse(blocks: &FxIndexMap, reachable: &mut [bool], block: usize) { if !reachable[block] { reachable[block] = true; - for dest_id in outgoing_edges(&blocks[block]) { - let dest_idx = label_to_index(blocks, dest_id); - recurse(blocks, reachable, dest_idx); + for dest_id in outgoing_edges(blocks[block]) { + recurse( + blocks, + reachable, + blocks.get_index_of(&LabelId(dest_id)).unwrap(), + ); } } } @@ -67,17 +75,19 @@ fn compute_reachable(blocks: &[Block]) -> Vec { reachable } -fn compute_preds(blocks: &[Block], reachable_blocks: &[bool]) -> Vec> { +fn compute_preds( + blocks: &FxIndexMap, + reachable_blocks: &[bool], +) -> Vec> { let mut result = vec![vec![]; blocks.len()]; // Do not count unreachable blocks as valid preds of blocks for (source_idx, source) in blocks - .iter() + .values() .enumerate() .filter(|&(b, _)| reachable_blocks[b]) { for dest_id in outgoing_edges(source) { - let dest_idx = label_to_index(blocks, dest_id); - result[dest_idx].push(source_idx); + result[blocks.get_index_of(&LabelId(dest_id)).unwrap()].push(source_idx); } } result @@ -161,7 +171,7 @@ fn insert_phis_all( types_global_values: &mut Vec, pointer_to_pointee: &FxHashMap, constants: &FxHashMap, - blocks: &mut [Block], + blocks: &mut FxIndexMap, dominance_frontier: &[FxHashSet], ) -> bool { let var_maps_and_types = blocks[0] @@ -198,7 +208,11 @@ fn insert_phis_all( rewrite_rules: FxHashMap::default(), }; renamer.rename(0, None); - apply_rewrite_rules(&renamer.rewrite_rules, blocks); + // FIXME(eddyb) shouldn't this full rescan of the function be done once? + apply_rewrite_rules( + &renamer.rewrite_rules, + blocks.values_mut().map(|block| &mut **block), + ); remove_nops(blocks); } remove_old_variables(blocks, &var_maps_and_types); @@ -216,7 +230,7 @@ struct VarInfo { fn collect_access_chains( pointer_to_pointee: &FxHashMap, constants: &FxHashMap, - blocks: &[Block], + blocks: &FxIndexMap, base_var: Word, base_var_ty: Word, ) -> Option> { @@ -249,7 +263,7 @@ fn collect_access_chains( // Loop in case a previous block references a later AccessChain loop { let mut changed = false; - for inst in blocks.iter().flat_map(|b| &b.instructions) { + for inst in blocks.values().flat_map(|b| &b.instructions) { for (index, op) in inst.operands.iter().enumerate() { if let Operand::IdRef(id) = op { if variables.contains_key(id) { @@ -307,10 +321,10 @@ fn collect_access_chains( // same var map (e.g. `s.x = s.y;`). fn split_copy_memory( header: &mut ModuleHeader, - blocks: &mut [Block], + blocks: &mut FxIndexMap, var_map: &FxHashMap, ) { - for block in blocks { + for block in blocks.values_mut() { let mut inst_index = 0; while inst_index < block.instructions.len() { let inst = &block.instructions[inst_index]; @@ -369,7 +383,7 @@ fn has_store(block: &Block, var_map: &FxHashMap) -> bool { } fn insert_phis( - blocks: &[Block], + blocks: &FxIndexMap, dominance_frontier: &[FxHashSet], var_map: &FxHashMap, ) -> FxHashSet { @@ -378,7 +392,7 @@ fn insert_phis( let mut ever_on_work_list = FxHashSet::default(); let mut work_list = Vec::new(); let mut blocks_with_phi = FxHashSet::default(); - for (block_idx, block) in blocks.iter().enumerate() { + for (block_idx, block) in blocks.values().enumerate() { if has_store(block, var_map) { ever_on_work_list.insert(block_idx); work_list.push(block_idx); @@ -423,10 +437,10 @@ fn top_stack_or_undef( } } -struct Renamer<'a> { +struct Renamer<'a, 'b> { header: &'a mut ModuleHeader, types_global_values: &'a mut Vec, - blocks: &'a mut [Block], + blocks: &'a mut FxIndexMap, blocks_with_phi: FxHashSet, base_var_type: Word, var_map: &'a FxHashMap, @@ -436,7 +450,7 @@ struct Renamer<'a> { rewrite_rules: FxHashMap, } -impl Renamer<'_> { +impl Renamer<'_, '_> { // Returns the phi definition. fn insert_phi_value(&mut self, block: usize, from_block: usize) -> Word { let from_block_label = self.blocks[from_block].label_id().unwrap(); @@ -558,9 +572,8 @@ impl Renamer<'_> { } } - for dest_id in outgoing_edges(&self.blocks[block]).collect::>() { - // TODO: Don't do this find - let dest_idx = label_to_index(self.blocks, dest_id); + for dest_id in outgoing_edges(self.blocks[block]).collect::>() { + let dest_idx = self.blocks.get_index_of(&LabelId(dest_id)).unwrap(); self.rename(dest_idx, Some(block)); } @@ -570,8 +583,8 @@ impl Renamer<'_> { } } -fn remove_nops(blocks: &mut [Block]) { - for block in blocks { +fn remove_nops(blocks: &mut FxIndexMap) { + for block in blocks.values_mut() { block .instructions .retain(|inst| inst.class.opcode != Op::Nop); @@ -579,7 +592,7 @@ fn remove_nops(blocks: &mut [Block]) { } fn remove_old_variables( - blocks: &mut [Block], + blocks: &mut FxIndexMap, var_maps_and_types: &[(FxHashMap, u32)], ) { blocks[0].instructions.retain(|inst| { @@ -590,7 +603,7 @@ fn remove_old_variables( .all(|(var_map, _)| !var_map.contains_key(&result_id)) } }); - for block in blocks { + for block in blocks.values_mut() { block.instructions.retain(|inst| { !matches!(inst.class.opcode, Op::AccessChain | Op::InBoundsAccessChain) || inst.operands.iter().all(|op| { diff --git a/crates/rustc_codegen_spirv/src/linker/mod.rs b/crates/rustc_codegen_spirv/src/linker/mod.rs index 96ad90a4d8..7abb72cd93 100644 --- a/crates/rustc_codegen_spirv/src/linker/mod.rs +++ b/crates/rustc_codegen_spirv/src/linker/mod.rs @@ -86,7 +86,10 @@ fn id(header: &mut ModuleHeader) -> Word { result } -fn apply_rewrite_rules(rewrite_rules: &FxHashMap, blocks: &mut [Block]) { +fn apply_rewrite_rules<'a>( + rewrite_rules: &FxHashMap, + blocks: impl IntoIterator, +) { let apply = |inst: &mut Instruction| { if let Some(ref mut id) = &mut inst.result_id { if let Some(&rewrite) = rewrite_rules.get(id) { From 252bd9d003dcf248ac97a88d0e68acbeac6c0859 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 27 Feb 2024 00:23:37 +0200 Subject: [PATCH 28/32] WIP: couple of inliner things that need to be disentangled --- .../rustc_codegen_spirv/src/linker/inline.rs | 297 ++++++++---------- tests/ui/lang/consts/nested-ref.stderr | 18 +- .../core/ref/member_ref_arg-broken.stderr | 38 ++- tests/ui/lang/core/ref/member_ref_arg.stderr | 20 ++ tests/ui/lang/panic/track_caller.stderr | 11 + 5 files changed, 214 insertions(+), 170 deletions(-) create mode 100644 tests/ui/lang/core/ref/member_ref_arg.stderr create mode 100644 tests/ui/lang/panic/track_caller.stderr diff --git a/crates/rustc_codegen_spirv/src/linker/inline.rs b/crates/rustc_codegen_spirv/src/linker/inline.rs index 6b3992eac7..23bf150b82 100644 --- a/crates/rustc_codegen_spirv/src/linker/inline.rs +++ b/crates/rustc_codegen_spirv/src/linker/inline.rs @@ -8,13 +8,15 @@ use super::apply_rewrite_rules; use super::ipo::CallGraph; use super::simple_passes::outgoing_edges; use super::{get_name, get_names}; +use crate::custom_decorations::SpanRegenerator; use crate::custom_insts::{self, CustomInst, CustomOp}; use rspirv::dr::{Block, Function, Instruction, Module, ModuleHeader, Operand}; use rspirv::spirv::{FunctionControl, Op, StorageClass, Word}; -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet}; use rustc_errors::ErrorGuaranteed; use rustc_session::Session; use smallvec::SmallVec; +use std::cmp::Ordering; use std::mem; // FIXME(eddyb) this is a bit silly, but this keeps being repeated everywhere. @@ -40,40 +42,10 @@ pub fn inline(sess: &Session, module: &mut Module) -> super::Result<()> { }) .map(|inst| inst.result_id.unwrap()); - /* - // Drop all the functions we'll be inlining. (This also means we won't waste time processing - // inlines in functions that will get inlined) - let mut dropped_ids = FxHashSet::default(); - let mut inlined_to_legalize_dont_inlines = Vec::new(); - module.functions.retain(|f| { - let should_inline_f = should_inline(&legal_globals, &functions_that_may_abort, f, None); - if should_inline_f != Ok(false) { - if should_inline_f == Err(MustInlineToLegalize) && has_dont_inline(f) { - inlined_to_legalize_dont_inlines.push(f.def_id().unwrap()); - } - // TODO: We should insert all defined IDs in this function. - dropped_ids.insert(f.def_id().unwrap()); - false - } else { - true - } - }); - - if !inlined_to_legalize_dont_inlines.is_empty() { - let names = get_names(module); - for f in inlined_to_legalize_dont_inlines { - sess.dcx().warn(format!( - "`#[inline(never)]` function `{}` needs to be inlined \ - because it has illegal argument or return types", - get_name(&names, f) - )); - } - } - */ - let legal_globals = LegalGlobal::gather_from_module(module); let header = module.header.as_mut().unwrap(); + // FIXME(eddyb) clippy false positive (seperate `map` required for borrowck). #[allow(clippy::map_unwrap_or)] let mut inliner = Inliner { @@ -153,6 +125,8 @@ pub fn inline(sess: &Session, module: &mut Module) -> super::Result<()> { .then_some(func.def_id().unwrap()) }) .collect(), + + inlined_dont_inlines_to_cause_and_callers: FxIndexMap::default(), }; let mut functions: Vec<_> = mem::take(&mut module.functions) @@ -171,14 +145,52 @@ pub fn inline(sess: &Session, module: &mut Module) -> super::Result<()> { module.functions = functions.into_iter().map(|func| func.unwrap()).collect(); - /* - // Drop OpName etc. for inlined functions - module.debug_names.retain(|inst| { - !inst.operands.iter().any(|op| { - op.id_ref_any() - .map_or(false, |id| dropped_ids.contains(&id)) - }) - });*/ + let Inliner { + id_to_name, + inlined_dont_inlines_to_cause_and_callers, + .. + } = inliner; + + let mut span_regen = SpanRegenerator::new(sess.source_map(), module); + for (callee_id, (cause, callers)) in inlined_dont_inlines_to_cause_and_callers { + let callee_name = get_name(&id_to_name, callee_id); + + // HACK(eddyb) `libcore` hides panics behind `#[inline(never)]` `fn`s, + // making this too noisy and useless (since it's an impl detail). + if cause == "panicking" && callee_name.starts_with("core::") { + continue; + } + + let callee_span = span_regen + .src_loc_for_id(callee_id) + .and_then(|src_loc| span_regen.src_loc_to_rustc(src_loc)) + .unwrap_or_default(); + sess.dcx() + .struct_span_warn( + callee_span, + format!("`#[inline(never)]` function `{callee_name}` has been inlined"), + ) + .with_note(format!("inlining was required due to {cause}")) + .with_note(format!( + "called from {}", + callers + .iter() + .enumerate() + .filter_map(|(i, &caller_id)| { + // HACK(eddyb) avoid showing too many names. + match i.cmp(&4) { + Ordering::Less => { + Some(format!("`{}`", get_name(&id_to_name, caller_id))) + } + Ordering::Equal => Some(format!("and {} more", callers.len() - i)), + Ordering::Greater => None, + } + }) + .collect::>() + .join(", ") + )) + .emit(); + } Ok(()) } @@ -361,42 +373,42 @@ fn has_dont_inline(function: &Function) -> bool { /// Helper error type for `should_inline` (see its doc comment). #[derive(Copy, Clone, PartialEq, Eq)] -struct MustInlineToLegalize; +struct MustInlineToLegalize(&'static str); -/// Returns `Ok(true)`/`Err(MustInlineToLegalize)` if `callee` should/must be +/// Returns `Ok(true)`/`Err(MustInlineToLegalize(_))` if `callee` should/must be /// inlined (either in general, or specifically from `call_site`, if provided). /// -/// The distinction made is that `Err(MustInlineToLegalize)` is not a heuristic, -/// and inlining is *mandatory* due to an illegal signature/arguments. +/// The distinction made here is that `Err(MustInlineToLegalize(cause))` is +/// very much *not* a heuristic, and inlining is *mandatory* due to `cause` +/// (usually illegal signature/arguments, but also the panicking mechanism). +// +// FIXME(eddyb) the causes here are not fine-grained enough. fn should_inline( legal_globals: &FxHashMap, functions_that_may_abort: &FxHashSet, callee: &Function, - call_site: Option>, + call_site: CallSite<'_>, ) -> Result { let callee_def = callee.def.as_ref().unwrap(); let callee_control = callee_def.operands[0].unwrap_function_control(); - // HACK(eddyb) this "has a call-site" check ensures entry-points don't get - // accidentally removed as "must inline to legalize" function, but can still - // be inlined into other entry-points (if such an unusual situation arises). - if call_site.is_some() && functions_that_may_abort.contains(&callee.def_id().unwrap()) { - return Err(MustInlineToLegalize); + if functions_that_may_abort.contains(&callee.def_id().unwrap()) { + return Err(MustInlineToLegalize("panicking")); } let ret_ty = legal_globals .get(&callee_def.result_type.unwrap()) - .ok_or(MustInlineToLegalize)?; + .ok_or(MustInlineToLegalize("illegal return type"))?; if !ret_ty.legal_as_fn_ret_ty() { - return Err(MustInlineToLegalize); + return Err(MustInlineToLegalize("illegal (pointer) return type")); } for (i, param) in callee.parameters.iter().enumerate() { let param_ty = legal_globals .get(param.result_type.as_ref().unwrap()) - .ok_or(MustInlineToLegalize)?; + .ok_or(MustInlineToLegalize("illegal parameter type"))?; if !param_ty.legal_as_fn_param_ty() { - return Err(MustInlineToLegalize); + return Err(MustInlineToLegalize("illegal (pointer) parameter type")); } // If the call isn't passing a legal pointer argument (a "memory object", @@ -404,13 +416,13 @@ fn should_inline( // then inlining is required to have a chance at producing legal SPIR-V. // // FIXME(eddyb) rewriting away the pointer could be another alternative. - if let (LegalGlobal::TypePointer(_), Some(call_site)) = (param_ty, call_site) { + if let LegalGlobal::TypePointer(_) = param_ty { let ptr_arg = call_site.call_inst.operands[i + 1].unwrap_id_ref(); match legal_globals.get(&ptr_arg) { Some(LegalGlobal::Variable) => {} // FIXME(eddyb) should some constants (undef/null) be allowed? - Some(_) => return Err(MustInlineToLegalize), + Some(_) => return Err(MustInlineToLegalize("illegal (pointer) argument")), None => { let mut caller_param_and_var_ids = call_site @@ -436,7 +448,7 @@ fn should_inline( .map(|caller_inst| caller_inst.result_id.unwrap()); if !caller_param_and_var_ids.any(|id| ptr_arg == id) { - return Err(MustInlineToLegalize); + return Err(MustInlineToLegalize("illegal (pointer) argument")); } } } @@ -457,7 +469,7 @@ struct FuncIsBeingInlined; // Renumber IDs // Insert blocks -struct Inliner<'m> { +struct Inliner<'a, 'b> { /// ID of `OpExtInstImport` for our custom "extended instruction set" /// (see `crate::custom_insts` for more details). custom_ext_inst_set_import: Word, @@ -469,26 +481,27 @@ struct Inliner<'m> { /// Pre-collected `OpName`s, that can be used to find any function's name /// during inlining (to be able to generate debuginfo that uses names). - id_to_name: FxHashMap, + id_to_name: FxHashMap, /// `OpString` cache (for deduplicating `OpString`s for the same string). // // FIXME(eddyb) currently this doesn't reuse existing `OpString`s, but since // this is mostly for inlined callee names, it's expected almost no overlap // exists between existing `OpString`s and new ones, anyway. - cached_op_strings: FxHashMap<&'m str, Word>, + cached_op_strings: FxHashMap<&'a str, Word>, - header: &'m mut ModuleHeader, - debug_string_source: &'m mut Vec, - annotations: &'m mut Vec, - types_global_values: &'m mut Vec, + header: &'b mut ModuleHeader, + debug_string_source: &'b mut Vec, + annotations: &'b mut Vec, + types_global_values: &'b mut Vec, legal_globals: FxHashMap, functions_that_may_abort: FxHashSet, + inlined_dont_inlines_to_cause_and_callers: FxIndexMap)>, // rewrite_rules: FxHashMap, } -impl Inliner<'_> { +impl Inliner<'_, '_> { fn id(&mut self) -> Word { next_id(self.header) } @@ -580,10 +593,19 @@ impl Inliner<'_> { &self.legal_globals, &self.functions_that_may_abort, f, - Some(call_site), + call_site, ) { Ok(inline) => inline, - Err(MustInlineToLegalize) => true, + Err(MustInlineToLegalize(cause)) => { + if has_dont_inline(f) { + self.inlined_dont_inlines_to_cause_and_callers + .entry(f.def_id().unwrap()) + .or_insert_with(|| (cause, Default::default())) + .1 + .insert(caller.def_id().unwrap()); + } + true + } } }); let (call_index, call_inst, callee) = match call { @@ -610,18 +632,28 @@ impl Inliner<'_> { }; let call_result_id = call_inst.result_id.unwrap(); - // Get the debuginfo instructions that apply to the call. - // TODO(eddyb) only one instruction should be necessary here w/ bottom-up. + // Get the debug "source location" instruction that applies to the call. let custom_ext_inst_set_import = self.custom_ext_inst_set_import; - let call_debug_insts = caller.blocks[block_idx].instructions[..call_index] + let call_debug_src_loc_inst = caller.blocks[block_idx].instructions[..call_index] .iter() - .filter(|inst| match inst.class.opcode { - Op::Line | Op::NoLine => true, - Op::ExtInst if inst.operands[0].unwrap_id_ref() == custom_ext_inst_set_import => { - CustomOp::decode_from_ext_inst(inst).is_debuginfo() - } - _ => false, - }); + .rev() + .find_map(|inst| { + Some(match inst.class.opcode { + Op::Line => Some(inst), + Op::NoLine => None, + Op::ExtInst + if inst.operands[0].unwrap_id_ref() == custom_ext_inst_set_import => + { + match CustomOp::decode_from_ext_inst(inst) { + CustomOp::SetDebugSrcLoc => Some(inst), + CustomOp::ClearDebugSrcLoc => None, + _ => return None, + } + } + _ => return None, + }) + }) + .flatten(); // Rewrite parameters to arguments let call_arguments = call_inst @@ -642,9 +674,12 @@ impl Inliner<'_> { }; let return_jump = self.id(); // Rewrite OpReturns of the callee. - #[allow(clippy::needless_borrow)] - let (mut inlined_callee_blocks, extra_debug_insts_pre_call, extra_debug_insts_post_call) = - self.get_inlined_blocks(&callee, call_debug_insts, return_variable, return_jump); + let mut inlined_callee_blocks = self.get_inlined_blocks( + callee, + call_debug_src_loc_inst, + return_variable, + return_jump, + ); // Clone the IDs of the callee, because otherwise they'd be defined multiple times if the // fn is inlined multiple times. self.add_clone_id_rules(&mut rewrite_rules, &inlined_callee_blocks); @@ -666,13 +701,6 @@ impl Inliner<'_> { .unwrap(); assert!(call.class.opcode == Op::FunctionCall); - // HACK(eddyb) inject the additional debuginfo instructions generated by - // `get_inlined_blocks`, so the inlined call frame "stack" isn't corrupted. - caller.blocks[pre_call_block_idx] - .instructions - .extend(extra_debug_insts_pre_call); - post_call_block_insts.splice(0..0, extra_debug_insts_post_call); - if let Some(call_result_type) = call_result_type { // Generate the storage space for the return value: Do this *after* the split above, // because if block_idx=0, inserting a variable here shifts call_index. @@ -867,59 +895,19 @@ impl Inliner<'_> { } } - // HACK(eddyb) the second and third return values are additional debuginfo - // instructions that need to be inserted just before/after the callsite. - fn get_inlined_blocks<'a>( + fn get_inlined_blocks( &mut self, callee: &Function, - call_debug_insts: impl Iterator, + call_debug_src_loc_inst: Option<&Instruction>, return_variable: Option, return_jump: Word, - ) -> ( - Vec, - SmallVec<[Instruction; 8]>, - SmallVec<[Instruction; 8]>, - ) { + ) -> Vec { let Self { custom_ext_inst_set_import, op_type_void_id, .. } = *self; - // TODO(eddyb) kill this as it shouldn't be needed for bottom-up inline. - // HACK(eddyb) this is terrible, but we have to deal with it becasue of - // how this inliner is outside-in, instead of inside-out, meaning that - // context builds up "outside" of the callee blocks, inside the caller. - let mut enclosing_inlined_frames = SmallVec::<[_; 8]>::new(); - let mut current_debug_src_loc_inst = None; - for inst in call_debug_insts { - match inst.class.opcode { - Op::Line => current_debug_src_loc_inst = Some(inst), - Op::NoLine => current_debug_src_loc_inst = None, - Op::ExtInst - if inst.operands[0].unwrap_id_ref() == self.custom_ext_inst_set_import => - { - match CustomOp::decode_from_ext_inst(inst) { - CustomOp::SetDebugSrcLoc => current_debug_src_loc_inst = Some(inst), - CustomOp::ClearDebugSrcLoc => current_debug_src_loc_inst = None, - CustomOp::PushInlinedCallFrame => { - enclosing_inlined_frames - .push((current_debug_src_loc_inst.take(), inst)); - } - CustomOp::PopInlinedCallFrame => { - if let Some((callsite_debug_src_loc_inst, _)) = - enclosing_inlined_frames.pop() - { - current_debug_src_loc_inst = callsite_debug_src_loc_inst; - } - } - CustomOp::Abort => {} - } - } - _ => {} - } - } - // Prepare the debuginfo insts to prepend/append to every block. // FIXME(eddyb) this could be more efficient if we only used one pair of // `{Push,Pop}InlinedCallFrame` for the whole inlined callee, but there @@ -944,7 +932,7 @@ impl Inliner<'_> { )); id }); - let mut mk_debuginfo_prefix_and_suffix = |include_callee_frame| { + let mut mk_debuginfo_prefix_and_suffix = || { // NOTE(eddyb) `OpExtInst`s have a result ID, even if unused, and // it has to be unique (same goes for the other instructions below). let instantiate_debuginfo = |this: &mut Self, inst: &Instruction| { @@ -968,33 +956,18 @@ impl Inliner<'_> { .collect(), ) }; - // FIXME(eddyb) this only allocates to avoid borrow conflicts. - let mut prefix = SmallVec::<[_; 8]>::new(); - let mut suffix = SmallVec::<[_; 8]>::new(); - for &(callsite_debug_src_loc_inst, push_inlined_call_frame_inst) in - &enclosing_inlined_frames - { - prefix.extend( - callsite_debug_src_loc_inst - .into_iter() - .chain([push_inlined_call_frame_inst]) - .map(|inst| instantiate_debuginfo(self, inst)), - ); - suffix.push(custom_inst_to_inst(self, CustomInst::PopInlinedCallFrame)); - } - prefix.extend(current_debug_src_loc_inst.map(|inst| instantiate_debuginfo(self, inst))); - - if include_callee_frame { - prefix.push(custom_inst_to_inst( - self, - CustomInst::PushInlinedCallFrame { - callee_name: Operand::IdRef(callee_name_id), - }, - )); - suffix.push(custom_inst_to_inst(self, CustomInst::PopInlinedCallFrame)); - } - (prefix, suffix) + ( + (call_debug_src_loc_inst.map(|inst| instantiate_debuginfo(self, inst))) + .into_iter() + .chain([custom_inst_to_inst( + self, + CustomInst::PushInlinedCallFrame { + callee_name: Operand::IdRef(callee_name_id), + }, + )]), + [custom_inst_to_inst(self, CustomInst::PopInlinedCallFrame)], + ) }; let mut blocks = callee.blocks.clone(); @@ -1048,7 +1021,7 @@ impl Inliner<'_> { // HACK(eddyb) avoid adding debuginfo to otherwise-empty blocks. if block.instructions.len() > num_phis { - let (debuginfo_prefix, debuginfo_suffix) = mk_debuginfo_prefix_and_suffix(true); + let (debuginfo_prefix, debuginfo_suffix) = mk_debuginfo_prefix_and_suffix(); // Insert the prefix debuginfo instructions after `OpPhi`s, // which sadly can't be covered by them. block @@ -1062,13 +1035,7 @@ impl Inliner<'_> { block.instructions.push(terminator); } - let (caller_restore_debuginfo_after_call, calleer_reset_debuginfo_before_call) = - mk_debuginfo_prefix_and_suffix(false); - ( - blocks, - calleer_reset_debuginfo_before_call, - caller_restore_debuginfo_after_call, - ) + blocks } fn insert_opvariables(&self, block: &mut Block, insts: impl IntoIterator) { diff --git a/tests/ui/lang/consts/nested-ref.stderr b/tests/ui/lang/consts/nested-ref.stderr index 692ea48ed7..e66427d0a3 100644 --- a/tests/ui/lang/consts/nested-ref.stderr +++ b/tests/ui/lang/consts/nested-ref.stderr @@ -1,6 +1,20 @@ -warning: `#[inline(never)]` function `nested_ref::deep_load` needs to be inlined because it has illegal argument or return types +warning: `#[inline(never)]` function `nested_ref::deep_load` has been inlined + --> $DIR/nested-ref.rs:12:4 + | +12 | fn deep_load(r: &'static &'static u32) -> u32 { + | ^^^^^^^^^ + | + = note: inlining was required due to illegal parameter type + = note: called from `nested_ref::main` -warning: `#[inline(never)]` function `nested_ref::deep_transpose` needs to be inlined because it has illegal argument or return types +warning: `#[inline(never)]` function `nested_ref::deep_transpose` has been inlined + --> $DIR/nested-ref.rs:19:4 + | +19 | fn deep_transpose(r: &'static &'static Mat2) -> Mat2 { + | ^^^^^^^^^^^^^^ + | + = note: inlining was required due to illegal parameter type + = note: called from `nested_ref::main` warning: 2 warnings emitted diff --git a/tests/ui/lang/core/ref/member_ref_arg-broken.stderr b/tests/ui/lang/core/ref/member_ref_arg-broken.stderr index 66dee4fc15..697d69504b 100644 --- a/tests/ui/lang/core/ref/member_ref_arg-broken.stderr +++ b/tests/ui/lang/core/ref/member_ref_arg-broken.stderr @@ -1,6 +1,38 @@ -warning: `#[inline(never)]` function `member_ref_arg_broken::h` needs to be inlined because it has illegal argument or return types +warning: `#[inline(never)]` function `member_ref_arg_broken::f` has been inlined + --> $DIR/member_ref_arg-broken.rs:20:4 + | +20 | fn f(x: &u32) -> u32 { + | ^ + | + = note: inlining was required due to illegal (pointer) argument + = note: called from `member_ref_arg_broken::main` -warning: `#[inline(never)]` function `member_ref_arg_broken::h_newtyped` needs to be inlined because it has illegal argument or return types +warning: `#[inline(never)]` function `member_ref_arg_broken::g` has been inlined + --> $DIR/member_ref_arg-broken.rs:25:4 + | +25 | fn g(xy: (&u32, &u32)) -> (u32, u32) { + | ^ + | + = note: inlining was required due to illegal (pointer) argument + = note: called from `member_ref_arg_broken::main` + +warning: `#[inline(never)]` function `member_ref_arg_broken::h` has been inlined + --> $DIR/member_ref_arg-broken.rs:30:4 + | +30 | fn h(xyz: (&u32, &u32, &u32)) -> (u32, u32, u32) { + | ^ + | + = note: inlining was required due to illegal parameter type + = note: called from `member_ref_arg_broken::main` + +warning: `#[inline(never)]` function `member_ref_arg_broken::h_newtyped` has been inlined + --> $DIR/member_ref_arg-broken.rs:41:4 + | +41 | fn h_newtyped(xyz: ((&u32, &u32, &u32),)) -> (u32, u32, u32) { + | ^^^^^^^^^^ + | + = note: inlining was required due to illegal parameter type + = note: called from `member_ref_arg_broken::main` error: error:0:0 - OpLoad Pointer '$ID[%$ID]' is not a logical pointer. %39 = OpLoad %uint %38 @@ -8,5 +40,5 @@ error: error:0:0 - OpLoad Pointer '$ID[%$ID]' is not a logical pointer. = note: spirv-val failed = note: module `$TEST_BUILD_DIR/lang/core/ref/member_ref_arg-broken.default` -error: aborting due to 1 previous error; 2 warnings emitted +error: aborting due to 1 previous error; 4 warnings emitted diff --git a/tests/ui/lang/core/ref/member_ref_arg.stderr b/tests/ui/lang/core/ref/member_ref_arg.stderr new file mode 100644 index 0000000000..fd875abfcc --- /dev/null +++ b/tests/ui/lang/core/ref/member_ref_arg.stderr @@ -0,0 +1,20 @@ +warning: `#[inline(never)]` function `member_ref_arg::f` has been inlined + --> $DIR/member_ref_arg.rs:14:4 + | +14 | fn f(x: &u32) {} + | ^ + | + = note: inlining was required due to illegal (pointer) argument + = note: called from `member_ref_arg::main` + +warning: `#[inline(never)]` function `member_ref_arg::g` has been inlined + --> $DIR/member_ref_arg.rs:17:4 + | +17 | fn g(xy: (&u32, &u32)) {} + | ^ + | + = note: inlining was required due to illegal (pointer) argument + = note: called from `member_ref_arg::main` + +warning: 2 warnings emitted + diff --git a/tests/ui/lang/panic/track_caller.stderr b/tests/ui/lang/panic/track_caller.stderr new file mode 100644 index 0000000000..0b97060a71 --- /dev/null +++ b/tests/ui/lang/panic/track_caller.stderr @@ -0,0 +1,11 @@ +warning: `#[inline(never)]` function `track_caller::track_caller_maybe_panic::panic_cold_explicit` has been inlined + --> $DIR/track_caller.rs:10:9 + | +10 | panic!(); + | ^^^^^^^^ + | + = note: inlining was required due to panicking + = note: called from `track_caller::track_caller_maybe_panic` + +warning: 1 warning emitted + From 38167f81760902e22210212e087316284b0a9dd0 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Thu, 8 Aug 2024 19:48:50 +0300 Subject: [PATCH 29/32] tests: add test for long chain of conditional panics. --- tests/ui/dis/panic_sequential_many.rs | 30 +++ tests/ui/dis/panic_sequential_many.stderr | 281 ++++++++++++++++++++++ 2 files changed, 311 insertions(+) create mode 100644 tests/ui/dis/panic_sequential_many.rs create mode 100644 tests/ui/dis/panic_sequential_many.stderr diff --git a/tests/ui/dis/panic_sequential_many.rs b/tests/ui/dis/panic_sequential_many.rs new file mode 100644 index 0000000000..fe04c82c6f --- /dev/null +++ b/tests/ui/dis/panic_sequential_many.rs @@ -0,0 +1,30 @@ +#![crate_name = "panic_sequential_many"] + +// Test a long sequence of conditional panics, which has historically generated +// very nested structured control-flow (instead of a single merged chain). + +// build-pass +// compile-flags: -C target-feature=+ext:SPV_KHR_non_semantic_info +// compile-flags: -C llvm-args=--abort-strategy=debug-printf +// compile-flags: -C llvm-args=--disassemble + +// FIXME(eddyb) consider using such replacements also for dealing +// with `OpLine` changing all the time (esp. in libcore functions). +// +// normalize-stderr-test "; (SPIR-V|Generator: rspirv|Version: 1\.\d+|Bound: \d+)\n" -> "" +// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" +// normalize-stderr-test "OpSource .*\n" -> "" +// normalize-stderr-test "OpExtension .SPV_KHR_vulkan_memory_model.\n" -> "" +// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" + +// FIXME(eddyb) handle this one in the test runner. +// normalize-stderr-test "\S*/lib/rustlib/" -> "$$SYSROOT/lib/rustlib/" + +use spirv_std::spirv; + +#[spirv(fragment)] +pub fn main(#[spirv(flat)] x: u32, #[spirv(flat)] y: u32, o: &mut u32) { + // HACK(eddyb) this might stop working if the checks get optimized out, + // after the first `y != 0` (which dominates the rest of the function). + *o = x / y / y / y / y / y / y / y / y / y / y / y / y / y / y / y / y / y; +} diff --git a/tests/ui/dis/panic_sequential_many.stderr b/tests/ui/dis/panic_sequential_many.stderr new file mode 100644 index 0000000000..615a34105a --- /dev/null +++ b/tests/ui/dis/panic_sequential_many.stderr @@ -0,0 +1,281 @@ +OpCapability Shader +OpCapability Float64 +OpCapability Int64 +OpCapability Int16 +OpCapability Int8 +OpCapability ShaderClockKHR +OpExtension "SPV_KHR_non_semantic_info" +OpExtension "SPV_KHR_shader_clock" +%1 = OpExtInstImport "NonSemantic.DebugPrintf" +OpMemoryModel Logical Simple +OpEntryPoint Fragment %2 "main" %3 %4 %5 +OpExecutionMode %2 OriginUpperLeft +%6 = OpString "/n[Rust panicked at $DIR/panic_sequential_many.rs:29:10]/n attempt to divide by zero/n in main()/n" +%7 = OpString "$DIR/panic_sequential_many.rs" +OpName %3 "x" +OpName %4 "y" +OpName %5 "o" +OpDecorate %3 Flat +OpDecorate %3 Location 0 +OpDecorate %4 Flat +OpDecorate %4 Location 1 +OpDecorate %5 Location 0 +%8 = OpTypeInt 32 0 +%9 = OpTypePointer Input %8 +%10 = OpTypePointer Output %8 +%11 = OpTypeVoid +%12 = OpTypeFunction %11 +%3 = OpVariable %9 Input +%4 = OpVariable %9 Input +%13 = OpTypeBool +%14 = OpConstant %8 0 +%5 = OpVariable %10 Output +%2 = OpFunction %11 None %12 +%15 = OpLabel +OpLine %7 26 12 +%16 = OpLoad %8 %3 +OpLine %7 26 35 +%17 = OpLoad %8 %4 +OpLine %7 29 9 +%18 = OpIEqual %13 %17 %14 +OpNoLine +OpSelectionMerge %19 None +OpBranchConditional %18 %20 %21 +%20 = OpLabel +OpLine %7 29 9 +%22 = OpExtInst %11 %1 1 %6 +OpNoLine +OpBranch %19 +%21 = OpLabel +OpLine %7 29 9 +%23 = OpUDiv %8 %16 %17 +%24 = OpIEqual %13 %17 %14 +OpNoLine +OpSelectionMerge %25 None +OpBranchConditional %24 %26 %27 +%26 = OpLabel +OpLine %7 29 9 +%28 = OpExtInst %11 %1 1 %6 +OpNoLine +OpBranch %25 +%27 = OpLabel +OpLine %7 29 9 +%29 = OpUDiv %8 %23 %17 +%30 = OpIEqual %13 %17 %14 +OpNoLine +OpSelectionMerge %31 None +OpBranchConditional %30 %32 %33 +%32 = OpLabel +OpLine %7 29 9 +%34 = OpExtInst %11 %1 1 %6 +OpNoLine +OpBranch %31 +%33 = OpLabel +OpLine %7 29 9 +%35 = OpUDiv %8 %29 %17 +%36 = OpIEqual %13 %17 %14 +OpNoLine +OpSelectionMerge %37 None +OpBranchConditional %36 %38 %39 +%38 = OpLabel +OpLine %7 29 9 +%40 = OpExtInst %11 %1 1 %6 +OpNoLine +OpBranch %37 +%39 = OpLabel +OpLine %7 29 9 +%41 = OpUDiv %8 %35 %17 +%42 = OpIEqual %13 %17 %14 +OpNoLine +OpSelectionMerge %43 None +OpBranchConditional %42 %44 %45 +%44 = OpLabel +OpLine %7 29 9 +%46 = OpExtInst %11 %1 1 %6 +OpNoLine +OpBranch %43 +%45 = OpLabel +OpLine %7 29 9 +%47 = OpUDiv %8 %41 %17 +%48 = OpIEqual %13 %17 %14 +OpNoLine +OpSelectionMerge %49 None +OpBranchConditional %48 %50 %51 +%50 = OpLabel +OpLine %7 29 9 +%52 = OpExtInst %11 %1 1 %6 +OpNoLine +OpBranch %49 +%51 = OpLabel +OpLine %7 29 9 +%53 = OpUDiv %8 %47 %17 +%54 = OpIEqual %13 %17 %14 +OpNoLine +OpSelectionMerge %55 None +OpBranchConditional %54 %56 %57 +%56 = OpLabel +OpLine %7 29 9 +%58 = OpExtInst %11 %1 1 %6 +OpNoLine +OpBranch %55 +%57 = OpLabel +OpLine %7 29 9 +%59 = OpUDiv %8 %53 %17 +%60 = OpIEqual %13 %17 %14 +OpNoLine +OpSelectionMerge %61 None +OpBranchConditional %60 %62 %63 +%62 = OpLabel +OpLine %7 29 9 +%64 = OpExtInst %11 %1 1 %6 +OpNoLine +OpBranch %61 +%63 = OpLabel +OpLine %7 29 9 +%65 = OpUDiv %8 %59 %17 +%66 = OpIEqual %13 %17 %14 +OpNoLine +OpSelectionMerge %67 None +OpBranchConditional %66 %68 %69 +%68 = OpLabel +OpLine %7 29 9 +%70 = OpExtInst %11 %1 1 %6 +OpNoLine +OpBranch %67 +%69 = OpLabel +OpLine %7 29 9 +%71 = OpUDiv %8 %65 %17 +%72 = OpIEqual %13 %17 %14 +OpNoLine +OpSelectionMerge %73 None +OpBranchConditional %72 %74 %75 +%74 = OpLabel +OpLine %7 29 9 +%76 = OpExtInst %11 %1 1 %6 +OpNoLine +OpBranch %73 +%75 = OpLabel +OpLine %7 29 9 +%77 = OpUDiv %8 %71 %17 +%78 = OpIEqual %13 %17 %14 +OpNoLine +OpSelectionMerge %79 None +OpBranchConditional %78 %80 %81 +%80 = OpLabel +OpLine %7 29 9 +%82 = OpExtInst %11 %1 1 %6 +OpNoLine +OpBranch %79 +%81 = OpLabel +OpLine %7 29 9 +%83 = OpUDiv %8 %77 %17 +%84 = OpIEqual %13 %17 %14 +OpNoLine +OpSelectionMerge %85 None +OpBranchConditional %84 %86 %87 +%86 = OpLabel +OpLine %7 29 9 +%88 = OpExtInst %11 %1 1 %6 +OpNoLine +OpBranch %85 +%87 = OpLabel +OpLine %7 29 9 +%89 = OpUDiv %8 %83 %17 +%90 = OpIEqual %13 %17 %14 +OpNoLine +OpSelectionMerge %91 None +OpBranchConditional %90 %92 %93 +%92 = OpLabel +OpLine %7 29 9 +%94 = OpExtInst %11 %1 1 %6 +OpNoLine +OpBranch %91 +%93 = OpLabel +OpLine %7 29 9 +%95 = OpUDiv %8 %89 %17 +%96 = OpIEqual %13 %17 %14 +OpNoLine +OpSelectionMerge %97 None +OpBranchConditional %96 %98 %99 +%98 = OpLabel +OpLine %7 29 9 +%100 = OpExtInst %11 %1 1 %6 +OpNoLine +OpBranch %97 +%99 = OpLabel +OpLine %7 29 9 +%101 = OpUDiv %8 %95 %17 +%102 = OpIEqual %13 %17 %14 +OpNoLine +OpSelectionMerge %103 None +OpBranchConditional %102 %104 %105 +%104 = OpLabel +OpLine %7 29 9 +%106 = OpExtInst %11 %1 1 %6 +OpNoLine +OpBranch %103 +%105 = OpLabel +OpLine %7 29 9 +%107 = OpUDiv %8 %101 %17 +%108 = OpIEqual %13 %17 %14 +OpNoLine +OpSelectionMerge %109 None +OpBranchConditional %108 %110 %111 +%110 = OpLabel +OpLine %7 29 9 +%112 = OpExtInst %11 %1 1 %6 +OpNoLine +OpBranch %109 +%111 = OpLabel +OpLine %7 29 9 +%113 = OpUDiv %8 %107 %17 +%114 = OpIEqual %13 %17 %14 +OpNoLine +OpSelectionMerge %115 None +OpBranchConditional %114 %116 %117 +%116 = OpLabel +OpLine %7 29 9 +%118 = OpExtInst %11 %1 1 %6 +OpNoLine +OpBranch %115 +%117 = OpLabel +OpLine %7 29 4 +%119 = OpUDiv %8 %113 %17 +OpStore %5 %119 +OpNoLine +OpBranch %115 +%115 = OpLabel +OpBranch %109 +%109 = OpLabel +OpBranch %103 +%103 = OpLabel +OpBranch %97 +%97 = OpLabel +OpBranch %91 +%91 = OpLabel +OpBranch %85 +%85 = OpLabel +OpBranch %79 +%79 = OpLabel +OpBranch %73 +%73 = OpLabel +OpBranch %67 +%67 = OpLabel +OpBranch %61 +%61 = OpLabel +OpBranch %55 +%55 = OpLabel +OpBranch %49 +%49 = OpLabel +OpBranch %43 +%43 = OpLabel +OpBranch %37 +%37 = OpLabel +OpBranch %31 +%31 = OpLabel +OpBranch %25 +%25 = OpLabel +OpBranch %19 +%19 = OpLabel +OpReturn +OpFunctionEnd From 92f12e81acc857238713f6473e8493a13f187cb4 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Fri, 16 Feb 2024 08:41:27 +0200 Subject: [PATCH 30/32] linker/inline: use `OpPhi` instead of `OpVariable` for return values. --- .../rustc_codegen_spirv/src/linker/inline.rs | 143 +++++++++--------- 1 file changed, 72 insertions(+), 71 deletions(-) diff --git a/crates/rustc_codegen_spirv/src/linker/inline.rs b/crates/rustc_codegen_spirv/src/linker/inline.rs index 717a73f85b..cd077e33bb 100644 --- a/crates/rustc_codegen_spirv/src/linker/inline.rs +++ b/crates/rustc_codegen_spirv/src/linker/inline.rs @@ -171,7 +171,6 @@ pub fn inline(sess: &Session, module: &mut Module) -> super::Result<()> { header, debug_string_source: &mut module.debug_string_source, annotations: &mut module.annotations, - types_global_values: &mut module.types_global_values, functions: &functions, legal_globals: &legal_globals, @@ -483,7 +482,6 @@ struct Inliner<'m, 'map> { header: &'m mut ModuleHeader, debug_string_source: &'m mut Vec, annotations: &'m mut Vec, - types_global_values: &'m mut Vec, functions: &'map FunctionMap, legal_globals: &'map FxHashMap, @@ -513,29 +511,6 @@ impl Inliner<'_, '_> { } } - fn ptr_ty(&mut self, pointee: Word) -> Word { - // TODO: This is horribly slow, fix this - let existing = self.types_global_values.iter().find(|inst| { - inst.class.opcode == Op::TypePointer - && inst.operands[0].unwrap_storage_class() == StorageClass::Function - && inst.operands[1].unwrap_id_ref() == pointee - }); - if let Some(existing) = existing { - return existing.result_id.unwrap(); - } - let inst_id = self.id(); - self.types_global_values.push(Instruction::new( - Op::TypePointer, - None, - Some(inst_id), - vec![ - Operand::StorageClass(StorageClass::Function), - Operand::IdRef(pointee), - ], - )); - inst_id - } - fn inline_fn(&mut self, function: &mut Function) { let mut block_idx = 0; while block_idx < function.blocks.len() { @@ -583,15 +558,19 @@ impl Inliner<'_, '_> { None => return false, Some(call) => call, }; - let call_result_type = { + let mut maybe_call_result_phi = { let ty = call_inst.result_type.unwrap(); if ty == self.op_type_void_id { None } else { - Some(ty) + Some(Instruction::new( + Op::Phi, + Some(ty), + Some(call_inst.result_id.unwrap()), + vec![], + )) } }; - let call_result_id = call_inst.result_id.unwrap(); // Get the debuginfo instructions that apply to the call. let custom_ext_inst_set_import = self.custom_ext_inst_set_import; @@ -617,22 +596,71 @@ impl Inliner<'_, '_> { }); let mut rewrite_rules = callee_parameters.zip(call_arguments).collect(); - let return_variable = if call_result_type.is_some() { - Some(self.id()) - } else { - None - }; let return_jump = self.id(); // Rewrite OpReturns of the callee. #[allow(clippy::needless_borrow)] let (mut inlined_callee_blocks, extra_debug_insts_pre_call, extra_debug_insts_post_call) = - self.get_inlined_blocks(&callee, call_debug_insts, return_variable, return_jump); + self.get_inlined_blocks( + callee, + call_debug_insts, + maybe_call_result_phi.as_mut(), + return_jump, + ); // Clone the IDs of the callee, because otherwise they'd be defined multiple times if the // fn is inlined multiple times. self.add_clone_id_rules(&mut rewrite_rules, &inlined_callee_blocks); apply_rewrite_rules(&rewrite_rules, &mut inlined_callee_blocks); self.apply_rewrite_for_decorations(&rewrite_rules); + if let Some(call_result_phi) = &mut maybe_call_result_phi { + // HACK(eddyb) new IDs should be generated earlier, to avoid pushing + // callee IDs to `call_result_phi.operands` only to rewrite them here. + for op in &mut call_result_phi.operands { + if let Some(id) = op.id_ref_any_mut() { + if let Some(&rewrite) = rewrite_rules.get(id) { + *id = rewrite; + } + } + } + + // HACK(eddyb) this special-casing of the single-return case is + // really necessary for passes like `mem2reg` which are not capable + // of skipping through the extraneous `OpPhi`s on their own. + if let [returned_value, _return_block] = &call_result_phi.operands[..] { + let call_result_id = call_result_phi.result_id.unwrap(); + let returned_value_id = returned_value.unwrap_id_ref(); + + maybe_call_result_phi = None; + + // HACK(eddyb) this is a conservative approximation of all the + // instructions that could potentially reference the call result. + let reaching_insts = { + let (pre_call_blocks, call_and_post_call_blocks) = + caller.blocks.split_at_mut(block_idx); + (pre_call_blocks.iter_mut().flat_map(|block| { + block + .instructions + .iter_mut() + .take_while(|inst| inst.class.opcode == Op::Phi) + })) + .chain( + call_and_post_call_blocks + .iter_mut() + .flat_map(|block| &mut block.instructions), + ) + }; + for reaching_inst in reaching_insts { + for op in &mut reaching_inst.operands { + if let Some(id) = op.id_ref_any_mut() { + if *id == call_result_id { + *id = returned_value_id; + } + } + } + } + } + } + // Split the block containing the `OpFunctionCall` into pre-call vs post-call. let pre_call_block_idx = block_idx; #[expect(unused)] @@ -655,20 +683,6 @@ impl Inliner<'_, '_> { .extend(extra_debug_insts_pre_call); post_call_block_insts.splice(0..0, extra_debug_insts_post_call); - if let Some(call_result_type) = call_result_type { - // Generate the storage space for the return value: Do this *after* the split above, - // because if block_idx=0, inserting a variable here shifts call_index. - insert_opvariables( - &mut caller.blocks[0], - [Instruction::new( - Op::Variable, - Some(self.ptr_ty(call_result_type)), - Some(return_variable.unwrap()), - vec![Operand::StorageClass(StorageClass::Function)], - )], - ); - } - // Insert non-entry inlined callee blocks just after the pre-call block. let non_entry_inlined_callee_blocks = inlined_callee_blocks.drain(1..); let num_non_entry_inlined_callee_blocks = non_entry_inlined_callee_blocks.len(); @@ -677,18 +691,9 @@ impl Inliner<'_, '_> { non_entry_inlined_callee_blocks, ); - if let Some(call_result_type) = call_result_type { - // Add the load of the result value after the inlined function. Note there's guaranteed no - // OpPhi instructions since we just split this block. - post_call_block_insts.insert( - 0, - Instruction::new( - Op::Load, - Some(call_result_type), - Some(call_result_id), - vec![Operand::IdRef(return_variable.unwrap())], - ), - ); + if let Some(call_result_phi) = maybe_call_result_phi { + // Add the `OpPhi` for the call result value, after the inlined function. + post_call_block_insts.insert(0, call_result_phi); } // Insert the post-call block, after all the inlined callee blocks. @@ -794,7 +799,7 @@ impl Inliner<'_, '_> { &mut self, callee: &Function, call_debug_insts: impl Iterator, - return_variable: Option, + mut maybe_call_result_phi: Option<&mut Instruction>, return_jump: Word, ) -> ( Vec, @@ -944,17 +949,13 @@ impl Inliner<'_, '_> { if let Op::Return | Op::ReturnValue = terminator.class.opcode { if Op::ReturnValue == terminator.class.opcode { let return_value = terminator.operands[0].id_ref_any().unwrap(); - block.instructions.push(Instruction::new( - Op::Store, - None, - None, - vec![ - Operand::IdRef(return_variable.unwrap()), - Operand::IdRef(return_value), - ], - )); + let call_result_phi = maybe_call_result_phi.as_deref_mut().unwrap(); + call_result_phi.operands.extend([ + Operand::IdRef(return_value), + Operand::IdRef(block.label_id().unwrap()), + ]); } else { - assert!(return_variable.is_none()); + assert!(maybe_call_result_phi.is_none()); } terminator = Instruction::new(Op::Branch, None, None, vec![Operand::IdRef(return_jump)]); From be293be4b28017c121b20d87575d222f59f01164 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sat, 13 Jul 2024 11:17:10 +0300 Subject: [PATCH 31/32] Use `ExitInvocation` for panics (avoiding deeply nested structurization). --- crates/rustc_codegen_spirv/src/linker/mod.rs | 3 + .../src/linker/spirt_passes/controlflow.rs | 8 +- .../ui/dis/entry-pass-mode-cast-array.stderr | 8 +- tests/ui/dis/index_user_dst.stderr | 8 +- tests/ui/dis/issue-731.stderr | 8 +- .../ui/dis/panic_builtin_bounds_check.stderr | 2 +- tests/ui/dis/panic_sequential_many.stderr | 102 +++++++++--------- 7 files changed, 74 insertions(+), 65 deletions(-) diff --git a/crates/rustc_codegen_spirv/src/linker/mod.rs b/crates/rustc_codegen_spirv/src/linker/mod.rs index b0548e679a..96ad90a4d8 100644 --- a/crates/rustc_codegen_spirv/src/linker/mod.rs +++ b/crates/rustc_codegen_spirv/src/linker/mod.rs @@ -442,6 +442,9 @@ pub fn link( } // NOTE(eddyb) this *must* run on unstructured CFGs, to do its job. + // FIXME(eddyb) no longer relying on structurization, try porting this + // to replace custom aborts in `Block`s and inject `ExitInvocation`s + // after them (truncating the `Block` and/or parent region if necessary). { let _timer = sess.timer("spirt_passes::controlflow::convert_custom_aborts_to_unstructured_returns_in_entry_points"); spirt_passes::controlflow::convert_custom_aborts_to_unstructured_returns_in_entry_points(opts, &mut module); diff --git a/crates/rustc_codegen_spirv/src/linker/spirt_passes/controlflow.rs b/crates/rustc_codegen_spirv/src/linker/spirt_passes/controlflow.rs index 2ac40b6d5a..7c5155cbe8 100644 --- a/crates/rustc_codegen_spirv/src/linker/spirt_passes/controlflow.rs +++ b/crates/rustc_codegen_spirv/src/linker/spirt_passes/controlflow.rs @@ -11,6 +11,10 @@ use std::fmt::Write as _; /// Replace our custom extended instruction `Abort`s with standard `OpReturn`s, /// but only in entry-points (and only before CFG structurization). +// +// FIXME(eddyb) no longer relying on structurization, try porting this +// to replace custom aborts in `Block`s and inject `ExitInvocation`s +// after them (truncating the `Block` and/or parent region if necessary). pub fn convert_custom_aborts_to_unstructured_returns_in_entry_points( linker_options: &crate::linker::Options, module: &mut Module, @@ -252,7 +256,9 @@ pub fn convert_custom_aborts_to_unstructured_returns_in_entry_points( )) = custom_terminator_inst { let abort_inst = func_at_abort_inst.position; - terminator.kind = cfg::ControlInstKind::Return; + terminator.kind = cfg::ControlInstKind::ExitInvocation( + cfg::ExitInvocationKind::SpvInst(wk.OpReturn.into()), + ); match abort_strategy { Some(Strategy::Unreachable) => { diff --git a/tests/ui/dis/entry-pass-mode-cast-array.stderr b/tests/ui/dis/entry-pass-mode-cast-array.stderr index 3dd6085685..959aaa2ddc 100644 --- a/tests/ui/dis/entry-pass-mode-cast-array.stderr +++ b/tests/ui/dis/entry-pass-mode-cast-array.stderr @@ -8,6 +8,10 @@ OpNoLine OpSelectionMerge %13 None OpBranchConditional %9 %14 %15 %14 = OpLabel +OpBranch %13 +%15 = OpLabel +OpReturn +%13 = OpLabel OpLine %5 14 4 %16 = OpCompositeExtract %17 %6 0 %18 = OpFAdd %17 %16 %19 @@ -15,9 +19,5 @@ OpLine %5 14 4 OpLine %5 15 4 OpStore %21 %20 OpNoLine -OpBranch %13 -%15 = OpLabel -OpBranch %13 -%13 = OpLabel OpReturn OpFunctionEnd diff --git a/tests/ui/dis/index_user_dst.stderr b/tests/ui/dis/index_user_dst.stderr index 7cff35e049..a05bf5ada5 100644 --- a/tests/ui/dis/index_user_dst.stderr +++ b/tests/ui/dis/index_user_dst.stderr @@ -9,13 +9,13 @@ OpNoLine OpSelectionMerge %14 None OpBranchConditional %12 %15 %16 %15 = OpLabel +OpBranch %14 +%16 = OpLabel +OpReturn +%14 = OpLabel OpLine %5 10 21 %17 = OpInBoundsAccessChain %18 %6 %9 %19 = OpLoad %20 %17 OpNoLine -OpBranch %14 -%16 = OpLabel -OpBranch %14 -%14 = OpLabel OpReturn OpFunctionEnd diff --git a/tests/ui/dis/issue-731.stderr b/tests/ui/dis/issue-731.stderr index 807400a153..4972c4a50a 100644 --- a/tests/ui/dis/issue-731.stderr +++ b/tests/ui/dis/issue-731.stderr @@ -8,6 +8,10 @@ OpNoLine OpSelectionMerge %13 None OpBranchConditional %9 %14 %15 %14 = OpLabel +OpBranch %13 +%15 = OpLabel +OpReturn +%13 = OpLabel OpLine %5 12 4 %16 = OpCompositeExtract %17 %6 0 %18 = OpFAdd %17 %16 %19 @@ -15,9 +19,5 @@ OpLine %5 12 4 OpLine %5 13 4 OpStore %21 %20 OpNoLine -OpBranch %13 -%15 = OpLabel -OpBranch %13 -%13 = OpLabel OpReturn OpFunctionEnd diff --git a/tests/ui/dis/panic_builtin_bounds_check.stderr b/tests/ui/dis/panic_builtin_bounds_check.stderr index 279553b922..f1a394f28f 100644 --- a/tests/ui/dis/panic_builtin_bounds_check.stderr +++ b/tests/ui/dis/panic_builtin_bounds_check.stderr @@ -32,7 +32,7 @@ OpBranch %14 OpLine %4 275 4 %17 = OpExtInst %6 %1 1 %3 %11 %10 OpNoLine -OpBranch %14 +OpReturn %14 = OpLabel OpReturn OpFunctionEnd diff --git a/tests/ui/dis/panic_sequential_many.stderr b/tests/ui/dis/panic_sequential_many.stderr index 615a34105a..d748d2fd49 100644 --- a/tests/ui/dis/panic_sequential_many.stderr +++ b/tests/ui/dis/panic_sequential_many.stderr @@ -45,8 +45,10 @@ OpBranchConditional %18 %20 %21 OpLine %7 29 9 %22 = OpExtInst %11 %1 1 %6 OpNoLine -OpBranch %19 +OpReturn %21 = OpLabel +OpBranch %19 +%19 = OpLabel OpLine %7 29 9 %23 = OpUDiv %8 %16 %17 %24 = OpIEqual %13 %17 %14 @@ -57,8 +59,10 @@ OpBranchConditional %24 %26 %27 OpLine %7 29 9 %28 = OpExtInst %11 %1 1 %6 OpNoLine -OpBranch %25 +OpReturn %27 = OpLabel +OpBranch %25 +%25 = OpLabel OpLine %7 29 9 %29 = OpUDiv %8 %23 %17 %30 = OpIEqual %13 %17 %14 @@ -69,8 +73,10 @@ OpBranchConditional %30 %32 %33 OpLine %7 29 9 %34 = OpExtInst %11 %1 1 %6 OpNoLine -OpBranch %31 +OpReturn %33 = OpLabel +OpBranch %31 +%31 = OpLabel OpLine %7 29 9 %35 = OpUDiv %8 %29 %17 %36 = OpIEqual %13 %17 %14 @@ -81,8 +87,10 @@ OpBranchConditional %36 %38 %39 OpLine %7 29 9 %40 = OpExtInst %11 %1 1 %6 OpNoLine -OpBranch %37 +OpReturn %39 = OpLabel +OpBranch %37 +%37 = OpLabel OpLine %7 29 9 %41 = OpUDiv %8 %35 %17 %42 = OpIEqual %13 %17 %14 @@ -93,8 +101,10 @@ OpBranchConditional %42 %44 %45 OpLine %7 29 9 %46 = OpExtInst %11 %1 1 %6 OpNoLine -OpBranch %43 +OpReturn %45 = OpLabel +OpBranch %43 +%43 = OpLabel OpLine %7 29 9 %47 = OpUDiv %8 %41 %17 %48 = OpIEqual %13 %17 %14 @@ -105,8 +115,10 @@ OpBranchConditional %48 %50 %51 OpLine %7 29 9 %52 = OpExtInst %11 %1 1 %6 OpNoLine -OpBranch %49 +OpReturn %51 = OpLabel +OpBranch %49 +%49 = OpLabel OpLine %7 29 9 %53 = OpUDiv %8 %47 %17 %54 = OpIEqual %13 %17 %14 @@ -117,8 +129,10 @@ OpBranchConditional %54 %56 %57 OpLine %7 29 9 %58 = OpExtInst %11 %1 1 %6 OpNoLine -OpBranch %55 +OpReturn %57 = OpLabel +OpBranch %55 +%55 = OpLabel OpLine %7 29 9 %59 = OpUDiv %8 %53 %17 %60 = OpIEqual %13 %17 %14 @@ -129,8 +143,10 @@ OpBranchConditional %60 %62 %63 OpLine %7 29 9 %64 = OpExtInst %11 %1 1 %6 OpNoLine -OpBranch %61 +OpReturn %63 = OpLabel +OpBranch %61 +%61 = OpLabel OpLine %7 29 9 %65 = OpUDiv %8 %59 %17 %66 = OpIEqual %13 %17 %14 @@ -141,8 +157,10 @@ OpBranchConditional %66 %68 %69 OpLine %7 29 9 %70 = OpExtInst %11 %1 1 %6 OpNoLine -OpBranch %67 +OpReturn %69 = OpLabel +OpBranch %67 +%67 = OpLabel OpLine %7 29 9 %71 = OpUDiv %8 %65 %17 %72 = OpIEqual %13 %17 %14 @@ -153,8 +171,10 @@ OpBranchConditional %72 %74 %75 OpLine %7 29 9 %76 = OpExtInst %11 %1 1 %6 OpNoLine -OpBranch %73 +OpReturn %75 = OpLabel +OpBranch %73 +%73 = OpLabel OpLine %7 29 9 %77 = OpUDiv %8 %71 %17 %78 = OpIEqual %13 %17 %14 @@ -165,8 +185,10 @@ OpBranchConditional %78 %80 %81 OpLine %7 29 9 %82 = OpExtInst %11 %1 1 %6 OpNoLine -OpBranch %79 +OpReturn %81 = OpLabel +OpBranch %79 +%79 = OpLabel OpLine %7 29 9 %83 = OpUDiv %8 %77 %17 %84 = OpIEqual %13 %17 %14 @@ -177,8 +199,10 @@ OpBranchConditional %84 %86 %87 OpLine %7 29 9 %88 = OpExtInst %11 %1 1 %6 OpNoLine -OpBranch %85 +OpReturn %87 = OpLabel +OpBranch %85 +%85 = OpLabel OpLine %7 29 9 %89 = OpUDiv %8 %83 %17 %90 = OpIEqual %13 %17 %14 @@ -189,8 +213,10 @@ OpBranchConditional %90 %92 %93 OpLine %7 29 9 %94 = OpExtInst %11 %1 1 %6 OpNoLine -OpBranch %91 +OpReturn %93 = OpLabel +OpBranch %91 +%91 = OpLabel OpLine %7 29 9 %95 = OpUDiv %8 %89 %17 %96 = OpIEqual %13 %17 %14 @@ -201,8 +227,10 @@ OpBranchConditional %96 %98 %99 OpLine %7 29 9 %100 = OpExtInst %11 %1 1 %6 OpNoLine -OpBranch %97 +OpReturn %99 = OpLabel +OpBranch %97 +%97 = OpLabel OpLine %7 29 9 %101 = OpUDiv %8 %95 %17 %102 = OpIEqual %13 %17 %14 @@ -213,8 +241,10 @@ OpBranchConditional %102 %104 %105 OpLine %7 29 9 %106 = OpExtInst %11 %1 1 %6 OpNoLine -OpBranch %103 +OpReturn %105 = OpLabel +OpBranch %103 +%103 = OpLabel OpLine %7 29 9 %107 = OpUDiv %8 %101 %17 %108 = OpIEqual %13 %17 %14 @@ -225,8 +255,10 @@ OpBranchConditional %108 %110 %111 OpLine %7 29 9 %112 = OpExtInst %11 %1 1 %6 OpNoLine -OpBranch %109 +OpReturn %111 = OpLabel +OpBranch %109 +%109 = OpLabel OpLine %7 29 9 %113 = OpUDiv %8 %107 %17 %114 = OpIEqual %13 %17 %14 @@ -237,45 +269,13 @@ OpBranchConditional %114 %116 %117 OpLine %7 29 9 %118 = OpExtInst %11 %1 1 %6 OpNoLine -OpBranch %115 +OpReturn %117 = OpLabel +OpBranch %115 +%115 = OpLabel OpLine %7 29 4 %119 = OpUDiv %8 %113 %17 OpStore %5 %119 OpNoLine -OpBranch %115 -%115 = OpLabel -OpBranch %109 -%109 = OpLabel -OpBranch %103 -%103 = OpLabel -OpBranch %97 -%97 = OpLabel -OpBranch %91 -%91 = OpLabel -OpBranch %85 -%85 = OpLabel -OpBranch %79 -%79 = OpLabel -OpBranch %73 -%73 = OpLabel -OpBranch %67 -%67 = OpLabel -OpBranch %61 -%61 = OpLabel -OpBranch %55 -%55 = OpLabel -OpBranch %49 -%49 = OpLabel -OpBranch %43 -%43 = OpLabel -OpBranch %37 -%37 = OpLabel -OpBranch %31 -%31 = OpLabel -OpBranch %25 -%25 = OpLabel -OpBranch %19 -%19 = OpLabel OpReturn OpFunctionEnd From 9d6b34f8eed1f11838832dc58bbf574a054c6724 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sat, 7 Jan 2023 06:26:31 +0200 Subject: [PATCH 32/32] [WIP] add `#[spirv(typed_buffer)]` for explicit `SpirvType::InterfaceBlock`s. --- crates/rustc_codegen_spirv/src/abi.rs | 38 +++- crates/rustc_codegen_spirv/src/attr.rs | 1 + .../src/builder/spirv_asm.rs | 6 +- .../src/codegen_cx/entry.rs | 171 ++++++++++-------- crates/rustc_codegen_spirv/src/spirv_type.rs | 10 +- crates/rustc_codegen_spirv/src/symbols.rs | 4 + crates/spirv-std/src/lib.rs | 2 + crates/spirv-std/src/typed_buffer.rs | 100 ++++++++++ .../ui/arch/debug_printf_type_checking.stderr | 20 +- .../runtime_descriptor_array_error.stderr | 2 +- 10 files changed, 259 insertions(+), 95 deletions(-) create mode 100644 crates/spirv-std/src/typed_buffer.rs diff --git a/crates/rustc_codegen_spirv/src/abi.rs b/crates/rustc_codegen_spirv/src/abi.rs index 0d3b8de664..7e8cf0a2e2 100644 --- a/crates/rustc_codegen_spirv/src/abi.rs +++ b/crates/rustc_codegen_spirv/src/abi.rs @@ -936,11 +936,13 @@ fn trans_intrinsic_type<'tcx>( .err("#[spirv(runtime_array)] type must have size 4")); } - // We use a generic to indicate the underlying element type. - // The spirv type of it will be generated by querying the type of the first generic. + // We use a generic param to indicate the underlying element type. + // The SPIR-V element type will be generated from the first generic param. if let Some(elem_ty) = args.types().next() { - let element = cx.layout_of(elem_ty).spirv_type(span, cx); - Ok(SpirvType::RuntimeArray { element }.def(span, cx)) + Ok(SpirvType::RuntimeArray { + element: cx.layout_of(elem_ty).spirv_type(span, cx), + } + .def(span, cx)) } else { Err(cx .tcx @@ -948,6 +950,34 @@ fn trans_intrinsic_type<'tcx>( .err("#[spirv(runtime_array)] type must have a generic element type")) } } + IntrinsicType::TypedBuffer => { + if ty.size != Size::from_bytes(4) { + return Err(cx + .tcx + .sess + .dcx() + .err("#[spirv(typed_buffer)] type must have size 4")); + } + + // We use a generic param to indicate the underlying data type. + // The SPIR-V data type will be generated from the first generic param. + if let Some(data_ty) = args.types().next() { + // HACK(eddyb) this should be a *pointer* to an "interface block", + // but SPIR-V screwed up and used no explicit indirection for the + // descriptor indexing case, and instead made a `RuntimeArray` of + // `InterfaceBlock`s be an "array of typed buffer resources". + Ok(SpirvType::InterfaceBlock { + inner_type: cx.layout_of(data_ty).spirv_type(span, cx), + } + .def(span, cx)) + } else { + Err(cx + .tcx + .sess + .dcx() + .err("#[spirv(typed_buffer)] type must have a generic data type")) + } + } IntrinsicType::Matrix => { let span = def_id_for_spirv_type_adt(ty) .map(|did| cx.tcx.def_span(did)) diff --git a/crates/rustc_codegen_spirv/src/attr.rs b/crates/rustc_codegen_spirv/src/attr.rs index f47062f31f..d3976747ba 100644 --- a/crates/rustc_codegen_spirv/src/attr.rs +++ b/crates/rustc_codegen_spirv/src/attr.rs @@ -65,6 +65,7 @@ pub enum IntrinsicType { SampledImage, RayQueryKhr, RuntimeArray, + TypedBuffer, Matrix, } diff --git a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs index 623893e465..4c0c92cb58 100644 --- a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs +++ b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs @@ -700,7 +700,11 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { }; ty = match cx.lookup_type(ty) { SpirvType::Array { element, .. } - | SpirvType::RuntimeArray { element } => element, + | SpirvType::RuntimeArray { element } + // HACK(eddyb) this is pretty bad because it's not + // checking that the index is an `OpConstant 0`, but + // there's no other valid choice anyway. + | SpirvType::InterfaceBlock { inner_type: element } => element, SpirvType::Adt { field_types, .. } => *index_to_usize() .and_then(|i| field_types.get(i)) diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs b/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs index 8979e9d9d5..f04080b88b 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/entry.rs @@ -495,71 +495,98 @@ impl<'tcx> CodegenCx<'tcx> { .dcx() .span_fatal(hir_param.ty_span, "pair type not supported yet") } + // FIXME(eddyb) should this talk about "typed buffers" instead of "interface blocks"? + // FIXME(eddyb) should we talk about "descriptor indexing" or + // actually use more reasonable terms like "resource arrays"? + let needs_interface_block_and_supports_descriptor_indexing = matches!( + storage_class, + Ok(StorageClass::Uniform | StorageClass::StorageBuffer) + ); + let needs_interface_block = needs_interface_block_and_supports_descriptor_indexing + || storage_class == Ok(StorageClass::PushConstant); + // NOTE(eddyb) `#[spirv(typed_buffer)]` adds `SpirvType::InterfaceBlock`s + // which must bypass the automated ones (i.e. the user is taking control). + let has_explicit_interface_block = needs_interface_block_and_supports_descriptor_indexing + && { + // Peel off arrays first (used for "descriptor indexing"). + let outermost_or_array_element = match self.lookup_type(value_spirv_type) { + SpirvType::Array { element, .. } | SpirvType::RuntimeArray { element } => { + element + } + _ => value_spirv_type, + }; + matches!( + self.lookup_type(outermost_or_array_element), + SpirvType::InterfaceBlock { .. } + ) + }; let var_ptr_spirv_type; - let (value_ptr, value_len) = match storage_class { - Ok( - StorageClass::PushConstant | StorageClass::Uniform | StorageClass::StorageBuffer, - ) => { - let var_spirv_type = SpirvType::InterfaceBlock { - inner_type: value_spirv_type, - } - .def(hir_param.span, self); - var_ptr_spirv_type = self.type_ptr_to(var_spirv_type); - - let zero_u32 = self.constant_u32(hir_param.span, 0).def_cx(self); - let value_ptr_spirv_type = self.type_ptr_to(value_spirv_type); - let value_ptr = bx - .emit() - .in_bounds_access_chain( - value_ptr_spirv_type, - None, - var_id.unwrap(), - [zero_u32].iter().cloned(), - ) - .unwrap() - .with_type(value_ptr_spirv_type); + let (value_ptr, value_len) = if needs_interface_block && !has_explicit_interface_block { + let var_spirv_type = SpirvType::InterfaceBlock { + inner_type: value_spirv_type, + } + .def(hir_param.span, self); + var_ptr_spirv_type = self.type_ptr_to(var_spirv_type); + + let zero_u32 = self.constant_u32(hir_param.span, 0).def_cx(self); + let value_ptr_spirv_type = self.type_ptr_to(value_spirv_type); + let value_ptr = bx + .emit() + .in_bounds_access_chain( + value_ptr_spirv_type, + None, + var_id.unwrap(), + [zero_u32].iter().cloned(), + ) + .unwrap() + .with_type(value_ptr_spirv_type); - let value_len = if is_unsized_with_len { - match self.lookup_type(value_spirv_type) { - SpirvType::RuntimeArray { .. } => {} - _ => { - self.tcx.dcx().span_err( - hir_param.ty_span, - "only plain slices are supported as unsized types", - ); - } + let value_len = if is_unsized_with_len { + match self.lookup_type(value_spirv_type) { + SpirvType::RuntimeArray { .. } => {} + _ => { + self.tcx.dcx().span_err( + hir_param.ty_span, + "only plain slices are supported as unsized types", + ); } + } - // FIXME(eddyb) shouldn't this be `usize`? - let len_spirv_type = self.type_isize(); - let len = bx - .emit() - .array_length(len_spirv_type, None, var_id.unwrap(), 0) - .unwrap(); - - Some(len.with_type(len_spirv_type)) - } else { - if is_unsized { - // It's OK to use a RuntimeArray and not have a length parameter, but - // it's just nicer ergonomics to use a slice. - self.tcx - .dcx() - .span_warn(hir_param.ty_span, "use &[T] instead of &RuntimeArray"); - } - None - }; + // FIXME(eddyb) shouldn't this be `usize`? + let len_spirv_type = self.type_isize(); + let len = bx + .emit() + .array_length(len_spirv_type, None, var_id.unwrap(), 0) + .unwrap(); - (Ok(value_ptr), value_len) - } - Ok(StorageClass::UniformConstant) => { - var_ptr_spirv_type = self.type_ptr_to(value_spirv_type); + Some(len.with_type(len_spirv_type)) + } else { + if is_unsized { + // It's OK to use a RuntimeArray and not have a length parameter, but + // it's just nicer ergonomics to use a slice. + self.tcx + .dcx() + .span_warn(hir_param.ty_span, "use &[T] instead of &RuntimeArray"); + } + None + }; + (Ok(value_ptr), value_len) + } else { + var_ptr_spirv_type = self.type_ptr_to(value_spirv_type); + + // FIXME(eddyb) should we talk about "descriptor indexing" or + // actually use more reasonable terms like "resource arrays"? + let unsized_is_descriptor_indexing = + needs_interface_block_and_supports_descriptor_indexing + || storage_class == Ok(StorageClass::UniformConstant); + if unsized_is_descriptor_indexing { match self.lookup_type(value_spirv_type) { SpirvType::RuntimeArray { .. } => { if is_unsized_with_len { self.tcx.dcx().span_err( hir_param.ty_span, - "uniform_constant must use &RuntimeArray, not &[T]", + "descriptor indexing must use &RuntimeArray, not &[T]", ); } } @@ -567,24 +594,15 @@ impl<'tcx> CodegenCx<'tcx> { if is_unsized { self.tcx.dcx().span_err( hir_param.ty_span, - "only plain slices are supported as unsized types", + "only RuntimeArray is supported, not other unsized types", ); } } } - - let value_len = if is_pair { - // We've already emitted an error, fill in a placeholder value - Some(bx.undef(self.type_isize())) - } else { - None - }; - - (Ok(var_id.unwrap().with_type(var_ptr_spirv_type)), value_len) - } - _ => { - var_ptr_spirv_type = self.type_ptr_to(value_spirv_type); - + } else { + // FIXME(eddyb) determine, based on the type, what kind of type + // this is, to narrow it further to e.g. "buffer in a non-buffer + // storage class" or "storage class expects fixed data sizes". if is_unsized { self.tcx.dcx().span_fatal( hir_param.ty_span, @@ -597,12 +615,19 @@ impl<'tcx> CodegenCx<'tcx> { ), ); } - - ( - var_id.map(|var_id| var_id.with_type(var_ptr_spirv_type)), - None, - ) } + + let value_len = if is_pair { + // We've already emitted an error, fill in a placeholder value + Some(bx.undef(self.type_isize())) + } else { + None + }; + + ( + var_id.map(|var_id| var_id.with_type(var_ptr_spirv_type)), + value_len, + ) }; // Compute call argument(s) to match what the Rust entry `fn` expects, diff --git a/crates/rustc_codegen_spirv/src/spirv_type.rs b/crates/rustc_codegen_spirv/src/spirv_type.rs index 074783116e..ad97e78c52 100644 --- a/crates/rustc_codegen_spirv/src/spirv_type.rs +++ b/crates/rustc_codegen_spirv/src/spirv_type.rs @@ -347,9 +347,8 @@ impl SpirvType<'_> { | Self::AccelerationStructureKhr | Self::RayQueryKhr | Self::Sampler - | Self::SampledImage { .. } => Size::from_bytes(4), - - Self::InterfaceBlock { inner_type } => cx.lookup_type(inner_type).sizeof(cx)?, + | Self::SampledImage { .. } + | Self::InterfaceBlock { .. } => Size::from_bytes(4), }; Some(result) } @@ -377,9 +376,8 @@ impl SpirvType<'_> { | Self::AccelerationStructureKhr | Self::RayQueryKhr | Self::Sampler - | Self::SampledImage { .. } => Align::from_bytes(4).unwrap(), - - Self::InterfaceBlock { inner_type } => cx.lookup_type(inner_type).alignof(cx), + | Self::SampledImage { .. } + | Self::InterfaceBlock { .. } => Align::from_bytes(4).unwrap(), } } diff --git a/crates/rustc_codegen_spirv/src/symbols.rs b/crates/rustc_codegen_spirv/src/symbols.rs index b0dae13875..f7038a0472 100644 --- a/crates/rustc_codegen_spirv/src/symbols.rs +++ b/crates/rustc_codegen_spirv/src/symbols.rs @@ -340,6 +340,10 @@ impl Symbols { "runtime_array", SpirvAttribute::IntrinsicType(IntrinsicType::RuntimeArray), ), + ( + "typed_buffer", + SpirvAttribute::IntrinsicType(IntrinsicType::TypedBuffer), + ), ( "matrix", SpirvAttribute::IntrinsicType(IntrinsicType::Matrix), diff --git a/crates/spirv-std/src/lib.rs b/crates/spirv-std/src/lib.rs index 3f4920c3e2..175099537a 100644 --- a/crates/spirv-std/src/lib.rs +++ b/crates/spirv-std/src/lib.rs @@ -107,6 +107,7 @@ mod runtime_array; mod sampler; pub mod scalar; pub(crate) mod sealed; +mod typed_buffer; pub mod vector; pub use self::sampler::Sampler; @@ -114,6 +115,7 @@ pub use crate::macros::Image; pub use byte_addressable_buffer::ByteAddressableBuffer; pub use num_traits; pub use runtime_array::*; +pub use typed_buffer::*; pub use glam; diff --git a/crates/spirv-std/src/typed_buffer.rs b/crates/spirv-std/src/typed_buffer.rs new file mode 100644 index 0000000000..9b5bff0747 --- /dev/null +++ b/crates/spirv-std/src/typed_buffer.rs @@ -0,0 +1,100 @@ +#[cfg(target_arch = "spirv")] +use core::arch::asm; +use core::marker::PhantomData; +use core::ops::{Deref, DerefMut}; + +/// Explicit (uniform/storage) buffer handle for descriptor indexing. +/// +/// Examples (for an `#[spirv(storage_buffer)]`-annotated entry-point parameter): +/// - `buffer: &[u32]` (implicit, 1 buffer) +/// - `buffer: &TypedBuffer<[u32]>` (explicit, one buffer) +/// - `buffers: &RuntimeArray>` (explicit, many buffers) +// +// TODO(eddyb) fully document! +#[spirv(typed_buffer)] +// HACK(eddyb) avoids "transparent newtype of `_anti_zst_padding`" misinterpretation. +#[repr(C)] +pub struct TypedBuffer { + // HACK(eddyb) avoids the layout becoming ZST (and being elided in one way + // or another, before `#[spirv(runtime_array)]` can special-case it). + _anti_zst_padding: core::mem::MaybeUninit, + _phantom: PhantomData, +} + +impl Deref for TypedBuffer { + type Target = T; + #[spirv_std_macros::gpu_only] + fn deref(&self) -> &T { + unsafe { + let mut result_slot = core::mem::MaybeUninit::uninit(); + asm! { + "%uint = OpTypeInt 32 0", + "%uint_0 = OpConstant %uint 0", + "%result = OpAccessChain _ {buffer} %uint_0", + "OpStore {result_slot} %result", + buffer = in(reg) self, + result_slot = in(reg) result_slot.as_mut_ptr(), + } + result_slot.assume_init() + } + } +} + +impl DerefMut for TypedBuffer { + #[spirv_std_macros::gpu_only] + fn deref_mut(&mut self) -> &mut T { + unsafe { + let mut result_slot = core::mem::MaybeUninit::uninit(); + asm! { + "%uint = OpTypeInt 32 0", + "%uint_0 = OpConstant %uint 0", + "%result = OpAccessChain _ {buffer} %uint_0", + "OpStore {result_slot} %result", + buffer = in(reg) self, + result_slot = in(reg) result_slot.as_mut_ptr(), + } + result_slot.assume_init() + } + } +} + +impl Deref for TypedBuffer<[T]> { + type Target = [T]; + #[spirv_std_macros::gpu_only] + fn deref(&self) -> &[T] { + unsafe { + let mut result_slot = core::mem::MaybeUninit::uninit(); + asm! { + "%uint = OpTypeInt 32 0", + "%uint_0 = OpConstant %uint 0", + "%inner_ptr = OpAccessChain _ {buffer} %uint_0", + "%inner_len = OpArrayLength %uint {buffer} 0", + "%result = OpCompositeConstruct typeof*{result_slot} %inner_ptr %inner_len", + "OpStore {result_slot} %result", + buffer = in(reg) self, + result_slot = in(reg) result_slot.as_mut_ptr(), + } + result_slot.assume_init() + } + } +} + +impl DerefMut for TypedBuffer<[T]> { + #[spirv_std_macros::gpu_only] + fn deref_mut(&mut self) -> &mut Self::Target { + unsafe { + let mut result_slot = core::mem::MaybeUninit::uninit(); + asm! { + "%uint = OpTypeInt 32 0", + "%uint_0 = OpConstant %uint 0", + "%inner_ptr = OpAccessChain _ {buffer} %uint_0", + "%inner_len = OpArrayLength %uint {buffer} 0", + "%result = OpCompositeConstruct typeof*{result_slot} %inner_ptr %inner_len", + "OpStore {result_slot} %result", + buffer = in(reg) self, + result_slot = in(reg) result_slot.as_mut_ptr(), + } + result_slot.assume_init() + } + } +} diff --git a/tests/ui/arch/debug_printf_type_checking.stderr b/tests/ui/arch/debug_printf_type_checking.stderr index fcd2013a15..b027cc7b34 100644 --- a/tests/ui/arch/debug_printf_type_checking.stderr +++ b/tests/ui/arch/debug_printf_type_checking.stderr @@ -75,9 +75,9 @@ help: the return type of this call is `u32` due to the type of the argument pass | | | this argument influences the return type of `spirv_std` note: function defined here - --> $SPIRV_STD_SRC/lib.rs:136:8 + --> $SPIRV_STD_SRC/lib.rs:138:8 | -136 | pub fn debug_printf_assert_is_type(ty: T) -> T { +138 | pub fn debug_printf_assert_is_type(ty: T) -> T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `debug_printf` (in Nightly builds, run with -Z macro-backtrace for more info) help: change the type of the numeric literal from `u32` to `f32` @@ -102,9 +102,9 @@ help: the return type of this call is `f32` due to the type of the argument pass | | | this argument influences the return type of `spirv_std` note: function defined here - --> $SPIRV_STD_SRC/lib.rs:136:8 + --> $SPIRV_STD_SRC/lib.rs:138:8 | -136 | pub fn debug_printf_assert_is_type(ty: T) -> T { +138 | pub fn debug_printf_assert_is_type(ty: T) -> T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `debug_printf` (in Nightly builds, run with -Z macro-backtrace for more info) help: change the type of the numeric literal from `f32` to `u32` @@ -129,12 +129,12 @@ error[E0277]: the trait bound `{float}: Vector` is not satisfied > and 5 others note: required by a bound in `debug_printf_assert_is_vector` - --> $SPIRV_STD_SRC/lib.rs:143:8 + --> $SPIRV_STD_SRC/lib.rs:145:8 | -141 | pub fn debug_printf_assert_is_vector< +143 | pub fn debug_printf_assert_is_vector< | ----------------------------- required by a bound in this function -142 | TY: crate::scalar::Scalar, -143 | V: crate::vector::Vector, +144 | TY: crate::scalar::Scalar, +145 | V: crate::vector::Vector, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `debug_printf_assert_is_vector` = note: this error originates in the macro `debug_printf` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -155,9 +155,9 @@ help: the return type of this call is `Vec2` due to the type of the argument pas | | | this argument influences the return type of `spirv_std` note: function defined here - --> $SPIRV_STD_SRC/lib.rs:136:8 + --> $SPIRV_STD_SRC/lib.rs:138:8 | -136 | pub fn debug_printf_assert_is_type(ty: T) -> T { +138 | pub fn debug_printf_assert_is_type(ty: T) -> T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `debug_printf` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/storage_class/runtime_descriptor_array_error.stderr b/tests/ui/storage_class/runtime_descriptor_array_error.stderr index a6025a5fd0..a3c0d1b0b6 100644 --- a/tests/ui/storage_class/runtime_descriptor_array_error.stderr +++ b/tests/ui/storage_class/runtime_descriptor_array_error.stderr @@ -1,4 +1,4 @@ -error: uniform_constant must use &RuntimeArray, not &[T] +error: descriptor indexing must use &RuntimeArray, not &[T] --> $DIR/runtime_descriptor_array_error.rs:7:52 | 7 | #[spirv(descriptor_set = 0, binding = 0)] one: &[Image!(2D, type=f32, sampled)],