Address review comments
This commit is contained in:
parent
a0fa2048a8
commit
e3293b84af
2 changed files with 50 additions and 50 deletions
|
|
@ -222,8 +222,10 @@ impl<'tcx> Mir<'tcx> {
|
|||
/// Returns an iterator over all user-defined variables and compiler-generated temporaries (all
|
||||
/// locals that are neither arguments nor the return pointer).
|
||||
#[inline]
|
||||
pub fn vars_and_temps_iter<'a>(&'a self) -> impl Iterator<Item=Local> + 'a {
|
||||
(self.arg_count+1..self.local_decls.len()).map(Local::new)
|
||||
pub fn vars_and_temps_iter(&self) -> impl Iterator<Item=Local> {
|
||||
let arg_count = self.arg_count;
|
||||
let local_count = self.local_decls.len();
|
||||
(arg_count+1..local_count).map(Local::new)
|
||||
}
|
||||
|
||||
/// Changes a statement to a nop. This is both faster than deleting instructions and avoids
|
||||
|
|
|
|||
|
|
@ -360,59 +360,57 @@ fn arg_local_refs<'bcx, 'tcx>(bcx: &BlockAndBuilder<'bcx, 'tcx>,
|
|||
let arg_decl = &mir.local_decls[local];
|
||||
let arg_ty = bcx.monomorphize(&arg_decl.ty);
|
||||
|
||||
if let Some(spread_local) = mir.spread_arg {
|
||||
if local == spread_local {
|
||||
// This argument (e.g. the last argument in the "rust-call" ABI)
|
||||
// is a tuple that was spread at the ABI level and now we have
|
||||
// to reconstruct it into a tuple local variable, from multiple
|
||||
// individual LLVM function arguments.
|
||||
if Some(local) == mir.spread_arg {
|
||||
// This argument (e.g. the last argument in the "rust-call" ABI)
|
||||
// is a tuple that was spread at the ABI level and now we have
|
||||
// to reconstruct it into a tuple local variable, from multiple
|
||||
// individual LLVM function arguments.
|
||||
|
||||
let tupled_arg_tys = match arg_ty.sty {
|
||||
ty::TyTuple(ref tys) => tys,
|
||||
_ => bug!("spread argument isn't a tuple?!")
|
||||
};
|
||||
let tupled_arg_tys = match arg_ty.sty {
|
||||
ty::TyTuple(ref tys) => tys,
|
||||
_ => bug!("spread argument isn't a tuple?!")
|
||||
};
|
||||
|
||||
let lltuplety = type_of::type_of(bcx.ccx(), arg_ty);
|
||||
let lltemp = bcx.with_block(|bcx| {
|
||||
base::alloc_ty(bcx, arg_ty, &format!("arg{}", arg_index))
|
||||
});
|
||||
for (i, &tupled_arg_ty) in tupled_arg_tys.iter().enumerate() {
|
||||
let dst = bcx.struct_gep(lltemp, i);
|
||||
let arg = &fcx.fn_ty.args[idx];
|
||||
let lltuplety = type_of::type_of(bcx.ccx(), arg_ty);
|
||||
let lltemp = bcx.with_block(|bcx| {
|
||||
base::alloc_ty(bcx, arg_ty, &format!("arg{}", arg_index))
|
||||
});
|
||||
for (i, &tupled_arg_ty) in tupled_arg_tys.iter().enumerate() {
|
||||
let dst = bcx.struct_gep(lltemp, i);
|
||||
let arg = &fcx.fn_ty.args[idx];
|
||||
idx += 1;
|
||||
if common::type_is_fat_ptr(tcx, tupled_arg_ty) {
|
||||
// We pass fat pointers as two words, but inside the tuple
|
||||
// they are the two sub-fields of a single aggregate field.
|
||||
let meta = &fcx.fn_ty.args[idx];
|
||||
idx += 1;
|
||||
if common::type_is_fat_ptr(tcx, tupled_arg_ty) {
|
||||
// We pass fat pointers as two words, but inside the tuple
|
||||
// they are the two sub-fields of a single aggregate field.
|
||||
let meta = &fcx.fn_ty.args[idx];
|
||||
idx += 1;
|
||||
arg.store_fn_arg(bcx, &mut llarg_idx, get_dataptr(bcx, dst));
|
||||
meta.store_fn_arg(bcx, &mut llarg_idx, get_meta(bcx, dst));
|
||||
} else {
|
||||
arg.store_fn_arg(bcx, &mut llarg_idx, dst);
|
||||
}
|
||||
|
||||
bcx.with_block(|bcx| arg_scope.map(|scope| {
|
||||
let byte_offset_of_var_in_tuple =
|
||||
machine::llelement_offset(bcx.ccx(), lltuplety, i);
|
||||
|
||||
let ops = unsafe {
|
||||
[llvm::LLVMRustDIBuilderCreateOpDeref(),
|
||||
llvm::LLVMRustDIBuilderCreateOpPlus(),
|
||||
byte_offset_of_var_in_tuple as i64]
|
||||
};
|
||||
|
||||
let variable_access = VariableAccess::IndirectVariable {
|
||||
alloca: lltemp,
|
||||
address_operations: &ops
|
||||
};
|
||||
declare_local(bcx, keywords::Invalid.name(),
|
||||
tupled_arg_ty, scope, variable_access,
|
||||
VariableKind::ArgumentVariable(arg_index + i + 1),
|
||||
bcx.fcx().span.unwrap_or(DUMMY_SP));
|
||||
}));
|
||||
arg.store_fn_arg(bcx, &mut llarg_idx, get_dataptr(bcx, dst));
|
||||
meta.store_fn_arg(bcx, &mut llarg_idx, get_meta(bcx, dst));
|
||||
} else {
|
||||
arg.store_fn_arg(bcx, &mut llarg_idx, dst);
|
||||
}
|
||||
return LocalRef::Lvalue(LvalueRef::new_sized(lltemp, LvalueTy::from_ty(arg_ty)));
|
||||
|
||||
bcx.with_block(|bcx| arg_scope.map(|scope| {
|
||||
let byte_offset_of_var_in_tuple =
|
||||
machine::llelement_offset(bcx.ccx(), lltuplety, i);
|
||||
|
||||
let ops = unsafe {
|
||||
[llvm::LLVMRustDIBuilderCreateOpDeref(),
|
||||
llvm::LLVMRustDIBuilderCreateOpPlus(),
|
||||
byte_offset_of_var_in_tuple as i64]
|
||||
};
|
||||
|
||||
let variable_access = VariableAccess::IndirectVariable {
|
||||
alloca: lltemp,
|
||||
address_operations: &ops
|
||||
};
|
||||
declare_local(bcx, keywords::Invalid.name(),
|
||||
tupled_arg_ty, scope, variable_access,
|
||||
VariableKind::ArgumentVariable(arg_index + i + 1),
|
||||
bcx.fcx().span.unwrap_or(DUMMY_SP));
|
||||
}));
|
||||
}
|
||||
return LocalRef::Lvalue(LvalueRef::new_sized(lltemp, LvalueTy::from_ty(arg_ty)));
|
||||
}
|
||||
|
||||
let arg = &fcx.fn_ty.args[idx];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue