mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Sync from rust 8142a319ed
This commit is contained in:
commit
214d474a85
@ -723,11 +723,8 @@ fn codegen_stmt<'tcx>(
|
||||
}
|
||||
Rvalue::Repeat(ref operand, times) => {
|
||||
let operand = codegen_operand(fx, operand);
|
||||
let times = fx
|
||||
.monomorphize(times)
|
||||
.eval(fx.tcx, ParamEnv::reveal_all())
|
||||
.try_to_bits(fx.tcx.data_layout.pointer_size)
|
||||
.unwrap();
|
||||
let times =
|
||||
fx.monomorphize(times).eval_target_usize(fx.tcx, ParamEnv::reveal_all());
|
||||
if operand.layout().size.bytes() == 0 {
|
||||
// Do nothing for ZST's
|
||||
} else if fx.clif_type(operand.layout().ty) == Some(types::I8) {
|
||||
|
@ -77,31 +77,9 @@ pub(crate) fn eval_mir_constant<'tcx>(
|
||||
fx: &FunctionCx<'_, '_, 'tcx>,
|
||||
constant: &Constant<'tcx>,
|
||||
) -> Option<(ConstValue<'tcx>, Ty<'tcx>)> {
|
||||
let constant_kind = fx.monomorphize(constant.literal);
|
||||
let uv = match constant_kind {
|
||||
ConstantKind::Ty(const_) => match const_.kind() {
|
||||
ty::ConstKind::Unevaluated(uv) => uv.expand(),
|
||||
ty::ConstKind::Value(val) => {
|
||||
return Some((fx.tcx.valtree_to_const_val((const_.ty(), val)), const_.ty()));
|
||||
}
|
||||
err => span_bug!(
|
||||
constant.span,
|
||||
"encountered bad ConstKind after monomorphizing: {:?}",
|
||||
err
|
||||
),
|
||||
},
|
||||
ConstantKind::Unevaluated(mir::UnevaluatedConst { def, .. }, _)
|
||||
if fx.tcx.is_static(def) =>
|
||||
{
|
||||
span_bug!(constant.span, "MIR constant refers to static");
|
||||
}
|
||||
ConstantKind::Unevaluated(uv, _) => uv,
|
||||
ConstantKind::Val(val, _) => return Some((val, constant_kind.ty())),
|
||||
};
|
||||
|
||||
let val = fx
|
||||
.tcx
|
||||
.const_eval_resolve(ty::ParamEnv::reveal_all(), uv, None)
|
||||
let cv = fx.monomorphize(constant.literal);
|
||||
let val = cv
|
||||
.eval(fx.tcx, ty::ParamEnv::reveal_all(), Some(constant.span))
|
||||
.map_err(|err| match err {
|
||||
ErrorHandled::Reported(_) => {
|
||||
fx.tcx.sess.span_err(constant.span, "erroneous constant encountered");
|
||||
@ -111,7 +89,7 @@ pub(crate) fn eval_mir_constant<'tcx>(
|
||||
}
|
||||
})
|
||||
.ok();
|
||||
val.map(|val| (val, constant_kind.ty()))
|
||||
val.map(|val| (val, cv.ty()))
|
||||
}
|
||||
|
||||
pub(crate) fn codegen_constant_operand<'tcx>(
|
||||
|
@ -81,7 +81,7 @@ impl DebugContext {
|
||||
|
||||
match tcx.sess.source_map().lookup_line(span.lo()) {
|
||||
Ok(SourceFileAndLine { sf: file, line }) => {
|
||||
let line_pos = file.lines(|lines| lines[line]);
|
||||
let line_pos = file.lines()[line];
|
||||
let col = file.relative_position(span.lo()) - line_pos;
|
||||
|
||||
(file, u64::try_from(line).unwrap() + 1, u64::from(col.to_u32()) + 1)
|
||||
|
@ -269,7 +269,7 @@ fn module_codegen(
|
||||
),
|
||||
) -> OngoingModuleCodegen {
|
||||
let (cgu_name, mut cx, mut module, codegened_functions) =
|
||||
tcx.prof.verbose_generic_activity_with_arg("codegen cgu", cgu_name.as_str()).run(|| {
|
||||
tcx.prof.generic_activity_with_arg("codegen cgu", cgu_name.as_str()).run(|| {
|
||||
let cgu = tcx.codegen_unit(cgu_name);
|
||||
let mono_items = cgu.items_in_deterministic_order(tcx);
|
||||
|
||||
@ -322,35 +322,24 @@ fn module_codegen(
|
||||
});
|
||||
|
||||
OngoingModuleCodegen::Async(std::thread::spawn(move || {
|
||||
cx.profiler.clone().verbose_generic_activity_with_arg("compile functions", &*cgu_name).run(
|
||||
|| {
|
||||
cx.profiler.clone().generic_activity_with_arg("compile functions", &*cgu_name).run(|| {
|
||||
cranelift_codegen::timing::set_thread_profiler(Box::new(super::MeasuremeProfiler(
|
||||
cx.profiler.clone(),
|
||||
)));
|
||||
|
||||
let mut cached_context = Context::new();
|
||||
for codegened_func in codegened_functions {
|
||||
crate::base::compile_fn(
|
||||
&mut cx,
|
||||
&mut cached_context,
|
||||
&mut module,
|
||||
codegened_func,
|
||||
);
|
||||
crate::base::compile_fn(&mut cx, &mut cached_context, &mut module, codegened_func);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
let global_asm_object_file = cx
|
||||
.profiler
|
||||
.verbose_generic_activity_with_arg("compile assembly", &*cgu_name)
|
||||
.run(|| {
|
||||
let global_asm_object_file =
|
||||
cx.profiler.generic_activity_with_arg("compile assembly", &*cgu_name).run(|| {
|
||||
crate::global_asm::compile_global_asm(&global_asm_config, &cgu_name, &cx.global_asm)
|
||||
})?;
|
||||
|
||||
let codegen_result = cx
|
||||
.profiler
|
||||
.verbose_generic_activity_with_arg("write object file", &*cgu_name)
|
||||
.run(|| {
|
||||
let codegen_result =
|
||||
cx.profiler.generic_activity_with_arg("write object file", &*cgu_name).run(|| {
|
||||
emit_cgu(
|
||||
&global_asm_config.output_filenames,
|
||||
&cx.profiler,
|
||||
|
@ -48,19 +48,12 @@ pub(crate) fn get_ptr_and_method_ref<'tcx>(
|
||||
) -> (Pointer, Value) {
|
||||
let (ptr, vtable) = 'block: {
|
||||
if let Abi::Scalar(_) = arg.layout().abi {
|
||||
'descend_newtypes: while !arg.layout().ty.is_unsafe_ptr() && !arg.layout().ty.is_ref() {
|
||||
for i in 0..arg.layout().fields.count() {
|
||||
let field = arg.value_field(fx, FieldIdx::new(i));
|
||||
if !field.layout().is_1zst() {
|
||||
// we found the one non-1-ZST field that is allowed
|
||||
// now find *its* non-zero-sized field, or stop if it's a
|
||||
// pointer
|
||||
arg = field;
|
||||
continue 'descend_newtypes;
|
||||
}
|
||||
}
|
||||
|
||||
bug!("receiver has no non-zero-sized fields {:?}", arg);
|
||||
while !arg.layout().ty.is_unsafe_ptr() && !arg.layout().ty.is_ref() {
|
||||
let (idx, _) = arg
|
||||
.layout()
|
||||
.non_1zst_field(fx)
|
||||
.expect("not exactly one non-1-ZST field in a `DispatchFromDyn` type");
|
||||
arg = arg.value_field(fx, FieldIdx::new(idx));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user