Skip to content

Commit

Permalink
Drop alloca_zeroed
Browse files Browse the repository at this point in the history
Its only user was lvalue_scratch_datum which is called with zero=true
anymore, so it's effectively unused.
  • Loading branch information
dotdash committed Mar 2, 2015
1 parent c514205 commit f580412
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/librustc_trans/trans/adt.rs
Expand Up @@ -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| {
Expand Down
16 changes: 0 additions & 16 deletions src/librustc_trans/trans/base.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
(),
|(),
Expand Down
14 changes: 4 additions & 10 deletions src/librustc_trans/trans/datum.rs
Expand Up @@ -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);
Expand Down Expand Up @@ -383,7 +377,7 @@ impl<'tcx> Datum<'tcx, Rvalue> {

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))
}
}
Expand Down

0 comments on commit f580412

Please sign in to comment.