Skip to content

Rollup of 8 pull requests #137497

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

Merged
merged 21 commits into from
Feb 24, 2025
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
04e7a10
intrinsics: unify rint, roundeven, nearbyint in a single round_ties_e…
RalfJung Feb 4, 2025
c930bb2
rustc_codegen_ssa: use slice patterns instead of len-check+indexing
yotamofek Feb 2, 2025
9e5e6a9
rustc_codegen_ssa: cleanup nested `if`s and a needless `match`
yotamofek Feb 2, 2025
a821785
rustc_codegen_ssa: simplify test for incompatible dependency formats
yotamofek Feb 2, 2025
73d5fe1
rustc_codegen_ssa: cleanup codegen attrs
yotamofek Feb 2, 2025
2c1f489
fix rustdoc test directives that were accidentally ignored
yotamofek Feb 15, 2025
17f2928
Adds binary_format to rustc target specs
Pyr0de Feb 14, 2025
d1b34ac
make the new intrinsics safe
RalfJung Feb 22, 2025
506532a
The sym crate is not a thing
compiler-errors Feb 23, 2025
54dd4c8
bootstrap: add module docs for core:metadata
Shourya742 Feb 23, 2025
08f1086
Update `compiler-builtins` to 0.1.147
tgross35 Feb 20, 2025
b9d0555
add stdarch compatibility hack
RalfJung Feb 23, 2025
c813d8f
rename sub_ptr 😅
bend-n Feb 23, 2025
31719b5
Rollup merge of #136439 - yotamofek:pr/codegen-ssa-no-indexing, r=Nor…
tgross35 Feb 23, 2025
a2bb4d7
Rollup merge of #136543 - RalfJung:round-ties-even, r=tgross35
tgross35 Feb 23, 2025
2c6fa32
Rollup merge of #136637 - Pyr0de:binary-format, r=Noratrieb
tgross35 Feb 23, 2025
5f35f78
Rollup merge of #137099 - yotamofek:pr/rustdoc/fix-ignored-test-direc…
tgross35 Feb 23, 2025
fb54acd
Rollup merge of #137297 - tgross35:update-builtins, r=tgross35
tgross35 Feb 23, 2025
781203d
Rollup merge of #137451 - compiler-errors:synm, r=Noratrieb
tgross35 Feb 23, 2025
e8342e7
Rollup merge of #137452 - Shourya742:2025-02-23-add-module-level-doc-…
tgross35 Feb 23, 2025
18ffee2
Rollup merge of #137483 - bend-n:😅, r=Noratrieb
tgross35 Feb 23, 2025
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 @@ -16,8 +16,8 @@ index 7165c3e48af..968552ad435 100644

[dependencies]
core = { path = "../core", public = true }
-compiler_builtins = { version = "=0.1.146", features = ['rustc-dep-of-std'] }
+compiler_builtins = { version = "=0.1.146", features = ['rustc-dep-of-std', 'no-f16-f128'] }
-compiler_builtins = { version = "=0.1.147", features = ['rustc-dep-of-std'] }
+compiler_builtins = { version = "=0.1.147", features = ['rustc-dep-of-std', 'no-f16-f128'] }

[dev-dependencies]
rand = { version = "0.8.5", default-features = false, features = ["alloc"] }
Expand Down
16 changes: 7 additions & 9 deletions compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,10 @@ fn codegen_float_intrinsic_call<'tcx>(
sym::ceilf64 => ("ceil", 1, fx.tcx.types.f64, types::F64),
sym::truncf32 => ("truncf", 1, fx.tcx.types.f32, types::F32),
sym::truncf64 => ("trunc", 1, fx.tcx.types.f64, types::F64),
sym::rintf32 => ("rintf", 1, fx.tcx.types.f32, types::F32),
sym::rintf64 => ("rint", 1, fx.tcx.types.f64, types::F64),
sym::round_ties_even_f32 => ("rintf", 1, fx.tcx.types.f32, types::F32),
sym::round_ties_even_f64 => ("rint", 1, fx.tcx.types.f64, types::F64),
sym::roundf32 => ("roundf", 1, fx.tcx.types.f32, types::F32),
sym::roundf64 => ("round", 1, fx.tcx.types.f64, types::F64),
sym::roundevenf32 => ("roundevenf", 1, fx.tcx.types.f32, types::F32),
sym::roundevenf64 => ("roundeven", 1, fx.tcx.types.f64, types::F64),
sym::nearbyintf32 => ("nearbyintf", 1, fx.tcx.types.f32, types::F32),
sym::nearbyintf64 => ("nearbyint", 1, fx.tcx.types.f64, types::F64),
sym::sinf32 => ("sinf", 1, fx.tcx.types.f32, types::F32),
sym::sinf64 => ("sin", 1, fx.tcx.types.f64, types::F64),
sym::cosf32 => ("cosf", 1, fx.tcx.types.f32, types::F32),
Expand Down Expand Up @@ -399,16 +395,18 @@ fn codegen_float_intrinsic_call<'tcx>(
| sym::ceilf64
| sym::truncf32
| sym::truncf64
| sym::nearbyintf32
| sym::nearbyintf64
| sym::round_ties_even_f32
| sym::round_ties_even_f64
| sym::sqrtf32
| sym::sqrtf64 => {
let val = match intrinsic {
sym::fabsf32 | sym::fabsf64 => fx.bcx.ins().fabs(args[0]),
sym::floorf32 | sym::floorf64 => fx.bcx.ins().floor(args[0]),
sym::ceilf32 | sym::ceilf64 => fx.bcx.ins().ceil(args[0]),
sym::truncf32 | sym::truncf64 => fx.bcx.ins().trunc(args[0]),
sym::nearbyintf32 | sym::nearbyintf64 => fx.bcx.ins().nearest(args[0]),
sym::round_ties_even_f32 | sym::round_ties_even_f64 => {
fx.bcx.ins().nearest(args[0])
}
sym::sqrtf32 | sym::sqrtf64 => fx.bcx.ins().sqrt(args[0]),
_ => unreachable!(),
};
Expand Down
9 changes: 3 additions & 6 deletions compiler/rustc_codegen_gcc/src/intrinsic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,11 @@ fn get_simple_intrinsic<'gcc, 'tcx>(
sym::ceilf64 => "ceil",
sym::truncf32 => "truncf",
sym::truncf64 => "trunc",
sym::rintf32 => "rintf",
sym::rintf64 => "rint",
sym::nearbyintf32 => "nearbyintf",
sym::nearbyintf64 => "nearbyint",
// We match the LLVM backend and lower this to `rint`.
sym::round_ties_even_f32 => "rintf",
sym::round_ties_even_f64 => "rint",
sym::roundf32 => "roundf",
sym::roundf64 => "round",
sym::roundevenf32 => "roundevenf",
sym::roundevenf64 => "roundeven",
sym::abort => "abort",
_ => return None,
};
Expand Down
22 changes: 8 additions & 14 deletions compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,14 @@ fn get_simple_intrinsic<'ll>(
sym::truncf64 => "llvm.trunc.f64",
sym::truncf128 => "llvm.trunc.f128",

sym::rintf16 => "llvm.rint.f16",
sym::rintf32 => "llvm.rint.f32",
sym::rintf64 => "llvm.rint.f64",
sym::rintf128 => "llvm.rint.f128",

sym::nearbyintf16 => "llvm.nearbyint.f16",
sym::nearbyintf32 => "llvm.nearbyint.f32",
sym::nearbyintf64 => "llvm.nearbyint.f64",
sym::nearbyintf128 => "llvm.nearbyint.f128",
// We could use any of `rint`, `nearbyint`, or `roundeven`
// for this -- they are all identical in semantics when
// assuming the default FP environment.
// `rint` is what we used for $forever.
sym::round_ties_even_f16 => "llvm.rint.f16",
sym::round_ties_even_f32 => "llvm.rint.f32",
sym::round_ties_even_f64 => "llvm.rint.f64",
sym::round_ties_even_f128 => "llvm.rint.f128",

sym::roundf16 => "llvm.round.f16",
sym::roundf32 => "llvm.round.f32",
Expand All @@ -144,11 +143,6 @@ fn get_simple_intrinsic<'ll>(

sym::ptr_mask => "llvm.ptrmask",

sym::roundevenf16 => "llvm.roundeven.f16",
sym::roundevenf32 => "llvm.roundeven.f32",
sym::roundevenf64 => "llvm.roundeven.f64",
sym::roundevenf128 => "llvm.roundeven.f128",

_ => return None,
};
Some(cx.get_intrinsic(llvm_name))
Expand Down
32 changes: 13 additions & 19 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,22 +244,17 @@ pub fn each_linked_rlib(

fmts
} else {
for combination in info.dependency_formats.iter().combinations(2) {
let (ty1, list1) = &combination[0];
let (ty2, list2) = &combination[1];
if list1 != list2 {
return Err(errors::LinkRlibError::IncompatibleDependencyFormats {
ty1: format!("{ty1:?}"),
ty2: format!("{ty2:?}"),
list1: format!("{list1:?}"),
list2: format!("{list2:?}"),
});
}
}
if info.dependency_formats.is_empty() {
return Err(errors::LinkRlibError::MissingFormat);
let mut dep_formats = info.dependency_formats.iter();
let (ty1, list1) = dep_formats.next().ok_or(errors::LinkRlibError::MissingFormat)?;
if let Some((ty2, list2)) = dep_formats.find(|(_, list2)| list1 != *list2) {
return Err(errors::LinkRlibError::IncompatibleDependencyFormats {
ty1: format!("{ty1:?}"),
ty2: format!("{ty2:?}"),
list1: format!("{list1:?}"),
list2: format!("{list2:?}"),
});
}
info.dependency_formats.first().unwrap().1
list1
};

let used_dep_crates = info.used_crates.iter();
Expand Down Expand Up @@ -626,10 +621,9 @@ fn link_staticlib(

let mut all_rust_dylibs = vec![];
for &cnum in crates {
match fmts.get(cnum) {
Some(&Linkage::Dynamic) => {}
_ => continue,
}
let Some(Linkage::Dynamic) = fmts.get(cnum) else {
continue;
};
let crate_name = codegen_results.crate_info.crate_name[&cnum];
let used_crate_source = &codegen_results.crate_info.used_crate_source[&cnum];
if let Some((path, _)) = &used_crate_source.dylib {
Expand Down
10 changes: 1 addition & 9 deletions compiler/rustc_codegen_ssa/src/back/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,7 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
// Unsupported architecture.
_ => return None,
};
let binary_format = if sess.target.is_like_osx {
BinaryFormat::MachO
} else if sess.target.is_like_windows {
BinaryFormat::Coff
} else if sess.target.is_like_aix {
BinaryFormat::Xcoff
} else {
BinaryFormat::Elf
};
let binary_format = sess.target.binary_format.to_object();

let mut file = write::Object::new(binary_format, architecture, endianness);
file.set_sub_architecture(sub_architecture);
Expand Down
15 changes: 8 additions & 7 deletions compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,10 +573,10 @@ fn produce_final_output_artifacts(
};

let copy_if_one_unit = |output_type: OutputType, keep_numbered: bool| {
if compiled_modules.modules.len() == 1 {
if let [module] = &compiled_modules.modules[..] {
// 1) Only one codegen unit. In this case it's no difficulty
// to copy `foo.0.x` to `foo.x`.
let module_name = Some(&compiled_modules.modules[0].name[..]);
let module_name = Some(&module.name[..]);
let path = crate_output.temp_path(output_type, module_name);
let output = crate_output.path(output_type);
if !output_type.is_text_output() && output.is_tty() {
Expand Down Expand Up @@ -708,8 +708,8 @@ fn produce_final_output_artifacts(
}

if sess.opts.json_artifact_notifications {
if compiled_modules.modules.len() == 1 {
compiled_modules.modules[0].for_each_output(|_path, ty| {
if let [module] = &compiled_modules.modules[..] {
module.for_each_output(|_path, ty| {
if sess.opts.output_types.contains_key(&ty) {
let descr = ty.shorthand();
// for single cgu file is renamed to drop cgu specific suffix
Expand Down Expand Up @@ -865,7 +865,7 @@ pub(crate) fn compute_per_cgu_lto_type(
// require LTO so the request for LTO is always unconditionally
// passed down to the backend, but we don't actually want to do
// anything about it yet until we've got a final product.
let is_rlib = sess_crate_types.len() == 1 && sess_crate_types[0] == CrateType::Rlib;
let is_rlib = matches!(sess_crate_types, [CrateType::Rlib]);

match sess_lto {
Lto::ThinLocal if !linker_does_lto && !is_allocator => ComputedLtoType::Thin,
Expand Down Expand Up @@ -1538,8 +1538,9 @@ fn start_executing_work<B: ExtraBackendMethods>(
// Spin up what work we can, only doing this while we've got available
// parallelism slots and work left to spawn.
if codegen_state != Aborted {
while !work_items.is_empty() && running_with_own_token < tokens.len() {
let (item, _) = work_items.pop().unwrap();
while running_with_own_token < tokens.len()
&& let Some((item, _)) = work_items.pop()
{
spawn_work(
&cgcx,
&mut llvm_start_time,
Expand Down
Loading
Loading