Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 214d474

Browse files
committed
Sync from rust 8142a31
2 parents d72f710 + 1956fb8 commit 214d474

File tree

5 files changed

+28
-71
lines changed

5 files changed

+28
-71
lines changed

src/base.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -723,11 +723,8 @@ fn codegen_stmt<'tcx>(
723723
}
724724
Rvalue::Repeat(ref operand, times) => {
725725
let operand = codegen_operand(fx, operand);
726-
let times = fx
727-
.monomorphize(times)
728-
.eval(fx.tcx, ParamEnv::reveal_all())
729-
.try_to_bits(fx.tcx.data_layout.pointer_size)
730-
.unwrap();
726+
let times =
727+
fx.monomorphize(times).eval_target_usize(fx.tcx, ParamEnv::reveal_all());
731728
if operand.layout().size.bytes() == 0 {
732729
// Do nothing for ZST's
733730
} else if fx.clif_type(operand.layout().ty) == Some(types::I8) {

src/constant.rs

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -77,31 +77,9 @@ pub(crate) fn eval_mir_constant<'tcx>(
7777
fx: &FunctionCx<'_, '_, 'tcx>,
7878
constant: &Constant<'tcx>,
7979
) -> Option<(ConstValue<'tcx>, Ty<'tcx>)> {
80-
let constant_kind = fx.monomorphize(constant.literal);
81-
let uv = match constant_kind {
82-
ConstantKind::Ty(const_) => match const_.kind() {
83-
ty::ConstKind::Unevaluated(uv) => uv.expand(),
84-
ty::ConstKind::Value(val) => {
85-
return Some((fx.tcx.valtree_to_const_val((const_.ty(), val)), const_.ty()));
86-
}
87-
err => span_bug!(
88-
constant.span,
89-
"encountered bad ConstKind after monomorphizing: {:?}",
90-
err
91-
),
92-
},
93-
ConstantKind::Unevaluated(mir::UnevaluatedConst { def, .. }, _)
94-
if fx.tcx.is_static(def) =>
95-
{
96-
span_bug!(constant.span, "MIR constant refers to static");
97-
}
98-
ConstantKind::Unevaluated(uv, _) => uv,
99-
ConstantKind::Val(val, _) => return Some((val, constant_kind.ty())),
100-
};
101-
102-
let val = fx
103-
.tcx
104-
.const_eval_resolve(ty::ParamEnv::reveal_all(), uv, None)
80+
let cv = fx.monomorphize(constant.literal);
81+
let val = cv
82+
.eval(fx.tcx, ty::ParamEnv::reveal_all(), Some(constant.span))
10583
.map_err(|err| match err {
10684
ErrorHandled::Reported(_) => {
10785
fx.tcx.sess.span_err(constant.span, "erroneous constant encountered");
@@ -111,7 +89,7 @@ pub(crate) fn eval_mir_constant<'tcx>(
11189
}
11290
})
11391
.ok();
114-
val.map(|val| (val, constant_kind.ty()))
92+
val.map(|val| (val, cv.ty()))
11593
}
11694

11795
pub(crate) fn codegen_constant_operand<'tcx>(

src/debuginfo/line_info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl DebugContext {
8181

8282
match tcx.sess.source_map().lookup_line(span.lo()) {
8383
Ok(SourceFileAndLine { sf: file, line }) => {
84-
let line_pos = file.lines(|lines| lines[line]);
84+
let line_pos = file.lines()[line];
8585
let col = file.relative_position(span.lo()) - line_pos;
8686

8787
(file, u64::try_from(line).unwrap() + 1, u64::from(col.to_u32()) + 1)

src/driver/aot.rs

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ fn module_codegen(
269269
),
270270
) -> OngoingModuleCodegen {
271271
let (cgu_name, mut cx, mut module, codegened_functions) =
272-
tcx.prof.verbose_generic_activity_with_arg("codegen cgu", cgu_name.as_str()).run(|| {
272+
tcx.prof.generic_activity_with_arg("codegen cgu", cgu_name.as_str()).run(|| {
273273
let cgu = tcx.codegen_unit(cgu_name);
274274
let mono_items = cgu.items_in_deterministic_order(tcx);
275275

@@ -322,35 +322,24 @@ fn module_codegen(
322322
});
323323

324324
OngoingModuleCodegen::Async(std::thread::spawn(move || {
325-
cx.profiler.clone().verbose_generic_activity_with_arg("compile functions", &*cgu_name).run(
326-
|| {
327-
cranelift_codegen::timing::set_thread_profiler(Box::new(super::MeasuremeProfiler(
328-
cx.profiler.clone(),
329-
)));
330-
331-
let mut cached_context = Context::new();
332-
for codegened_func in codegened_functions {
333-
crate::base::compile_fn(
334-
&mut cx,
335-
&mut cached_context,
336-
&mut module,
337-
codegened_func,
338-
);
339-
}
340-
},
341-
);
325+
cx.profiler.clone().generic_activity_with_arg("compile functions", &*cgu_name).run(|| {
326+
cranelift_codegen::timing::set_thread_profiler(Box::new(super::MeasuremeProfiler(
327+
cx.profiler.clone(),
328+
)));
329+
330+
let mut cached_context = Context::new();
331+
for codegened_func in codegened_functions {
332+
crate::base::compile_fn(&mut cx, &mut cached_context, &mut module, codegened_func);
333+
}
334+
});
342335

343-
let global_asm_object_file = cx
344-
.profiler
345-
.verbose_generic_activity_with_arg("compile assembly", &*cgu_name)
346-
.run(|| {
336+
let global_asm_object_file =
337+
cx.profiler.generic_activity_with_arg("compile assembly", &*cgu_name).run(|| {
347338
crate::global_asm::compile_global_asm(&global_asm_config, &cgu_name, &cx.global_asm)
348339
})?;
349340

350-
let codegen_result = cx
351-
.profiler
352-
.verbose_generic_activity_with_arg("write object file", &*cgu_name)
353-
.run(|| {
341+
let codegen_result =
342+
cx.profiler.generic_activity_with_arg("write object file", &*cgu_name).run(|| {
354343
emit_cgu(
355344
&global_asm_config.output_filenames,
356345
&cx.profiler,

src/vtable.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,12 @@ pub(crate) fn get_ptr_and_method_ref<'tcx>(
4848
) -> (Pointer, Value) {
4949
let (ptr, vtable) = 'block: {
5050
if let Abi::Scalar(_) = arg.layout().abi {
51-
'descend_newtypes: while !arg.layout().ty.is_unsafe_ptr() && !arg.layout().ty.is_ref() {
52-
for i in 0..arg.layout().fields.count() {
53-
let field = arg.value_field(fx, FieldIdx::new(i));
54-
if !field.layout().is_1zst() {
55-
// we found the one non-1-ZST field that is allowed
56-
// now find *its* non-zero-sized field, or stop if it's a
57-
// pointer
58-
arg = field;
59-
continue 'descend_newtypes;
60-
}
61-
}
62-
63-
bug!("receiver has no non-zero-sized fields {:?}", arg);
51+
while !arg.layout().ty.is_unsafe_ptr() && !arg.layout().ty.is_ref() {
52+
let (idx, _) = arg
53+
.layout()
54+
.non_1zst_field(fx)
55+
.expect("not exactly one non-1-ZST field in a `DispatchFromDyn` type");
56+
arg = arg.value_field(fx, FieldIdx::new(idx));
6457
}
6558
}
6659

0 commit comments

Comments
 (0)