Merge commit '1fa693ca4462fc1f790693464cf765ad693616af' into sync_cg_clif-2024-11-09

This commit is contained in:
bjorn3 2024-11-09 13:48:06 +00:00
commit c94f759f10
17 changed files with 52 additions and 26 deletions

View File

@ -38,7 +38,7 @@ index 42a26ae..5ac1042 100644
@@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
+#![cfg(test)] +#![cfg(test)]
// tidy-alphabetical-start // tidy-alphabetical-start
#![cfg_attr(bootstrap, feature(const_three_way_compare))]
#![cfg_attr(bootstrap, feature(strict_provenance))] #![cfg_attr(bootstrap, feature(strict_provenance))]
#![cfg_attr(not(bootstrap), feature(strict_provenance_lints))]
-- --
2.21.0 (Apple Git-122) 2.21.0 (Apple Git-122)

View File

@ -15,7 +15,7 @@ index 1e336bf..35e6f54 100644
--- a/lib.rs --- a/lib.rs
+++ b/lib.rs +++ b/lib.rs
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
// tidy-alphabetical-start #![cfg_attr(bootstrap, feature(const_three_way_compare))]
#![cfg_attr(bootstrap, feature(strict_provenance))] #![cfg_attr(bootstrap, feature(strict_provenance))]
#![cfg_attr(not(bootstrap), feature(strict_provenance_lints))] #![cfg_attr(not(bootstrap), feature(strict_provenance_lints))]
-#![cfg_attr(target_has_atomic = "128", feature(integer_atomics))] -#![cfg_attr(target_has_atomic = "128", feature(integer_atomics))]

View File

@ -1,4 +1,4 @@
[toolchain] [toolchain]
channel = "nightly-2024-11-02" channel = "nightly-2024-11-09"
components = ["rust-src", "rustc-dev", "llvm-tools"] components = ["rust-src", "rustc-dev", "llvm-tools"]
profile = "minimal" profile = "minimal"

View File

@ -11,5 +11,22 @@ rm -r compiler/rustc_codegen_cranelift/{Cargo.*,src}
cp ../Cargo.* compiler/rustc_codegen_cranelift/ cp ../Cargo.* compiler/rustc_codegen_cranelift/
cp -r ../src compiler/rustc_codegen_cranelift/src cp -r ../src compiler/rustc_codegen_cranelift/src
# FIXME(rust-lang/rust#132719) remove once it doesn't break without this patch
cat <<EOF | git apply -
diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs
index 3394f2a84a0..cb980dd4d7c 100644
--- a/src/bootstrap/src/core/build_steps/compile.rs
+++ b/src/bootstrap/src/core/build_steps/compile.rs
@@ -1976,7 +1976,7 @@ fn run(self, builder: &Builder<'_>) -> Compiler {
}
}
- {
+ if builder.config.llvm_enabled(target_compiler.host) && builder.config.llvm_tools_enabled {
// \`llvm-strip\` is used by rustc, which is actually just a symlink to \`llvm-objcopy\`,
// so copy and rename \`llvm-objcopy\`.
let src_exe = exe("llvm-objcopy", target_compiler.host);
EOF
./x.py build --stage 1 library/std ./x.py build --stage 1 library/std
popd popd

View File

@ -3,7 +3,7 @@
use std::borrow::Cow; use std::borrow::Cow;
use rustc_target::abi::call::PassMode; use rustc_target::callconv::PassMode;
use crate::prelude::*; use crate::prelude::*;

View File

@ -10,6 +10,7 @@
use cranelift_codegen::ir::{ArgumentPurpose, SigRef}; use cranelift_codegen::ir::{ArgumentPurpose, SigRef};
use cranelift_codegen::isa::CallConv; use cranelift_codegen::isa::CallConv;
use cranelift_module::ModuleError; use cranelift_module::ModuleError;
use rustc_abi::ExternAbi;
use rustc_codegen_ssa::base::is_call_from_compiler_builtins_to_upstream_monomorphization; use rustc_codegen_ssa::base::is_call_from_compiler_builtins_to_upstream_monomorphization;
use rustc_codegen_ssa::errors::CompilerBuiltinsCannotCall; use rustc_codegen_ssa::errors::CompilerBuiltinsCannotCall;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
@ -18,8 +19,7 @@
use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_session::Session; use rustc_session::Session;
use rustc_span::source_map::Spanned; use rustc_span::source_map::Spanned;
use rustc_target::abi::call::{Conv, FnAbi, PassMode}; use rustc_target::callconv::{Conv, FnAbi, PassMode};
use rustc_target::spec::abi::Abi;
use self::pass_mode::*; use self::pass_mode::*;
pub(crate) use self::returning::codegen_return; pub(crate) use self::returning::codegen_return;
@ -443,7 +443,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
RevealAllLayoutCx(fx.tcx).fn_abi_of_fn_ptr(fn_sig, extra_args) RevealAllLayoutCx(fx.tcx).fn_abi_of_fn_ptr(fn_sig, extra_args)
}; };
let is_cold = if fn_sig.abi() == Abi::RustCold { let is_cold = if fn_sig.abi() == ExternAbi::RustCold {
true true
} else { } else {
instance.is_some_and(|inst| { instance.is_some_and(|inst| {
@ -458,7 +458,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
} }
// Unpack arguments tuple for closures // Unpack arguments tuple for closures
let mut args = if fn_sig.abi() == Abi::RustCall { let mut args = if fn_sig.abi() == ExternAbi::RustCall {
let (self_arg, pack_arg) = match args { let (self_arg, pack_arg) = match args {
[pack_arg] => (None, codegen_call_argument_operand(fx, &pack_arg.node)), [pack_arg] => (None, codegen_call_argument_operand(fx, &pack_arg.node)),
[self_arg, pack_arg] => ( [self_arg, pack_arg] => (

View File

@ -1,8 +1,9 @@
//! Argument passing //! Argument passing
use cranelift_codegen::ir::{ArgumentExtension, ArgumentPurpose}; use cranelift_codegen::ir::{ArgumentExtension, ArgumentPurpose};
use rustc_target::abi::call::{ use rustc_abi::{Reg, RegKind};
ArgAbi, ArgAttributes, ArgExtension as RustcArgExtension, CastTarget, PassMode, Reg, RegKind, use rustc_target::callconv::{
ArgAbi, ArgAttributes, ArgExtension as RustcArgExtension, CastTarget, PassMode,
}; };
use smallvec::{SmallVec, smallvec}; use smallvec::{SmallVec, smallvec};

View File

@ -1,6 +1,6 @@
//! Return value handling //! Return value handling
use rustc_target::abi::call::{ArgAbi, PassMode}; use rustc_target::callconv::{ArgAbi, PassMode};
use smallvec::{SmallVec, smallvec}; use smallvec::{SmallVec, smallvec};
use crate::prelude::*; use crate::prelude::*;

View File

@ -934,7 +934,7 @@ fn is_wide_ptr<'tcx>(fx: &FunctionCx<'_, '_, 'tcx>, ty: Ty<'tcx>) -> bool {
let dst = codegen_operand(fx, dst); let dst = codegen_operand(fx, dst);
let pointee = dst let pointee = dst
.layout() .layout()
.pointee_info_at(fx, rustc_target::abi::Size::ZERO) .pointee_info_at(fx, rustc_abi::Size::ZERO)
.expect("Expected pointer"); .expect("Expected pointer");
let dst = dst.load_scalar(fx); let dst = dst.load_scalar(fx);
let src = codegen_operand(fx, src).load_scalar(fx); let src = codegen_operand(fx, src).load_scalar(fx);

View File

@ -1,13 +1,13 @@
use cranelift_codegen::isa::TargetFrontendConfig; use cranelift_codegen::isa::TargetFrontendConfig;
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext}; use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
use rustc_abi::{Float, Integer, Primitive};
use rustc_index::IndexVec; use rustc_index::IndexVec;
use rustc_middle::ty::TypeFoldable; use rustc_middle::ty::TypeFoldable;
use rustc_middle::ty::layout::{ use rustc_middle::ty::layout::{
self, FnAbiError, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOfHelpers, self, FnAbiError, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOfHelpers,
}; };
use rustc_span::source_map::Spanned; use rustc_span::source_map::Spanned;
use rustc_target::abi::call::FnAbi; use rustc_target::callconv::FnAbi;
use rustc_target::abi::{Float, Integer, Primitive};
use rustc_target::spec::{HasTargetSpec, Target}; use rustc_target::spec::{HasTargetSpec, Target};
use crate::constant::ConstantCx; use crate::constant::ConstantCx;
@ -162,8 +162,8 @@ pub(crate) fn codegen_icmp_imm(
pub(crate) fn codegen_bitcast(fx: &mut FunctionCx<'_, '_, '_>, dst_ty: Type, val: Value) -> Value { pub(crate) fn codegen_bitcast(fx: &mut FunctionCx<'_, '_, '_>, dst_ty: Type, val: Value) -> Value {
let mut flags = MemFlags::new(); let mut flags = MemFlags::new();
flags.set_endianness(match fx.tcx.data_layout.endian { flags.set_endianness(match fx.tcx.data_layout.endian {
rustc_target::abi::Endian::Big => cranelift_codegen::ir::Endianness::Big, rustc_abi::Endian::Big => cranelift_codegen::ir::Endianness::Big,
rustc_target::abi::Endian::Little => cranelift_codegen::ir::Endianness::Little, rustc_abi::Endian::Little => cranelift_codegen::ir::Endianness::Little,
}); });
fx.bcx.ins().bitcast(dst_ty, flags, val) fx.bcx.ins().bitcast(dst_ty, flags, val)
} }
@ -333,8 +333,8 @@ fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
} }
} }
impl<'tcx> rustc_target::abi::HasDataLayout for FunctionCx<'_, '_, 'tcx> { impl<'tcx> rustc_abi::HasDataLayout for FunctionCx<'_, '_, 'tcx> {
fn data_layout(&self) -> &rustc_target::abi::TargetDataLayout { fn data_layout(&self) -> &rustc_abi::TargetDataLayout {
&self.tcx.data_layout &self.tcx.data_layout
} }
} }
@ -491,8 +491,8 @@ fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
} }
} }
impl<'tcx> rustc_target::abi::HasDataLayout for RevealAllLayoutCx<'tcx> { impl<'tcx> rustc_abi::HasDataLayout for RevealAllLayoutCx<'tcx> {
fn data_layout(&self) -> &rustc_target::abi::TargetDataLayout { fn data_layout(&self) -> &rustc_abi::TargetDataLayout {
&self.0.data_layout &self.0.data_layout
} }
} }

View File

@ -20,7 +20,7 @@
use rustc_hir::def_id::DefIdMap; use rustc_hir::def_id::DefIdMap;
use rustc_session::Session; use rustc_session::Session;
use rustc_span::{FileNameDisplayPreference, SourceFileHash, StableSourceFileId}; use rustc_span::{FileNameDisplayPreference, SourceFileHash, StableSourceFileId};
use rustc_target::abi::call::FnAbi; use rustc_target::callconv::FnAbi;
pub(crate) use self::emit::{DebugReloc, DebugRelocName}; pub(crate) use self::emit::{DebugReloc, DebugRelocName};
pub(crate) use self::types::TypeDebugContext; pub(crate) use self::types::TypeDebugContext;

View File

@ -2,6 +2,7 @@
//! standalone executable. //! standalone executable.
use std::fs::{self, File}; use std::fs::{self, File};
use std::io::BufWriter;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::sync::Arc; use std::sync::Arc;
use std::thread::JoinHandle; use std::thread::JoinHandle;
@ -397,14 +398,19 @@ fn emit_module(
} }
let tmp_file = output_filenames.temp_path(OutputType::Object, Some(&name)); let tmp_file = output_filenames.temp_path(OutputType::Object, Some(&name));
let mut file = match File::create(&tmp_file) { let file = match File::create(&tmp_file) {
Ok(file) => file, Ok(file) => file,
Err(err) => return Err(format!("error creating object file: {}", err)), Err(err) => return Err(format!("error creating object file: {}", err)),
}; };
let mut file = BufWriter::new(file);
if let Err(err) = object.write_stream(&mut file) { if let Err(err) = object.write_stream(&mut file) {
return Err(format!("error writing object file: {}", err)); return Err(format!("error writing object file: {}", err));
} }
let file = match file.into_inner() {
Ok(file) => file,
Err(err) => return Err(format!("error writing object file: {}", err)),
};
prof.artifact_size("object_file", &*name, file.metadata().unwrap().len()); prof.artifact_size("object_file", &*name, file.metadata().unwrap().len());

View File

@ -464,7 +464,7 @@ fn allocate_stack_slots(&mut self) {
let new_slot_fn = |slot_size: &mut Size, reg_class: InlineAsmRegClass| { let new_slot_fn = |slot_size: &mut Size, reg_class: InlineAsmRegClass| {
let reg_size = let reg_size =
reg_class.supported_types(self.arch).iter().map(|(ty, _)| ty.size()).max().unwrap(); reg_class.supported_types(self.arch).iter().map(|(ty, _)| ty.size()).max().unwrap();
let align = rustc_target::abi::Align::from_bytes(reg_size.bytes()).unwrap(); let align = rustc_abi::Align::from_bytes(reg_size.bytes()).unwrap();
let offset = slot_size.align_to(align); let offset = slot_size.align_to(align);
*slot_size = offset + reg_size; *slot_size = offset + reg_size;
offset offset

View File

@ -1,7 +1,7 @@
//! Codegen SIMD intrinsics. //! Codegen SIMD intrinsics.
use cranelift_codegen::ir::immediates::Offset32; use cranelift_codegen::ir::immediates::Offset32;
use rustc_target::abi::Endian; use rustc_abi::Endian;
use super::*; use super::*;
use crate::prelude::*; use crate::prelude::*;

View File

@ -241,6 +241,8 @@ fn join_codegen(
sess: &Session, sess: &Session,
outputs: &OutputFilenames, outputs: &OutputFilenames,
) -> (CodegenResults, FxIndexMap<WorkProductId, WorkProduct>) { ) -> (CodegenResults, FxIndexMap<WorkProductId, WorkProduct>) {
let _timer = sess.timer("finish_ongoing_codegen");
ongoing_codegen.downcast::<driver::aot::OngoingCodegen>().unwrap().join( ongoing_codegen.downcast::<driver::aot::OngoingCodegen>().unwrap().join(
sess, sess,
outputs, outputs,

View File

@ -2,7 +2,7 @@
//! operations. //! operations.
use cranelift_codegen::ir::immediates::Offset32; use cranelift_codegen::ir::immediates::Offset32;
use rustc_target::abi::Align; use rustc_abi::Align;
use crate::prelude::*; use crate::prelude::*;

View File

@ -64,7 +64,7 @@
use cranelift_codegen::write::{FuncWriter, PlainWriter}; use cranelift_codegen::write::{FuncWriter, PlainWriter};
use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_session::config::{OutputFilenames, OutputType}; use rustc_session::config::{OutputFilenames, OutputType};
use rustc_target::abi::call::FnAbi; use rustc_target::callconv::FnAbi;
use crate::prelude::*; use crate::prelude::*;