Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subtree sync for rustc_codegen_cranelift #132807

Merged
merged 21 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
322d392
Move versioned LLVM target creation to rustc_codegen_ssa
madsmtm Nov 1, 2024
e2a5108
Merge commit '5b1246bb4bed72fd0bb8fa497d8e5ed2c7f3515c' into sync_cg_…
bjorn3 Nov 2, 2024
2b97b2a
Merge branch 'sync_from_rust'
bjorn3 Nov 2, 2024
541c33e
Rename target triple to target tuple in many places in the compiler
Noratrieb Oct 17, 2024
12677fd
Auto merge of #132526 - bjorn3:sync_cg_clif-2024-11-02, r=bjorn3
bors Nov 3, 2024
29d225d
Manual rustup to rustc 1.84.0-nightly (b3f75cc87 2024-11-02)
bjorn3 Nov 3, 2024
521288e
Skip testing extended_sysroot tests with cg_llvm on CI
bjorn3 Nov 3, 2024
42f7128
cg_clif: Directly use rustc_abi
workingjubilee Nov 3, 2024
5e1298c
Revert "Skip testing extended_sysroot tests with cg_llvm on CI"
bjorn3 Nov 3, 2024
aedbae6
Merge pull request #1540 from workingjubilee/directly-use-rustc-abi
bjorn3 Nov 3, 2024
e7279c8
Sync from rust 8549802939cd01111c46e34a7b67cb1933977af9
bjorn3 Nov 7, 2024
b71483b
Rustup to rustc 1.84.0-nightly (854980293 2024-11-06)
bjorn3 Nov 7, 2024
b5966e4
Fix bootstrap test
bjorn3 Nov 7, 2024
ba6a384
remove 'platform-intrinsic' ABI leftovers
RalfJung Nov 7, 2024
00354dd
remove support for rustc_safe_intrinsic attribute; use rustc_intrinsi…
RalfJung Nov 7, 2024
c637a84
Add finish_ongoing_codegen timer in join_codegen to match cg_llvm
bjorn3 Nov 8, 2024
8a0053e
Use a BufWriter in emit_module to reduce syscall overhead
bjorn3 Nov 8, 2024
e9ac680
Merge pull request #1541 from rust-lang/perf_opts
bjorn3 Nov 9, 2024
cc7d30a
Sync from rust 59cec72a57af178767a7b8e7f624b06cc50f1087
bjorn3 Nov 9, 2024
1fa693c
Rustup to rustc 1.84.0-nightly (59cec72a5 2024-11-08)
bjorn3 Nov 9, 2024
c94f759
Merge commit '1fa693ca4462fc1f790693464cf765ad693616af' into sync_cg_…
bjorn3 Nov 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ index 42a26ae..5ac1042 100644
@@ -1,3 +1,4 @@
+#![cfg(test)]
// tidy-alphabetical-start
#![cfg_attr(bootstrap, feature(const_three_way_compare))]
#![cfg_attr(bootstrap, feature(strict_provenance))]
#![cfg_attr(not(bootstrap), feature(strict_provenance_lints))]
--
2.21.0 (Apple Git-122)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ index 1e336bf..35e6f54 100644
--- a/lib.rs
+++ b/lib.rs
@@ -2,7 +2,6 @@
// tidy-alphabetical-start
#![cfg_attr(bootstrap, feature(const_three_way_compare))]
#![cfg_attr(bootstrap, feature(strict_provenance))]
#![cfg_attr(not(bootstrap), feature(strict_provenance_lints))]
-#![cfg_attr(target_has_atomic = "128", feature(integer_atomics))]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "nightly-2024-11-02"
channel = "nightly-2024-11-09"
components = ["rust-src", "rustc-dev", "llvm-tools"]
profile = "minimal"
17 changes: 17 additions & 0 deletions compiler/rustc_codegen_cranelift/scripts/test_bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,22 @@ rm -r compiler/rustc_codegen_cranelift/{Cargo.*,src}
cp ../Cargo.* compiler/rustc_codegen_cranelift/
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
popd
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/abi/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use std::borrow::Cow;

use rustc_target::abi::call::PassMode;
use rustc_target::callconv::PassMode;

use crate::prelude::*;

Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_cranelift/src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::mem;
use cranelift_codegen::ir::{ArgumentPurpose, SigRef};
use cranelift_codegen::isa::CallConv;
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::errors::CompilerBuiltinsCannotCall;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
Expand All @@ -18,8 +19,7 @@ use rustc_middle::ty::layout::FnAbiOf;
use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_session::Session;
use rustc_span::source_map::Spanned;
use rustc_target::abi::call::{Conv, FnAbi, PassMode};
use rustc_target::spec::abi::Abi;
use rustc_target::callconv::{Conv, FnAbi, PassMode};

use self::pass_mode::*;
pub(crate) use self::returning::codegen_return;
Expand Down Expand Up @@ -443,7 +443,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
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
} else {
instance.is_some_and(|inst| {
Expand All @@ -458,7 +458,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
}

// 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 {
[pack_arg] => (None, codegen_call_argument_operand(fx, &pack_arg.node)),
[self_arg, pack_arg] => (
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//! Argument passing

use cranelift_codegen::ir::{ArgumentExtension, ArgumentPurpose};
use rustc_target::abi::call::{
ArgAbi, ArgAttributes, ArgExtension as RustcArgExtension, CastTarget, PassMode, Reg, RegKind,
use rustc_abi::{Reg, RegKind};
use rustc_target::callconv::{
ArgAbi, ArgAttributes, ArgExtension as RustcArgExtension, CastTarget, PassMode,
};
use smallvec::{SmallVec, smallvec};

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/abi/returning.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Return value handling

use rustc_target::abi::call::{ArgAbi, PassMode};
use rustc_target::callconv::{ArgAbi, PassMode};
use smallvec::{SmallVec, smallvec};

use crate::prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ fn codegen_stmt<'tcx>(
let dst = codegen_operand(fx, dst);
let pointee = dst
.layout()
.pointee_info_at(fx, rustc_target::abi::Size::ZERO)
.pointee_info_at(fx, rustc_abi::Size::ZERO)
.expect("Expected pointer");
let dst = dst.load_scalar(fx);
let src = codegen_operand(fx, src).load_scalar(fx);
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_codegen_cranelift/src/common.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use cranelift_codegen::isa::TargetFrontendConfig;
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
use rustc_abi::{Float, Integer, Primitive};
use rustc_index::IndexVec;
use rustc_middle::ty::TypeFoldable;
use rustc_middle::ty::layout::{
self, FnAbiError, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOfHelpers,
};
use rustc_span::source_map::Spanned;
use rustc_target::abi::call::FnAbi;
use rustc_target::abi::{Float, Integer, Primitive};
use rustc_target::callconv::FnAbi;
use rustc_target::spec::{HasTargetSpec, Target};

use crate::constant::ConstantCx;
Expand Down Expand Up @@ -162,8 +162,8 @@ pub(crate) fn codegen_icmp_imm(
pub(crate) fn codegen_bitcast(fx: &mut FunctionCx<'_, '_, '_>, dst_ty: Type, val: Value) -> Value {
let mut flags = MemFlags::new();
flags.set_endianness(match fx.tcx.data_layout.endian {
rustc_target::abi::Endian::Big => cranelift_codegen::ir::Endianness::Big,
rustc_target::abi::Endian::Little => cranelift_codegen::ir::Endianness::Little,
rustc_abi::Endian::Big => cranelift_codegen::ir::Endianness::Big,
rustc_abi::Endian::Little => cranelift_codegen::ir::Endianness::Little,
});
fx.bcx.ins().bitcast(dst_ty, flags, val)
}
Expand Down Expand Up @@ -333,8 +333,8 @@ impl<'tcx> layout::HasTyCtxt<'tcx> for FunctionCx<'_, '_, 'tcx> {
}
}

impl<'tcx> rustc_target::abi::HasDataLayout for FunctionCx<'_, '_, 'tcx> {
fn data_layout(&self) -> &rustc_target::abi::TargetDataLayout {
impl<'tcx> rustc_abi::HasDataLayout for FunctionCx<'_, '_, 'tcx> {
fn data_layout(&self) -> &rustc_abi::TargetDataLayout {
&self.tcx.data_layout
}
}
Expand Down Expand Up @@ -491,8 +491,8 @@ impl<'tcx> layout::HasTyCtxt<'tcx> for RevealAllLayoutCx<'tcx> {
}
}

impl<'tcx> rustc_target::abi::HasDataLayout for RevealAllLayoutCx<'tcx> {
fn data_layout(&self) -> &rustc_target::abi::TargetDataLayout {
impl<'tcx> rustc_abi::HasDataLayout for RevealAllLayoutCx<'tcx> {
fn data_layout(&self) -> &rustc_abi::TargetDataLayout {
&self.0.data_layout
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefIdMap;
use rustc_session::Session;
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::types::TypeDebugContext;
Expand Down
8 changes: 7 additions & 1 deletion compiler/rustc_codegen_cranelift/src/driver/aot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//! standalone executable.

use std::fs::{self, File};
use std::io::BufWriter;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use std::thread::JoinHandle;
Expand Down Expand Up @@ -397,14 +398,19 @@ fn emit_module(
}

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,
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) {
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());

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/inline_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> {
let new_slot_fn = |slot_size: &mut Size, reg_class: InlineAsmRegClass| {
let reg_size =
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);
*slot_size = offset + reg_size;
offset
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Codegen SIMD intrinsics.

use cranelift_codegen::ir::immediates::Offset32;
use rustc_target::abi::Endian;
use rustc_abi::Endian;

use super::*;
use crate::prelude::*;
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_codegen_cranelift/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ impl CodegenBackend for CraneliftCodegenBackend {
sess: &Session,
outputs: &OutputFilenames,
) -> (CodegenResults, FxIndexMap<WorkProductId, WorkProduct>) {
let _timer = sess.timer("finish_ongoing_codegen");

ongoing_codegen.downcast::<driver::aot::OngoingCodegen>().unwrap().join(
sess,
outputs,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! operations.

use cranelift_codegen::ir::immediates::Offset32;
use rustc_target::abi::Align;
use rustc_abi::Align;

use crate::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/pretty_clif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ use cranelift_codegen::ir::entities::AnyEntity;
use cranelift_codegen::write::{FuncWriter, PlainWriter};
use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_session::config::{OutputFilenames, OutputType};
use rustc_target::abi::call::FnAbi;
use rustc_target::callconv::FnAbi;

use crate::prelude::*;

Expand Down
Loading