diff --git a/.cargo/config.toml b/.cargo/config.toml index 946679c0889..388ac776f1e 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -82,7 +82,6 @@ rustflags = [ "-Wclippy::string_add_assign", "-Wclippy::string_add", "-Wclippy::string_lit_as_bytes", - "-Wclippy::string_to_string", "-Wclippy::todo", "-Wclippy::trait_duplication_in_bounds", "-Wclippy::unimplemented", diff --git a/Cargo.lock b/Cargo.lock index ed781d90609..e0b1ed7a7bc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2743,6 +2743,7 @@ dependencies = [ "spirt", "spirv-std-types", "spirv-tools", + "termcolor", "thorin-dwp", "tracing", "tracing-subscriber", diff --git a/crates/rustc_codegen_spirv-types/src/target_spec.rs b/crates/rustc_codegen_spirv-types/src/target_spec.rs index 67d339423b9..3af35c8a8cc 100644 --- a/crates/rustc_codegen_spirv-types/src/target_spec.rs +++ b/crates/rustc_codegen_spirv-types/src/target_spec.rs @@ -16,6 +16,8 @@ pub enum TargetSpecVersion { /// Some later version requires them. /// Some earlier version fails with them (notably our 0.9.0 release). Rustc_1_76_0, + /// rustc 1.93 requires that the value of "target-pointer-width" is no longer a string but u16 + Rustc_1_93_0, } impl TargetSpecVersion { @@ -39,7 +41,9 @@ impl TargetSpecVersion { /// Returns the version of the target spec required for a certain rustc version. May return `None` if the version /// is old enough to not need target specs. pub fn from_rustc_version(rustc_version: Version) -> Option { - if rustc_version >= Version::new(1, 85, 0) { + if rustc_version >= Version::new(1, 93, 0) { + Some(Self::Rustc_1_93_0) + } else if rustc_version >= Version::new(1, 85, 0) { Some(Self::Rustc_1_85_0) } else if rustc_version >= Version::new(1, 76, 0) { Some(Self::Rustc_1_76_0) @@ -52,8 +56,12 @@ impl TargetSpecVersion { pub fn format_spec(&self, target: &SpirvTarget) -> String { let target_env = target.env(); let extra = match self { - TargetSpecVersion::Rustc_1_85_0 => r#""crt-static-respected": true,"#, TargetSpecVersion::Rustc_1_76_0 => r#""os": "unknown","#, + _ => r#""crt-static-respected": true,"#, + }; + let target_pointer_width = match self { + TargetSpecVersion::Rustc_1_76_0 | TargetSpecVersion::Rustc_1_85_0 => "\"32\"", + TargetSpecVersion::Rustc_1_93_0 => "32", }; format!( r#"{{ @@ -80,7 +88,7 @@ impl TargetSpecVersion { {extra} "panic-strategy": "abort", "simd-types-indirect": false, - "target-pointer-width": "32" + "target-pointer-width": {target_pointer_width} }}"# ) } diff --git a/crates/rustc_codegen_spirv/Cargo.toml b/crates/rustc_codegen_spirv/Cargo.toml index 2357ae1f7f3..ed72fbd2800 100644 --- a/crates/rustc_codegen_spirv/Cargo.toml +++ b/crates/rustc_codegen_spirv/Cargo.toml @@ -64,6 +64,7 @@ tracing-tree = "0.4.0" [dev-dependencies] pretty_assertions = "1.0" +termcolor = "1.1.3" # HACK(eddyb) can't re-introduce deps of `rustc_codegen_ssa`, for `pqp_cg_ssa` # (see `build.rs`). diff --git a/crates/rustc_codegen_spirv/build.rs b/crates/rustc_codegen_spirv/build.rs index 4577f737937..4a199352c35 100644 --- a/crates/rustc_codegen_spirv/build.rs +++ b/crates/rustc_codegen_spirv/build.rs @@ -19,9 +19,9 @@ use std::{env, fs, mem}; /// `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-2025-06-30" +channel = "nightly-2025-10-28" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = 35f6036521777bdc0dcea1f980be4c192962a168"#; +# commit_hash = adaa838976ff99a4f0661136322f64cb466b58a0"#; fn rustc_output(arg: &str) -> Result> { let rustc = env::var("RUSTC").unwrap_or_else(|_| "rustc".into()); @@ -198,6 +198,13 @@ mod win {", for link_path in raw_dylib::", ); } + src = src.replace( + " + for (link_path, as_needed) in raw_dylib::", + " + #[cfg(any())] + for (link_path, as_needed) in raw_dylib::", + ); if relative_path == Path::new("src/back/metadata.rs") { // HACK(eddyb) remove `object` dependency. src = src.replace( @@ -237,6 +244,14 @@ pub(super) fn elf_e_flags(architecture: Architecture, sess: &Session) -> u32 {", src = src.replace("alloca(field.size,", "typed_alloca(llfield_ty,"); } + // HACK(fee1-dead): our backend type number doesn't always match the type of the value. Should fix? + if relative_path == Path::new("src/mir/rvalue.rs") { + src = src.replace( + "debug_assert_eq!(bx.cx().val_ty(imm), from_backend_ty);", + "", + ); + } + fs::write(out_path, src)?; } } diff --git a/crates/rustc_codegen_spirv/src/abi.rs b/crates/rustc_codegen_spirv/src/abi.rs index 0c5cf69f4d8..bcfa0d86af9 100644 --- a/crates/rustc_codegen_spirv/src/abi.rs +++ b/crates/rustc_codegen_spirv/src/abi.rs @@ -286,7 +286,7 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> { span = cx.tcx.def_span(adt.did()); } - let attrs = AggregatedSpirvAttributes::parse(cx, cx.tcx.get_attrs_unchecked(adt.did())); + let attrs = AggregatedSpirvAttributes::parse(cx, cx.tcx.get_all_attrs(adt.did())); if let Some(intrinsic_type_attr) = attrs.intrinsic_type.map(|attr| attr.value) && let Ok(spirv_type) = @@ -791,7 +791,7 @@ fn trans_intrinsic_type<'tcx>( let sampled_type = match args.type_at(0).kind() { TyKind::Int(int) => match int { IntTy::Isize => { - SpirvType::Integer(cx.tcx.data_layout.pointer_size.bits() as u32, true) + SpirvType::Integer(cx.tcx.data_layout.pointer_size().bits() as u32, true) .def(span, cx) } IntTy::I8 => SpirvType::Integer(8, true).def(span, cx), @@ -802,7 +802,7 @@ fn trans_intrinsic_type<'tcx>( }, TyKind::Uint(uint) => match uint { UintTy::Usize => { - SpirvType::Integer(cx.tcx.data_layout.pointer_size.bits() as u32, false) + SpirvType::Integer(cx.tcx.data_layout.pointer_size().bits() as u32, false) .def(span, cx) } UintTy::U8 => SpirvType::Integer(8, false).def(span, cx), diff --git a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs index d8712343ace..05157d7f93d 100644 --- a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs +++ b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs @@ -1825,10 +1825,6 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { self.declare_func_local_var(self.type_array(self.type_i8(), size.bytes()), align) } - fn dynamic_alloca(&mut self, _len: Self::Value, _align: Align) -> Self::Value { - self.fatal("dynamic alloca not supported yet") - } - fn load(&mut self, ty: Self::Type, ptr: Self::Value, _align: Align) -> Self::Value { let (ptr, access_ty) = self.adjust_pointer_for_typed_access(ptr, ty); let loaded_val = ptr.const_fold_load(self).unwrap_or_else(|| { @@ -2796,6 +2792,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { _src_align: Align, size: Self::Value, flags: MemFlags, + _tt: Option, ) { if flags != MemFlags::empty() { self.err(format!( @@ -2882,7 +2879,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { size: Self::Value, flags: MemFlags, ) { - self.memcpy(dst, dst_align, src, src_align, size, flags); + self.memcpy(dst, dst_align, src, src_align, size, flags, None); } fn memset( @@ -3128,6 +3125,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { dst: Self::Value, src: Self::Value, order: AtomicOrdering, + _ret_ptr: bool, ) -> Self::Value { let ty = src.ty; @@ -3253,6 +3251,10 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { // ignore } + #[tracing::instrument( + level = "debug", + skip(self, callee_ty, _fn_attrs, fn_abi, callee, args, funclet) + )] fn call( &mut self, callee_ty: Self::Type, @@ -3263,9 +3265,6 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { funclet: Option<&Self::Funclet>, instance: Option>, ) -> Self::Value { - let span = tracing::span!(tracing::Level::DEBUG, "call"); - let _enter = span.enter(); - if funclet.is_some() { self.fatal("TODO: Funclets are not supported"); } @@ -3389,6 +3388,15 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { } } + // HACK(fee1-dead): `MaybeUninit` uses a union which we don't have very good support yet. Replacing all calls to it + // with an `Undef` serves the same purpose and fixes compiler errors + if instance_def_id.is_some_and(|did| { + self.tcx + .is_diagnostic_item(rustc_span::sym::maybe_uninit_uninit, did) + }) { + return self.undef(result_type); + } + // Default: emit a regular function call let args = args.iter().map(|arg| arg.def(self)).collect::>(); self.emit() @@ -3397,6 +3405,19 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { .with_type(result_type) } + fn tail_call( + &mut self, + _llty: Self::Type, + _fn_attrs: Option<&CodegenFnAttrs>, + _fn_abi: &FnAbi<'tcx, Ty<'tcx>>, + _llfn: Self::Value, + _args: &[Self::Value], + _funclet: Option<&Self::Funclet>, + _instance: Option>, + ) { + todo!() + } + fn zext(&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 07c89669610..7135e144c8b 100644 --- a/crates/rustc_codegen_spirv/src/builder/mod.rs +++ b/crates/rustc_codegen_spirv/src/builder/mod.rs @@ -183,7 +183,7 @@ impl<'a, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'tcx> { _direct_offset: Size, // NB: each offset implies a deref (i.e. they're steps in a pointer chain). _indirect_offsets: &[Size], - _fragment: Option>, + _fragment: &Option>, ) { todo!() } @@ -203,6 +203,21 @@ impl<'a, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'tcx> { fn set_var_name(&mut self, _value: Self::Value, _name: &str) { todo!() } + + fn dbg_var_value( + &mut self, + _dbg_var: Self::DIVariable, + _dbg_loc: Self::DILocation, + _value: Self::Value, + _direct_offset: Size, + // NB: each offset implies a deref (i.e. they're steps in a pointer chain). + _indirect_offsets: &[Size], + // Byte range in the `dbg_var` covered by this fragment, + // if this is a fragment of a composite `DIVariable`. + _fragment: &Option>, + ) { + todo!() + } } impl<'a, 'tcx> ArgAbiBuilderMethods<'tcx> for Builder<'a, 'tcx> { diff --git a/crates/rustc_codegen_spirv/src/builder_spirv.rs b/crates/rustc_codegen_spirv/src/builder_spirv.rs index e05b433057f..ba8e01fd44f 100644 --- a/crates/rustc_codegen_spirv/src/builder_spirv.rs +++ b/crates/rustc_codegen_spirv/src/builder_spirv.rs @@ -887,7 +887,7 @@ impl<'tcx> BuilderSpirv<'tcx> { FileName::Real(name) => { name.to_string_lossy(FileNameDisplayPreference::Remapped) } - _ => sf.name.prefer_remapped_unconditionaly().to_string().into(), + _ => sf.name.prefer_remapped_unconditionally().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/constant.rs b/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs index acd9b42172c..f4e73354d62 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs @@ -152,7 +152,7 @@ impl ConstCodegenMethods for CodegenCx<'_> { self.const_uint_big(ty, i) } fn const_usize(&self, i: u64) -> Self::Value { - let ptr_size = self.tcx.data_layout.pointer_size.bits() as u32; + let ptr_size = self.tcx.data_layout.pointer_size().bits() as u32; let t = SpirvType::Integer(ptr_size, false).def(DUMMY_SP, self); self.constant_int(t, i.into()) } @@ -246,7 +246,7 @@ impl ConstCodegenMethods for CodegenCx<'_> { } } Scalar::Ptr(ptr, _) => { - let (prov, offset) = ptr.into_parts(); + let (prov, offset) = ptr.prov_and_relative_offset(); let alloc_id = prov.alloc_id(); let (base_addr, _base_addr_space) = match self.tcx.global_alloc(alloc_id) { GlobalAlloc::Memory(alloc) => { @@ -263,7 +263,7 @@ impl ConstCodegenMethods for CodegenCx<'_> { .try_read_from_const_alloc(alloc, pointee) .unwrap_or_else(|| self.const_data_from_alloc(alloc)); let value = self.static_addr_of(init, alloc.inner().align, None); - (value, AddressSpace::DATA) + (value, AddressSpace::ZERO) } GlobalAlloc::Function { instance } => ( self.get_fn_addr(instance), @@ -292,12 +292,24 @@ impl ConstCodegenMethods for CodegenCx<'_> { .try_read_from_const_alloc(alloc, pointee) .unwrap_or_else(|| self.const_data_from_alloc(alloc)); let value = self.static_addr_of(init, alloc.inner().align, None); - (value, AddressSpace::DATA) + (value, AddressSpace::ZERO) } GlobalAlloc::Static(def_id) => { assert!(self.tcx.is_static(def_id)); assert!(!self.tcx.is_thread_local_static(def_id)); - (self.get_static(def_id), AddressSpace::DATA) + (self.get_static(def_id), AddressSpace::ZERO) + } + GlobalAlloc::TypeId { .. } => { + return if offset.bytes() == 0 { + self.constant_null(ty) + } else { + let result = self.undef(ty); + self.zombie_no_span( + result.def_cx(self), + "pointer has non-null integer address", + ); + result + }; } }; self.const_bitcast(self.const_ptr_byte_offset(base_addr, offset), ty) @@ -430,7 +442,7 @@ impl<'tcx> CodegenCx<'tcx> { .fatal(format!("invalid size for float: {other}")); } }), - SpirvType::Pointer { .. } => Primitive::Pointer(AddressSpace::DATA), + SpirvType::Pointer { .. } => Primitive::Pointer(AddressSpace::ZERO), _ => unreachable!(), }; @@ -449,7 +461,7 @@ impl<'tcx> CodegenCx<'tcx> { .inner() .read_scalar(self, range, /* read_provenance */ true) { - let (prov, _offset) = ptr.into_parts(); + let (prov, _offset) = ptr.prov_and_relative_offset(); primitive = Primitive::Pointer( self.tcx.global_alloc(prov.alloc_id()).address_space(self), ); @@ -494,8 +506,7 @@ impl<'tcx> CodegenCx<'tcx> { // HACK(eddyb) these should never happen when using // `read_scalar`, but better not outright crash. - AllocError::ScalarSizeMismatch(_) - | AllocError::OverwritePartialPointer(_) => { + AllocError::ScalarSizeMismatch(_) => { Err(format!("unrecognized `AllocError::{err:?}`")) } }, diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs b/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs index a568b80783b..71eeb5085ac 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/declare.rs @@ -10,11 +10,11 @@ use crate::spirv_type::SpirvType; use itertools::Itertools; use rspirv::spirv::{FunctionControl, LinkageType, StorageClass, Word}; use rustc_abi::Align; -use rustc_attr_data_structures::InlineAttr; use rustc_codegen_ssa::traits::{PreDefineCodegenMethods, StaticCodegenMethods}; +use rustc_hir::attrs::{InlineAttr, Linkage}; use rustc_middle::bug; use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}; -use rustc_middle::mir::mono::{Linkage, MonoItem, Visibility}; +use rustc_middle::mir::mono::{MonoItem, Visibility}; use rustc_middle::ty::layout::{FnAbiOf, LayoutOf}; use rustc_middle::ty::{self, Instance, TypeVisitableExt, TypingEnv}; use rustc_span::Span; @@ -133,7 +133,7 @@ impl<'tcx> CodegenCx<'tcx> { self.set_linkage(fn_id, symbol_name.to_owned(), linkage); } - let attrs = AggregatedSpirvAttributes::parse(self, self.tcx.get_attrs_unchecked(def_id)); + let attrs = AggregatedSpirvAttributes::parse(self, self.tcx.get_all_attrs(def_id)); if let Some(entry) = attrs.entry.map(|attr| attr.value) { // HACK(eddyb) early insert to let `shader_entry_stub` call this // very function via `get_fn_addr`. @@ -177,8 +177,8 @@ impl<'tcx> CodegenCx<'tcx> { } // Check if this is a From trait implementation - if let Some(impl_def_id) = self.tcx.impl_of_method(def_id) - && let Some(trait_ref) = self.tcx.impl_trait_ref(impl_def_id) + if let Some(impl_def_id) = self.tcx.impl_of_assoc(def_id) + && let Some(trait_ref) = self.tcx.impl_opt_trait_ref(impl_def_id) { let trait_def_id = trait_ref.skip_binder().def_id; diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs b/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs index 6ed23ead891..be570c7015a 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/type_.rs @@ -124,7 +124,7 @@ impl<'tcx> LayoutTypeCodegenMethods<'tcx> for CodegenCx<'tcx> { impl<'tcx> CodegenCx<'tcx> { pub fn type_usize(&self) -> Word { - let ptr_size = self.tcx.data_layout.pointer_size.bits() as u32; + let ptr_size = self.tcx.data_layout.pointer_size().bits() as u32; SpirvType::Integer(ptr_size, false).def(DUMMY_SP, self) } } @@ -146,7 +146,7 @@ impl BaseTypeCodegenMethods for CodegenCx<'_> { SpirvType::Integer(128, false).def(DUMMY_SP, self) } fn type_isize(&self) -> Self::Type { - let ptr_size = self.tcx.data_layout.pointer_size.bits() as u32; + let ptr_size = self.tcx.data_layout.pointer_size().bits() as u32; SpirvType::Integer(ptr_size, false).def(DUMMY_SP, self) } diff --git a/crates/rustc_codegen_spirv/src/lib.rs b/crates/rustc_codegen_spirv/src/lib.rs index 3e57d8648d7..76f5f5bc715 100644 --- a/crates/rustc_codegen_spirv/src/lib.rs +++ b/crates/rustc_codegen_spirv/src/lib.rs @@ -85,8 +85,6 @@ extern crate rustc_arena; #[cfg(rustc_codegen_spirv_disable_pqp_cg_ssa)] extern crate rustc_ast; #[cfg(rustc_codegen_spirv_disable_pqp_cg_ssa)] -extern crate rustc_attr_data_structures; -#[cfg(rustc_codegen_spirv_disable_pqp_cg_ssa)] extern crate rustc_attr_parsing; #[cfg(rustc_codegen_spirv_disable_pqp_cg_ssa)] extern crate rustc_codegen_ssa; @@ -141,7 +139,7 @@ mod target_feature; use builder::Builder; use codegen_cx::CodegenCx; -use maybe_pqp_cg_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule}; +use maybe_pqp_cg_ssa::back::lto::{SerializedModule, ThinModule}; use maybe_pqp_cg_ssa::back::write::{ CodegenContext, FatLtoInput, ModuleConfig, OngoingCodegen, TargetMachineFactoryConfig, }; @@ -153,10 +151,9 @@ use maybe_pqp_cg_ssa::traits::{ }; use maybe_pqp_cg_ssa::{CodegenResults, CompiledModule, ModuleCodegen, ModuleKind, TargetConfig}; use rspirv::binary::Assemble; -use rustc_ast::expand::allocator::AllocatorKind; -use rustc_ast::expand::autodiff_attrs::AutoDiffItem; +use rustc_ast::expand::allocator::AllocatorMethod; use rustc_data_structures::fx::FxIndexMap; -use rustc_errors::{DiagCtxtHandle, FatalError}; +use rustc_errors::DiagCtxtHandle; use rustc_metadata::EncodedMetadata; use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; use rustc_middle::mir::mono::{MonoItem, MonoItemData}; @@ -170,7 +167,7 @@ use std::any::Any; use std::fs; use std::io::Cursor; use std::io::Write; -use std::path::Path; +use std::path::{Path, PathBuf}; use std::sync::Arc; use tracing::{error, warn}; @@ -283,6 +280,10 @@ impl CodegenBackend for SpirvCodegenBackend { ); drop(timer); } + + fn name(&self) -> &'static str { + "SpirvCodegenBackend" + } } struct SpirvModuleBuffer(Vec); @@ -301,16 +302,13 @@ impl ThinBufferMethods for SpirvModuleBuffer { fn data(&self) -> &[u8] { self.as_bytes() } - fn thin_link_data(&self) -> &[u8] { - &[] - } } impl SpirvCodegenBackend { fn optimize_common( _cgcx: &CodegenContext, module: &mut ModuleCodegen<::Module>, - ) -> Result<(), FatalError> { + ) { // Apply DCE ("dead code elimination") to modules before ever serializing // them as `.spv` files (technically, `.rcgu.o` files inside `.rlib`s), // that will later get linked (potentially many times, esp. if this is @@ -319,8 +317,6 @@ impl SpirvCodegenBackend { linker::dce::dce(&mut module.module_llvm); // FIXME(eddyb) run as many optimization passes as possible, not just DCE. - - Ok(()) } } @@ -332,33 +328,19 @@ impl WriteBackendMethods for SpirvCodegenBackend { type ThinData = (); type ThinBuffer = SpirvModuleBuffer; - // FIXME(eddyb) reuse the "merge" stage of `crate::linker` for this, or even - // delegate to `run_fat_lto` (although `-Zcombine-cgu` is much more niche). - fn run_link( - cgcx: &CodegenContext, - diag_handler: DiagCtxtHandle<'_>, - _modules: Vec>, - ) -> Result, FatalError> { - assert!( - cgcx.opts.unstable_opts.combine_cgu, - "`run_link` (for `WorkItemResult::NeedsLink`) should \ - only be invoked due to `-Zcombine-cgu`" - ); - diag_handler.fatal("Rust-GPU does not support `-Zcombine-cgu`") - } - // FIXME(eddyb) reuse the "merge" stage of `crate::linker` for this, or even // consider setting `requires_lto = true` in the target specs and moving the // entirety of `crate::linker` into this stage (lacking diagnostics may be // an issue - it's surprising `CodegenBackend::link` has `Session` at all). - fn run_fat_lto( + fn run_and_optimize_fat_lto( cgcx: &CodegenContext, + _exported_symbols_for_lto: &[String], + _each_linked_rlib_for_lto: &[PathBuf], _modules: Vec>, - _cached_modules: Vec<(SerializedModule, WorkProduct)>, - ) -> Result, FatalError> { + ) -> ModuleCodegen { assert!( cgcx.lto == rustc_session::config::Lto::Fat, - "`run_fat_lto` (for `WorkItemResult::NeedsFatLto`) should \ + "`run_and_optimize_fat_lto` (for `WorkItemResult::NeedsFatLto`) should \ only be invoked due to `-Clto` (or equivalent)" ); unreachable!("Rust-GPU does not support fat LTO") @@ -366,9 +348,12 @@ impl WriteBackendMethods for SpirvCodegenBackend { fn run_thin_lto( cgcx: &CodegenContext, + // FIXME(bjorn3): Limit LTO exports to these symbols + _exported_symbols_for_lto: &[String], + _each_linked_rlib_for_lto: &[PathBuf], // njn: ? modules: Vec<(String, Self::ThinBuffer)>, cached_modules: Vec<(SerializedModule, WorkProduct)>, - ) -> Result<(Vec>, Vec), FatalError> { + ) -> (Vec>, Vec) { link::run_thin(cgcx, modules, cached_modules) } @@ -385,14 +370,14 @@ impl WriteBackendMethods for SpirvCodegenBackend { _dcx: DiagCtxtHandle<'_>, module: &mut ModuleCodegen, _config: &ModuleConfig, - ) -> Result<(), FatalError> { - Self::optimize_common(cgcx, module) + ) { + Self::optimize_common(cgcx, module); } fn optimize_thin( cgcx: &CodegenContext, thin_module: ThinModule, - ) -> Result, FatalError> { + ) -> ModuleCodegen { // FIXME(eddyb) the inefficiency of Module -> [u8] -> Module roundtrips // comes from upstream and it applies to `rustc_codegen_llvm` as well, // eventually it should be properly addressed (for `ThinLocal` at least). @@ -405,23 +390,15 @@ impl WriteBackendMethods for SpirvCodegenBackend { kind: ModuleKind::Regular, thin_lto_buffer: None, }; - Self::optimize_common(cgcx, &mut module)?; - Ok(module) - } - - fn optimize_fat( - cgcx: &CodegenContext, - module: &mut ModuleCodegen, - ) -> Result<(), FatalError> { - Self::optimize_common(cgcx, module) + Self::optimize_common(cgcx, &mut module); + module } fn codegen( cgcx: &CodegenContext, - _diag_handler: DiagCtxtHandle<'_>, module: ModuleCodegen, _config: &ModuleConfig, - ) -> Result { + ) -> CompiledModule { let kind = module.kind; let (name, module_buffer) = Self::serialize_module(module); @@ -432,7 +409,7 @@ impl WriteBackendMethods for SpirvCodegenBackend { ); fs::write(&path, module_buffer.as_bytes()).unwrap(); - Ok(CompiledModule { + CompiledModule { name, kind, object: Some(path), @@ -441,13 +418,10 @@ impl WriteBackendMethods for SpirvCodegenBackend { assembly: None, llvm_ir: None, links_from_incr_cache: vec![], - }) + } } - fn prepare_thin( - module: ModuleCodegen, - _want_summary: bool, - ) -> (String, Self::ThinBuffer) { + fn prepare_thin(module: ModuleCodegen) -> (String, Self::ThinBuffer) { Self::serialize_module(module) } @@ -457,25 +431,10 @@ impl WriteBackendMethods for SpirvCodegenBackend { SpirvModuleBuffer(module.module_llvm.assemble()), ) } - - fn autodiff( - _cgcx: &CodegenContext, - _module: &ModuleCodegen, - _diff_fncs: Vec, - _config: &ModuleConfig, - ) -> Result<(), FatalError> { - unreachable!("Rust-GPU does not support autodiff") - } } impl ExtraBackendMethods for SpirvCodegenBackend { - fn codegen_allocator( - &self, - _: TyCtxt<'_>, - _: &str, - _: AllocatorKind, - _: AllocatorKind, - ) -> Self::Module { + fn codegen_allocator(&self, _: TyCtxt<'_>, _: &str, _: &[AllocatorMethod]) -> Self::Module { todo!() } @@ -510,6 +469,7 @@ impl ExtraBackendMethods for SpirvCodegenBackend { // ... and now that we have everything pre-defined, fill out those definitions. for &(mono_item, mono_item_data) in &mono_items { + tracing::trace!(?mono_item, "defining"); mono_item.define::>(cx, cgu_name.as_str(), mono_item_data); } @@ -547,8 +507,7 @@ impl ExtraBackendMethods for SpirvCodegenBackend { _sess: &Session, _opt_level: config::OptLevel, _target_features: &[String], - ) -> Arc<(dyn Fn(TargetMachineFactoryConfig) -> Result<(), String> + Send + Sync + 'static)> - { + ) -> Arc Result<(), String> + Send + Sync + 'static> { Arc::new(|_| Ok(())) } } diff --git a/crates/rustc_codegen_spirv/src/link.rs b/crates/rustc_codegen_spirv/src/link.rs index 038d3079306..430cbac59b6 100644 --- a/crates/rustc_codegen_spirv/src/link.rs +++ b/crates/rustc_codegen_spirv/src/link.rs @@ -7,12 +7,14 @@ use ar::{Archive, GnuBuilder, Header}; use rspirv::binary::Assemble; use rspirv::dr::Module; use rustc_ast::CRATE_NODE_ID; +use rustc_attr_parsing::{ShouldEmit, eval_config_entry}; use rustc_codegen_spirv_types::{CompileResult, ModuleResult}; -use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule, ThinShared}; +use rustc_codegen_ssa::back::lto::{SerializedModule, ThinModule, ThinShared}; use rustc_codegen_ssa::back::write::CodegenContext; use rustc_codegen_ssa::{CodegenResults, NativeLib}; use rustc_data_structures::fx::FxHashSet; -use rustc_errors::{Diag, FatalError}; +use rustc_errors::Diag; +use rustc_hir::attrs::NativeLibKind; use rustc_metadata::{EncodedMetadata, fs::METADATA_FILENAME}; use rustc_middle::bug; use rustc_middle::dep_graph::WorkProduct; @@ -22,7 +24,6 @@ use rustc_session::config::{ CrateType, DebugInfo, Lto, OptLevel, OutFileName, OutputFilenames, OutputType, }; use rustc_session::output::{check_file_is_writeable, invalid_output_for_target, out_filename}; -use rustc_session::utils::NativeLibKind; use rustc_span::Symbol; use std::collections::BTreeMap; use std::ffi::{CString, OsStr}; @@ -496,7 +497,9 @@ 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_parsing::cfg_matches(cfg, sess, CRATE_NODE_ID, None), + Some(ref cfg) => { + eval_config_entry(sess, cfg, CRATE_NODE_ID, None, ShouldEmit::ErrorsAndLints).as_bool() + } None => true, } } @@ -634,7 +637,7 @@ pub(crate) fn run_thin( cgcx: &CodegenContext, modules: Vec<(String, SpirvModuleBuffer)>, cached_modules: Vec<(SerializedModule, WorkProduct)>, -) -> Result<(Vec>, Vec), FatalError> { +) -> (Vec>, Vec) { if cgcx.opts.cg.linker_plugin_lto.enabled() { unreachable!("We should never reach this case if the LTO step is deferred to the linker"); } @@ -668,11 +671,11 @@ pub(crate) fn run_thin( let mut opt_jobs = vec![]; for (module_index, _) in shared.module_names.iter().enumerate() { - opt_jobs.push(LtoModuleCodegen::Thin(ThinModule { + opt_jobs.push(ThinModule { shared: shared.clone(), idx: module_index, - })); + }); } - Ok((opt_jobs, vec![])) + (opt_jobs, vec![]) } diff --git a/crates/rustc_codegen_spirv/src/linker/test.rs b/crates/rustc_codegen_spirv/src/linker/test.rs index 3fdd7185af5..e71e31b493b 100644 --- a/crates/rustc_codegen_spirv/src/linker/test.rs +++ b/crates/rustc_codegen_spirv/src/linker/test.rs @@ -6,13 +6,6 @@ use rustc_session::config::{Input, OutputFilenames, OutputTypes}; use rustc_span::FileName; use std::io::Write; use std::sync::{Arc, Mutex}; - -// `termcolor` is needed because we cannot construct an Emitter after it was added in -// https://github.com/rust-lang/rust/pull/114104. This can be removed when -// https://github.com/rust-lang/rust/pull/115393 lands. -// We need to construct an emitter as yet another workaround, -// see https://github.com/rust-lang/rust/pull/102992. -extern crate termcolor; use termcolor::{ColorSpec, WriteColor}; // https://github.com/colin-kiegel/rust-pretty-assertions/issues/24 @@ -162,7 +155,6 @@ fn link_with_linker_opts( rustc_interface::util::rustc_version_str().unwrap_or("unknown"), Default::default(), &rustc_driver_impl::USING_INTERNAL_FEATURES, - Default::default(), ); // HACK(eddyb) inject `write_diags` into `sess`, to work around @@ -171,7 +163,7 @@ fn link_with_linker_opts( let source_map = sess.psess.clone_source_map(); let emitter = rustc_errors::emitter::HumanEmitter::new( - Box::new(buf), + rustc_errors::AutoStream::new(Box::new(buf), rustc_errors::ColorChoice::Never), rustc_driver_impl::default_translator(), ) .sm(Some(source_map.clone())); @@ -193,6 +185,7 @@ fn link_with_linker_opts( "".into(), None, None, + None, "".into(), OutputTypes::new(&[]), ), diff --git a/crates/rustc_codegen_spirv/src/spirv_type.rs b/crates/rustc_codegen_spirv/src/spirv_type.rs index 3213b131295..f10e09e28ec 100644 --- a/crates/rustc_codegen_spirv/src/spirv_type.rs +++ b/crates/rustc_codegen_spirv/src/spirv_type.rs @@ -335,7 +335,7 @@ impl SpirvType<'_> { .expect("SpirvType::Array.count to be a u32 constant"); element.checked_mul(count, cx).expect("overflow") } - Self::Pointer { .. } => cx.tcx.data_layout.pointer_size, + Self::Pointer { .. } => cx.tcx.data_layout.pointer_size(), Self::Image { .. } | Self::AccelerationStructureKhr | Self::RayQueryKhr @@ -357,7 +357,7 @@ impl SpirvType<'_> { Self::Array { element, .. } | Self::RuntimeArray { element } | Self::Matrix { element, .. } => cx.lookup_type(element).alignof(cx), - Self::Pointer { .. } => cx.tcx.data_layout.pointer_align.abi, + Self::Pointer { .. } => cx.tcx.data_layout.pointer_align().abi, Self::Image { .. } | Self::AccelerationStructureKhr | Self::RayQueryKhr @@ -850,5 +850,6 @@ impl<'tcx> CodegenCx<'tcx> { ty = ty.debug(id, self) ); } + tracing::trace!(?id, "type_cache_def, ty={:?}", self.debug_type(id)); } } diff --git a/crates/spirv-builder/src/lib.rs b/crates/spirv-builder/src/lib.rs index 9adfb3d112d..b84c70969ba 100644 --- a/crates/spirv-builder/src/lib.rs +++ b/crates/spirv-builder/src/lib.rs @@ -53,7 +53,6 @@ clippy::string_add_assign, clippy::string_add, clippy::string_lit_as_bytes, - clippy::string_to_string, clippy::todo, clippy::trait_duplication_in_bounds, clippy::unimplemented, diff --git a/crates/spirv-std/macros/src/lib.rs b/crates/spirv-std/macros/src/lib.rs index 05d14af6ed6..8822d82fb81 100644 --- a/crates/spirv-std/macros/src/lib.rs +++ b/crates/spirv-std/macros/src/lib.rs @@ -53,7 +53,6 @@ clippy::string_add_assign, clippy::string_add, clippy::string_lit_as_bytes, - clippy::string_to_string, clippy::todo, clippy::trait_duplication_in_bounds, clippy::unimplemented, diff --git a/crates/spirv-std/src/lib.rs b/crates/spirv-std/src/lib.rs index 6e178fe8749..78457b3ad81 100644 --- a/crates/spirv-std/src/lib.rs +++ b/crates/spirv-std/src/lib.rs @@ -59,7 +59,6 @@ clippy::string_add_assign, clippy::string_add, clippy::string_lit_as_bytes, - clippy::string_to_string, clippy::todo, clippy::trait_duplication_in_bounds, clippy::unimplemented, diff --git a/examples/runners/ash/src/main.rs b/examples/runners/ash/src/main.rs index a62d58709f8..4c479e20741 100644 --- a/examples/runners/ash/src/main.rs +++ b/examples/runners/ash/src/main.rs @@ -53,7 +53,6 @@ clippy::string_add_assign, clippy::string_add, clippy::string_lit_as_bytes, - clippy::string_to_string, clippy::todo, clippy::trait_duplication_in_bounds, clippy::unimplemented, diff --git a/examples/runners/cpu/src/main.rs b/examples/runners/cpu/src/main.rs index 318f729a5d4..4b4328faa09 100644 --- a/examples/runners/cpu/src/main.rs +++ b/examples/runners/cpu/src/main.rs @@ -53,7 +53,6 @@ clippy::string_add_assign, clippy::string_add, clippy::string_lit_as_bytes, - clippy::string_to_string, clippy::todo, clippy::trait_duplication_in_bounds, clippy::unimplemented, diff --git a/examples/runners/wgpu/src/lib.rs b/examples/runners/wgpu/src/lib.rs index 58dcbf677ec..3f601b43f1a 100644 --- a/examples/runners/wgpu/src/lib.rs +++ b/examples/runners/wgpu/src/lib.rs @@ -53,7 +53,6 @@ clippy::string_add_assign, clippy::string_add, clippy::string_lit_as_bytes, - clippy::string_to_string, clippy::todo, clippy::trait_duplication_in_bounds, clippy::unimplemented, diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 06deb6d52df..853b90472e3 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,7 +1,7 @@ [toolchain] -channel = "nightly-2025-06-30" +channel = "nightly-2025-10-28" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = 35f6036521777bdc0dcea1f980be4c192962a168 +# commit_hash = adaa838976ff99a4f0661136322f64cb466b58a0 # Whenever changing the nightly channel, update the commit hash above, and # change `REQUIRED_RUST_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` too. diff --git a/tests/compiletests/ui/arch/subgroup/subgroup_cluster_size_0_fail.stderr b/tests/compiletests/ui/arch/subgroup/subgroup_cluster_size_0_fail.stderr index d5f06bdb4b2..f6e00334ed6 100644 --- a/tests/compiletests/ui/arch/subgroup/subgroup_cluster_size_0_fail.stderr +++ b/tests/compiletests/ui/arch/subgroup/subgroup_cluster_size_0_fail.stderr @@ -26,7 +26,7 @@ LL | | "); | = note: this note originates in the macro `macro_subgroup_op_clustered` (in Nightly builds, run with -Z macro-backtrace for more info) -note: the above error was encountered while instantiating `fn spirv_std::arch::subgroup_clustered_i_add::<0, u32, u32>` +note: the above error was encountered while instantiating `fn subgroup_clustered_i_add::<0, u32, u32>` --> $DIR/subgroup_cluster_size_0_fail.rs:10:5 | LL | spirv_std::arch::subgroup_clustered_i_add::<0, _>(value) diff --git a/tests/compiletests/ui/arch/subgroup/subgroup_cluster_size_non_power_of_two_fail.stderr b/tests/compiletests/ui/arch/subgroup/subgroup_cluster_size_non_power_of_two_fail.stderr index db300c3e121..2ce25684953 100644 --- a/tests/compiletests/ui/arch/subgroup/subgroup_cluster_size_non_power_of_two_fail.stderr +++ b/tests/compiletests/ui/arch/subgroup/subgroup_cluster_size_non_power_of_two_fail.stderr @@ -26,7 +26,7 @@ LL | | "); | = note: this note originates in the macro `macro_subgroup_op_clustered` (in Nightly builds, run with -Z macro-backtrace for more info) -note: the above error was encountered while instantiating `fn spirv_std::arch::subgroup_clustered_i_add::<5, u32, u32>` +note: the above error was encountered while instantiating `fn subgroup_clustered_i_add::<5, u32, u32>` --> $DIR/subgroup_cluster_size_non_power_of_two_fail.rs:10:5 | LL | spirv_std::arch::subgroup_clustered_i_add::<5, _>(value) diff --git a/tests/compiletests/ui/arch/subgroup/subgroup_composite_enum_err.stderr b/tests/compiletests/ui/arch/subgroup/subgroup_composite_enum_err.stderr index 4d0c7ce481b..a6aa555235e 100644 --- a/tests/compiletests/ui/arch/subgroup/subgroup_composite_enum_err.stderr +++ b/tests/compiletests/ui/arch/subgroup/subgroup_composite_enum_err.stderr @@ -43,7 +43,7 @@ LL + #[repr(crate::NoFrom)] LL - #[repr(C)] LL + #[repr(crate::NoRepr)] | - and 2 other candidates + = and 2 other candidates help: a type parameter with a similar name exists | LL - #[repr(C)] @@ -60,14 +60,19 @@ LL | #[repr(u16)] | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #68585 - = note: `#[deny(conflicting_repr_hints)]` on by default + = note: `#[deny(conflicting_repr_hints)]` (part of `#[deny(future_incompatible)]`) on by default error[E0277]: the trait bound `NoFrom: From` is not satisfied --> $DIR/subgroup_composite_enum_err.rs: | LL | #[derive(Copy, Clone, Default, ScalarComposite)] - | ^^^^^^^^^^^^^^^ the trait `From` is not implemented for `NoFrom` + | ^^^^^^^^^^^^^^^ unsatisfied trait bound | +help: the trait `From` is not implemented for `NoFrom` + --> $DIR/subgroup_composite_enum_err.rs: + | +LL | pub enum NoFrom { + | ^^^^^^^^^^^^^^^ = note: this error originates in the derive macro `ScalarComposite` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `i32: From` is not satisfied @@ -90,7 +95,7 @@ error[E0277]: the trait bound `WrongFrom: From` is not satisfied --> $DIR/subgroup_composite_enum_err.rs: | LL | #[derive(Copy, Clone, Default, ScalarComposite)] - | ^^^^^^^^^^^^^^^ the trait `From` is not implemented for `WrongFrom` + | ^^^^^^^^^^^^^^^ unsatisfied trait bound | = help: the trait `From` is not implemented for `WrongFrom` but trait `From` is implemented for it diff --git a/tests/compiletests/ui/dis/issue-1062.stderr b/tests/compiletests/ui/dis/issue-1062.stderr index 5019327bfb5..9a72a047cb3 100644 --- a/tests/compiletests/ui/dis/issue-1062.stderr +++ b/tests/compiletests/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 1128 4 +OpLine %11 1134 4 %12 = OpBitwiseAnd %7 %9 %13 %14 = OpISub %7 %15 %12 %16 = OpShiftLeftLogical %7 %6 %12 diff --git a/tests/compiletests/ui/dis/panic_builtin_bounds_check.stderr b/tests/compiletests/ui/dis/panic_builtin_bounds_check.stderr index a3bee642b1b..6486f832eb2 100644 --- a/tests/compiletests/ui/dis/panic_builtin_bounds_check.stderr +++ b/tests/compiletests/ui/dis/panic_builtin_bounds_check.stderr @@ -4,7 +4,7 @@ OpExtension "SPV_KHR_non_semantic_info" 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:280: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:276: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" OpDecorate %6 ArrayStride 4 @@ -42,7 +42,7 @@ OpBranchConditional %28 %30 %31 %30 = OpLabel OpBranch %29 %31 = OpLabel -OpLine %4 280 4 +OpLine %4 276 4 %32 = OpExtInst %7 %1 1 %3 %10 %18 OpNoLine OpReturn diff --git a/tests/compiletests/ui/dis/panic_sequential_many.stderr b/tests/compiletests/ui/dis/panic_sequential_many.stderr index ad3952f81b9..ffe854c6fe1 100644 --- a/tests/compiletests/ui/dis/panic_sequential_many.stderr +++ b/tests/compiletests/ui/dis/panic_sequential_many.stderr @@ -4,7 +4,7 @@ OpExtension "SPV_KHR_non_semantic_info" OpMemoryModel Logical Simple OpEntryPoint Fragment %2 "main" %3 %4 %5 OpExecutionMode %2 OriginUpperLeft -%6 = OpString "/n[Rust panicked at $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs:187:5]/n attempt to divide by zero/n in main()/n" +%6 = OpString "/n[Rust panicked at $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs:192:5]/n attempt to divide by zero/n in main()/n" %7 = OpString $SYSROOT/lib/rustlib/src/rust/library/core/src/panicking.rs" %8 = OpString "$DIR/panic_sequential_many.rs" OpName %3 "x" @@ -37,7 +37,7 @@ OpNoLine OpSelectionMerge %20 None OpBranchConditional %19 %21 %22 %21 = OpLabel -OpLine %7 187 4 +OpLine %7 192 4 %23 = OpExtInst %12 %1 1 %6 OpNoLine OpReturn @@ -51,7 +51,7 @@ OpNoLine OpSelectionMerge %26 None OpBranchConditional %25 %27 %28 %27 = OpLabel -OpLine %7 187 4 +OpLine %7 192 4 %29 = OpExtInst %12 %1 1 %6 OpNoLine OpReturn @@ -65,7 +65,7 @@ OpNoLine OpSelectionMerge %32 None OpBranchConditional %31 %33 %34 %33 = OpLabel -OpLine %7 187 4 +OpLine %7 192 4 %35 = OpExtInst %12 %1 1 %6 OpNoLine OpReturn @@ -79,7 +79,7 @@ OpNoLine OpSelectionMerge %38 None OpBranchConditional %37 %39 %40 %39 = OpLabel -OpLine %7 187 4 +OpLine %7 192 4 %41 = OpExtInst %12 %1 1 %6 OpNoLine OpReturn @@ -93,7 +93,7 @@ OpNoLine OpSelectionMerge %44 None OpBranchConditional %43 %45 %46 %45 = OpLabel -OpLine %7 187 4 +OpLine %7 192 4 %47 = OpExtInst %12 %1 1 %6 OpNoLine OpReturn @@ -107,7 +107,7 @@ OpNoLine OpSelectionMerge %50 None OpBranchConditional %49 %51 %52 %51 = OpLabel -OpLine %7 187 4 +OpLine %7 192 4 %53 = OpExtInst %12 %1 1 %6 OpNoLine OpReturn @@ -121,7 +121,7 @@ OpNoLine OpSelectionMerge %56 None OpBranchConditional %55 %57 %58 %57 = OpLabel -OpLine %7 187 4 +OpLine %7 192 4 %59 = OpExtInst %12 %1 1 %6 OpNoLine OpReturn @@ -135,7 +135,7 @@ OpNoLine OpSelectionMerge %62 None OpBranchConditional %61 %63 %64 %63 = OpLabel -OpLine %7 187 4 +OpLine %7 192 4 %65 = OpExtInst %12 %1 1 %6 OpNoLine OpReturn @@ -149,7 +149,7 @@ OpNoLine OpSelectionMerge %68 None OpBranchConditional %67 %69 %70 %69 = OpLabel -OpLine %7 187 4 +OpLine %7 192 4 %71 = OpExtInst %12 %1 1 %6 OpNoLine OpReturn @@ -163,7 +163,7 @@ OpNoLine OpSelectionMerge %74 None OpBranchConditional %73 %75 %76 %75 = OpLabel -OpLine %7 187 4 +OpLine %7 192 4 %77 = OpExtInst %12 %1 1 %6 OpNoLine OpReturn @@ -177,7 +177,7 @@ OpNoLine OpSelectionMerge %80 None OpBranchConditional %79 %81 %82 %81 = OpLabel -OpLine %7 187 4 +OpLine %7 192 4 %83 = OpExtInst %12 %1 1 %6 OpNoLine OpReturn @@ -191,7 +191,7 @@ OpNoLine OpSelectionMerge %86 None OpBranchConditional %85 %87 %88 %87 = OpLabel -OpLine %7 187 4 +OpLine %7 192 4 %89 = OpExtInst %12 %1 1 %6 OpNoLine OpReturn @@ -205,7 +205,7 @@ OpNoLine OpSelectionMerge %92 None OpBranchConditional %91 %93 %94 %93 = OpLabel -OpLine %7 187 4 +OpLine %7 192 4 %95 = OpExtInst %12 %1 1 %6 OpNoLine OpReturn @@ -219,7 +219,7 @@ OpNoLine OpSelectionMerge %98 None OpBranchConditional %97 %99 %100 %99 = OpLabel -OpLine %7 187 4 +OpLine %7 192 4 %101 = OpExtInst %12 %1 1 %6 OpNoLine OpReturn @@ -233,7 +233,7 @@ OpNoLine OpSelectionMerge %104 None OpBranchConditional %103 %105 %106 %105 = OpLabel -OpLine %7 187 4 +OpLine %7 192 4 %107 = OpExtInst %12 %1 1 %6 OpNoLine OpReturn @@ -247,7 +247,7 @@ OpNoLine OpSelectionMerge %110 None OpBranchConditional %109 %111 %112 %111 = OpLabel -OpLine %7 187 4 +OpLine %7 192 4 %113 = OpExtInst %12 %1 1 %6 OpNoLine OpReturn @@ -261,7 +261,7 @@ OpNoLine OpSelectionMerge %116 None OpBranchConditional %115 %117 %118 %117 = OpLabel -OpLine %7 187 4 +OpLine %7 192 4 %119 = OpExtInst %12 %1 1 %6 OpNoLine OpReturn diff --git a/tests/compiletests/ui/dis/ptr_copy.normal.stderr b/tests/compiletests/ui/dis/ptr_copy.normal.stderr index dd442fbb402..fd9b231031a 100644 --- a/tests/compiletests/ui/dis/ptr_copy.normal.stderr +++ b/tests/compiletests/ui/dis/ptr_copy.normal.stderr @@ -1,11 +1,11 @@ error: cannot memcpy dynamically sized data - --> $CORE_SRC/ptr/mod.rs:633:9 + --> $CORE_SRC/ptr/mod.rs:638:9 | LL | crate::intrinsics::copy(src, dst, count) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: used from within `core::ptr::copy::` - --> $CORE_SRC/ptr/mod.rs:618:21 + --> $CORE_SRC/ptr/mod.rs:623:21 | LL | pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { | ^^^^ @@ -28,7 +28,7 @@ LL | pub fn main(i: f32, o: &mut f32) { error: cannot cast between pointer types from `*f32` to `*struct () { }` - --> $CORE_SRC/ptr/mod.rs:621:9 + --> $CORE_SRC/ptr/mod.rs:626:9 | LL | / ub_checks::assert_unsafe_precondition!( LL | | check_language_ub, @@ -39,7 +39,7 @@ LL | | ); | |_________^ | note: used from within `core::ptr::copy::` - --> $CORE_SRC/ptr/mod.rs:621:9 + --> $CORE_SRC/ptr/mod.rs:626:9 | LL | / ub_checks::assert_unsafe_precondition!( LL | | check_language_ub, diff --git a/tests/compiletests/ui/dis/ptr_read.stderr b/tests/compiletests/ui/dis/ptr_read.stderr index 87764b0941e..9ddcc0dd96f 100644 --- a/tests/compiletests/ui/dis/ptr_read.stderr +++ b/tests/compiletests/ui/dis/ptr_read.stderr @@ -2,7 +2,7 @@ %4 = OpFunctionParameter %5 %6 = OpFunctionParameter %5 %7 = OpLabel -OpLine %8 1732 8 +OpLine %8 1744 8 %9 = OpLoad %10 %4 OpLine %11 7 13 OpStore %6 %9 diff --git a/tests/compiletests/ui/dis/ptr_read_method.stderr b/tests/compiletests/ui/dis/ptr_read_method.stderr index 87764b0941e..9ddcc0dd96f 100644 --- a/tests/compiletests/ui/dis/ptr_read_method.stderr +++ b/tests/compiletests/ui/dis/ptr_read_method.stderr @@ -2,7 +2,7 @@ %4 = OpFunctionParameter %5 %6 = OpFunctionParameter %5 %7 = OpLabel -OpLine %8 1732 8 +OpLine %8 1744 8 %9 = OpLoad %10 %4 OpLine %11 7 13 OpStore %6 %9 diff --git a/tests/compiletests/ui/dis/ptr_write.stderr b/tests/compiletests/ui/dis/ptr_write.stderr index 26d592becb9..3b8503a01ca 100644 --- a/tests/compiletests/ui/dis/ptr_write.stderr +++ b/tests/compiletests/ui/dis/ptr_write.stderr @@ -4,7 +4,7 @@ %7 = OpLabel OpLine %8 7 35 %9 = OpLoad %10 %4 -OpLine %11 1932 8 +OpLine %11 1944 8 OpStore %6 %9 OpNoLine OpReturn diff --git a/tests/compiletests/ui/dis/ptr_write_method.stderr b/tests/compiletests/ui/dis/ptr_write_method.stderr index 7b94da100ba..c9dcea78f48 100644 --- a/tests/compiletests/ui/dis/ptr_write_method.stderr +++ b/tests/compiletests/ui/dis/ptr_write_method.stderr @@ -4,7 +4,7 @@ %7 = OpLabel OpLine %8 7 37 %9 = OpLoad %10 %4 -OpLine %11 1932 8 +OpLine %11 1944 8 OpStore %6 %9 OpNoLine OpReturn diff --git a/tests/compiletests/ui/lang/asm/block_tracking_fail.stderr b/tests/compiletests/ui/lang/asm/block_tracking_fail.stderr index cdd2c7b0b36..a498a6a77a3 100644 --- a/tests/compiletests/ui/lang/asm/block_tracking_fail.stderr +++ b/tests/compiletests/ui/lang/asm/block_tracking_fail.stderr @@ -1,15 +1,15 @@ -error: `noreturn` requires a terminator at the end - --> $DIR/block_tracking_fail.rs:11:15 - | -LL | asm!("", options(noreturn)); - | ^ - error: trailing terminator `OpUnreachable` requires `options(noreturn)` --> $DIR/block_tracking_fail.rs:18:15 | LL | asm!("OpUnreachable"); | ^^^^^^^^^^^^^ +error: `noreturn` requires a terminator at the end + --> $DIR/block_tracking_fail.rs:11:15 + | +LL | asm!("", options(noreturn)); + | ^ + error: expected `OpLabel` after terminator `OpKill` --> $DIR/block_tracking_fail.rs:26:14 | diff --git a/tests/compiletests/ui/lang/asm/issue-1002.stderr b/tests/compiletests/ui/lang/asm/issue-1002.stderr index 8b811d8ae93..974ce761ab7 100644 --- a/tests/compiletests/ui/lang/asm/issue-1002.stderr +++ b/tests/compiletests/ui/lang/asm/issue-1002.stderr @@ -6,14 +6,6 @@ LL | asm!("OpReturn", options(noreturn)); | = note: resuming execution, without falling through the end of the `asm!` block, is always undefined behavior -error: using `OpReturnValue` to return from within `asm!` is disallowed - --> $DIR/issue-1002.rs:16:14 - | -LL | "OpReturnValue {x}", - | ^^^^^^^^^^^^^^^^^ - | - = note: resuming execution, without falling through the end of the `asm!` block, is always undefined behavior - error: using `OpReturn` to return from within `asm!` is disallowed --> $DIR/issue-1002.rs:26:14 | @@ -22,6 +14,14 @@ LL | "OpReturn", // close active block | = note: resuming execution, without falling through the end of the `asm!` block, is always undefined behavior +error: using `OpReturnValue` to return from within `asm!` is disallowed + --> $DIR/issue-1002.rs:16:14 + | +LL | "OpReturnValue {x}", + | ^^^^^^^^^^^^^^^^^ + | + = note: resuming execution, without falling through the end of the `asm!` block, is always undefined behavior + error: using `OpReturnValue` to return from within `asm!` is disallowed --> $DIR/issue-1002.rs:35:14 | diff --git a/tests/compiletests/ui/lang/consts/nested-ref-in-composite.stderr b/tests/compiletests/ui/lang/consts/nested-ref-in-composite.stderr index 4b1883e4543..b2da8063b89 100644 --- a/tests/compiletests/ui/lang/consts/nested-ref-in-composite.stderr +++ b/tests/compiletests/ui/lang/consts/nested-ref-in-composite.stderr @@ -1,20 +1,3 @@ -error: constant arrays/structs cannot contain pointers to other constants - --> $DIR/nested-ref-in-composite.rs:20:17 - | -LL | *pair_out = pair_deep_load(&(&123, &3.14)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: used from within `nested_ref_in_composite::main_pair` - --> $DIR/nested-ref-in-composite.rs:20:17 - | -LL | *pair_out = pair_deep_load(&(&123, &3.14)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: called by `main_pair` - --> $DIR/nested-ref-in-composite.rs:19:8 - | -LL | pub fn main_pair(pair_out: &mut (u32, f32)) { - | ^^^^^^^^^ - error: constant arrays/structs cannot contain pointers to other constants --> $DIR/nested-ref-in-composite.rs:25:19 | @@ -32,5 +15,22 @@ note: called by `main_array3` LL | pub fn main_array3(array3_out: &mut [u32; 3]) { | ^^^^^^^^^^^ +error: constant arrays/structs cannot contain pointers to other constants + --> $DIR/nested-ref-in-composite.rs:20:17 + | +LL | *pair_out = pair_deep_load(&(&123, &3.14)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: used from within `nested_ref_in_composite::main_pair` + --> $DIR/nested-ref-in-composite.rs:20:17 + | +LL | *pair_out = pair_deep_load(&(&123, &3.14)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: called by `main_pair` + --> $DIR/nested-ref-in-composite.rs:19:8 + | +LL | pub fn main_pair(pair_out: &mut (u32, f32)) { + | ^^^^^^^^^ + error: aborting due to 2 previous errors diff --git a/tests/compiletests/ui/lang/core/intrinsics/black_box.stderr b/tests/compiletests/ui/lang/core/intrinsics/black_box.stderr index 192a37e3a3c..c5dfb04dea5 100644 --- a/tests/compiletests/ui/lang/core/intrinsics/black_box.stderr +++ b/tests/compiletests/ui/lang/core/intrinsics/black_box.stderr @@ -8,7 +8,7 @@ OpLine %5 41 19 %10 = OpIAdd %7 %11 %12 OpLine %5 47 8 %13 = OpBitcast %7 %14 -OpLine %15 1092 17 +OpLine %15 1103 17 %16 = OpBitcast %7 %17 OpLine %5 46 4 %18 = OpCompositeConstruct %2 %13 %16 %19 %20 %21 %22 %6 %23 %10 %24 %24 %24 diff --git a/tests/compiletests/ui/lang/core/unwrap_or.stderr b/tests/compiletests/ui/lang/core/unwrap_or.stderr index e950047a283..a5bcc86afba 100644 --- a/tests/compiletests/ui/lang/core/unwrap_or.stderr +++ b/tests/compiletests/ui/lang/core/unwrap_or.stderr @@ -1,23 +1,20 @@ %1 = OpFunction %2 None %3 %4 = OpLabel -OpLine %5 13 11 -%6 = OpCompositeInsert %7 %8 %9 0 -%10 = OpCompositeExtract %11 %6 1 -OpLine %12 1026 14 -%13 = OpBitcast %14 %8 -OpLine %12 1026 8 -%15 = OpINotEqual %16 %13 %17 +OpLine %5 1041 14 +%6 = OpBitcast %7 %8 +OpLine %5 1041 8 +%9 = OpINotEqual %10 %6 %11 OpNoLine -OpSelectionMerge %18 None -OpBranchConditional %15 %19 %20 -%19 = OpLabel -OpBranch %18 -%20 = OpLabel -OpBranch %18 -%18 = OpLabel -%21 = OpPhi %11 %10 %19 %22 %20 -OpLine %5 13 4 -OpStore %23 %21 +OpSelectionMerge %12 None +OpBranchConditional %9 %13 %14 +%13 = OpLabel +OpBranch %12 +%14 = OpLabel +OpBranch %12 +%12 = OpLabel +%15 = OpPhi %16 %17 %13 %18 %14 +OpLine %19 13 4 +OpStore %20 %15 OpNoLine OpReturn OpFunctionEnd diff --git a/tests/compiletests/ui/lang/issue-452.stderr b/tests/compiletests/ui/lang/issue-452.stderr index adc228530a5..2f6b71f0427 100644 --- a/tests/compiletests/ui/lang/issue-452.stderr +++ b/tests/compiletests/ui/lang/issue-452.stderr @@ -4,35 +4,8 @@ error: function pointer types are not allowed LL | fn use_cmp(cmp: fn(&Position) -> u32) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: used by unnamed global (%10) -note: used from within `issue_452::use_cmp` - --> $DIR/issue-452.rs:8:4 - | -LL | fn use_cmp(cmp: fn(&Position) -> u32) { - | ^^^^^^^ -note: called by `issue_452::main` - --> $DIR/issue-452.rs:17:5 - | -LL | use_cmp(|p| p.0); - | ^^^^^^^^^^^^^^^^ -note: called by `main` - --> $DIR/issue-452.rs:16:8 - | -LL | pub fn main() { - | ^^^^ - -error: indirect calls are not supported in SPIR-V - --> $DIR/issue-452.rs:12:27 - | -LL | let _ = if cmp(&a) <= cmp(&b) { a } else { b }; - | ^^^^^^^ - | -note: used from within `issue_452::use_cmp` - --> $DIR/issue-452.rs:8:4 - | -LL | fn use_cmp(cmp: fn(&Position) -> u32) { - | ^^^^^^^ -note: called by `issue_452::main` + = note: used by unnamed global (%44) +note: used from within `issue_452::main` --> $DIR/issue-452.rs:17:5 | LL | use_cmp(|p| p.0); @@ -43,5 +16,5 @@ note: called by `main` LL | pub fn main() { | ^^^^ -error: aborting due to 2 previous errors +error: aborting due to 1 previous error diff --git a/tests/compiletests/ui/lang/panic/track_caller.stderr b/tests/compiletests/ui/lang/panic/track_caller.stderr deleted file mode 100644 index b18b2fed0d2..00000000000 --- a/tests/compiletests/ui/lang/panic/track_caller.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: `#[inline(never)]` function `track_caller::track_caller_maybe_panic::panic_cold_explicit` has been inlined - --> $DIR/track_caller.rs:10:9 - | -LL | panic!(); - | ^^^^^^^^ - | - = note: inlining was required due to panicking - = note: called from `track_caller::track_caller_maybe_panic` - -warning: 1 warning emitted - diff --git a/tests/compiletests/ui/spirv-attr/invalid-target.stderr b/tests/compiletests/ui/spirv-attr/invalid-target.stderr index 5cb3a5e890b..4e5cb57615b 100644 --- a/tests/compiletests/ui/spirv-attr/invalid-target.stderr +++ b/tests/compiletests/ui/spirv-attr/invalid-target.stderr @@ -328,133 +328,133 @@ error: attribute is only valid on a function parameter, not on a foreign module LL | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^ -error: attribute is only valid on a struct, not on a static item +error: attribute is only valid on a struct, not on a static --> $DIR/invalid-target.rs:96:5 | LL | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^ -error: attribute is only valid on a struct, not on a static item +error: attribute is only valid on a struct, not on a static --> $DIR/invalid-target.rs:96:14 | LL | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^ -error: attribute is only valid on a struct, not on a static item +error: attribute is only valid on a struct, not on a static --> $DIR/invalid-target.rs:96:21 | LL | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^^^^^^^ -error: attribute is only valid on a struct, not on a static item +error: attribute is only valid on a struct, not on a static --> $DIR/invalid-target.rs:96:36 | LL | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^^^^^^^^^^^^ -error: attribute is only valid on a function, not on a static item +error: attribute is only valid on a function, not on a static --> $DIR/invalid-target.rs:97:5 | LL | vertex, // fn-only | ^^^^^^ -error: attribute is only valid on a function parameter, not on a static item +error: attribute is only valid on a function parameter, not on a static --> $DIR/invalid-target.rs:98:5 | LL | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^ -error: attribute is only valid on a function parameter, not on a static item +error: attribute is only valid on a function parameter, not on a static --> $DIR/invalid-target.rs:98:14 | LL | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^ -error: attribute is only valid on a function parameter, not on a static item +error: attribute is only valid on a function parameter, not on a static --> $DIR/invalid-target.rs:98:24 | LL | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^^^^^^^^^^ -error: attribute is only valid on a function parameter, not on a static item +error: attribute is only valid on a function parameter, not on a static --> $DIR/invalid-target.rs:98:44 | LL | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^^^ -error: attribute is only valid on a function parameter, not on a static item +error: attribute is only valid on a function parameter, not on a static --> $DIR/invalid-target.rs:98:57 | LL | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^ -error: attribute is only valid on a function parameter, not on a static item +error: attribute is only valid on a function parameter, not on a static --> $DIR/invalid-target.rs:98:63 | LL | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^ -error: attribute is only valid on a struct, not on a constant item +error: attribute is only valid on a struct, not on a constant --> $DIR/invalid-target.rs:103:5 | LL | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^ -error: attribute is only valid on a struct, not on a constant item +error: attribute is only valid on a struct, not on a constant --> $DIR/invalid-target.rs:103:14 | LL | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^ -error: attribute is only valid on a struct, not on a constant item +error: attribute is only valid on a struct, not on a constant --> $DIR/invalid-target.rs:103:21 | LL | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^^^^^^^ -error: attribute is only valid on a struct, not on a constant item +error: attribute is only valid on a struct, not on a constant --> $DIR/invalid-target.rs:103:36 | LL | sampler, block, sampled_image, generic_image_type, // struct-only | ^^^^^^^^^^^^^^^^^^ -error: attribute is only valid on a function, not on a constant item +error: attribute is only valid on a function, not on a constant --> $DIR/invalid-target.rs:104:5 | LL | vertex, // fn-only | ^^^^^^ -error: attribute is only valid on a function parameter, not on a constant item +error: attribute is only valid on a function parameter, not on a constant --> $DIR/invalid-target.rs:105:5 | LL | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^ -error: attribute is only valid on a function parameter, not on a constant item +error: attribute is only valid on a function parameter, not on a constant --> $DIR/invalid-target.rs:105:14 | LL | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^ -error: attribute is only valid on a function parameter, not on a constant item +error: attribute is only valid on a function parameter, not on a constant --> $DIR/invalid-target.rs:105:24 | LL | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^^^^^^^^^^ -error: attribute is only valid on a function parameter, not on a constant item +error: attribute is only valid on a function parameter, not on a constant --> $DIR/invalid-target.rs:105:44 | LL | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^^^^^^^^ -error: attribute is only valid on a function parameter, not on a constant item +error: attribute is only valid on a function parameter, not on a constant --> $DIR/invalid-target.rs:105:57 | LL | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only | ^^^^ -error: attribute is only valid on a function parameter, not on a constant item +error: attribute is only valid on a function parameter, not on a constant --> $DIR/invalid-target.rs:105:63 | LL | uniform, position, descriptor_set = 0, binding = 0, flat, invariant, // param-only