mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-15 16:33:49 +00:00
Sync from rust 6b6a867ae9
This commit is contained in:
commit
632ccacd81
@ -80,7 +80,7 @@ pub(crate) fn get_function_sig<'tcx>(
|
||||
clif_sig_from_fn_abi(
|
||||
tcx,
|
||||
default_call_conv,
|
||||
&RevealAllLayoutCx(tcx).fn_abi_of_instance(inst, ty::List::empty()),
|
||||
&FullyMonomorphizedLayoutCx(tcx).fn_abi_of_instance(inst, ty::List::empty()),
|
||||
)
|
||||
}
|
||||
|
||||
@ -438,9 +438,9 @@ pub(crate) fn codegen_terminator_call<'tcx>(
|
||||
extra_args.iter().map(|op_arg| fx.monomorphize(op_arg.node.ty(fx.mir, fx.tcx))),
|
||||
);
|
||||
let fn_abi = if let Some(instance) = instance {
|
||||
RevealAllLayoutCx(fx.tcx).fn_abi_of_instance(instance, extra_args)
|
||||
FullyMonomorphizedLayoutCx(fx.tcx).fn_abi_of_instance(instance, extra_args)
|
||||
} else {
|
||||
RevealAllLayoutCx(fx.tcx).fn_abi_of_fn_ptr(fn_sig, extra_args)
|
||||
FullyMonomorphizedLayoutCx(fx.tcx).fn_abi_of_fn_ptr(fn_sig, extra_args)
|
||||
};
|
||||
|
||||
let is_cold = if fn_sig.abi() == ExternAbi::RustCold {
|
||||
@ -721,8 +721,8 @@ pub(crate) fn codegen_drop<'tcx>(
|
||||
def: ty::InstanceKind::Virtual(drop_instance.def_id(), 0),
|
||||
args: drop_instance.args,
|
||||
};
|
||||
let fn_abi =
|
||||
RevealAllLayoutCx(fx.tcx).fn_abi_of_instance(virtual_drop, ty::List::empty());
|
||||
let fn_abi = FullyMonomorphizedLayoutCx(fx.tcx)
|
||||
.fn_abi_of_instance(virtual_drop, ty::List::empty());
|
||||
|
||||
let sig = clif_sig_from_fn_abi(fx.tcx, fx.target_config.default_call_conv, &fn_abi);
|
||||
let sig = fx.bcx.import_signature(sig);
|
||||
@ -764,8 +764,8 @@ pub(crate) fn codegen_drop<'tcx>(
|
||||
def: ty::InstanceKind::Virtual(drop_instance.def_id(), 0),
|
||||
args: drop_instance.args,
|
||||
};
|
||||
let fn_abi =
|
||||
RevealAllLayoutCx(fx.tcx).fn_abi_of_instance(virtual_drop, ty::List::empty());
|
||||
let fn_abi = FullyMonomorphizedLayoutCx(fx.tcx)
|
||||
.fn_abi_of_instance(virtual_drop, ty::List::empty());
|
||||
|
||||
let sig = clif_sig_from_fn_abi(fx.tcx, fx.target_config.default_call_conv, &fn_abi);
|
||||
let sig = fx.bcx.import_signature(sig);
|
||||
@ -774,8 +774,8 @@ pub(crate) fn codegen_drop<'tcx>(
|
||||
_ => {
|
||||
assert!(!matches!(drop_instance.def, InstanceKind::Virtual(_, _)));
|
||||
|
||||
let fn_abi =
|
||||
RevealAllLayoutCx(fx.tcx).fn_abi_of_instance(drop_instance, ty::List::empty());
|
||||
let fn_abi = FullyMonomorphizedLayoutCx(fx.tcx)
|
||||
.fn_abi_of_instance(drop_instance, ty::List::empty());
|
||||
|
||||
let arg_value = drop_place.place_ref(
|
||||
fx,
|
||||
|
@ -104,7 +104,7 @@ pub(crate) fn codegen_fn<'tcx>(
|
||||
let block_map: IndexVec<BasicBlock, Block> =
|
||||
(0..mir.basic_blocks.len()).map(|_| bcx.create_block()).collect();
|
||||
|
||||
let fn_abi = RevealAllLayoutCx(tcx).fn_abi_of_instance(instance, ty::List::empty());
|
||||
let fn_abi = FullyMonomorphizedLayoutCx(tcx).fn_abi_of_instance(instance, ty::List::empty());
|
||||
|
||||
// Make FunctionCx
|
||||
let target_config = module.target_config();
|
||||
|
@ -311,7 +311,7 @@ pub(crate) struct FunctionCx<'m, 'clif, 'tcx: 'm> {
|
||||
impl<'tcx> LayoutOfHelpers<'tcx> for FunctionCx<'_, '_, 'tcx> {
|
||||
#[inline]
|
||||
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
|
||||
RevealAllLayoutCx(self.tcx).handle_layout_err(err, span, ty)
|
||||
FullyMonomorphizedLayoutCx(self.tcx).handle_layout_err(err, span, ty)
|
||||
}
|
||||
}
|
||||
|
||||
@ -323,7 +323,7 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for FunctionCx<'_, '_, 'tcx> {
|
||||
span: Span,
|
||||
fn_abi_request: FnAbiRequest<'tcx>,
|
||||
) -> ! {
|
||||
RevealAllLayoutCx(self.tcx).handle_fn_abi_err(err, span, fn_abi_request)
|
||||
FullyMonomorphizedLayoutCx(self.tcx).handle_fn_abi_err(err, span, fn_abi_request)
|
||||
}
|
||||
}
|
||||
|
||||
@ -443,9 +443,9 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct RevealAllLayoutCx<'tcx>(pub(crate) TyCtxt<'tcx>);
|
||||
pub(crate) struct FullyMonomorphizedLayoutCx<'tcx>(pub(crate) TyCtxt<'tcx>);
|
||||
|
||||
impl<'tcx> LayoutOfHelpers<'tcx> for RevealAllLayoutCx<'tcx> {
|
||||
impl<'tcx> LayoutOfHelpers<'tcx> for FullyMonomorphizedLayoutCx<'tcx> {
|
||||
#[inline]
|
||||
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
|
||||
if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err {
|
||||
@ -459,7 +459,7 @@ impl<'tcx> LayoutOfHelpers<'tcx> for RevealAllLayoutCx<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> FnAbiOfHelpers<'tcx> for RevealAllLayoutCx<'tcx> {
|
||||
impl<'tcx> FnAbiOfHelpers<'tcx> for FullyMonomorphizedLayoutCx<'tcx> {
|
||||
#[inline]
|
||||
fn handle_fn_abi_err(
|
||||
&self,
|
||||
@ -485,25 +485,25 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for RevealAllLayoutCx<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> layout::HasTyCtxt<'tcx> for RevealAllLayoutCx<'tcx> {
|
||||
impl<'tcx> layout::HasTyCtxt<'tcx> for FullyMonomorphizedLayoutCx<'tcx> {
|
||||
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> rustc_abi::HasDataLayout for RevealAllLayoutCx<'tcx> {
|
||||
impl<'tcx> rustc_abi::HasDataLayout for FullyMonomorphizedLayoutCx<'tcx> {
|
||||
fn data_layout(&self) -> &rustc_abi::TargetDataLayout {
|
||||
&self.0.data_layout
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> layout::HasTypingEnv<'tcx> for RevealAllLayoutCx<'tcx> {
|
||||
impl<'tcx> layout::HasTypingEnv<'tcx> for FullyMonomorphizedLayoutCx<'tcx> {
|
||||
fn typing_env(&self) -> ty::TypingEnv<'tcx> {
|
||||
ty::TypingEnv::fully_monomorphized()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> HasTargetSpec for RevealAllLayoutCx<'tcx> {
|
||||
impl<'tcx> HasTargetSpec for FullyMonomorphizedLayoutCx<'tcx> {
|
||||
fn target_spec(&self) -> &Target {
|
||||
&self.0.sess.target
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_middle::ty::layout::LayoutOf;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
|
||||
use crate::{DebugContext, RevealAllLayoutCx, has_ptr_meta};
|
||||
use crate::{DebugContext, FullyMonomorphizedLayoutCx, has_ptr_meta};
|
||||
|
||||
#[derive(Default)]
|
||||
pub(crate) struct TypeDebugContext<'tcx> {
|
||||
@ -85,7 +85,7 @@ impl DebugContext {
|
||||
type_entry.set(gimli::DW_AT_encoding, AttributeValue::Encoding(encoding));
|
||||
type_entry.set(
|
||||
gimli::DW_AT_byte_size,
|
||||
AttributeValue::Udata(RevealAllLayoutCx(tcx).layout_of(ty).size.bytes()),
|
||||
AttributeValue::Udata(FullyMonomorphizedLayoutCx(tcx).layout_of(ty).size.bytes()),
|
||||
);
|
||||
|
||||
type_id
|
||||
@ -159,7 +159,7 @@ impl DebugContext {
|
||||
return_if_type_created_in_meantime!(type_dbg, tuple_type);
|
||||
|
||||
let name = type_names::compute_debuginfo_type_name(tcx, tuple_type, false);
|
||||
let layout = RevealAllLayoutCx(tcx).layout_of(tuple_type);
|
||||
let layout = FullyMonomorphizedLayoutCx(tcx).layout_of(tuple_type);
|
||||
|
||||
let tuple_type_id =
|
||||
self.dwarf.unit.add(self.dwarf.unit.root(), gimli::DW_TAG_structure_type);
|
||||
@ -178,7 +178,9 @@ impl DebugContext {
|
||||
member_entry.set(gimli::DW_AT_type, AttributeValue::UnitRef(dw_ty));
|
||||
member_entry.set(
|
||||
gimli::DW_AT_alignment,
|
||||
AttributeValue::Udata(RevealAllLayoutCx(tcx).layout_of(ty).align.pref.bytes()),
|
||||
AttributeValue::Udata(
|
||||
FullyMonomorphizedLayoutCx(tcx).layout_of(ty).align.pref.bytes(),
|
||||
),
|
||||
);
|
||||
member_entry.set(
|
||||
gimli::DW_AT_data_member_location,
|
||||
@ -198,7 +200,11 @@ impl DebugContext {
|
||||
self.debug_type(
|
||||
tcx,
|
||||
type_dbg,
|
||||
Ty::new_array(tcx, tcx.types.u8, RevealAllLayoutCx(tcx).layout_of(ty).size.bytes()),
|
||||
Ty::new_array(
|
||||
tcx,
|
||||
tcx.types.u8,
|
||||
FullyMonomorphizedLayoutCx(tcx).layout_of(ty).size.bytes(),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ pub(crate) fn codegen_global_asm_item(tcx: TyCtxt<'_>, global_asm: &mut String,
|
||||
tcx,
|
||||
op_sp,
|
||||
const_value,
|
||||
RevealAllLayoutCx(tcx).layout_of(ty),
|
||||
FullyMonomorphizedLayoutCx(tcx).layout_of(ty),
|
||||
);
|
||||
global_asm.push_str(&string);
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ pub(crate) fn codegen_naked_asm<'tcx>(
|
||||
tcx,
|
||||
span,
|
||||
const_value,
|
||||
RevealAllLayoutCx(tcx).layout_of(cv.ty()),
|
||||
FullyMonomorphizedLayoutCx(tcx).layout_of(cv.ty()),
|
||||
);
|
||||
CInlineAsmOperand::Const { value }
|
||||
}
|
||||
@ -459,8 +459,12 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> {
|
||||
let mut slots_output = vec![None; self.operands.len()];
|
||||
|
||||
let new_slot_fn = |slot_size: &mut Size, reg_class: InlineAsmRegClass| {
|
||||
let reg_size =
|
||||
reg_class.supported_types(self.arch).iter().map(|(ty, _)| ty.size()).max().unwrap();
|
||||
let reg_size = reg_class
|
||||
.supported_types(self.arch, true)
|
||||
.iter()
|
||||
.map(|(ty, _)| ty.size())
|
||||
.max()
|
||||
.unwrap();
|
||||
let align = rustc_abi::Align::from_bytes(reg_size.bytes()).unwrap();
|
||||
let offset = slot_size.align_to(align);
|
||||
*slot_size = offset + reg_size;
|
||||
|
Loading…
Reference in New Issue
Block a user