Handle operand temps for function calls

This allows temporary destinations for function calls to have their
allocas omitted.
This commit is contained in:
James Miller 2016-04-04 19:21:27 +12:00
parent 9c2186d4d7
commit e4d4fa3295
5 changed files with 191 additions and 45 deletions

View file

@ -45,8 +45,9 @@ impl fmt::Debug for CodeExtent {
ty::tls::with_opt(|opt_tcx| {
if let Some(tcx) = opt_tcx {
let data = tcx.region_maps.code_extents.borrow()[self.0 as usize];
write!(f, "/{:?}", data)?;
if let Some(data) = tcx.region_maps.code_extents.borrow().get(self.0 as usize) {
write!(f, "/{:?}", data)?;
}
}
Ok(())
})?;

View file

@ -407,7 +407,7 @@ macro_rules! make_mir_visitor {
self.visit_operand(arg);
}
if let Some((ref $($mutability)* destination, target)) = *destination {
self.visit_lvalue(destination, LvalueContext::Store);
self.visit_lvalue(destination, LvalueContext::Call);
self.visit_branch(block, target);
}
cleanup.map(|t| self.visit_branch(block, t));
@ -692,9 +692,12 @@ make_mir_visitor!(MutVisitor,mut);
#[derive(Copy, Clone, Debug)]
pub enum LvalueContext {
// Appears as LHS of an assignment or as dest of a call
// Appears as LHS of an assignment
Store,
// Dest of a call
Call,
// Being dropped
Drop,