Sync from rust 7531d2fdd4
This commit is contained in:
commit
489bff5543
3 changed files with 8 additions and 43 deletions
37
src/base.rs
37
src/base.rs
|
@ -715,30 +715,6 @@ fn codegen_stmt<'tcx>(
|
|||
let operand = operand.load_scalar(fx);
|
||||
lval.write_cvalue(fx, CValue::by_val(operand, box_layout));
|
||||
}
|
||||
Rvalue::NullaryOp(NullOp::Box, content_ty) => {
|
||||
let usize_type = fx.clif_type(fx.tcx.types.usize).unwrap();
|
||||
let content_ty = fx.monomorphize(content_ty);
|
||||
let layout = fx.layout_of(content_ty);
|
||||
let llsize = fx.bcx.ins().iconst(usize_type, layout.size.bytes() as i64);
|
||||
let llalign = fx.bcx.ins().iconst(usize_type, layout.align.abi.bytes() as i64);
|
||||
let box_layout = fx.layout_of(fx.tcx.mk_box(content_ty));
|
||||
|
||||
// Allocate space:
|
||||
let def_id =
|
||||
match fx.tcx.lang_items().require(rustc_hir::LangItem::ExchangeMalloc) {
|
||||
Ok(id) => id,
|
||||
Err(s) => {
|
||||
fx.tcx
|
||||
.sess
|
||||
.fatal(&format!("allocation of `{}` {}", box_layout.ty, s));
|
||||
}
|
||||
};
|
||||
let instance = ty::Instance::mono(fx.tcx, def_id).polymorphize(fx.tcx);
|
||||
let func_ref = fx.get_function_ref(instance);
|
||||
let call = fx.bcx.ins().call(func_ref, &[llsize, llalign]);
|
||||
let ptr = fx.bcx.inst_results(call)[0];
|
||||
lval.write_cvalue(fx, CValue::by_val(ptr, box_layout));
|
||||
}
|
||||
Rvalue::NullaryOp(null_op, ty) => {
|
||||
assert!(
|
||||
lval.layout()
|
||||
|
@ -749,7 +725,6 @@ fn codegen_stmt<'tcx>(
|
|||
let val = match null_op {
|
||||
NullOp::SizeOf => layout.size.bytes(),
|
||||
NullOp::AlignOf => layout.align.abi.bytes(),
|
||||
NullOp::Box => unreachable!(),
|
||||
};
|
||||
let val = CValue::const_val(fx, fx.layout_of(fx.tcx.types.usize), val.into());
|
||||
lval.write_cvalue(fx, val);
|
||||
|
@ -774,18 +749,6 @@ fn codegen_stmt<'tcx>(
|
|||
| StatementKind::Retag { .. }
|
||||
| StatementKind::AscribeUserType(..) => {}
|
||||
|
||||
StatementKind::LlvmInlineAsm(asm) => {
|
||||
match asm.asm.asm.as_str().trim() {
|
||||
"" => {
|
||||
// Black box
|
||||
}
|
||||
_ => fx.tcx.sess.span_fatal(
|
||||
stmt.source_info.span,
|
||||
"Legacy `llvm_asm!` inline assembly is not supported. \
|
||||
Try using the new `asm!` instead.",
|
||||
),
|
||||
}
|
||||
}
|
||||
StatementKind::Coverage { .. } => fx.tcx.sess.fatal("-Zcoverage is unimplemented"),
|
||||
StatementKind::CopyNonOverlapping(inner) => {
|
||||
let dst = codegen_operand(fx, &inner.dst);
|
||||
|
|
|
@ -129,11 +129,13 @@ pub(crate) fn codegen_constant<'tcx>(
|
|||
};
|
||||
let const_val = match const_.val {
|
||||
ConstKind::Value(const_val) => const_val,
|
||||
ConstKind::Unevaluated(uv) if fx.tcx.is_static(uv.def.did) => {
|
||||
assert!(uv.substs(fx.tcx).is_empty());
|
||||
assert!(uv.promoted.is_none());
|
||||
ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted })
|
||||
if fx.tcx.is_static(def.did) =>
|
||||
{
|
||||
assert!(substs.is_empty());
|
||||
assert!(promoted.is_none());
|
||||
|
||||
return codegen_static_ref(fx, uv.def.did, fx.layout_of(const_.ty)).to_cvalue(fx);
|
||||
return codegen_static_ref(fx, def.did, fx.layout_of(const_.ty)).to_cvalue(fx);
|
||||
}
|
||||
ConstKind::Unevaluated(unevaluated) => {
|
||||
match fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), unevaluated, None) {
|
||||
|
@ -506,7 +508,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
|
|||
{
|
||||
return None;
|
||||
}
|
||||
StatementKind::LlvmInlineAsm(_) | StatementKind::CopyNonOverlapping(_) => {
|
||||
StatementKind::CopyNonOverlapping(_) => {
|
||||
return None;
|
||||
} // conservative handling
|
||||
StatementKind::Assign(_)
|
||||
|
|
|
@ -174,7 +174,7 @@ impl<'tcx> DebugContext<'tcx> {
|
|||
|
||||
field_entry.set(
|
||||
gimli::DW_AT_name,
|
||||
AttributeValue::String(field_def.ident.as_str().to_string().into_bytes()),
|
||||
AttributeValue::String(field_def.name.as_str().to_string().into_bytes()),
|
||||
);
|
||||
field_entry.set(
|
||||
gimli::DW_AT_data_member_location,
|
||||
|
|
Loading…
Add table
Reference in a new issue