Skip to content

Commit b73478b

Browse files
committed
Auto merge of rust-lang#132807 - bjorn3:sync_cg_clif-2024-11-09, r=bjorn3
Subtree sync for rustc_codegen_cranelift Apart from a perf optimization for some crates (rust-lang/rustc_codegen_cranelift#1541) not much changed this time as the last sync was less than a week ago. r? `@ghost` `@rustbot` label +A-codegen +A-cranelift +T-compiler
2 parents 8044557 + c94f759 commit b73478b

17 files changed

+52
-26
lines changed

compiler/rustc_codegen_cranelift/patches/0022-coretests-Disable-not-compiling-tests.patch

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ index 42a26ae..5ac1042 100644
3838
@@ -1,3 +1,4 @@
3939
+#![cfg(test)]
4040
// tidy-alphabetical-start
41+
#![cfg_attr(bootstrap, feature(const_three_way_compare))]
4142
#![cfg_attr(bootstrap, feature(strict_provenance))]
42-
#![cfg_attr(not(bootstrap), feature(strict_provenance_lints))]
4343
--
4444
2.21.0 (Apple Git-122)

compiler/rustc_codegen_cranelift/patches/0027-coretests-128bit-atomic-operations.patch

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ index 1e336bf..35e6f54 100644
1515
--- a/lib.rs
1616
+++ b/lib.rs
1717
@@ -2,7 +2,6 @@
18-
// tidy-alphabetical-start
18+
#![cfg_attr(bootstrap, feature(const_three_way_compare))]
1919
#![cfg_attr(bootstrap, feature(strict_provenance))]
2020
#![cfg_attr(not(bootstrap), feature(strict_provenance_lints))]
2121
-#![cfg_attr(target_has_atomic = "128", feature(integer_atomics))]
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[toolchain]
2-
channel = "nightly-2024-11-02"
2+
channel = "nightly-2024-11-09"
33
components = ["rust-src", "rustc-dev", "llvm-tools"]
44
profile = "minimal"

compiler/rustc_codegen_cranelift/scripts/test_bootstrap.sh

+17
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,22 @@ rm -r compiler/rustc_codegen_cranelift/{Cargo.*,src}
1111
cp ../Cargo.* compiler/rustc_codegen_cranelift/
1212
cp -r ../src compiler/rustc_codegen_cranelift/src
1313

14+
# FIXME(rust-lang/rust#132719) remove once it doesn't break without this patch
15+
cat <<EOF | git apply -
16+
diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs
17+
index 3394f2a84a0..cb980dd4d7c 100644
18+
--- a/src/bootstrap/src/core/build_steps/compile.rs
19+
+++ b/src/bootstrap/src/core/build_steps/compile.rs
20+
@@ -1976,7 +1976,7 @@ fn run(self, builder: &Builder<'_>) -> Compiler {
21+
}
22+
}
23+
24+
- {
25+
+ if builder.config.llvm_enabled(target_compiler.host) && builder.config.llvm_tools_enabled {
26+
// \`llvm-strip\` is used by rustc, which is actually just a symlink to \`llvm-objcopy\`,
27+
// so copy and rename \`llvm-objcopy\`.
28+
let src_exe = exe("llvm-objcopy", target_compiler.host);
29+
EOF
30+
1431
./x.py build --stage 1 library/std
1532
popd

compiler/rustc_codegen_cranelift/src/abi/comments.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
use std::borrow::Cow;
55

6-
use rustc_target::abi::call::PassMode;
6+
use rustc_target::callconv::PassMode;
77

88
use crate::prelude::*;
99

compiler/rustc_codegen_cranelift/src/abi/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use std::mem;
1010
use cranelift_codegen::ir::{ArgumentPurpose, SigRef};
1111
use cranelift_codegen::isa::CallConv;
1212
use cranelift_module::ModuleError;
13+
use rustc_abi::ExternAbi;
1314
use rustc_codegen_ssa::base::is_call_from_compiler_builtins_to_upstream_monomorphization;
1415
use rustc_codegen_ssa::errors::CompilerBuiltinsCannotCall;
1516
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
@@ -18,8 +19,7 @@ use rustc_middle::ty::layout::FnAbiOf;
1819
use rustc_middle::ty::print::with_no_trimmed_paths;
1920
use rustc_session::Session;
2021
use rustc_span::source_map::Spanned;
21-
use rustc_target::abi::call::{Conv, FnAbi, PassMode};
22-
use rustc_target::spec::abi::Abi;
22+
use rustc_target::callconv::{Conv, FnAbi, PassMode};
2323

2424
use self::pass_mode::*;
2525
pub(crate) use self::returning::codegen_return;
@@ -443,7 +443,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
443443
RevealAllLayoutCx(fx.tcx).fn_abi_of_fn_ptr(fn_sig, extra_args)
444444
};
445445

446-
let is_cold = if fn_sig.abi() == Abi::RustCold {
446+
let is_cold = if fn_sig.abi() == ExternAbi::RustCold {
447447
true
448448
} else {
449449
instance.is_some_and(|inst| {
@@ -458,7 +458,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
458458
}
459459

460460
// Unpack arguments tuple for closures
461-
let mut args = if fn_sig.abi() == Abi::RustCall {
461+
let mut args = if fn_sig.abi() == ExternAbi::RustCall {
462462
let (self_arg, pack_arg) = match args {
463463
[pack_arg] => (None, codegen_call_argument_operand(fx, &pack_arg.node)),
464464
[self_arg, pack_arg] => (

compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
//! Argument passing
22
33
use cranelift_codegen::ir::{ArgumentExtension, ArgumentPurpose};
4-
use rustc_target::abi::call::{
5-
ArgAbi, ArgAttributes, ArgExtension as RustcArgExtension, CastTarget, PassMode, Reg, RegKind,
4+
use rustc_abi::{Reg, RegKind};
5+
use rustc_target::callconv::{
6+
ArgAbi, ArgAttributes, ArgExtension as RustcArgExtension, CastTarget, PassMode,
67
};
78
use smallvec::{SmallVec, smallvec};
89

compiler/rustc_codegen_cranelift/src/abi/returning.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Return value handling
22
3-
use rustc_target::abi::call::{ArgAbi, PassMode};
3+
use rustc_target::callconv::{ArgAbi, PassMode};
44
use smallvec::{SmallVec, smallvec};
55

66
use crate::prelude::*;

compiler/rustc_codegen_cranelift/src/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ fn codegen_stmt<'tcx>(
934934
let dst = codegen_operand(fx, dst);
935935
let pointee = dst
936936
.layout()
937-
.pointee_info_at(fx, rustc_target::abi::Size::ZERO)
937+
.pointee_info_at(fx, rustc_abi::Size::ZERO)
938938
.expect("Expected pointer");
939939
let dst = dst.load_scalar(fx);
940940
let src = codegen_operand(fx, src).load_scalar(fx);

compiler/rustc_codegen_cranelift/src/common.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use cranelift_codegen::isa::TargetFrontendConfig;
22
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
3+
use rustc_abi::{Float, Integer, Primitive};
34
use rustc_index::IndexVec;
45
use rustc_middle::ty::TypeFoldable;
56
use rustc_middle::ty::layout::{
67
self, FnAbiError, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOfHelpers,
78
};
89
use rustc_span::source_map::Spanned;
9-
use rustc_target::abi::call::FnAbi;
10-
use rustc_target::abi::{Float, Integer, Primitive};
10+
use rustc_target::callconv::FnAbi;
1111
use rustc_target::spec::{HasTargetSpec, Target};
1212

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

336-
impl<'tcx> rustc_target::abi::HasDataLayout for FunctionCx<'_, '_, 'tcx> {
337-
fn data_layout(&self) -> &rustc_target::abi::TargetDataLayout {
336+
impl<'tcx> rustc_abi::HasDataLayout for FunctionCx<'_, '_, 'tcx> {
337+
fn data_layout(&self) -> &rustc_abi::TargetDataLayout {
338338
&self.tcx.data_layout
339339
}
340340
}
@@ -491,8 +491,8 @@ impl<'tcx> layout::HasTyCtxt<'tcx> for RevealAllLayoutCx<'tcx> {
491491
}
492492
}
493493

494-
impl<'tcx> rustc_target::abi::HasDataLayout for RevealAllLayoutCx<'tcx> {
495-
fn data_layout(&self) -> &rustc_target::abi::TargetDataLayout {
494+
impl<'tcx> rustc_abi::HasDataLayout for RevealAllLayoutCx<'tcx> {
495+
fn data_layout(&self) -> &rustc_abi::TargetDataLayout {
496496
&self.0.data_layout
497497
}
498498
}

compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use rustc_hir::def::DefKind;
2020
use rustc_hir::def_id::DefIdMap;
2121
use rustc_session::Session;
2222
use rustc_span::{FileNameDisplayPreference, SourceFileHash, StableSourceFileId};
23-
use rustc_target::abi::call::FnAbi;
23+
use rustc_target::callconv::FnAbi;
2424

2525
pub(crate) use self::emit::{DebugReloc, DebugRelocName};
2626
pub(crate) use self::types::TypeDebugContext;

compiler/rustc_codegen_cranelift/src/driver/aot.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//! standalone executable.
33
44
use std::fs::{self, File};
5+
use std::io::BufWriter;
56
use std::path::{Path, PathBuf};
67
use std::sync::Arc;
78
use std::thread::JoinHandle;
@@ -397,14 +398,19 @@ fn emit_module(
397398
}
398399

399400
let tmp_file = output_filenames.temp_path(OutputType::Object, Some(&name));
400-
let mut file = match File::create(&tmp_file) {
401+
let file = match File::create(&tmp_file) {
401402
Ok(file) => file,
402403
Err(err) => return Err(format!("error creating object file: {}", err)),
403404
};
404405

406+
let mut file = BufWriter::new(file);
405407
if let Err(err) = object.write_stream(&mut file) {
406408
return Err(format!("error writing object file: {}", err));
407409
}
410+
let file = match file.into_inner() {
411+
Ok(file) => file,
412+
Err(err) => return Err(format!("error writing object file: {}", err)),
413+
};
408414

409415
prof.artifact_size("object_file", &*name, file.metadata().unwrap().len());
410416

compiler/rustc_codegen_cranelift/src/inline_asm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> {
464464
let new_slot_fn = |slot_size: &mut Size, reg_class: InlineAsmRegClass| {
465465
let reg_size =
466466
reg_class.supported_types(self.arch).iter().map(|(ty, _)| ty.size()).max().unwrap();
467-
let align = rustc_target::abi::Align::from_bytes(reg_size.bytes()).unwrap();
467+
let align = rustc_abi::Align::from_bytes(reg_size.bytes()).unwrap();
468468
let offset = slot_size.align_to(align);
469469
*slot_size = offset + reg_size;
470470
offset

compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Codegen SIMD intrinsics.
22
33
use cranelift_codegen::ir::immediates::Offset32;
4-
use rustc_target::abi::Endian;
4+
use rustc_abi::Endian;
55

66
use super::*;
77
use crate::prelude::*;

compiler/rustc_codegen_cranelift/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ impl CodegenBackend for CraneliftCodegenBackend {
241241
sess: &Session,
242242
outputs: &OutputFilenames,
243243
) -> (CodegenResults, FxIndexMap<WorkProductId, WorkProduct>) {
244+
let _timer = sess.timer("finish_ongoing_codegen");
245+
244246
ongoing_codegen.downcast::<driver::aot::OngoingCodegen>().unwrap().join(
245247
sess,
246248
outputs,

compiler/rustc_codegen_cranelift/src/pointer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! operations.
33
44
use cranelift_codegen::ir::immediates::Offset32;
5-
use rustc_target::abi::Align;
5+
use rustc_abi::Align;
66

77
use crate::prelude::*;
88

compiler/rustc_codegen_cranelift/src/pretty_clif.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ use cranelift_codegen::ir::entities::AnyEntity;
6464
use cranelift_codegen::write::{FuncWriter, PlainWriter};
6565
use rustc_middle::ty::print::with_no_trimmed_paths;
6666
use rustc_session::config::{OutputFilenames, OutputType};
67-
use rustc_target::abi::call::FnAbi;
67+
use rustc_target::callconv::FnAbi;
6868

6969
use crate::prelude::*;
7070

0 commit comments

Comments
 (0)