Skip to content

Commit

Permalink
move our check to reuse a previous computation
Browse files Browse the repository at this point in the history
  • Loading branch information
japaric authored and RalfJung committed Sep 30, 2018
1 parent 7294fcd commit 00ba5cb
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions src/librustc_codegen_llvm/mir/block.rs
Expand Up @@ -463,8 +463,28 @@ impl FunctionCx<'a, 'll, 'tcx> {
return;
}

let extra_args = &args[sig.inputs().len()..];
let extra_args = extra_args.iter().map(|op_arg| {
let op_ty = op_arg.ty(self.mir, bx.tcx());
self.monomorphize(&op_ty)
}).collect::<Vec<_>>();

let fn_ty = match def {
Some(ty::InstanceDef::Virtual(..)) => {
FnType::new_vtable(bx.cx, sig, &extra_args)
}
Some(ty::InstanceDef::DropGlue(_, None)) => {
// empty drop glue - a nop.
let &(_, target) = destination.as_ref().unwrap();
funclet_br(self, bx, target);
return;
}
_ => FnType::new(bx.cx, sig, &extra_args)
};

// emit a panic instead of instantiating an uninhabited type
if (intrinsic == Some("init") || intrinsic == Some("uninit")) &&
bx.cx.layout_of(sig.output()).abi.is_uninhabited()
fn_ty.ret.layout.abi.is_uninhabited()
{
let loc = bx.sess().codemap().lookup_char_pos(span.lo());
let filename = Symbol::intern(&loc.file.name.to_string()).as_str();
Expand Down Expand Up @@ -510,25 +530,6 @@ impl FunctionCx<'a, 'll, 'tcx> {
return;
}

let extra_args = &args[sig.inputs().len()..];
let extra_args = extra_args.iter().map(|op_arg| {
let op_ty = op_arg.ty(self.mir, bx.tcx());
self.monomorphize(&op_ty)
}).collect::<Vec<_>>();

let fn_ty = match def {
Some(ty::InstanceDef::Virtual(..)) => {
FnType::new_vtable(bx.cx, sig, &extra_args)
}
Some(ty::InstanceDef::DropGlue(_, None)) => {
// empty drop glue - a nop.
let &(_, target) = destination.as_ref().unwrap();
funclet_br(self, bx, target);
return;
}
_ => FnType::new(bx.cx, sig, &extra_args)
};

// The arguments we'll be passing. Plus one to account for outptr, if used.
let arg_count = fn_ty.args.len() + fn_ty.ret.is_indirect() as usize;
let mut llargs = Vec::with_capacity(arg_count);
Expand Down

0 comments on commit 00ba5cb

Please sign in to comment.