diff options
| author | Mark Simulacrum <mark.simulacrum@gmail.com> | 2016-12-18 16:06:41 -0700 |
|---|---|---|
| committer | Mark Simulacrum <mark.simulacrum@gmail.com> | 2016-12-20 20:03:33 -0700 |
| commit | 0a71b3880397b89b04e2a4b25b0528df41d39c70 (patch) | |
| tree | 43566a63036927c5a1f2875563ab4636811427e7 | |
| parent | e10695f161fade16829f9fa96f48465b123c133e (diff) | |
| download | rust-0a71b3880397b89b04e2a4b25b0528df41d39c70.tar.gz rust-0a71b3880397b89b04e2a4b25b0528df41d39c70.zip | |
Remove llretslotptr from FunctionContext
| -rw-r--r-- | src/librustc_trans/base.rs | 4 | ||||
| -rw-r--r-- | src/librustc_trans/callee.rs | 4 | ||||
| -rw-r--r-- | src/librustc_trans/common.rs | 29 | ||||
| -rw-r--r-- | src/librustc_trans/glue.rs | 2 | ||||
| -rw-r--r-- | src/librustc_trans/intrinsic.rs | 2 | ||||
| -rw-r--r-- | src/librustc_trans/meth.rs | 2 |
6 files changed, 8 insertions, 35 deletions
diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 35507c6e6ab..7abf2bb3151 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -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 diff --git a/src/librustc_trans/callee.rs b/src/librustc_trans/callee.rs index 4dbfdc9d499..892b402bf10 100644 --- a/src/librustc_trans/callee.rs +++ b/src/librustc_trans/callee.rs @@ -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); diff --git a/src/librustc_trans/common.rs b/src/librustc_trans/common.rs index 9a6127746ff..b7f2fabf184 100644 --- a/src/librustc_trans/common.rs +++ b/src/librustc_trans/common.rs @@ -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 } diff --git a/src/librustc_trans/glue.rs b/src/librustc_trans/glue.rs index 1176de4010a..262a958347d 100644 --- a/src/librustc_trans/glue.rs +++ b/src/librustc_trans/glue.rs @@ -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); diff --git a/src/librustc_trans/intrinsic.rs b/src/librustc_trans/intrinsic.rs index fd5048f8c59..30f3e549e78 100644 --- a/src/librustc_trans/intrinsic.rs +++ b/src/librustc_trans/intrinsic.rs @@ -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 } diff --git a/src/librustc_trans/meth.rs b/src/librustc_trans/meth.rs index 33b43e9a3ab..b9a6491f52f 100644 --- a/src/librustc_trans/meth.rs +++ b/src/librustc_trans/meth.rs @@ -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); |
