]> git.lizzy.rs Git - rust.git/commitdiff
Remove llretslotptr from FunctionContext
authorMark Simulacrum <mark.simulacrum@gmail.com>
Sun, 18 Dec 2016 23:06:41 +0000 (16:06 -0700)
committerMark Simulacrum <mark.simulacrum@gmail.com>
Wed, 21 Dec 2016 03:03:33 +0000 (20:03 -0700)
src/librustc_trans/base.rs
src/librustc_trans/callee.rs
src/librustc_trans/common.rs
src/librustc_trans/glue.rs
src/librustc_trans/intrinsic.rs
src/librustc_trans/meth.rs

index 35507c6e6ab7cf4add31203ddc5760bb4c40614e..7abf2bb3151924cb7b837dddb027e826ad173db7 100644 (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
index 4dbfdc9d4999efdd93c24ad5e83351ca829aae41..892b402bf100974f81925ef38f3d861d10bed495 100644 (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);
index 9a6127746ff3ca742dcc8ad5823ac1ab3b4fc36d..b7f2fabf184da3ff4bae2a11aa1f55e7babd9d78 100644 (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 @@ pub fn new(
         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 @@ pub fn new(
         // 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
     }
 
index 1176de4010a172131489413c4320ebb686db51b7..262a958347d54025fc1c9b7782b115b972f3628d 100644 (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);
index fd5048f8c5938bc5864dff3ca8d8d11332a6a767..30f3e549e78c2d4ca460595c318b336e6eaaf774 100644 (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
 }
index 33b43e9a3ab06ac1234d7886df66aade07630ac2..b9a6491f52f3f5098bc397469255a09b1fa05a7d 100644 (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);