From 7e213fe42835b4fe828426271de220f0bf9a97e5 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 18 Dec 2023 22:21:37 +1100 Subject: [PATCH 01/15] Remove `Session` methods that duplicate `DiagCtxt` methods. Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access. --- src/abi/mod.rs | 18 +++++++++--------- src/base.rs | 8 ++++---- src/common.rs | 9 ++++++--- src/constant.rs | 8 ++++---- src/driver/aot.rs | 8 ++++---- src/driver/jit.rs | 8 ++++---- src/global_asm.rs | 4 ++-- src/inline_asm.rs | 6 +++--- src/intrinsics/llvm.rs | 2 +- src/intrinsics/llvm_aarch64.rs | 2 +- src/intrinsics/llvm_x86.rs | 14 +++++++++----- src/intrinsics/mod.rs | 10 +++++----- src/intrinsics/simd.rs | 18 +++++++++--------- src/lib.rs | 19 +++++++++++-------- src/main_shim.rs | 4 ++-- src/value_and_place.rs | 2 +- 16 files changed, 75 insertions(+), 65 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 2c194f6d6d3ad..795c8daec6a34 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -47,12 +47,12 @@ pub(crate) fn conv_to_call_conv(sess: &Session, c: Conv, default_call_conv: Call } Conv::X86Intr | Conv::RiscvInterrupt { .. } => { - sess.fatal(format!("interrupt call conv {c:?} not yet implemented")) + sess.dcx().fatal(format!("interrupt call conv {c:?} not yet implemented")) } - Conv::ArmAapcs => sess.fatal("aapcs call conv not yet implemented"), + Conv::ArmAapcs => sess.dcx().fatal("aapcs call conv not yet implemented"), Conv::CCmseNonSecureCall => { - sess.fatal("C-cmse-nonsecure-call call conv is not yet implemented"); + sess.dcx().fatal("C-cmse-nonsecure-call call conv is not yet implemented"); } Conv::Msp430Intr @@ -88,10 +88,10 @@ pub(crate) fn import_function<'tcx>( let sig = get_function_sig(tcx, module.target_config().default_call_conv, inst); match module.declare_function(name, Linkage::Import, &sig) { Ok(func_id) => func_id, - Err(ModuleError::IncompatibleDeclaration(_)) => tcx.sess.fatal(format!( + Err(ModuleError::IncompatibleDeclaration(_)) => tcx.dcx().fatal(format!( "attempt to declare `{name}` as function, but it was already declared as static" )), - Err(ModuleError::IncompatibleSignature(_, prev_sig, new_sig)) => tcx.sess.fatal(format!( + Err(ModuleError::IncompatibleSignature(_, prev_sig, new_sig)) => tcx.dcx().fatal(format!( "attempt to declare `{name}` with signature {new_sig:?}, \ but it was already declared with signature {prev_sig:?}" )), @@ -181,7 +181,7 @@ fn make_local_place<'tcx>( is_ssa: bool, ) -> CPlace<'tcx> { if layout.is_unsized() { - fx.tcx.sess.span_fatal( + fx.tcx.dcx().span_fatal( fx.mir.local_decls[local].source_info.span, "unsized locals are not yet supported", ); @@ -226,7 +226,7 @@ pub(crate) fn codegen_fn_prelude<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, start_ // FIXME implement variadics in cranelift if fn_abi.c_variadic { - fx.tcx.sess.span_fatal( + fx.tcx.dcx().span_fatal( fx.mir.span, "Defining variadic functions is not yet supported by Cranelift", ); @@ -543,7 +543,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( // FIXME find a cleaner way to support varargs if fn_sig.c_variadic() { if !matches!(fn_sig.abi(), Abi::C { .. }) { - fx.tcx.sess.span_fatal( + fx.tcx.dcx().span_fatal( source_info.span, format!("Variadic call for non-C abi {:?}", fn_sig.abi()), ); @@ -555,7 +555,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let ty = fx.bcx.func.dfg.value_type(arg); if !ty.is_int() { // FIXME set %al to upperbound on float args once floats are supported - fx.tcx.sess.span_fatal( + fx.tcx.dcx().span_fatal( source_info.span, format!("Non int ty {:?} for variadic call", ty), ); diff --git a/src/base.rs b/src/base.rs index 8d3be19839e9a..881c0c0b56b6f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -236,13 +236,13 @@ pub(crate) fn verify_func( match cranelift_codegen::verify_function(&func, &flags) { Ok(_) => {} Err(err) => { - tcx.sess.err(format!("{:?}", err)); + tcx.dcx().err(format!("{:?}", err)); let pretty_error = cranelift_codegen::print_errors::pretty_verifier_error( &func, Some(Box::new(writer)), err, ); - tcx.sess.fatal(format!("cranelift verify error:\n{}", pretty_error)); + tcx.dcx().fatal(format!("cranelift verify error:\n{}", pretty_error)); } } }); @@ -450,7 +450,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) { unwind: _, } => { if options.contains(InlineAsmOptions::MAY_UNWIND) { - fx.tcx.sess.span_fatal( + fx.tcx.dcx().span_fatal( source_info.span, "cranelift doesn't support unwinding from inline assembly.", ); @@ -812,7 +812,7 @@ fn codegen_stmt<'tcx>( | StatementKind::PlaceMention(..) | StatementKind::AscribeUserType(..) => {} - StatementKind::Coverage { .. } => fx.tcx.sess.fatal("-Zcoverage is unimplemented"), + StatementKind::Coverage { .. } => fx.tcx.dcx().fatal("-Zcoverage is unimplemented"), StatementKind::Intrinsic(ref intrinsic) => match &**intrinsic { // We ignore `assume` intrinsics, they are only useful for optimizations NonDivergingIntrinsic::Assume(_) => {} diff --git a/src/common.rs b/src/common.rs index bd19a7ed0592e..1e37825b54896 100644 --- a/src/common.rs +++ b/src/common.rs @@ -465,9 +465,12 @@ impl<'tcx> LayoutOfHelpers<'tcx> for RevealAllLayoutCx<'tcx> { #[inline] fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! { if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err { - self.0.sess.span_fatal(span, err.to_string()) + self.0.sess.dcx().span_fatal(span, err.to_string()) } else { - self.0.sess.span_fatal(span, format!("failed to get layout for `{}`: {}", ty, err)) + self.0 + .sess + .dcx() + .span_fatal(span, format!("failed to get layout for `{}`: {}", ty, err)) } } } @@ -483,7 +486,7 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for RevealAllLayoutCx<'tcx> { fn_abi_request: FnAbiRequest<'tcx>, ) -> ! { if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err { - self.0.sess.emit_fatal(Spanned { span, node: err }) + self.0.sess.dcx().emit_fatal(Spanned { span, node: err }) } else { match fn_abi_request { FnAbiRequest::OfFnPtr { sig, extra_args } => { diff --git a/src/constant.rs b/src/constant.rs index 9ffa006e59b69..b6de688130c79 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -263,7 +263,7 @@ fn data_id_for_static( attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL), ) { Ok(data_id) => data_id, - Err(ModuleError::IncompatibleDeclaration(_)) => tcx.sess.fatal(format!( + Err(ModuleError::IncompatibleDeclaration(_)) => tcx.dcx().fatal(format!( "attempt to declare `{symbol_name}` as static, but it was already declared as function" )), Err(err) => Err::<_, _>(err).unwrap(), @@ -311,7 +311,7 @@ fn data_id_for_static( attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL), ) { Ok(data_id) => data_id, - Err(ModuleError::IncompatibleDeclaration(_)) => tcx.sess.fatal(format!( + Err(ModuleError::IncompatibleDeclaration(_)) => tcx.dcx().fatal(format!( "attempt to declare `{symbol_name}` as static, but it was already declared as function" )), Err(err) => Err::<_, _>(err).unwrap(), @@ -360,7 +360,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant if let Some(names) = section_name.split_once(',') { names } else { - tcx.sess.fatal(format!( + tcx.dcx().fatal(format!( "#[link_section = \"{}\"] is not valid for macos target: must be segment and section separated by comma", section_name )); @@ -406,7 +406,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant GlobalAlloc::Static(def_id) => { if tcx.codegen_fn_attrs(def_id).flags.contains(CodegenFnAttrFlags::THREAD_LOCAL) { - tcx.sess.fatal(format!( + tcx.dcx().fatal(format!( "Allocation {:?} contains reference to TLS value {:?}", alloc_id, def_id )); diff --git a/src/driver/aot.rs b/src/driver/aot.rs index b3ab533df3dcb..df457b1608502 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -69,7 +69,7 @@ impl OngoingCodegen { let module_codegen_result = match module_codegen_result { Ok(module_codegen_result) => module_codegen_result, - Err(err) => sess.fatal(err), + Err(err) => sess.dcx().fatal(err), }; let ModuleCodegenResult { module_regular, module_global_asm, existing_work_product } = module_codegen_result; @@ -422,7 +422,7 @@ pub(crate) fn run_aot( backend_config.clone(), global_asm_config.clone(), cgu.name(), - concurrency_limiter.acquire(tcx.sess.dcx()), + concurrency_limiter.acquire(tcx.dcx()), ), module_codegen, Some(rustc_middle::dep_graph::hash_result), @@ -455,7 +455,7 @@ pub(crate) fn run_aot( "allocator_shim".to_owned(), ) { Ok(allocator_module) => Some(allocator_module), - Err(err) => tcx.sess.fatal(err), + Err(err) => tcx.dcx().fatal(err), } } else { None @@ -478,7 +478,7 @@ pub(crate) fn run_aot( let obj = create_compressed_metadata_file(tcx.sess, &metadata, &symbol_name); if let Err(err) = std::fs::write(&tmp_file, obj) { - tcx.sess.fatal(format!("error writing metadata object file: {}", err)); + tcx.dcx().fatal(format!("error writing metadata object file: {}", err)); } (metadata_cgu_name, tmp_file) diff --git a/src/driver/jit.rs b/src/driver/jit.rs index 6ee65d12c73e9..63fa89d79bcda 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -94,11 +94,11 @@ fn create_jit_module( pub(crate) fn run_jit(tcx: TyCtxt<'_>, backend_config: BackendConfig) -> ! { if !tcx.sess.opts.output_types.should_codegen() { - tcx.sess.fatal("JIT mode doesn't work with `cargo check`"); + tcx.dcx().fatal("JIT mode doesn't work with `cargo check`"); } if !tcx.crate_types().contains(&rustc_session::config::CrateType::Executable) { - tcx.sess.fatal("can't jit non-executable crate"); + tcx.dcx().fatal("can't jit non-executable crate"); } let (mut jit_module, mut cx) = create_jit_module( @@ -141,14 +141,14 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, backend_config: BackendConfig) -> ! { } MonoItem::GlobalAsm(item_id) => { let item = tcx.hir().item(item_id); - tcx.sess.span_fatal(item.span, "Global asm is not supported in JIT mode"); + tcx.dcx().span_fatal(item.span, "Global asm is not supported in JIT mode"); } } } }); if !cx.global_asm.is_empty() { - tcx.sess.fatal("Inline asm is not supported in JIT mode"); + tcx.dcx().fatal("Inline asm is not supported in JIT mode"); } tcx.sess.abort_if_errors(); diff --git a/src/global_asm.rs b/src/global_asm.rs index b14007f4e5232..af99239d81593 100644 --- a/src/global_asm.rs +++ b/src/global_asm.rs @@ -47,7 +47,7 @@ pub(crate) fn codegen_global_asm_item(tcx: TyCtxt<'_>, global_asm: &mut String, } InlineAsmOperand::SymFn { anon_const } => { if cfg!(not(feature = "inline_asm_sym")) { - tcx.sess.span_err( + tcx.dcx().span_err( item.span, "asm! and global_asm! sym operands are not yet supported", ); @@ -65,7 +65,7 @@ pub(crate) fn codegen_global_asm_item(tcx: TyCtxt<'_>, global_asm: &mut String, } InlineAsmOperand::SymStatic { path: _, def_id } => { if cfg!(not(feature = "inline_asm_sym")) { - tcx.sess.span_err( + tcx.dcx().span_err( item.span, "asm! and global_asm! sym operands are not yet supported", ); diff --git a/src/inline_asm.rs b/src/inline_asm.rs index 73f4bc7c15111..6b9cec39d7020 100644 --- a/src/inline_asm.rs +++ b/src/inline_asm.rs @@ -84,7 +84,7 @@ pub(crate) fn codegen_inline_asm_terminator<'tcx>( InlineAsmOperand::SymFn { ref value } => { if cfg!(not(feature = "inline_asm_sym")) { fx.tcx - .sess + .dcx() .span_err(span, "asm! and global_asm! sym operands are not yet supported"); } @@ -455,7 +455,7 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> { } _ => self .tcx - .sess + .dcx() .fatal(format!("Unsupported binary format for inline asm: {binary_format:?}")), } @@ -563,7 +563,7 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> { BinaryFormat::Macho | BinaryFormat::Coff => {} _ => self .tcx - .sess + .dcx() .fatal(format!("Unsupported binary format for inline asm: {binary_format:?}")), } diff --git a/src/intrinsics/llvm.rs b/src/intrinsics/llvm.rs index dbd5db87511df..a38a728c926d8 100644 --- a/src/intrinsics/llvm.rs +++ b/src/intrinsics/llvm.rs @@ -68,7 +68,7 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>( _ => { fx.tcx - .sess + .dcx() .warn(format!("unsupported llvm intrinsic {}; replacing with trap", intrinsic)); crate::trap::trap_unimplemented(fx, intrinsic); return; diff --git a/src/intrinsics/llvm_aarch64.rs b/src/intrinsics/llvm_aarch64.rs index e1e514dca44f3..c8f9c3997a63f 100644 --- a/src/intrinsics/llvm_aarch64.rs +++ b/src/intrinsics/llvm_aarch64.rs @@ -309,7 +309,7 @@ pub(crate) fn codegen_aarch64_llvm_intrinsic_call<'tcx>( } */ _ => { - fx.tcx.sess.warn(format!( + fx.tcx.dcx().warn(format!( "unsupported AArch64 llvm intrinsic {}; replacing with trap", intrinsic )); diff --git a/src/intrinsics/llvm_x86.rs b/src/intrinsics/llvm_x86.rs index 99bb5c4eae2d8..81114cbf40d83 100644 --- a/src/intrinsics/llvm_x86.rs +++ b/src/intrinsics/llvm_x86.rs @@ -960,7 +960,9 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( { imm8 } else { - fx.tcx.sess.span_fatal(span, "Index argument for `_mm_cmpestri` is not a constant"); + fx.tcx + .dcx() + .span_fatal(span, "Index argument for `_mm_cmpestri` is not a constant"); }; let imm8 = imm8.try_to_u8().unwrap_or_else(|_| panic!("kind not scalar: {:?}", imm8)); @@ -1011,7 +1013,9 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( { imm8 } else { - fx.tcx.sess.span_fatal(span, "Index argument for `_mm_cmpestrm` is not a constant"); + fx.tcx + .dcx() + .span_fatal(span, "Index argument for `_mm_cmpestrm` is not a constant"); }; let imm8 = imm8.try_to_u8().unwrap_or_else(|_| panic!("kind not scalar: {:?}", imm8)); @@ -1056,7 +1060,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( { imm8 } else { - fx.tcx.sess.span_fatal( + fx.tcx.dcx().span_fatal( span, "Index argument for `_mm_clmulepi64_si128` is not a constant", ); @@ -1093,7 +1097,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( { imm8 } else { - fx.tcx.sess.span_fatal( + fx.tcx.dcx().span_fatal( span, "Index argument for `_mm_aeskeygenassist_si128` is not a constant", ); @@ -1361,7 +1365,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>( _ => { fx.tcx - .sess + .dcx() .warn(format!("unsupported x86 llvm intrinsic {}; replacing with trap", intrinsic)); crate::trap::trap_unimplemented(fx, intrinsic); return; diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 68126f1242426..15249402a63e7 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -37,7 +37,7 @@ fn report_atomic_type_validation_error<'tcx>( span: Span, ty: Ty<'tcx>, ) { - fx.tcx.sess.span_err( + fx.tcx.dcx().span_err( span, format!( "`{}` intrinsic: expected basic integer or raw pointer type, found `{:?}`", @@ -785,7 +785,7 @@ fn codegen_regular_intrinsic_call<'tcx>( return; } else { fx.tcx - .sess + .dcx() .span_fatal(source_info.span, "128bit atomics not yet supported"); } } @@ -816,7 +816,7 @@ fn codegen_regular_intrinsic_call<'tcx>( return; } else { fx.tcx - .sess + .dcx() .span_fatal(source_info.span, "128bit atomics not yet supported"); } } @@ -1245,7 +1245,7 @@ fn codegen_regular_intrinsic_call<'tcx>( // FIXME implement variadics in cranelift sym::va_copy | sym::va_arg | sym::va_end => { - fx.tcx.sess.span_fatal( + fx.tcx.dcx().span_fatal( source_info.span, "Defining variadic functions is not yet supported by Cranelift", ); @@ -1253,7 +1253,7 @@ fn codegen_regular_intrinsic_call<'tcx>( _ => { fx.tcx - .sess + .dcx() .span_fatal(source_info.span, format!("unsupported intrinsic {}", intrinsic)); } } diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index fe4f073f79933..16a550f45b839 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -12,7 +12,7 @@ fn report_simd_type_validation_error( span: Span, ty: Ty<'_>, ) { - fx.tcx.sess.span_err(span, format!("invalid monomorphization of `{}` intrinsic: expected SIMD input type, found non-SIMD `{}`", intrinsic, ty)); + fx.tcx.dcx().span_err(span, format!("invalid monomorphization of `{}` intrinsic: expected SIMD input type, found non-SIMD `{}`", intrinsic, ty)); // Prevent verifier error fx.bcx.ins().trap(TrapCode::UnreachableCodeReached); } @@ -192,7 +192,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( .try_into() .unwrap(), _ => { - fx.tcx.sess.span_err( + fx.tcx.dcx().span_err( span, format!("simd_shuffle index must be an array of `u32`, got `{}`", idx_ty), ); @@ -278,7 +278,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( { idx_const } else { - fx.tcx.sess.span_fatal(span, "Index argument for `simd_insert` is not a constant"); + fx.tcx.dcx().span_fatal(span, "Index argument for `simd_insert` is not a constant"); }; let idx: u32 = idx_const @@ -286,7 +286,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( .unwrap_or_else(|_| panic!("kind not scalar: {:?}", idx_const)); let (lane_count, _lane_ty) = base.layout().ty.simd_size_and_type(fx.tcx); if u64::from(idx) >= lane_count { - fx.tcx.sess.span_fatal( + fx.tcx.dcx().span_fatal( fx.mir.span, format!("[simd_insert] idx {} >= lane_count {}", idx, lane_count), ); @@ -316,7 +316,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( { idx_const } else { - fx.tcx.sess.span_warn(span, "Index argument for `simd_extract` is not a constant"); + fx.tcx.dcx().span_warn(span, "Index argument for `simd_extract` is not a constant"); let trap_block = fx.bcx.create_block(); let true_ = fx.bcx.ins().iconst(types::I8, 1); let ret_block = fx.get_block(target); @@ -334,7 +334,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( .unwrap_or_else(|_| panic!("kind not scalar: {:?}", idx_const)); let (lane_count, _lane_ty) = v.layout().ty.simd_size_and_type(fx.tcx); if u64::from(idx) >= lane_count { - fx.tcx.sess.span_fatal( + fx.tcx.dcx().span_fatal( fx.mir.span, format!("[simd_extract] idx {} >= lane_count {}", idx, lane_count), ); @@ -859,7 +859,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( match lane_ty.kind() { ty::Int(_) | ty::Uint(_) => {} _ => { - fx.tcx.sess.span_fatal( + fx.tcx.dcx().span_fatal( span, format!( "invalid monomorphization of `simd_bitmask` intrinsic: \ @@ -899,7 +899,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( && len.try_eval_target_usize(fx.tcx, ty::ParamEnv::reveal_all()) == Some(expected_bytes) => {} _ => { - fx.tcx.sess.span_fatal( + fx.tcx.dcx().span_fatal( span, format!( "invalid monomorphization of `simd_bitmask` intrinsic: \ @@ -1086,7 +1086,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( } _ => { - fx.tcx.sess.span_err(span, format!("Unknown SIMD intrinsic {}", intrinsic)); + fx.tcx.dcx().span_err(span, format!("Unknown SIMD intrinsic {}", intrinsic)); // Prevent verifier error fx.bcx.ins().trap(TrapCode::UnreachableCodeReached); return; diff --git a/src/lib.rs b/src/lib.rs index d0ce209be4446..b9e02587fbc0d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -177,13 +177,15 @@ impl CodegenBackend for CraneliftCodegenBackend { use rustc_session::config::Lto; match sess.lto() { Lto::No | Lto::ThinLocal => {} - Lto::Thin | Lto::Fat => sess.warn("LTO is not supported. You may get a linker error."), + Lto::Thin | Lto::Fat => { + sess.dcx().warn("LTO is not supported. You may get a linker error.") + } } let mut config = self.config.borrow_mut(); if config.is_none() { let new_config = BackendConfig::from_opts(&sess.opts.cg.llvm_args) - .unwrap_or_else(|err| sess.fatal(err)); + .unwrap_or_else(|err| sess.dcx().fatal(err)); *config = Some(new_config); } } @@ -211,7 +213,7 @@ impl CodegenBackend for CraneliftCodegenBackend { driver::jit::run_jit(tcx, config); #[cfg(not(feature = "jit"))] - tcx.sess.fatal("jit support was disabled when compiling rustc_codegen_cranelift"); + tcx.dcx().fatal("jit support was disabled when compiling rustc_codegen_cranelift"); } } } @@ -243,7 +245,7 @@ impl CodegenBackend for CraneliftCodegenBackend { fn target_triple(sess: &Session) -> target_lexicon::Triple { match sess.target.llvm_target.parse() { Ok(triple) => triple, - Err(err) => sess.fatal(format!("target not recognized: {}", err)), + Err(err) => sess.dcx().fatal(format!("target not recognized: {}", err)), } } @@ -310,17 +312,18 @@ fn build_isa(sess: &Session, backend_config: &BackendConfig) -> Arc { let mut builder = cranelift_codegen::isa::lookup(target_triple.clone()).unwrap_or_else(|err| { - sess.fatal(format!("can't compile for {}: {}", target_triple, err)); + sess.dcx().fatal(format!("can't compile for {}: {}", target_triple, err)); }); if let Err(_) = builder.enable(value) { - sess.fatal("the specified target cpu isn't currently supported by Cranelift."); + sess.dcx() + .fatal("the specified target cpu isn't currently supported by Cranelift."); } builder } None => { let mut builder = cranelift_codegen::isa::lookup(target_triple.clone()).unwrap_or_else(|err| { - sess.fatal(format!("can't compile for {}: {}", target_triple, err)); + sess.dcx().fatal(format!("can't compile for {}: {}", target_triple, err)); }); if target_triple.architecture == target_lexicon::Architecture::X86_64 { // Don't use "haswell" as the default, as it implies `has_lzcnt`. @@ -333,7 +336,7 @@ fn build_isa(sess: &Session, backend_config: &BackendConfig) -> Arc target_isa, - Err(err) => sess.fatal(format!("failed to build TargetIsa: {}", err)), + Err(err) => sess.dcx().fatal(format!("failed to build TargetIsa: {}", err)), } } diff --git a/src/main_shim.rs b/src/main_shim.rs index b5efe44d8b3c8..6535c3a367b87 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -74,7 +74,7 @@ pub(crate) fn maybe_create_entry_wrapper( let cmain_func_id = match m.declare_function(entry_name, Linkage::Export, &cmain_sig) { Ok(func_id) => func_id, Err(err) => { - tcx.sess + tcx.dcx() .fatal(format!("entry symbol `{entry_name}` declared multiple times: {err}")); } }; @@ -171,7 +171,7 @@ pub(crate) fn maybe_create_entry_wrapper( } if let Err(err) = m.define_function(cmain_func_id, &mut ctx) { - tcx.sess.fatal(format!("entry symbol `{entry_name}` defined multiple times: {err}")); + tcx.dcx().fatal(format!("entry symbol `{entry_name}` defined multiple times: {err}")); } unwind_context.add_function(cmain_func_id, &ctx, m.isa()); diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 567a5669d4969..838c73fa21365 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -397,7 +397,7 @@ impl<'tcx> CPlace<'tcx> { if layout.size.bytes() >= u64::from(u32::MAX - 16) { fx.tcx - .sess + .dcx() .fatal(format!("values of type {} are too big to store on the stack", layout.ty)); } From 93c86f78b2e04b5a8c60f48d97fe5623638f0c00 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 21 Dec 2023 16:26:09 +1100 Subject: [PATCH 02/15] Remove more `Session` methods that duplicate `DiagCtxt` methods. --- src/driver/aot.rs | 2 +- src/driver/jit.rs | 4 ++-- src/lib.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/driver/aot.rs b/src/driver/aot.rs index df457b1608502..e77b0cd0721b2 100644 --- a/src/driver/aot.rs +++ b/src/driver/aot.rs @@ -108,7 +108,7 @@ impl OngoingCodegen { self.concurrency_limiter.finished(); - sess.abort_if_errors(); + sess.dcx().abort_if_errors(); ( CodegenResults { diff --git a/src/driver/jit.rs b/src/driver/jit.rs index 63fa89d79bcda..7905ec8402dfd 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -151,7 +151,7 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, backend_config: BackendConfig) -> ! { tcx.dcx().fatal("Inline asm is not supported in JIT mode"); } - tcx.sess.abort_if_errors(); + tcx.dcx().abort_if_errors(); jit_module.finalize_definitions().unwrap(); unsafe { cx.unwind_context.register_jit(&jit_module) }; @@ -338,7 +338,7 @@ fn dep_symbol_lookup_fn( .collect::>(), ); - sess.abort_if_errors(); + sess.dcx().abort_if_errors(); Box::new(move |sym_name| { for dylib in &*imported_dylibs { diff --git a/src/lib.rs b/src/lib.rs index b9e02587fbc0d..b482f0dd2f0ab 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -204,7 +204,7 @@ impl CodegenBackend for CraneliftCodegenBackend { metadata: EncodedMetadata, need_metadata_module: bool, ) -> Box { - tcx.sess.abort_if_errors(); + tcx.dcx().abort_if_errors(); let config = self.config.borrow().clone().unwrap(); match config.codegen_mode { CodegenMode::Aot => driver::aot::run_aot(tcx, config, metadata, need_metadata_module), From 7325d0de63b1b8992a11970eb51e7a2f10aee191 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 24 Dec 2023 14:35:19 +0000 Subject: [PATCH 03/15] Merge commit '26c02eb2904da9a53d2220d4f3069b19a3c81d3d' into sync_cg_clif-2023-12-24 --- Cargo.lock | 52 ++++++++++++++++++------------------- Cargo.toml | 12 ++++----- rust-toolchain | 2 +- scripts/test_rustc_tests.sh | 3 ++- src/intrinsics/simd.rs | 31 ++++++++++++++++++++++ 5 files changed, 66 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 901d1dbea66b3..74e7afee7bcb2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -45,18 +45,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cranelift-bforest" -version = "0.102.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76eb38f2af690b5a4411d9a8782b6d77dabff3ca939e0518453ab9f9a4392d41" +checksum = "7c22542c0b95bd3302f7ed6839869c561f2324bac2fd5e7e99f5cfa65fdc8b92" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.102.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39526c036b92912417e8931f52c1e235796688068d3efdbbd8b164f299d19156" +checksum = "6b3db903ef2e9c8a4de2ea6db5db052c7857282952f9df604aa55d169e6000d8" dependencies = [ "bumpalo", "cranelift-bforest", @@ -75,39 +75,39 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.102.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdb0deedc9fccf2db53a5a3c9c9d0163e44143b0d004dca9bf6ab6a0024cd79a" +checksum = "6590feb5a1d6438f974bf6a5ac4dddf69fca14e1f07f3265d880f69e61a94463" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.102.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cea2d1b274e45aa8e61e9103efa1ba82d4b5a19d12bd1fd10744c3b7380ba3ff" +checksum = "7239038c56fafe77fddc8788fc8533dd6c474dc5bdc5637216404f41ba807330" [[package]] name = "cranelift-control" -version = "0.102.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea5977559a71e63db79a263f0e81a89b996e8a38212c4281e37dd1dbaa8b65c" +checksum = "f7dc9c595341404d381d27a3d950160856b35b402275f0c3990cd1ad683c8053" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.102.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f871ada808b58158d84dfc43a6a2e2d2756baaf4ed1c51fd969ca8330e6ca5c" +checksum = "44e3ee532fc4776c69bcedf7e62f9632cbb3f35776fa9a525cdade3195baa3f7" [[package]] name = "cranelift-frontend" -version = "0.102.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8e6890f587ef59824b3debe577e68fdf9b307b3808c54b8d93a18fd0b70941b" +checksum = "a612c94d09e653662ec37681dc2d6fd2b9856e6df7147be0afc9aabb0abf19df" dependencies = [ "cranelift-codegen", "log", @@ -117,15 +117,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.102.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8d5fc6d5d3b52d1917002b17a8ecce448c2621b5bf394bb4e77e2f676893537" +checksum = "85db9830abeb1170b7d29b536ffd55af1d4d26ac8a77570b5d1aca003bf225cc" [[package]] name = "cranelift-jit" -version = "0.102.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8a2d7744f743f59d9646d7589ad22ea17ed0d71e04906eb77c31e99bc13bd8b" +checksum = "4946271f1055e26544ef8c90fa24776f201566419dfac4b3962c39d5a804ff67" dependencies = [ "anyhow", "cranelift-codegen", @@ -143,9 +143,9 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.102.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b96cb196334698e612c197d7d0ae59af5e07667306ec20d7be414717db400873" +checksum = "cb7e3bdae2597556e59edeb8ecb62eb32c7e054c4f042d393732902979db69c3" dependencies = [ "anyhow", "cranelift-codegen", @@ -154,9 +154,9 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.102.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e10c2e7faa65d4ae7de9a83b44f2c31aca7dc638e17d0a79572fdf8103d720b" +checksum = "301ef0edafeaeda5771a5d2db64ac53e1818ae3111220a185677025fe91db4a1" dependencies = [ "cranelift-codegen", "libc", @@ -165,9 +165,9 @@ dependencies = [ [[package]] name = "cranelift-object" -version = "0.102.0" +version = "0.103.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83ce94e18756058af8a66e3c0ba1123ae15517c72162d8060d0cb0974642adf2" +checksum = "59e0ee3d013728903e0c513c31afa389b559bfd4fe8a44f80335c799e3132a41" dependencies = [ "anyhow", "cranelift-codegen", @@ -374,9 +374,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasmtime-jit-icache-coherence" -version = "15.0.0" +version = "16.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b73ad1395eda136baec5ece7e079e0536a82ef73488e345456cc9b89858ad0ec" +checksum = "6b6d197fcc34ad32ed440e1f9552fd57d1f377d9699d31dee1b5b457322c1f8a" dependencies = [ "cfg-if", "libc", diff --git a/Cargo.toml b/Cargo.toml index 20fcd22273219..fdac789423c9c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,12 +8,12 @@ crate-type = ["dylib"] [dependencies] # These have to be in sync with each other -cranelift-codegen = { version = "0.102", default-features = false, features = ["std", "unwind", "all-arch"] } -cranelift-frontend = { version = "0.102" } -cranelift-module = { version = "0.102" } -cranelift-native = { version = "0.102" } -cranelift-jit = { version = "0.102", optional = true } -cranelift-object = { version = "0.102" } +cranelift-codegen = { version = "0.103", default-features = false, features = ["std", "unwind", "all-arch"] } +cranelift-frontend = { version = "0.103" } +cranelift-module = { version = "0.103" } +cranelift-native = { version = "0.103" } +cranelift-jit = { version = "0.103", optional = true } +cranelift-object = { version = "0.103" } target-lexicon = "0.12.0" gimli = { version = "0.28", default-features = false, features = ["write"]} object = { version = "0.32", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] } diff --git a/rust-toolchain b/rust-toolchain index 4ba08f1af44bf..e1e1760c5977f 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-12-19" +channel = "nightly-2023-12-24" components = ["rust-src", "rustc-dev", "llvm-tools"] diff --git a/scripts/test_rustc_tests.sh b/scripts/test_rustc_tests.sh index 7d7ffdadc7f74..636f2875a6873 100755 --- a/scripts/test_rustc_tests.sh +++ b/scripts/test_rustc_tests.sh @@ -31,6 +31,7 @@ rm tests/ui/parser/unclosed-delimiter-in-dep.rs # submodule contains //~ERROR # FIXME add needs-unwind to these tests rm -r tests/run-make/libtest-junit rm tests/ui/asm/may_unwind.rs +rm tests/ui/stable-mir-print/basic_function.rs # extra warning about -Cpanic=abort for proc macros rm tests/ui/proc-macro/crt-static.rs @@ -44,7 +45,6 @@ rm tests/ui/proc-macro/no-mangle-in-proc-macro-issue-111888.rs # vendor intrinsics rm tests/ui/sse2.rs # CodegenBackend::target_features not yet implemented rm tests/ui/simd/array-type.rs # "Index argument for `simd_insert` is not a constant" -rm tests/ui/simd/masked-load-store.rs # exotic linkages rm tests/ui/issues/issue-33992.rs # unsupported linkages @@ -80,6 +80,7 @@ rm -r tests/run-make/codegen-options-parsing rm -r tests/run-make/lto-* rm -r tests/run-make/reproducible-build-2 rm -r tests/run-make/issue-109934-lto-debuginfo +rm -r tests/run-make/no-builtins-lto # optimization tests # ================== diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index fe4f073f79933..9242021ce2e54 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -962,6 +962,37 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( } } + sym::simd_masked_store => { + intrinsic_args!(fx, args => (mask, ptr, val); intrinsic); + + let (val_lane_count, val_lane_ty) = val.layout().ty.simd_size_and_type(fx.tcx); + let (mask_lane_count, _mask_lane_ty) = mask.layout().ty.simd_size_and_type(fx.tcx); + assert_eq!(val_lane_count, mask_lane_count); + let lane_clif_ty = fx.clif_type(val_lane_ty).unwrap(); + let ptr_val = ptr.load_scalar(fx); + + for lane_idx in 0..val_lane_count { + let val_lane = val.value_lane(fx, lane_idx).load_scalar(fx); + let mask_lane = mask.value_lane(fx, lane_idx).load_scalar(fx); + + let if_enabled = fx.bcx.create_block(); + let next = fx.bcx.create_block(); + + fx.bcx.ins().brif(mask_lane, if_enabled, &[], next, &[]); + fx.bcx.seal_block(if_enabled); + + fx.bcx.switch_to_block(if_enabled); + let offset = lane_idx as i32 * lane_clif_ty.bytes() as i32; + fx.bcx.ins().store(MemFlags::trusted(), val_lane, ptr_val, Offset32::new(offset)); + fx.bcx.ins().jump(next, &[]); + + fx.bcx.seal_block(next); + fx.bcx.switch_to_block(next); + + fx.bcx.ins().nop(); + } + } + sym::simd_gather => { intrinsic_args!(fx, args => (val, ptr, mask); intrinsic); From 653121cd38433cd1e697b2af5196a3a8c7fbb894 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 24 Dec 2023 14:38:37 +0000 Subject: [PATCH 04/15] Fix borked subtree syncs --- example/mini_core_hello_world.rs | 287 ++++--------------------------- src/intrinsics/simd.rs | 2 +- 2 files changed, 33 insertions(+), 256 deletions(-) diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs index 1d51b499c8bae..a1cdf31c68a00 100644 --- a/example/mini_core_hello_world.rs +++ b/example/mini_core_hello_world.rs @@ -538,261 +538,38 @@ pub enum E1 { pub enum E2 { V1 { f: bool }, - /*_00*/ _01(X), - _02(X), - _03(X), - _04(X), - _05(X), - _06(X), - _07(X), - _08(X), - _09(X), - _0A(X), - _0B(X), - _0C(X), - _0D(X), - _0E(X), - _0F(X), - _10(X), - _11(X), - _12(X), - _13(X), - _14(X), - _15(X), - _16(X), - _17(X), - _18(X), - _19(X), - _1A(X), - _1B(X), - _1C(X), - _1D(X), - _1E(X), - _1F(X), - _20(X), - _21(X), - _22(X), - _23(X), - _24(X), - _25(X), - _26(X), - _27(X), - _28(X), - _29(X), - _2A(X), - _2B(X), - _2C(X), - _2D(X), - _2E(X), - _2F(X), - _30(X), - _31(X), - _32(X), - _33(X), - _34(X), - _35(X), - _36(X), - _37(X), - _38(X), - _39(X), - _3A(X), - _3B(X), - _3C(X), - _3D(X), - _3E(X), - _3F(X), - _40(X), - _41(X), - _42(X), - _43(X), - _44(X), - _45(X), - _46(X), - _47(X), - _48(X), - _49(X), - _4A(X), - _4B(X), - _4C(X), - _4D(X), - _4E(X), - _4F(X), - _50(X), - _51(X), - _52(X), - _53(X), - _54(X), - _55(X), - _56(X), - _57(X), - _58(X), - _59(X), - _5A(X), - _5B(X), - _5C(X), - _5D(X), - _5E(X), - _5F(X), - _60(X), - _61(X), - _62(X), - _63(X), - _64(X), - _65(X), - _66(X), - _67(X), - _68(X), - _69(X), - _6A(X), - _6B(X), - _6C(X), - _6D(X), - _6E(X), - _6F(X), - _70(X), - _71(X), - _72(X), - _73(X), - _74(X), - _75(X), - _76(X), - _77(X), - _78(X), - _79(X), - _7A(X), - _7B(X), - _7C(X), - _7D(X), - _7E(X), - _7F(X), - _80(X), - _81(X), - _82(X), - _83(X), - _84(X), - _85(X), - _86(X), - _87(X), - _88(X), - _89(X), - _8A(X), - _8B(X), - _8C(X), - _8D(X), - _8E(X), - _8F(X), - _90(X), - _91(X), - _92(X), - _93(X), - _94(X), - _95(X), - _96(X), - _97(X), - _98(X), - _99(X), - _9A(X), - _9B(X), - _9C(X), - _9D(X), - _9E(X), - _9F(X), - _A0(X), - _A1(X), - _A2(X), - _A3(X), - _A4(X), - _A5(X), - _A6(X), - _A7(X), - _A8(X), - _A9(X), - _AA(X), - _AB(X), - _AC(X), - _AD(X), - _AE(X), - _AF(X), - _B0(X), - _B1(X), - _B2(X), - _B3(X), - _B4(X), - _B5(X), - _B6(X), - _B7(X), - _B8(X), - _B9(X), - _BA(X), - _BB(X), - _BC(X), - _BD(X), - _BE(X), - _BF(X), - _C0(X), - _C1(X), - _C2(X), - _C3(X), - _C4(X), - _C5(X), - _C6(X), - _C7(X), - _C8(X), - _C9(X), - _CA(X), - _CB(X), - _CC(X), - _CD(X), - _CE(X), - _CF(X), - _D0(X), - _D1(X), - _D2(X), - _D3(X), - _D4(X), - _D5(X), - _D6(X), - _D7(X), - _D8(X), - _D9(X), - _DA(X), - _DB(X), - _DC(X), - _DD(X), - _DE(X), - _DF(X), - _E0(X), - _E1(X), - _E2(X), - _E3(X), - _E4(X), - _E5(X), - _E6(X), - _E7(X), - _E8(X), - _E9(X), - _EA(X), - _EB(X), - _EC(X), - _ED(X), - _EE(X), - _EF(X), - _F0(X), - _F1(X), - _F2(X), - _F3(X), - _F4(X), - _F5(X), - _F6(X), - _F7(X), - _F8(X), - _F9(X), - _FA(X), - _FB(X), - _FC(X), - _FD(X), - _FE(X), - _FF(X), + /*_00*/ _01(X), _02(X), _03(X), _04(X), _05(X), _06(X), _07(X), + _08(X), _09(X), _0A(X), _0B(X), _0C(X), _0D(X), _0E(X), _0F(X), + _10(X), _11(X), _12(X), _13(X), _14(X), _15(X), _16(X), _17(X), + _18(X), _19(X), _1A(X), _1B(X), _1C(X), _1D(X), _1E(X), _1F(X), + _20(X), _21(X), _22(X), _23(X), _24(X), _25(X), _26(X), _27(X), + _28(X), _29(X), _2A(X), _2B(X), _2C(X), _2D(X), _2E(X), _2F(X), + _30(X), _31(X), _32(X), _33(X), _34(X), _35(X), _36(X), _37(X), + _38(X), _39(X), _3A(X), _3B(X), _3C(X), _3D(X), _3E(X), _3F(X), + _40(X), _41(X), _42(X), _43(X), _44(X), _45(X), _46(X), _47(X), + _48(X), _49(X), _4A(X), _4B(X), _4C(X), _4D(X), _4E(X), _4F(X), + _50(X), _51(X), _52(X), _53(X), _54(X), _55(X), _56(X), _57(X), + _58(X), _59(X), _5A(X), _5B(X), _5C(X), _5D(X), _5E(X), _5F(X), + _60(X), _61(X), _62(X), _63(X), _64(X), _65(X), _66(X), _67(X), + _68(X), _69(X), _6A(X), _6B(X), _6C(X), _6D(X), _6E(X), _6F(X), + _70(X), _71(X), _72(X), _73(X), _74(X), _75(X), _76(X), _77(X), + _78(X), _79(X), _7A(X), _7B(X), _7C(X), _7D(X), _7E(X), _7F(X), + _80(X), _81(X), _82(X), _83(X), _84(X), _85(X), _86(X), _87(X), + _88(X), _89(X), _8A(X), _8B(X), _8C(X), _8D(X), _8E(X), _8F(X), + _90(X), _91(X), _92(X), _93(X), _94(X), _95(X), _96(X), _97(X), + _98(X), _99(X), _9A(X), _9B(X), _9C(X), _9D(X), _9E(X), _9F(X), + _A0(X), _A1(X), _A2(X), _A3(X), _A4(X), _A5(X), _A6(X), _A7(X), + _A8(X), _A9(X), _AA(X), _AB(X), _AC(X), _AD(X), _AE(X), _AF(X), + _B0(X), _B1(X), _B2(X), _B3(X), _B4(X), _B5(X), _B6(X), _B7(X), + _B8(X), _B9(X), _BA(X), _BB(X), _BC(X), _BD(X), _BE(X), _BF(X), + _C0(X), _C1(X), _C2(X), _C3(X), _C4(X), _C5(X), _C6(X), _C7(X), + _C8(X), _C9(X), _CA(X), _CB(X), _CC(X), _CD(X), _CE(X), _CF(X), + _D0(X), _D1(X), _D2(X), _D3(X), _D4(X), _D5(X), _D6(X), _D7(X), + _D8(X), _D9(X), _DA(X), _DB(X), _DC(X), _DD(X), _DE(X), _DF(X), + _E0(X), _E1(X), _E2(X), _E3(X), _E4(X), _E5(X), _E6(X), _E7(X), + _E8(X), _E9(X), _EA(X), _EB(X), _EC(X), _ED(X), _EE(X), _EF(X), + _F0(X), _F1(X), _F2(X), _F3(X), _F4(X), _F5(X), _F6(X), _F7(X), + _F8(X), _F9(X), _FA(X), _FB(X), _FC(X), _FD(X), _FE(X), _FF(X), V3, V4, diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index 9242021ce2e54..d06237f8d9182 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -1088,7 +1088,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( } sym::simd_scatter => { - intrinsic_args!(fx, args => (mask, ptr, val); intrinsic); + intrinsic_args!(fx, args => (val, ptr, mask); intrinsic); let (val_lane_count, _val_lane_ty) = val.layout().ty.simd_size_and_type(fx.tcx); let (ptr_lane_count, _ptr_lane_ty) = ptr.layout().ty.simd_size_and_type(fx.tcx); From e101a1bbb765496e0cf7d460519c5cdf875baa92 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 26 Dec 2023 11:25:52 +0000 Subject: [PATCH 05/15] Avoid warning about the jobserver fd not being open for recursive rustc calls for inline asm Fixes rust-lang/rustc_codegen_cranelift#1437 --- src/global_asm.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/global_asm.rs b/src/global_asm.rs index b14007f4e5232..f5ecfc7a51309 100644 --- a/src/global_asm.rs +++ b/src/global_asm.rs @@ -154,6 +154,8 @@ pub(crate) fn compile_global_asm( } } else { let mut child = Command::new(std::env::current_exe().unwrap()) + // Avoid a warning about the jobserver fd not being passed + .env_remove("CARGO_MAKEFLAGS") .arg("--target") .arg(&config.target) .arg("--crate-type") From 1dbb24984411bf8a7b20b3678059779e4209d302 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 28 Dec 2023 16:26:57 +0000 Subject: [PATCH 06/15] Rustup to rustc 1.77.0-nightly (89e2160c4 2023-12-27) --- rust-toolchain | 2 +- src/driver/jit.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rust-toolchain b/rust-toolchain index e1e1760c5977f..d6c1738dfa54d 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-12-24" +channel = "nightly-2023-12-28" components = ["rust-src", "rustc-dev", "llvm-tools"] diff --git a/src/driver/jit.rs b/src/driver/jit.rs index 7905ec8402dfd..a8d8fb189e2e0 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -321,7 +321,7 @@ fn dep_symbol_lookup_fn( Linkage::NotLinked | Linkage::IncludedFromDylib => {} Linkage::Static => { let name = crate_info.crate_name[&cnum]; - let mut err = sess.struct_err(format!("Can't load static lib {}", name)); + let mut err = sess.dcx().struct_err(format!("Can't load static lib {}", name)); err.note("rustc_codegen_cranelift can only load dylibs in JIT mode."); err.emit(); } From 6b1a3ad4a69c5d4374081f9caf362b54bb277dda Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Thu, 21 Dec 2023 01:52:10 +0000 Subject: [PATCH 07/15] Remove movability from TyKind::Coroutine --- src/value_and_place.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 838c73fa21365..f016e6950d48d 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -974,8 +974,8 @@ pub(crate) fn assert_assignable<'tcx>( } } } - (&ty::Coroutine(def_id_a, args_a, mov_a), &ty::Coroutine(def_id_b, args_b, mov_b)) - if def_id_a == def_id_b && mov_a == mov_b => + (&ty::Coroutine(def_id_a, args_a), &ty::Coroutine(def_id_b, args_b)) + if def_id_a == def_id_b => { let mut types_a = args_a.types(); let mut types_b = args_b.types(); From 5c95200e9609e8382ed7147d66beeca1769d60b2 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sat, 30 Dec 2023 12:06:21 +0000 Subject: [PATCH 08/15] Rustup to rustc 1.77.0-nightly (3cdd004e5 2023-12-29) --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index d6c1738dfa54d..8bbd92732d083 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-12-28" +channel = "nightly-2023-12-30" components = ["rust-src", "rustc-dev", "llvm-tools"] From 75f1c2b5a7e2e63271cc848430300c1173279f4e Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 31 Dec 2023 10:46:02 +0000 Subject: [PATCH 09/15] Rustup to rustc 1.77.0-nightly (2a3e63551 2023-12-30) --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index 8bbd92732d083..a086c0293601f 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-12-30" +channel = "nightly-2023-12-31" components = ["rust-src", "rustc-dev", "llvm-tools"] From 4b239facd7d6ccaa2e5fc6775030f5c5b87dd6aa Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 31 Dec 2023 11:01:07 +0000 Subject: [PATCH 10/15] Install hyperfine using the system package manager --- .github/workflows/main.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 05dc28d074530..402d279cc8597 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -175,14 +175,10 @@ jobs: path: build/cg_clif key: ${{ runner.os }}-x86_64-unknown-linux-gnu-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }} - - name: Cache cargo bin dir - uses: actions/cache@v3 - with: - path: ~/.cargo/bin - key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-bin-dir-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }} - - name: Install hyperfine - run: cargo install hyperfine || true + run: | + sudo apt update + sudo apt install -y hyperfine - name: Prepare dependencies run: ./y.sh prepare From e2502acd157c605a7341244b0c02c25b213e9078 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 31 Dec 2023 11:04:53 +0000 Subject: [PATCH 11/15] Update the GHA artifacts actions to v4 --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 402d279cc8597..9bbb18fc37fca 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -253,14 +253,14 @@ jobs: - name: Upload prebuilt cg_clif if: matrix.os == 'windows-latest' || matrix.env.TARGET_TRIPLE != 'x86_64-pc-windows-gnu' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: cg_clif-${{ matrix.env.TARGET_TRIPLE }} path: cg_clif.tar.xz - name: Upload prebuilt cg_clif (cross compile) if: matrix.os != 'windows-latest' && matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: cg_clif-${{ runner.os }}-cross-x86_64-mingw path: cg_clif.tar.xz @@ -279,7 +279,7 @@ jobs: - uses: actions/checkout@v3 - name: Download all built artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: path: artifacts/ From 3fa4efffb0dd3b7ebd82d2096deecb5dd7f8c8fc Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 31 Dec 2023 11:14:50 +0000 Subject: [PATCH 12/15] Install ripgrep using the system package manager --- .github/workflows/rustc.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/rustc.yml b/.github/workflows/rustc.yml index cb5dd51fee310..8085dc58263cc 100644 --- a/.github/workflows/rustc.yml +++ b/.github/workflows/rustc.yml @@ -43,6 +43,11 @@ jobs: path: build/cg_clif key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }} + - name: Install ripgrep + run: | + sudo apt update + sudo apt install -y ripgrep + - name: Prepare dependencies run: ./y.sh prepare From d58de3ea817301655ec74b211d0cb7a6e08d40c4 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 31 Dec 2023 11:34:26 +0000 Subject: [PATCH 13/15] Suppress progress notifications for all git commands --- scripts/setup_rust_fork.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/setup_rust_fork.sh b/scripts/setup_rust_fork.sh index 731828caae2c4..578f7b1d07267 100644 --- a/scripts/setup_rust_fork.sh +++ b/scripts/setup_rust_fork.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e -# CG_CLIF_FORCE_GNU_AS will force usage of as instead of the LLVM backend of rustc as we +# CG_CLIF_FORCE_GNU_AS will force usage of as instead of the LLVM backend of rustc as # the LLVM backend isn't compiled in here. export CG_CLIF_FORCE_GNU_AS=1 @@ -11,11 +11,13 @@ export CG_CLIF_FORCE_GNU_AS=1 CG_CLIF_STDLIB_REMAP_PATH_PREFIX=/rustc/FAKE_PREFIX ./y.sh build echo "[SETUP] Rust fork" -git clone https://github.com/rust-lang/rust.git --filter=tree:0 || true +git clone --quiet https://github.com/rust-lang/rust.git --filter=tree:0 || true pushd rust git fetch -git checkout -- . -git checkout "$(rustc -V | cut -d' ' -f3 | tr -d '(')" +git checkout --no-progress -- . +git checkout --no-progress "$(rustc -V | cut -d' ' -f3 | tr -d '(')" + +git submodule update --quiet --init src/tools/cargo library/backtrace library/stdarch git -c user.name=Dummy -c user.email=dummy@example.com -c commit.gpgSign=false \ am ../patches/*-stdlib-*.patch From 02183f79e402cc94047510e8834d3ac742eeec07 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 31 Dec 2023 12:22:38 +0000 Subject: [PATCH 14/15] Suppress default config change warnings --- scripts/setup_rust_fork.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/setup_rust_fork.sh b/scripts/setup_rust_fork.sh index 578f7b1d07267..8526a4f736524 100644 --- a/scripts/setup_rust_fork.sh +++ b/scripts/setup_rust_fork.sh @@ -23,7 +23,7 @@ git -c user.name=Dummy -c user.email=dummy@example.com -c commit.gpgSign=false \ am ../patches/*-stdlib-*.patch cat > config.toml < Date: Sun, 31 Dec 2023 12:39:20 +0000 Subject: [PATCH 15/15] Remove no longer needed config option from setup_rust_fork.sh --- scripts/setup_rust_fork.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/setup_rust_fork.sh b/scripts/setup_rust_fork.sh index 8526a4f736524..684a5d0729355 100644 --- a/scripts/setup_rust_fork.sh +++ b/scripts/setup_rust_fork.sh @@ -25,9 +25,6 @@ git -c user.name=Dummy -c user.email=dummy@example.com -c commit.gpgSign=false \ cat > config.toml <