trans: noop drops don't need their lvalue in an alloca.
This commit is contained in:
parent
eb9cb4dbca
commit
bec32eb4ff
2 changed files with 15 additions and 3 deletions
|
|
@ -18,6 +18,7 @@ use rustc::mir::repr::TerminatorKind;
|
|||
use rustc::mir::visit::{Visitor, LvalueContext};
|
||||
use rustc::mir::traversal;
|
||||
use common::{self, Block, BlockAndBuilder};
|
||||
use glue;
|
||||
use super::rvalue;
|
||||
|
||||
pub fn lvalue_temps<'bcx,'tcx>(bcx: Block<'bcx,'tcx>,
|
||||
|
|
@ -138,13 +139,21 @@ impl<'mir, 'bcx, 'tcx> Visitor<'tcx> for TempAnalyzer<'mir, 'bcx, 'tcx> {
|
|||
LvalueContext::Consume => {
|
||||
}
|
||||
LvalueContext::Store |
|
||||
LvalueContext::Drop |
|
||||
LvalueContext::Inspect |
|
||||
LvalueContext::Borrow { .. } |
|
||||
LvalueContext::Slice { .. } |
|
||||
LvalueContext::Projection => {
|
||||
self.mark_as_lvalue(temp.index());
|
||||
}
|
||||
LvalueContext::Drop => {
|
||||
let ty = self.mir.temp_decls[index as usize].ty;
|
||||
let ty = self.bcx.monomorphize(&ty);
|
||||
|
||||
// Only need the lvalue if we're actually dropping it.
|
||||
if glue::type_needs_drop(self.bcx.tcx(), ty) {
|
||||
self.mark_as_lvalue(index as usize);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
|
|
|
|||
|
|
@ -196,13 +196,16 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
|
|||
}
|
||||
|
||||
mir::TerminatorKind::Drop { ref location, target, unwind } => {
|
||||
let lvalue = self.trans_lvalue(&bcx, location);
|
||||
let ty = lvalue.ty.to_ty(bcx.tcx());
|
||||
let ty = mir.lvalue_ty(bcx.tcx(), location).to_ty(bcx.tcx());
|
||||
let ty = bcx.monomorphize(&ty);
|
||||
|
||||
// Double check for necessity to drop
|
||||
if !glue::type_needs_drop(bcx.tcx(), ty) {
|
||||
funclet_br(self, bcx, target);
|
||||
return;
|
||||
}
|
||||
|
||||
let lvalue = self.trans_lvalue(&bcx, location);
|
||||
let drop_fn = glue::get_drop_glue(bcx.ccx(), ty);
|
||||
let drop_ty = glue::get_drop_glue_type(bcx.tcx(), ty);
|
||||
let llvalue = if drop_ty != ty {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue