Skip to content

Commit 4fff195

Browse files
committed
remove filling on drop
1 parent 8d6d646 commit 4fff195

File tree

6 files changed

+6
-102
lines changed

6 files changed

+6
-102
lines changed

src/librustc_trans/mir/block.rs

+1-21
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use glue;
2626
use type_::Type;
2727
use rustc_data_structures::fnv::FnvHashMap;
2828

29-
use super::{MirContext, TempRef, drop};
29+
use super::{MirContext, TempRef};
3030
use super::constant::Const;
3131
use super::lvalue::{LvalueRef, load_fat_ptr};
3232
use super::operand::OperandRef;
@@ -168,11 +168,9 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
168168
cleanup_bundle.as_ref());
169169
self.bcx(target).at_start(|bcx| {
170170
debug_loc.apply_to_bcx(bcx);
171-
drop::drop_fill(bcx, lvalue.llval, ty)
172171
});
173172
} else {
174173
bcx.call(drop_fn, &[llvalue], cleanup_bundle.as_ref());
175-
drop::drop_fill(&bcx, lvalue.llval, ty);
176174
funclet_br(bcx, self.llblock(target));
177175
}
178176
}
@@ -215,7 +213,6 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
215213
let llptr = self.trans_operand(&bcx, &args[0]).immediate();
216214
let val = self.trans_operand(&bcx, &args[1]);
217215
self.store_operand(&bcx, llptr, val);
218-
self.set_operand_dropped(&bcx, &args[1]);
219216
funclet_br(bcx, self.llblock(target));
220217
return;
221218
}
@@ -226,7 +223,6 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
226223
this.trans_transmute(&bcx, &args[0], dest);
227224
});
228225

229-
self.set_operand_dropped(&bcx, &args[0]);
230226
funclet_br(bcx, self.llblock(target));
231227
return;
232228
}
@@ -332,9 +328,6 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
332328
}
333329

334330
if let Some((_, target)) = *destination {
335-
for op in args {
336-
self.set_operand_dropped(&bcx, op);
337-
}
338331
funclet_br(bcx, self.llblock(target));
339332
} else {
340333
// trans_intrinsic_call already used Unreachable.
@@ -363,13 +356,6 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
363356
cleanup_bundle.as_ref());
364357
fn_ty.apply_attrs_callsite(invokeret);
365358

366-
landingpad.at_start(|bcx| {
367-
debug_loc.apply_to_bcx(bcx);
368-
for op in args {
369-
self.set_operand_dropped(bcx, op);
370-
}
371-
});
372-
373359
if destination.is_some() {
374360
let ret_bcx = ret_bcx.build();
375361
ret_bcx.at_start(|ret_bcx| {
@@ -379,9 +365,6 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
379365
ty: sig.output.unwrap()
380366
};
381367
self.store_return(&ret_bcx, ret_dest, fn_ty.ret, op);
382-
for op in args {
383-
self.set_operand_dropped(&ret_bcx, op);
384-
}
385368
});
386369
}
387370
} else {
@@ -393,9 +376,6 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
393376
ty: sig.output.unwrap()
394377
};
395378
self.store_return(&bcx, ret_dest, fn_ty.ret, op);
396-
for op in args {
397-
self.set_operand_dropped(&bcx, op);
398-
}
399379
funclet_br(bcx, self.llblock(target));
400380
} else {
401381
// no need to drop args, because the call never returns

src/librustc_trans/mir/drop.rs

-27
This file was deleted.

src/librustc_trans/mir/lvalue.rs

-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use common::{self, BlockAndBuilder, CrateContext, C_uint, C_undef};
2020
use consts;
2121
use machine;
2222
use type_of::type_of;
23-
use mir::drop;
2423
use Disr;
2524

2625
use std::ptr;
@@ -51,9 +50,6 @@ impl<'tcx> LvalueRef<'tcx> {
5150
{
5251
assert!(!ty.has_erasable_regions());
5352
let lltemp = bcx.with_block(|bcx| base::alloc_ty(bcx, ty, name));
54-
if bcx.fcx().type_needs_drop(ty) {
55-
drop::drop_fill(bcx, lltemp, ty);
56-
}
5753
LvalueRef::new_sized(lltemp, LvalueTy::from_ty(ty))
5854
}
5955

src/librustc_trans/mir/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,6 @@ fn arg_value_refs<'bcx, 'tcx>(bcx: &BlockAndBuilder<'bcx, 'tcx>,
431431
mod analyze;
432432
mod block;
433433
mod constant;
434-
mod drop;
435434
mod lvalue;
436435
mod operand;
437436
mod rvalue;

src/librustc_trans/mir/operand.rs

+1-27
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ use base;
1515
use common::{self, Block, BlockAndBuilder};
1616
use datum;
1717
use value::Value;
18-
use glue;
1918

2019
use std::fmt;
2120

2221
use super::lvalue::load_fat_ptr;
23-
use super::{MirContext, TempRef, drop};
22+
use super::{MirContext, TempRef};
2423

2524
/// The representation of a Rust value. The enum variant is in fact
2625
/// uniquely determined by the value's type, but is kept as a
@@ -179,29 +178,4 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
179178
}
180179
}
181180
}
182-
183-
pub fn set_operand_dropped(&mut self,
184-
bcx: &BlockAndBuilder<'bcx, 'tcx>,
185-
operand: &mir::Operand<'tcx>) {
186-
match *operand {
187-
mir::Operand::Constant(_) => return,
188-
mir::Operand::Consume(ref lvalue) => {
189-
if let mir::Lvalue::Temp(idx) = *lvalue {
190-
if let TempRef::Operand(..) = self.temps[idx as usize] {
191-
// All lvalues which have an associated drop are promoted to an alloca
192-
// beforehand. If this is an operand, it is safe to say this is never
193-
// dropped and there’s no reason for us to zero this out at all.
194-
return
195-
}
196-
}
197-
let lvalue = self.trans_lvalue(bcx, lvalue);
198-
let ty = lvalue.ty.to_ty(bcx.tcx());
199-
if !glue::type_needs_drop(bcx.tcx(), ty) {
200-
return
201-
} else {
202-
drop::drop_fill(bcx, lvalue.llval, ty);
203-
}
204-
}
205-
}
206-
}
207181
}

src/librustc_trans/mir/rvalue.rs

+4-22
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use type_of;
2525
use tvec;
2626
use value::Value;
2727
use Disr;
28-
use glue;
2928

3029
use super::MirContext;
3130
use super::operand::{OperandRef, OperandValue};
@@ -48,7 +47,6 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
4847
// FIXME: consider not copying constants through stack. (fixable by translating
4948
// constants into OperandValue::Ref, why don’t we do that yet if we don’t?)
5049
self.store_operand(&bcx, dest.llval, tr_operand);
51-
self.set_operand_dropped(&bcx, operand);
5250
bcx
5351
}
5452

@@ -92,7 +90,6 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
9290
}
9391
}
9492
});
95-
self.set_operand_dropped(&bcx, source);
9693
bcx
9794
}
9895

@@ -107,7 +104,6 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
107104
block
108105
})
109106
});
110-
self.set_operand_dropped(&bcx, elem);
111107
bcx
112108
}
113109

@@ -128,7 +124,6 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
128124
val, disr, i);
129125
self.store_operand(&bcx, lldest_i, op);
130126
}
131-
self.set_operand_dropped(&bcx, operand);
132127
}
133128
},
134129
_ => {
@@ -167,7 +162,6 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
167162
let dest = bcx.gepi(dest.llval, &[0, i]);
168163
self.store_operand(&bcx, dest, op);
169164
}
170-
self.set_operand_dropped(&bcx, operand);
171165
}
172166
}
173167
}
@@ -209,9 +203,6 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
209203
asm::trans_inline_asm(bcx, asm, outputs, input_vals);
210204
});
211205

212-
for input in inputs {
213-
self.set_operand_dropped(&bcx, input);
214-
}
215206
bcx
216207
}
217208

@@ -269,7 +260,6 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
269260
// &'a fmt::Debug+Send => &'a fmt::Debug,
270261
// So we need to pointercast the base to ensure
271262
// the types match up.
272-
self.set_operand_dropped(&bcx, source);
273263
let llcast_ty = type_of::fat_ptr_base_ty(bcx.ccx(), cast_ty);
274264
let lldata = bcx.pointercast(lldata, llcast_ty);
275265
OperandValue::FatPtr(lldata, llextra)
@@ -280,7 +270,6 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
280270
base::unsize_thin_ptr(bcx, lldata,
281271
operand.ty, cast_ty)
282272
});
283-
self.set_operand_dropped(&bcx, source);
284273
OperandValue::FatPtr(lldata, llextra)
285274
}
286275
OperandValue::Ref(_) => {
@@ -569,30 +558,23 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
569558
}
570559
}
571560

572-
pub fn rvalue_creates_operand<'bcx, 'tcx>(mir: &mir::Mir<'tcx>,
573-
bcx: &BlockAndBuilder<'bcx, 'tcx>,
561+
pub fn rvalue_creates_operand<'bcx, 'tcx>(_mir: &mir::Mir<'tcx>,
562+
_bcx: &BlockAndBuilder<'bcx, 'tcx>,
574563
rvalue: &mir::Rvalue<'tcx>) -> bool {
575564
match *rvalue {
576565
mir::Rvalue::Ref(..) |
577566
mir::Rvalue::Len(..) |
578567
mir::Rvalue::Cast(..) | // (*)
579568
mir::Rvalue::BinaryOp(..) |
580569
mir::Rvalue::UnaryOp(..) |
581-
mir::Rvalue::Box(..) =>
570+
mir::Rvalue::Box(..) |
571+
mir::Rvalue::Use(..) =>
582572
true,
583573
mir::Rvalue::Repeat(..) |
584574
mir::Rvalue::Aggregate(..) |
585575
mir::Rvalue::Slice { .. } |
586576
mir::Rvalue::InlineAsm { .. } =>
587577
false,
588-
mir::Rvalue::Use(ref operand) => {
589-
let ty = mir.operand_ty(bcx.tcx(), operand);
590-
let ty = bcx.monomorphize(&ty);
591-
// Types that don't need dropping can just be an operand,
592-
// this allows temporary lvalues, used as rvalues, to
593-
// avoid a stack slot when it's unnecessary
594-
!glue::type_needs_drop(bcx.tcx(), ty)
595-
}
596578
}
597579

598580
// (*) this is only true if the type is suitable

0 commit comments

Comments
 (0)