Skip to content

Commit f580412

Browse files
committed
Drop alloca_zeroed
Its only user was lvalue_scratch_datum which is called with zero=true anymore, so it's effectively unused.
1 parent c514205 commit f580412

File tree

3 files changed

+5
-27
lines changed

3 files changed

+5
-27
lines changed

src/librustc_trans/trans/adt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ pub fn trans_drop_flag_ptr<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, r: &Repr<'tcx
10001000
let fcx = bcx.fcx;
10011001
let custom_cleanup_scope = fcx.push_custom_cleanup_scope();
10021002
let scratch = unpack_datum!(bcx, datum::lvalue_scratch_datum(
1003-
bcx, tcx.types.bool, "drop_flag", false,
1003+
bcx, tcx.types.bool, "drop_flag",
10041004
cleanup::CustomScope(custom_cleanup_scope), (), |_, bcx, _| bcx
10051005
));
10061006
bcx = fold_variants(bcx, r, val, |variant_cx, st, value| {

src/librustc_trans/trans/base.rs

-16
Original file line numberDiff line numberDiff line change
@@ -1203,21 +1203,6 @@ pub fn alloca_no_lifetime(cx: Block, ty: Type, name: &str) -> ValueRef {
12031203
Alloca(cx, ty, name)
12041204
}
12051205

1206-
pub fn alloca_zeroed<'blk, 'tcx>(cx: Block<'blk, 'tcx>, ty: Ty<'tcx>,
1207-
name: &str) -> ValueRef {
1208-
let llty = type_of::type_of(cx.ccx(), ty);
1209-
if cx.unreachable.get() {
1210-
unsafe {
1211-
return llvm::LLVMGetUndef(llty.ptr_to().to_ref());
1212-
}
1213-
}
1214-
let p = alloca_no_lifetime(cx, llty, name);
1215-
let b = cx.fcx.ccx.builder();
1216-
b.position_before(cx.fcx.alloca_insert_pt.get().unwrap());
1217-
memzero(&b, p, ty);
1218-
p
1219-
}
1220-
12211206
// Creates the alloca slot which holds the pointer to the slot for the final return value
12221207
pub fn make_return_slot_pointer<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>,
12231208
output_type: Ty<'tcx>) -> ValueRef {
@@ -1547,7 +1532,6 @@ fn create_datums_for_fn_args_under_call_abi<'blk, 'tcx>(
15471532
datum::lvalue_scratch_datum(bcx,
15481533
arg_ty,
15491534
"tupled_args",
1550-
false,
15511535
tuple_args_scope_id,
15521536
(),
15531537
|(),

src/librustc_trans/trans/datum.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -195,24 +195,18 @@ pub fn immediate_rvalue_bcx<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
195195

196196
/// Allocates temporary space on the stack using alloca() and returns a by-ref Datum pointing to
197197
/// it. The memory will be dropped upon exit from `scope`. The callback `populate` should
198-
/// initialize the memory. If `zero` is true, the space will be zeroed when it is allocated; this
199-
/// is not necessary unless `bcx` does not dominate the end of `scope`.
198+
/// initialize the memory.
200199
pub fn lvalue_scratch_datum<'blk, 'tcx, A, F>(bcx: Block<'blk, 'tcx>,
201200
ty: Ty<'tcx>,
202201
name: &str,
203-
zero: bool,
204202
scope: cleanup::ScopeId,
205203
arg: A,
206204
populate: F)
207205
-> DatumBlock<'blk, 'tcx, Lvalue> where
208206
F: FnOnce(A, Block<'blk, 'tcx>, ValueRef) -> Block<'blk, 'tcx>,
209207
{
210-
let scratch = if zero {
211-
alloca_zeroed(bcx, ty, name)
212-
} else {
213-
let llty = type_of::type_of(bcx.ccx(), ty);
214-
alloca(bcx, llty, name)
215-
};
208+
let llty = type_of::type_of(bcx.ccx(), ty);
209+
let scratch = alloca(bcx, llty, name);
216210

217211
// Subtle. Populate the scratch memory *before* scheduling cleanup.
218212
let bcx = populate(arg, bcx, scratch);
@@ -383,7 +377,7 @@ impl<'tcx> Datum<'tcx, Rvalue> {
383377

384378
ByValue => {
385379
lvalue_scratch_datum(
386-
bcx, self.ty, name, false, scope, self,
380+
bcx, self.ty, name, scope, self,
387381
|this, bcx, llval| this.store_to(bcx, llval))
388382
}
389383
}

0 commit comments

Comments
 (0)