Merge commit '03f01bbe90
' into update_cg_clif-2020-11-01
This commit is contained in:
commit
216c4ae463
53 changed files with 609 additions and 385 deletions
|
@ -11,9 +11,9 @@ use crate::abi::pass_mode::*;
|
|||
use crate::prelude::*;
|
||||
|
||||
pub(super) fn add_args_header_comment(fx: &mut FunctionCx<'_, '_, impl Module>) {
|
||||
fx.add_global_comment(format!(
|
||||
"kind loc.idx param pass mode ty"
|
||||
));
|
||||
fx.add_global_comment(
|
||||
"kind loc.idx param pass mode ty".to_string(),
|
||||
);
|
||||
}
|
||||
|
||||
pub(super) fn add_arg_comment<'tcx>(
|
||||
|
@ -56,9 +56,9 @@ pub(super) fn add_arg_comment<'tcx>(
|
|||
|
||||
pub(super) fn add_locals_header_comment(fx: &mut FunctionCx<'_, '_, impl Module>) {
|
||||
fx.add_global_comment(String::new());
|
||||
fx.add_global_comment(format!(
|
||||
"kind local ty size align (abi,pref)"
|
||||
));
|
||||
fx.add_global_comment(
|
||||
"kind local ty size align (abi,pref)".to_string(),
|
||||
);
|
||||
}
|
||||
|
||||
pub(super) fn add_local_place_comments<'tcx>(
|
||||
|
|
|
@ -300,7 +300,7 @@ impl<'tcx, M: Module> FunctionCx<'_, 'tcx, M> {
|
|||
return_ty: Ty<'tcx>,
|
||||
) -> CValue<'tcx> {
|
||||
let (input_tys, args): (Vec<_>, Vec<_>) = args
|
||||
.into_iter()
|
||||
.iter()
|
||||
.map(|arg| {
|
||||
(
|
||||
self.clif_type(arg.layout().ty).unwrap(),
|
||||
|
@ -421,34 +421,31 @@ pub(crate) fn codegen_fn_prelude<'tcx>(
|
|||
|
||||
// While this is normally an optimization to prevent an unnecessary copy when an argument is
|
||||
// not mutated by the current function, this is necessary to support unsized arguments.
|
||||
match arg_kind {
|
||||
ArgKind::Normal(Some(val)) => {
|
||||
if let Some((addr, meta)) = val.try_to_ptr() {
|
||||
let local_decl = &fx.mir.local_decls[local];
|
||||
// v this ! is important
|
||||
let internally_mutable = !val.layout().ty.is_freeze(
|
||||
fx.tcx.at(local_decl.source_info.span),
|
||||
ParamEnv::reveal_all(),
|
||||
);
|
||||
if local_decl.mutability == mir::Mutability::Not && !internally_mutable {
|
||||
// We wont mutate this argument, so it is fine to borrow the backing storage
|
||||
// of this argument, to prevent a copy.
|
||||
if let ArgKind::Normal(Some(val)) = arg_kind {
|
||||
if let Some((addr, meta)) = val.try_to_ptr() {
|
||||
let local_decl = &fx.mir.local_decls[local];
|
||||
// v this ! is important
|
||||
let internally_mutable = !val.layout().ty.is_freeze(
|
||||
fx.tcx.at(local_decl.source_info.span),
|
||||
ParamEnv::reveal_all(),
|
||||
);
|
||||
if local_decl.mutability == mir::Mutability::Not && !internally_mutable {
|
||||
// We wont mutate this argument, so it is fine to borrow the backing storage
|
||||
// of this argument, to prevent a copy.
|
||||
|
||||
let place = if let Some(meta) = meta {
|
||||
CPlace::for_ptr_with_extra(addr, meta, val.layout())
|
||||
} else {
|
||||
CPlace::for_ptr(addr, val.layout())
|
||||
};
|
||||
let place = if let Some(meta) = meta {
|
||||
CPlace::for_ptr_with_extra(addr, meta, val.layout())
|
||||
} else {
|
||||
CPlace::for_ptr(addr, val.layout())
|
||||
};
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
self::comments::add_local_place_comments(fx, place, local);
|
||||
#[cfg(debug_assertions)]
|
||||
self::comments::add_local_place_comments(fx, place, local);
|
||||
|
||||
assert_eq!(fx.local_map.push(place), local);
|
||||
continue;
|
||||
}
|
||||
assert_eq!(fx.local_map.push(place), local);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let place = make_local_place(fx, local, layout, is_ssa);
|
||||
|
@ -500,7 +497,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
|
|||
.tcx
|
||||
.normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), &fn_ty.fn_sig(fx.tcx));
|
||||
|
||||
let destination = destination.map(|(place, bb)| (trans_place(fx, place), bb));
|
||||
let destination = destination.map(|(place, bb)| (codegen_place(fx, place), bb));
|
||||
|
||||
// Handle special calls like instrinsics and empty drop glue.
|
||||
let instance = if let ty::FnDef(def_id, substs) = *fn_ty.kind() {
|
||||
|
@ -553,8 +550,8 @@ pub(crate) fn codegen_terminator_call<'tcx>(
|
|||
// Unpack arguments tuple for closures
|
||||
let args = if fn_sig.abi == Abi::RustCall {
|
||||
assert_eq!(args.len(), 2, "rust-call abi requires two arguments");
|
||||
let self_arg = trans_operand(fx, &args[0]);
|
||||
let pack_arg = trans_operand(fx, &args[1]);
|
||||
let self_arg = codegen_operand(fx, &args[0]);
|
||||
let pack_arg = codegen_operand(fx, &args[1]);
|
||||
|
||||
let tupled_arguments = match pack_arg.layout().ty.kind() {
|
||||
ty::Tuple(ref tupled_arguments) => tupled_arguments,
|
||||
|
@ -568,8 +565,8 @@ pub(crate) fn codegen_terminator_call<'tcx>(
|
|||
}
|
||||
args
|
||||
} else {
|
||||
args.into_iter()
|
||||
.map(|arg| trans_operand(fx, arg))
|
||||
args.iter()
|
||||
.map(|arg| codegen_operand(fx, arg))
|
||||
.collect::<Vec<_>>()
|
||||
};
|
||||
|
||||
|
@ -613,7 +610,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
|
|||
let nop_inst = fx.bcx.ins().nop();
|
||||
fx.add_comment(nop_inst, "indirect call");
|
||||
}
|
||||
let func = trans_operand(fx, func).load_scalar(fx);
|
||||
let func = codegen_operand(fx, func).load_scalar(fx);
|
||||
(
|
||||
Some(func),
|
||||
args.get(0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue