From f580412e952957dc1d91884338f2edc7866d1d17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Mon, 2 Mar 2015 17:11:02 +0100 Subject: [PATCH] Drop alloca_zeroed Its only user was lvalue_scratch_datum which is called with zero=true anymore, so it's effectively unused. --- src/librustc_trans/trans/adt.rs | 2 +- src/librustc_trans/trans/base.rs | 16 ---------------- src/librustc_trans/trans/datum.rs | 14 ++++---------- 3 files changed, 5 insertions(+), 27 deletions(-) diff --git a/src/librustc_trans/trans/adt.rs b/src/librustc_trans/trans/adt.rs index 3ea14d3c589..777fd28d31f 100644 --- a/src/librustc_trans/trans/adt.rs +++ b/src/librustc_trans/trans/adt.rs @@ -1000,7 +1000,7 @@ pub fn trans_drop_flag_ptr<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, r: &Repr<'tcx let fcx = bcx.fcx; let custom_cleanup_scope = fcx.push_custom_cleanup_scope(); let scratch = unpack_datum!(bcx, datum::lvalue_scratch_datum( - bcx, tcx.types.bool, "drop_flag", false, + bcx, tcx.types.bool, "drop_flag", cleanup::CustomScope(custom_cleanup_scope), (), |_, bcx, _| bcx )); bcx = fold_variants(bcx, r, val, |variant_cx, st, value| { diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index 1f578ac0bdb..032620d2861 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -1203,21 +1203,6 @@ pub fn alloca_no_lifetime(cx: Block, ty: Type, name: &str) -> ValueRef { Alloca(cx, ty, name) } -pub fn alloca_zeroed<'blk, 'tcx>(cx: Block<'blk, 'tcx>, ty: Ty<'tcx>, - name: &str) -> ValueRef { - let llty = type_of::type_of(cx.ccx(), ty); - if cx.unreachable.get() { - unsafe { - return llvm::LLVMGetUndef(llty.ptr_to().to_ref()); - } - } - let p = alloca_no_lifetime(cx, llty, name); - let b = cx.fcx.ccx.builder(); - b.position_before(cx.fcx.alloca_insert_pt.get().unwrap()); - memzero(&b, p, ty); - p -} - // Creates the alloca slot which holds the pointer to the slot for the final return value pub fn make_return_slot_pointer<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>, output_type: Ty<'tcx>) -> ValueRef { @@ -1547,7 +1532,6 @@ fn create_datums_for_fn_args_under_call_abi<'blk, 'tcx>( datum::lvalue_scratch_datum(bcx, arg_ty, "tupled_args", - false, tuple_args_scope_id, (), |(), diff --git a/src/librustc_trans/trans/datum.rs b/src/librustc_trans/trans/datum.rs index 6ca71254868..e181df545e6 100644 --- a/src/librustc_trans/trans/datum.rs +++ b/src/librustc_trans/trans/datum.rs @@ -195,24 +195,18 @@ pub fn immediate_rvalue_bcx<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, /// Allocates temporary space on the stack using alloca() and returns a by-ref Datum pointing to /// it. The memory will be dropped upon exit from `scope`. The callback `populate` should -/// initialize the memory. If `zero` is true, the space will be zeroed when it is allocated; this -/// is not necessary unless `bcx` does not dominate the end of `scope`. +/// initialize the memory. pub fn lvalue_scratch_datum<'blk, 'tcx, A, F>(bcx: Block<'blk, 'tcx>, ty: Ty<'tcx>, name: &str, - zero: bool, scope: cleanup::ScopeId, arg: A, populate: F) -> DatumBlock<'blk, 'tcx, Lvalue> where F: FnOnce(A, Block<'blk, 'tcx>, ValueRef) -> Block<'blk, 'tcx>, { - let scratch = if zero { - alloca_zeroed(bcx, ty, name) - } else { - let llty = type_of::type_of(bcx.ccx(), ty); - alloca(bcx, llty, name) - }; + let llty = type_of::type_of(bcx.ccx(), ty); + let scratch = alloca(bcx, llty, name); // Subtle. Populate the scratch memory *before* scheduling cleanup. let bcx = populate(arg, bcx, scratch); @@ -383,7 +377,7 @@ pub fn to_lvalue_datum_in_scope<'blk>(self, ByValue => { lvalue_scratch_datum( - bcx, self.ty, name, false, scope, self, + bcx, self.ty, name, scope, self, |this, bcx, llval| this.store_to(bcx, llval)) } }