diff --git a/.cargo/config.toml b/.cargo/config.toml index e0072bb0c5..240a843bbb 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -45,7 +45,6 @@ rustflags = [ "-Wclippy::flat_map_option", "-Wclippy::float_cmp_const", "-Wclippy::fn_params_excessive_bools", - "-Wclippy::from_iter_instead_of_collect", "-Wclippy::if_let_mutex", "-Wclippy::implicit_clone", "-Wclippy::imprecise_flops", diff --git a/crates/rustc_codegen_spirv/build.rs b/crates/rustc_codegen_spirv/build.rs index 135151e543..e66dfe096f 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-2026-05-22" +channel = "nightly-2026-06-25" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = e96c36b6f76833388c519561d145492d2c08db4e"#; +# commit_hash = f28ac764c36004fa6a6e098d15b4016a838c13c6"#; fn rustc_output(arg: &str) -> Result> { let rustc = env::var("RUSTC").unwrap_or_else(|_| "rustc".into()); @@ -256,6 +256,34 @@ pub(super) fn elf_e_flags(architecture: Architecture, sess: &Session) -> u32 {", ); } + // HACK(firestar99): Undo code cleanup that prevents passing ScalarPairs as `PassMode::Direct` + // https://github.com/rust-lang/rust/commit/dfc475d018c780475ea962f15d86cfa05a50a148 + if relative_path == Path::new("src/mir/mod.rs") { + src = src.replace( + " + debug_assert!(bx.is_backend_immediate(arg.layout)); + return local(OperandRef { + val: OperandValue::Immediate(llarg), + layout: arg.layout, + move_annotation: None, + });", + " + return local(OperandRef::from_immediate_or_packed_pair( + bx, llarg, arg.layout, + ));", + ); + src = src.replace("fx.fill_function_debug_context();", ""); + } + if relative_path == Path::new("src/mir/block.rs") { + src = src.replace( + r#" + PassMode::Direct(_) => (op.immediate(), arg.layout.align.abi, false), + PassMode::Ignore | PassMode::Pair(..) => unreachable!("handled above"),"#, + "\ + _ => (op.immediate_or_packed_pair(bx), arg.layout.align.abi, false),", + ); + } + fs::write(out_path, src)?; } } diff --git a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs index 16fa2bca7a..ce4a709259 100644 --- a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs +++ b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs @@ -1986,7 +1986,8 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { align: Align, flags: MemFlags, ) -> Self::Value { - if flags != MemFlags::empty() { + let allowed_flags = MemFlags::CAPTURES_READ_ONLY; + if !(flags & !allowed_flags).is_empty() { self.err(format!("store_with_flags is not supported yet: {flags:?}")); } self.store(val, ptr, align) diff --git a/crates/rustc_codegen_spirv/src/builder/intrinsics.rs b/crates/rustc_codegen_spirv/src/builder/intrinsics.rs index 041ca3463f..0504e2ea8e 100644 --- a/crates/rustc_codegen_spirv/src/builder/intrinsics.rs +++ b/crates/rustc_codegen_spirv/src/builder/intrinsics.rs @@ -10,8 +10,9 @@ use crate::spirv_type::SpirvType; use rspirv::dr::Operand; use rspirv::spirv::GlslStd450Op as GLOp; use rustc_codegen_ssa::RetagInfo; +use rustc_codegen_ssa::mir::IntrinsicResult; use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; -use rustc_codegen_ssa::mir::place::PlaceRef; +use rustc_codegen_ssa::mir::place::{PlaceRef, PlaceValue}; use rustc_codegen_ssa::traits::{BuilderMethods, IntrinsicCallBuilderMethods}; use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::{FnDef, Instance, Ty, TyKind, TypingEnv}; @@ -64,9 +65,14 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> { &mut self, instance: Instance<'tcx>, args: &[OperandRef<'tcx, Self::Value>], - result: PlaceRef<'tcx, Self::Value>, + result_layout: ty::layout::TyAndLayout<'tcx>, + result_place: Option>, _span: Span, - ) -> Result<(), ty::Instance<'tcx>> { + ) -> IntrinsicResult<'tcx, Self::Value> { + let result = PlaceRef { + val: result_place.unwrap(), + layout: result_layout, + }; let callee_ty = instance.ty(self.tcx, TypingEnv::fully_monomorphized()); let (def_id, fn_args) = match *callee_ty.kind() { @@ -95,7 +101,7 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> { sym::breakpoint => { self.abort(); assert!(result.layout.ty.is_unit()); - return Ok(()); + return IntrinsicResult::WroteIntoPlace; } sym::volatile_load | sym::unaligned_volatile_load => { @@ -105,7 +111,7 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> { if !result.layout.is_zst() { self.store(load, result.val.llval, result.val.align); } - return Ok(()); + return IntrinsicResult::WroteIntoPlace; } sym::prefetch_read_data @@ -114,7 +120,7 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> { | sym::prefetch_write_instruction => { // ignore assert!(result.layout.ty.is_unit()); - return Ok(()); + return IntrinsicResult::WroteIntoPlace; } sym::saturating_add => { @@ -352,7 +358,10 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> { _ => { // Call the fallback body instead of generating the intrinsic code - return Err(ty::Instance::new_raw(instance.def_id(), instance.args)); + return IntrinsicResult::Fallback(Instance::new_raw( + instance.def_id(), + instance.args, + )); } }; @@ -368,7 +377,7 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> { .val .store(self, result); } - Ok(()) + IntrinsicResult::WroteIntoPlace } fn codegen_llvm_intrinsic_call( @@ -402,16 +411,7 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> { todo!() } - fn va_start(&mut self, val: Self::Value) -> Self::Value { - // SPIR-V backend has no variadic ABI support; keep the placeholder - // operand unchanged so MIR lowering can proceed without crashing. - val - } - - fn va_end(&mut self, val: Self::Value) -> Self::Value { - // See `va_start` above. - val - } + fn va_start(&mut self, _val: Self::Value) {} fn retag_mem(&mut self, _place: Self::Value, _info: &RetagInfo) { bug!("retag not supported") diff --git a/crates/rustc_codegen_spirv/src/builder/mod.rs b/crates/rustc_codegen_spirv/src/builder/mod.rs index ba4af829a9..b5d8fd8035 100644 --- a/crates/rustc_codegen_spirv/src/builder/mod.rs +++ b/crates/rustc_codegen_spirv/src/builder/mod.rs @@ -185,24 +185,15 @@ impl<'a, 'tcx> DebugInfoBuilderMethods<'_> for Builder<'a, 'tcx> { _indirect_offsets: &[Size], _fragment: &Option>, ) { - todo!() } - fn set_dbg_loc(&mut self, _: Self::DILocation) { - todo!() - } + fn set_dbg_loc(&mut self, _: Self::DILocation) {} - fn clear_dbg_loc(&mut self) { - todo!() - } + fn clear_dbg_loc(&mut self) {} - fn insert_reference_to_gdb_debug_scripts_section_global(&mut self) { - todo!() - } + fn insert_reference_to_gdb_debug_scripts_section_global(&mut self) {} - fn set_var_name(&mut self, _value: Self::Value, _name: &str) { - todo!() - } + fn set_var_name(&mut self, _value: Self::Value, _name: &str) {} fn dbg_var_value( &mut self, @@ -216,7 +207,6 @@ impl<'a, 'tcx> DebugInfoBuilderMethods<'_> for Builder<'a, 'tcx> { // if this is a fragment of a composite `DIVariable`. _fragment: &Option>, ) { - todo!() } } diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs index 075df21e87..aa82bd0c91 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/mod.rs @@ -20,20 +20,19 @@ use rspirv::dr::{Module, Operand}; use rspirv::spirv::{Decoration, LinkageType, Word}; use rustc_abi::{AddressSpace, HasDataLayout, TargetDataLayout}; use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece}; -use rustc_codegen_ssa::mir::debuginfo::{FunctionDebugContext, VariableKind}; +use rustc_codegen_ssa::mir::debuginfo::VariableKind; use rustc_codegen_ssa::traits::{ AsmCodegenMethods, BackendTypes, DebugInfoCodegenMethods, GlobalAsmOperandRef, MiscCodegenMethods, }; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir::def_id::DefId; -use rustc_middle::mir; use rustc_middle::mono::CodegenUnit; use rustc_middle::ty::layout::{HasTyCtxt, HasTypingEnv}; use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypingEnv}; use rustc_session::Session; use rustc_span::symbol::Symbol; -use rustc_span::{DUMMY_SP, SourceFile, Span}; +use rustc_span::{BytePos, DUMMY_SP, SourceFile, Span}; use rustc_target::callconv::FnAbi; use rustc_target::spec::{HasTargetSpec, Target, TargetTuple}; use std::cell::RefCell; @@ -930,6 +929,10 @@ impl<'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'tcx> { fn declare_c_main(&self, _fn_type: Self::FunctionSignature) -> Option { todo!() } + + fn intrinsic_call_expects_place_always(&self, _: Symbol) -> bool { + true + } } impl<'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'tcx> { @@ -942,41 +945,39 @@ impl<'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'tcx> { // Ignore. } - fn dbg_scope_fn( + fn dbg_create_lexical_block( &self, - _: rustc_middle::ty::Instance<'tcx>, - _: &FnAbi<'tcx, Ty<'tcx>>, - _: Option, + _pos: BytePos, + _parent_scope: Self::DIScope, ) -> Self::DIScope { - todo!() } - fn dbg_loc(&self, _: Self::DIScope, _: Option, _: Span) -> Self::DILocation { - todo!() + fn dbg_location_clone_with_discriminator( + &self, + _loc: Self::DILocation, + _discriminator: u32, + ) -> Option { + None } - fn create_function_debug_context( + fn dbg_scope_fn( &self, - _instance: Instance<'tcx>, - _fn_abi: &FnAbi<'tcx, Ty<'tcx>>, - _llfn: Self::Function, - _mir: &mir::Body<'tcx>, - ) -> Option> { - // TODO: This is ignored. Do we want to implement this at some point? - None + _: Instance<'tcx>, + _: &FnAbi<'tcx, Ty<'tcx>>, + _: Option, + ) -> Self::DIScope { } + fn dbg_loc(&self, _: Self::DIScope, _: Option, _: Span) -> Self::DILocation {} + fn extend_scope_to_file( &self, _scope_metadata: Self::DIScope, _file: &SourceFile, ) -> Self::DIScope { - todo!() } - fn debuginfo_finalize(&self) { - todo!() - } + fn debuginfo_finalize(&self) {} fn create_dbg_var( &self, @@ -986,7 +987,6 @@ impl<'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'tcx> { _variable_kind: VariableKind, _span: Span, ) -> Self::DIVariable { - todo!() } } diff --git a/crates/rustc_codegen_spirv/src/lib.rs b/crates/rustc_codegen_spirv/src/lib.rs index 857255dbfa..df16829a6b 100644 --- a/crates/rustc_codegen_spirv/src/lib.rs +++ b/crates/rustc_codegen_spirv/src/lib.rs @@ -152,11 +152,10 @@ use maybe_pqp_cg_ssa::{ }; use rspirv::binary::Assemble; use rustc_ast::expand::allocator::AllocatorMethod; -use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::profiling::SelfProfilerRef; use rustc_errors::DiagCtxtHandle; use rustc_metadata::EncodedMetadata; -use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; +use rustc_middle::dep_graph::{WorkProduct, WorkProductMap}; use rustc_middle::mono::{MonoItem, MonoItemData}; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::{InstanceKind, TyCtxt}; @@ -258,7 +257,7 @@ impl CodegenBackend for SpirvCodegenBackend { sess: &Session, _outputs: &OutputFilenames, crate_info: &CrateInfo, - ) -> (CompiledModules, FxIndexMap) { + ) -> (CompiledModules, WorkProductMap) { ongoing_codegen .downcast::>() .expect("Expected OngoingCodegen, found Box") @@ -411,6 +410,7 @@ impl WriteBackendMethods for SpirvCodegenBackend { name, kind, object: Some(path), + global_asm_object: None, dwarf_object: None, bytecode: None, assembly: None, @@ -434,6 +434,8 @@ impl WriteBackendMethods for SpirvCodegenBackend { } impl ExtraBackendMethods for SpirvCodegenBackend { + type Module = rspirv::dr::Module; + fn codegen_allocator(&self, _: TyCtxt<'_>, _: &str, _: &[AllocatorMethod]) -> Self::Module { todo!() } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 195e4c217d..bdb37d55c2 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,7 +1,7 @@ [toolchain] -channel = "nightly-2026-05-22" +channel = "nightly-2026-06-25" components = ["rust-src", "rustc-dev", "llvm-tools"] -# commit_hash = e96c36b6f76833388c519561d145492d2c08db4e +# commit_hash = f28ac764c36004fa6a6e098d15b4016a838c13c6 # 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/lang/core/intrinsics/black_box.stderr b/tests/compiletests/ui/lang/core/intrinsics/black_box.stderr index 99432734e6..409f635047 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 1244 17 +OpLine %15 1245 17 %16 = OpBitcast %7 %17 OpLine %5 46 4 %18 = OpCompositeConstruct %2 %13 %16 %19 %20 %21 %22 %6 %23 %10 %24 %24 %24