Skip to content

Commit fab2460

Browse files
authored
Merge branch 'rust-lang:master' into zero-cost-rc-arc-deref
2 parents ec93cba + f43e549 commit fab2460

File tree

133 files changed

+1233
-1775
lines changed

Some content is hidden

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

133 files changed

+1233
-1775
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4571,6 +4571,7 @@ dependencies = [
45714571
"itertools",
45724572
"minifier",
45734573
"pulldown-cmark 0.9.6",
4574+
"pulldown-cmark-escape",
45744575
"regex",
45754576
"rinja",
45764577
"rustdoc-json-types",

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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 7 additions & 9 deletions
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

Lines changed: 3 additions & 6 deletions
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/builder.rs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ use tracing::{debug, instrument};
3131
use crate::abi::FnAbiLlvmExt;
3232
use crate::common::Funclet;
3333
use crate::context::{CodegenCx, SimpleCx};
34-
use crate::llvm::{self, AtomicOrdering, AtomicRmwBinOp, BasicBlock, False, Metadata, True};
34+
use crate::llvm::{
35+
self, AtomicOrdering, AtomicRmwBinOp, BasicBlock, False, GEPNoWrapFlags, Metadata, True,
36+
};
3537
use crate::type_::Type;
3638
use crate::type_of::LayoutLlvmExt;
3739
use crate::value::Value;
@@ -910,13 +912,14 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
910912

911913
fn gep(&mut self, ty: &'ll Type, ptr: &'ll Value, indices: &[&'ll Value]) -> &'ll Value {
912914
unsafe {
913-
llvm::LLVMBuildGEP2(
915+
llvm::LLVMBuildGEPWithNoWrapFlags(
914916
self.llbuilder,
915917
ty,
916918
ptr,
917919
indices.as_ptr(),
918920
indices.len() as c_uint,
919921
UNNAMED,
922+
GEPNoWrapFlags::default(),
920923
)
921924
}
922925
}
@@ -928,13 +931,33 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
928931
indices: &[&'ll Value],
929932
) -> &'ll Value {
930933
unsafe {
931-
llvm::LLVMBuildInBoundsGEP2(
934+
llvm::LLVMBuildGEPWithNoWrapFlags(
935+
self.llbuilder,
936+
ty,
937+
ptr,
938+
indices.as_ptr(),
939+
indices.len() as c_uint,
940+
UNNAMED,
941+
GEPNoWrapFlags::InBounds,
942+
)
943+
}
944+
}
945+
946+
fn inbounds_nuw_gep(
947+
&mut self,
948+
ty: &'ll Type,
949+
ptr: &'ll Value,
950+
indices: &[&'ll Value],
951+
) -> &'ll Value {
952+
unsafe {
953+
llvm::LLVMBuildGEPWithNoWrapFlags(
932954
self.llbuilder,
933955
ty,
934956
ptr,
935957
indices.as_ptr(),
936958
indices.len() as c_uint,
937959
UNNAMED,
960+
GEPNoWrapFlags::InBounds | GEPNoWrapFlags::NUW,
938961
)
939962
}
940963
}

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 8 additions & 14 deletions
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_llvm/src/llvm/ffi.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,17 @@ bitflags! {
954954
}
955955
}
956956

957+
// These values **must** match with LLVMGEPNoWrapFlags
958+
bitflags! {
959+
#[repr(transparent)]
960+
#[derive(Default)]
961+
pub struct GEPNoWrapFlags : c_uint {
962+
const InBounds = 1 << 0;
963+
const NUSW = 1 << 1;
964+
const NUW = 1 << 2;
965+
}
966+
}
967+
957968
unsafe extern "C" {
958969
pub type ModuleBuffer;
959970
}
@@ -1454,21 +1465,14 @@ unsafe extern "C" {
14541465

14551466
pub(crate) fn LLVMBuildStore<'a>(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value;
14561467

1457-
pub(crate) fn LLVMBuildGEP2<'a>(
1458-
B: &Builder<'a>,
1459-
Ty: &'a Type,
1460-
Pointer: &'a Value,
1461-
Indices: *const &'a Value,
1462-
NumIndices: c_uint,
1463-
Name: *const c_char,
1464-
) -> &'a Value;
1465-
pub(crate) fn LLVMBuildInBoundsGEP2<'a>(
1468+
pub(crate) fn LLVMBuildGEPWithNoWrapFlags<'a>(
14661469
B: &Builder<'a>,
14671470
Ty: &'a Type,
14681471
Pointer: &'a Value,
14691472
Indices: *const &'a Value,
14701473
NumIndices: c_uint,
14711474
Name: *const c_char,
1475+
Flags: GEPNoWrapFlags,
14721476
) -> &'a Value;
14731477

14741478
// Casts

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 13 additions & 19 deletions
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

Lines changed: 1 addition & 9 deletions
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

Lines changed: 8 additions & 7 deletions
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)