Remove llretslotptr from FunctionContext

This commit is contained in:
Mark Simulacrum 2016-12-18 16:06:41 -07:00
parent e10695f161
commit 0a71b38803
6 changed files with 8 additions and 35 deletions

View File

@ -598,7 +598,7 @@ pub fn trans_instance<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, instance: Instance
let fn_ty = FnType::new(ccx, abi, &sig, &[]);
let fcx = FunctionContext::new(ccx, lldecl, fn_ty, Some((instance, &sig, abi)), true);
let fcx = FunctionContext::new(ccx, lldecl, fn_ty);
let mir = ccx.tcx().item_mir(instance.def);
mir::trans_mir(&fcx, &mir, instance, &sig, abi);
@ -618,7 +618,7 @@ pub fn trans_ctor_shim<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
let sig = ccx.tcx().erase_late_bound_regions_and_normalize(&ctor_ty.fn_sig());
let fn_ty = FnType::new(ccx, Abi::Rust, &sig, &[]);
let fcx = FunctionContext::new(ccx, llfndecl, fn_ty, None, false);
let fcx = FunctionContext::new(ccx, llfndecl, fn_ty);
let bcx = fcx.get_entry_block();
if !fcx.fn_ty.ret.is_ignore() {
// But if there are no nested returns, we skip the indirection

View File

@ -328,7 +328,7 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
let lloncefn = declare::define_internal_fn(ccx, &function_name, llonce_fn_ty);
attributes::set_frame_pointer_elimination(ccx, lloncefn);
let fcx = FunctionContext::new(ccx, lloncefn, fn_ty, None, false);
let fcx = FunctionContext::new(ccx, lloncefn, fn_ty);
let mut bcx = fcx.get_entry_block();
// the first argument (`self`) will be the (by value) closure env.
@ -499,7 +499,7 @@ fn trans_fn_pointer_shim<'a, 'tcx>(
let llfn = declare::define_internal_fn(ccx, &function_name, tuple_fn_ty);
attributes::set_frame_pointer_elimination(ccx, llfn);
//
let fcx = FunctionContext::new(ccx, llfn, fn_ty, None, false);
let fcx = FunctionContext::new(ccx, llfn, fn_ty);
let bcx = fcx.get_entry_block();
let llargs = get_params(fcx.llfn);

View File

@ -15,8 +15,7 @@
use session::Session;
use llvm;
use llvm::{ValueRef, BasicBlockRef, ContextRef, TypeKind};
use llvm::{True, False, Bool, OperandBundleDef, get_param};
use monomorphize::Instance;
use llvm::{True, False, Bool, OperandBundleDef};
use rustc::hir::def::Def;
use rustc::hir::def_id::DefId;
use rustc::hir::map::DefPathData;
@ -230,12 +229,6 @@ pub struct FunctionContext<'a, 'tcx: 'a> {
// section of the executable we're generating.
pub llfn: ValueRef,
// A pointer to where to store the return value. If the return type is
// immediate, this points to an alloca in the function. Otherwise, it's a
// pointer to the hidden first parameter of the function. After function
// construction, this should always be Some.
pub llretslotptr: Option<ValueRef>,
// These pub elements: "hoisted basic blocks" containing
// administrative activities that have to happen in only one place in
// the function, due to LLVM's quirks.
@ -259,11 +252,9 @@ impl<'a, 'tcx> FunctionContext<'a, 'tcx> {
ccx: &'a CrateContext<'a, 'tcx>,
llfndecl: ValueRef,
fn_ty: FnType,
skip_retptr: bool,
) -> FunctionContext<'a, 'tcx> {
let mut fcx = FunctionContext {
llfn: llfndecl,
llretslotptr: None,
alloca_insert_pt: None,
fn_ty: fn_ty,
ccx: ccx,
@ -281,24 +272,6 @@ impl<'a, 'tcx> FunctionContext<'a, 'tcx> {
// This is later removed in the drop of FunctionContext.
fcx.alloca_insert_pt = Some(val);
// We normally allocate the llretslotptr, unless we
// have been instructed to skip it for immediate return
// values, or there is nothing to return at all.
if !fcx.fn_ty.ret.is_ignore() && !skip_retptr {
// But if there are no nested returns, we skip the indirection
// and have a single retslot
let slot = if fcx.fn_ty.ret.is_indirect() {
get_param(fcx.llfn, 0)
} else {
// We create an alloca to hold a pointer of type `ret.original_ty`
// which will hold the pointer to the right alloca which has the
// final ret value
fcx.alloca(fcx.fn_ty.ret.memory_ty(ccx), "sret_slot")
};
fcx.llretslotptr = Some(slot);
}
fcx
}

View File

@ -195,7 +195,7 @@ pub fn implement_drop_glue<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, g: DropGlueKi
assert_eq!(g.ty(), get_drop_glue_type(ccx.shared(), g.ty()));
let (llfn, fn_ty) = ccx.drop_glues().borrow().get(&g).unwrap().clone();
let fcx = FunctionContext::new(ccx, llfn, fn_ty, None, false);
let fcx = FunctionContext::new(ccx, llfn, fn_ty);
let bcx = fcx.get_entry_block();
ccx.stats().n_glues_created.set(ccx.stats().n_glues_created.get() + 1);

View File

@ -893,7 +893,7 @@ fn gen_fn<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>,
sig: ty::Binder(sig)
}));
let llfn = declare::define_internal_fn(ccx, name, rust_fn_ty);
let fcx = FunctionContext::new(ccx, llfn, fn_ty, None, true);
let fcx = FunctionContext::new(ccx, llfn, fn_ty);
trans(fcx.get_entry_block());
llfn
}

View File

@ -81,7 +81,7 @@ pub fn trans_object_shim<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>,
let llfn = declare::define_internal_fn(ccx, &function_name, callee.ty);
attributes::set_frame_pointer_elimination(ccx, llfn);
let fcx = FunctionContext::new(ccx, llfn, fn_ty, None, false);
let fcx = FunctionContext::new(ccx, llfn, fn_ty);
let bcx = fcx.get_entry_block();
let llargs = get_params(fcx.llfn);