Skip to content

Commit 9af8985

Browse files
committed
Auto merge of rust-lang#137497 - tgross35:rollup-1oeclrr, r=tgross35
Rollup of 8 pull requests Successful merges: - rust-lang#136439 (Misc. `rustc_codegen_ssa` cleanups 🧹) - rust-lang#136543 (intrinsics: unify rint, roundeven, nearbyint in a single round_ties_even intrinsic) - rust-lang#136637 (Add binary_format to rustc target specs) - rust-lang#137099 (Fix rustdoc test directives that were accidentally ignored 🧐) - rust-lang#137297 (Update `compiler-builtins` to 0.1.147) - rust-lang#137451 (FIx `sym` -> `syn` typo in tail-expr-drop-order type opt-out) - rust-lang#137452 (bootstrap: add module docs for core:metadata) - rust-lang#137483 (rename sub_ptr to offset_from_unsigned) r? `@ghost` `@rustbot` modify labels: rollup
2 parents f8a913b + 18ffee2 commit 9af8985

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+406
-441
lines changed

compiler/rustc_codegen_cranelift/patches/0029-stdlib-Disable-f16-and-f128-in-compiler-builtins.patch

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ index 7165c3e48af..968552ad435 100644
1616

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

2222
[dev-dependencies]
2323
rand = { version = "0.8.5", default-features = false, features = ["alloc"] }

compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,10 @@ fn codegen_float_intrinsic_call<'tcx>(
340340
sym::ceilf64 => ("ceil", 1, fx.tcx.types.f64, types::F64),
341341
sym::truncf32 => ("truncf", 1, fx.tcx.types.f32, types::F32),
342342
sym::truncf64 => ("trunc", 1, fx.tcx.types.f64, types::F64),
343-
sym::rintf32 => ("rintf", 1, fx.tcx.types.f32, types::F32),
344-
sym::rintf64 => ("rint", 1, fx.tcx.types.f64, types::F64),
343+
sym::round_ties_even_f32 => ("rintf", 1, fx.tcx.types.f32, types::F32),
344+
sym::round_ties_even_f64 => ("rint", 1, fx.tcx.types.f64, types::F64),
345345
sym::roundf32 => ("roundf", 1, fx.tcx.types.f32, types::F32),
346346
sym::roundf64 => ("round", 1, fx.tcx.types.f64, types::F64),
347-
sym::roundevenf32 => ("roundevenf", 1, fx.tcx.types.f32, types::F32),
348-
sym::roundevenf64 => ("roundeven", 1, fx.tcx.types.f64, types::F64),
349-
sym::nearbyintf32 => ("nearbyintf", 1, fx.tcx.types.f32, types::F32),
350-
sym::nearbyintf64 => ("nearbyint", 1, fx.tcx.types.f64, types::F64),
351347
sym::sinf32 => ("sinf", 1, fx.tcx.types.f32, types::F32),
352348
sym::sinf64 => ("sin", 1, fx.tcx.types.f64, types::F64),
353349
sym::cosf32 => ("cosf", 1, fx.tcx.types.f32, types::F32),
@@ -399,16 +395,18 @@ fn codegen_float_intrinsic_call<'tcx>(
399395
| sym::ceilf64
400396
| sym::truncf32
401397
| sym::truncf64
402-
| sym::nearbyintf32
403-
| sym::nearbyintf64
398+
| sym::round_ties_even_f32
399+
| sym::round_ties_even_f64
404400
| sym::sqrtf32
405401
| sym::sqrtf64 => {
406402
let val = match intrinsic {
407403
sym::fabsf32 | sym::fabsf64 => fx.bcx.ins().fabs(args[0]),
408404
sym::floorf32 | sym::floorf64 => fx.bcx.ins().floor(args[0]),
409405
sym::ceilf32 | sym::ceilf64 => fx.bcx.ins().ceil(args[0]),
410406
sym::truncf32 | sym::truncf64 => fx.bcx.ins().trunc(args[0]),
411-
sym::nearbyintf32 | sym::nearbyintf64 => fx.bcx.ins().nearest(args[0]),
407+
sym::round_ties_even_f32 | sym::round_ties_even_f64 => {
408+
fx.bcx.ins().nearest(args[0])
409+
}
412410
sym::sqrtf32 | sym::sqrtf64 => fx.bcx.ins().sqrt(args[0]),
413411
_ => unreachable!(),
414412
};

compiler/rustc_codegen_gcc/src/intrinsic/mod.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,11 @@ fn get_simple_intrinsic<'gcc, 'tcx>(
8484
sym::ceilf64 => "ceil",
8585
sym::truncf32 => "truncf",
8686
sym::truncf64 => "trunc",
87-
sym::rintf32 => "rintf",
88-
sym::rintf64 => "rint",
89-
sym::nearbyintf32 => "nearbyintf",
90-
sym::nearbyintf64 => "nearbyint",
87+
// We match the LLVM backend and lower this to `rint`.
88+
sym::round_ties_even_f32 => "rintf",
89+
sym::round_ties_even_f64 => "rint",
9190
sym::roundf32 => "roundf",
9291
sym::roundf64 => "round",
93-
sym::roundevenf32 => "roundevenf",
94-
sym::roundevenf64 => "roundeven",
9592
sym::abort => "abort",
9693
_ => return None,
9794
};

compiler/rustc_codegen_llvm/src/intrinsic.rs

+8-14
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,14 @@ fn get_simple_intrinsic<'ll>(
127127
sym::truncf64 => "llvm.trunc.f64",
128128
sym::truncf128 => "llvm.trunc.f128",
129129

130-
sym::rintf16 => "llvm.rint.f16",
131-
sym::rintf32 => "llvm.rint.f32",
132-
sym::rintf64 => "llvm.rint.f64",
133-
sym::rintf128 => "llvm.rint.f128",
134-
135-
sym::nearbyintf16 => "llvm.nearbyint.f16",
136-
sym::nearbyintf32 => "llvm.nearbyint.f32",
137-
sym::nearbyintf64 => "llvm.nearbyint.f64",
138-
sym::nearbyintf128 => "llvm.nearbyint.f128",
130+
// We could use any of `rint`, `nearbyint`, or `roundeven`
131+
// for this -- they are all identical in semantics when
132+
// assuming the default FP environment.
133+
// `rint` is what we used for $forever.
134+
sym::round_ties_even_f16 => "llvm.rint.f16",
135+
sym::round_ties_even_f32 => "llvm.rint.f32",
136+
sym::round_ties_even_f64 => "llvm.rint.f64",
137+
sym::round_ties_even_f128 => "llvm.rint.f128",
139138

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

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

147-
sym::roundevenf16 => "llvm.roundeven.f16",
148-
sym::roundevenf32 => "llvm.roundeven.f32",
149-
sym::roundevenf64 => "llvm.roundeven.f64",
150-
sym::roundevenf128 => "llvm.roundeven.f128",
151-
152146
_ => return None,
153147
};
154148
Some(cx.get_intrinsic(llvm_name))

compiler/rustc_codegen_ssa/src/back/link.rs

+13-19
Original file line numberDiff line numberDiff line change
@@ -244,22 +244,17 @@ pub fn each_linked_rlib(
244244

245245
fmts
246246
} else {
247-
for combination in info.dependency_formats.iter().combinations(2) {
248-
let (ty1, list1) = &combination[0];
249-
let (ty2, list2) = &combination[1];
250-
if list1 != list2 {
251-
return Err(errors::LinkRlibError::IncompatibleDependencyFormats {
252-
ty1: format!("{ty1:?}"),
253-
ty2: format!("{ty2:?}"),
254-
list1: format!("{list1:?}"),
255-
list2: format!("{list2:?}"),
256-
});
257-
}
258-
}
259-
if info.dependency_formats.is_empty() {
260-
return Err(errors::LinkRlibError::MissingFormat);
247+
let mut dep_formats = info.dependency_formats.iter();
248+
let (ty1, list1) = dep_formats.next().ok_or(errors::LinkRlibError::MissingFormat)?;
249+
if let Some((ty2, list2)) = dep_formats.find(|(_, list2)| list1 != *list2) {
250+
return Err(errors::LinkRlibError::IncompatibleDependencyFormats {
251+
ty1: format!("{ty1:?}"),
252+
ty2: format!("{ty2:?}"),
253+
list1: format!("{list1:?}"),
254+
list2: format!("{list2:?}"),
255+
});
261256
}
262-
info.dependency_formats.first().unwrap().1
257+
list1
263258
};
264259

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

627622
let mut all_rust_dylibs = vec![];
628623
for &cnum in crates {
629-
match fmts.get(cnum) {
630-
Some(&Linkage::Dynamic) => {}
631-
_ => continue,
632-
}
624+
let Some(Linkage::Dynamic) = fmts.get(cnum) else {
625+
continue;
626+
};
633627
let crate_name = codegen_results.crate_info.crate_name[&cnum];
634628
let used_crate_source = &codegen_results.crate_info.used_crate_source[&cnum];
635629
if let Some((path, _)) = &used_crate_source.dylib {

compiler/rustc_codegen_ssa/src/back/metadata.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,7 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
252252
// Unsupported architecture.
253253
_ => return None,
254254
};
255-
let binary_format = if sess.target.is_like_osx {
256-
BinaryFormat::MachO
257-
} else if sess.target.is_like_windows {
258-
BinaryFormat::Coff
259-
} else if sess.target.is_like_aix {
260-
BinaryFormat::Xcoff
261-
} else {
262-
BinaryFormat::Elf
263-
};
255+
let binary_format = sess.target.binary_format.to_object();
264256

265257
let mut file = write::Object::new(binary_format, architecture, endianness);
266258
file.set_sub_architecture(sub_architecture);

compiler/rustc_codegen_ssa/src/back/write.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -573,10 +573,10 @@ fn produce_final_output_artifacts(
573573
};
574574

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

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

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

0 commit comments

Comments
 (0)