Skip to content

Commit 77009e9

Browse files
committedFeb 1, 2025
Sync from rust 854f225
2 parents e7b1853 + b8172d7 commit 77009e9

13 files changed

+68
-121
lines changed
 

‎build_system/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
151151
apply_patches(
152152
&runner.dirs,
153153
"coretests",
154-
&runner.stdlib_source.join("library/core/tests"),
154+
&runner.stdlib_source.join("library/coretests"),
155155
&LIBCORE_TESTS_SRC.to_path(&runner.dirs),
156156
);
157157

‎patches/0022-coretests-Disable-not-compiling-tests.patch

-44
This file was deleted.

‎patches/0027-coretests-128bit-atomic-operations.patch

+7-8
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,20 @@ Cranelift doesn't support them yet
1010
library/core/tests/atomic.rs | 4 ---
1111
4 files changed, 4 insertions(+), 50 deletions(-)
1212

13-
diff --git a/lib.rs b/lib.rs
13+
diff --git a/tests/lib.rs b/tests/lib.rs
1414
index 1e336bf..35e6f54 100644
15-
--- a/lib.rs
16-
+++ b/lib.rs
17-
@@ -2,6 +2,5 @@
18-
#![cfg(test)]
15+
--- a/tests/lib.rs
16+
+++ b/tests/lib.rs
17+
@@ -2,5 +2,4 @@
1918
// tidy-alphabetical-start
2019
-#![cfg_attr(target_has_atomic = "128", feature(integer_atomics))]
2120
#![cfg_attr(test, feature(cfg_match))]
2221
#![feature(alloc_layout_extra)]
2322
#![feature(array_chunks)]
24-
diff --git a/atomic.rs b/atomic.rs
23+
diff --git a/tests/atomic.rs b/tests/atomic.rs
2524
index b735957..ea728b6 100644
26-
--- a/atomic.rs
27-
+++ b/atomic.rs
25+
--- a/tests/atomic.rs
26+
+++ b/tests/atomic.rs
2827
@@ -185,10 +185,6 @@ fn atomic_alignment() {
2928
assert_eq!(align_of::<AtomicU64>(), size_of::<AtomicU64>());
3029
#[cfg(target_has_atomic = "64")]

‎patches/0028-coretests-Disable-long-running-tests.patch

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ Subject: [PATCH] Disable long running tests
77
library/core/tests/slice.rs | 2 ++
88
1 file changed, 2 insertions(+)
99

10-
diff --git a/slice.rs b/slice.rs
10+
diff --git a/tests/slice.rs b/tests/slice.rs
1111
index 8402833..84592e0 100644
12-
--- a/slice.rs
13-
+++ b/slice.rs
12+
--- a/tests/slice.rs
13+
+++ b/tests/slice.rs
1414
@@ -1809,6 +1809,7 @@ fn sort_unstable() {
1515
}
1616
}

‎src/abi/mod.rs

+13-9
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
126126
&mut self,
127127
name: &str,
128128
params: Vec<AbiParam>,
129-
returns: Vec<AbiParam>,
129+
mut returns: Vec<AbiParam>,
130130
args: &[Value],
131131
) -> Cow<'_, [Value]> {
132132
// Pass i128 arguments by-ref on Windows.
@@ -150,15 +150,19 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
150150
(params, args.into())
151151
};
152152

153-
// Return i128 using a return area pointer on Windows and s390x.
154-
let adjust_ret_param =
155-
if self.tcx.sess.target.is_like_windows || self.tcx.sess.target.arch == "s390x" {
156-
returns.len() == 1 && returns[0].value_type == types::I128
157-
} else {
158-
false
159-
};
153+
let ret_single_i128 = returns.len() == 1 && returns[0].value_type == types::I128;
154+
if ret_single_i128 && self.tcx.sess.target.is_like_windows {
155+
// Return i128 using the vector ABI on Windows
156+
returns[0].value_type = types::I64X2;
157+
158+
let ret = self.lib_call_unadjusted(name, params, returns, &args)[0];
160159

161-
if adjust_ret_param {
160+
// FIXME(bytecodealliance/wasmtime#6104) use bitcast instead of store to get from i64x2 to i128
161+
let ret_ptr = self.create_stack_slot(16, 16);
162+
ret_ptr.store(self, ret, MemFlags::trusted());
163+
Cow::Owned(vec![ret_ptr.load(self, types::I128, MemFlags::trusted())])
164+
} else if ret_single_i128 && self.tcx.sess.target.arch == "s390x" {
165+
// Return i128 using a return area pointer on s390x.
162166
let mut params = params;
163167
let mut args = args.to_vec();
164168

‎src/base.rs

+10
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,16 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
417417
Some(source_info.span),
418418
);
419419
}
420+
AssertKind::NullPointerDereference => {
421+
let location = fx.get_caller_location(source_info).load_scalar(fx);
422+
423+
codegen_panic_inner(
424+
fx,
425+
rustc_hir::LangItem::PanicNullPointerDereference,
426+
&[location],
427+
Some(source_info.span),
428+
)
429+
}
420430
_ => {
421431
let location = fx.get_caller_location(source_info).load_scalar(fx);
422432

‎src/cast.rs

+3-19
Original file line numberDiff line numberDiff line change
@@ -96,25 +96,9 @@ pub(crate) fn clif_int_or_float_cast(
9696
},
9797
);
9898

99-
if fx.tcx.sess.target.is_like_windows {
100-
let ret = fx.lib_call(
101-
&name,
102-
vec![AbiParam::new(from_ty)],
103-
vec![AbiParam::new(types::I64X2)],
104-
&[from],
105-
)[0];
106-
// FIXME(bytecodealliance/wasmtime#6104) use bitcast instead of store to get from i64x2 to i128
107-
let ret_ptr = fx.create_stack_slot(16, 16);
108-
ret_ptr.store(fx, ret, MemFlags::trusted());
109-
ret_ptr.load(fx, types::I128, MemFlags::trusted())
110-
} else {
111-
fx.lib_call(
112-
&name,
113-
vec![AbiParam::new(from_ty)],
114-
vec![AbiParam::new(types::I128)],
115-
&[from],
116-
)[0]
117-
}
99+
fx.lib_call(&name, vec![AbiParam::new(from_ty)], vec![AbiParam::new(types::I128)], &[
100+
from,
101+
])[0]
118102
} else if to_ty == types::I8 || to_ty == types::I16 {
119103
// FIXME implement fcvt_to_*int_sat.i8/i16
120104
let val = if to_signed {

‎src/codegen_i128.rs

+8-22
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,14 @@ pub(crate) fn maybe_codegen<'tcx>(
3333
(BinOp::Rem, true) => "__modti3",
3434
_ => unreachable!(),
3535
};
36-
if fx.tcx.sess.target.is_like_windows {
37-
let args = [lhs.load_scalar(fx), rhs.load_scalar(fx)];
38-
let ret = fx.lib_call(
39-
name,
40-
vec![AbiParam::new(types::I128), AbiParam::new(types::I128)],
41-
vec![AbiParam::new(types::I64X2)],
42-
&args,
43-
)[0];
44-
// FIXME(bytecodealliance/wasmtime#6104) use bitcast instead of store to get from i64x2 to i128
45-
let ret_place = CPlace::new_stack_slot(fx, lhs.layout());
46-
ret_place.to_ptr().store(fx, ret, MemFlags::trusted());
47-
Some(ret_place.to_cvalue(fx))
48-
} else {
49-
let args = [lhs.load_scalar(fx), rhs.load_scalar(fx)];
50-
let ret_val = fx.lib_call(
51-
name,
52-
vec![AbiParam::new(types::I128), AbiParam::new(types::I128)],
53-
vec![AbiParam::new(types::I128)],
54-
&args,
55-
)[0];
56-
Some(CValue::by_val(ret_val, lhs.layout()))
57-
}
36+
let args = [lhs.load_scalar(fx), rhs.load_scalar(fx)];
37+
let ret_val = fx.lib_call(
38+
name,
39+
vec![AbiParam::new(types::I128), AbiParam::new(types::I128)],
40+
vec![AbiParam::new(types::I128)],
41+
&args,
42+
)[0];
43+
Some(CValue::by_val(ret_val, lhs.layout()))
5844
}
5945
BinOp::Lt | BinOp::Le | BinOp::Eq | BinOp::Ge | BinOp::Gt | BinOp::Ne | BinOp::Cmp => None,
6046
BinOp::Shl | BinOp::ShlUnchecked | BinOp::Shr | BinOp::ShrUnchecked => None,

‎src/constant.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use cranelift_module::*;
66
use rustc_data_structures::fx::FxHashSet;
77
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
88
use rustc_middle::mir::interpret::{AllocId, GlobalAlloc, Scalar, read_target_uint};
9-
use rustc_middle::ty::{Binder, ExistentialTraitRef, ScalarInt};
9+
use rustc_middle::ty::{ExistentialTraitRef, ScalarInt};
1010

1111
use crate::prelude::*;
1212

@@ -167,7 +167,9 @@ pub(crate) fn codegen_const_value<'tcx>(
167167
&mut fx.constants_cx,
168168
fx.module,
169169
ty,
170-
dyn_ty.principal(),
170+
dyn_ty.principal().map(|principal| {
171+
fx.tcx.instantiate_bound_regions_with_erased(principal)
172+
}),
171173
);
172174
let local_data_id =
173175
fx.module.declare_data_in_func(data_id, &mut fx.bcx.func);
@@ -243,7 +245,7 @@ pub(crate) fn data_id_for_vtable<'tcx>(
243245
cx: &mut ConstantCx,
244246
module: &mut dyn Module,
245247
ty: Ty<'tcx>,
246-
trait_ref: Option<Binder<'tcx, ExistentialTraitRef<'tcx>>>,
248+
trait_ref: Option<ExistentialTraitRef<'tcx>>,
247249
) -> DataId {
248250
let alloc_id = tcx.vtable_allocation((ty, trait_ref));
249251
data_id_for_alloc_id(cx, module, alloc_id, Mutability::Not)
@@ -460,9 +462,15 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
460462
GlobalAlloc::Memory(target_alloc) => {
461463
data_id_for_alloc_id(cx, module, alloc_id, target_alloc.inner().mutability)
462464
}
463-
GlobalAlloc::VTable(ty, dyn_ty) => {
464-
data_id_for_vtable(tcx, cx, module, ty, dyn_ty.principal())
465-
}
465+
GlobalAlloc::VTable(ty, dyn_ty) => data_id_for_vtable(
466+
tcx,
467+
cx,
468+
module,
469+
ty,
470+
dyn_ty
471+
.principal()
472+
.map(|principal| tcx.instantiate_bound_regions_with_erased(principal)),
473+
),
466474
GlobalAlloc::Static(def_id) => {
467475
if tcx.codegen_fn_attrs(def_id).flags.contains(CodegenFnAttrFlags::THREAD_LOCAL)
468476
{

‎src/driver/aot.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ pub(crate) fn run_aot(
676676
.to_owned();
677677

678678
let cgus = if tcx.sess.opts.output_types.should_codegen() {
679-
tcx.collect_and_partition_mono_items(()).1
679+
tcx.collect_and_partition_mono_items(()).codegen_units
680680
} else {
681681
// If only `--emit metadata` is used, we shouldn't perform any codegen.
682682
// Also `tcx.collect_and_partition_mono_items` may panic in that case.

‎src/intrinsics/simd.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
129129
return;
130130
}
131131

132-
let idx = generic_args[2]
133-
.expect_const()
134-
.try_to_valtree()
135-
.expect("expected monomorphic const in codegen")
136-
.0
137-
.unwrap_branch();
132+
let idx = generic_args[2].expect_const().to_value().valtree.unwrap_branch();
138133

139134
assert_eq!(x.layout(), y.layout());
140135
let layout = x.layout();

‎src/unsize.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ pub(crate) fn unsized_info<'tcx>(
6161
old_info
6262
}
6363
}
64-
(_, ty::Dynamic(data, ..)) => crate::vtable::get_vtable(fx, source, data.principal()),
64+
(_, ty::Dynamic(data, ..)) => crate::vtable::get_vtable(
65+
fx,
66+
source,
67+
data.principal()
68+
.map(|principal| fx.tcx.instantiate_bound_regions_with_erased(principal)),
69+
),
6570
_ => bug!("unsized_info: invalid unsizing {:?} -> {:?}", source, target),
6671
}
6772
}

‎src/vtable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub(crate) fn get_ptr_and_method_ref<'tcx>(
9090
pub(crate) fn get_vtable<'tcx>(
9191
fx: &mut FunctionCx<'_, '_, 'tcx>,
9292
ty: Ty<'tcx>,
93-
trait_ref: Option<ty::PolyExistentialTraitRef<'tcx>>,
93+
trait_ref: Option<ty::ExistentialTraitRef<'tcx>>,
9494
) -> Value {
9595
let data_id = data_id_for_vtable(fx.tcx, &mut fx.constants_cx, fx.module, ty, trait_ref);
9696
let local_data_id = fx.module.declare_data_in_func(data_id, fx.bcx.func);

0 commit comments

Comments
 (0)