Don't allocate a local array at all if there are no locals
This commit is contained in:
parent
b18b776b8f
commit
4ea4dd23cd
1 changed files with 22 additions and 16 deletions
|
@ -383,24 +383,30 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
|
||||||
) -> EvalResult<'tcx> {
|
) -> EvalResult<'tcx> {
|
||||||
::log_settings::settings().indentation += 1;
|
::log_settings::settings().indentation += 1;
|
||||||
|
|
||||||
let mut locals = IndexVec::from_elem(Some(Value::ByVal(PrimVal::Undef)), &mir.local_decls);
|
let locals = if mir.local_decls.len() > 1 {
|
||||||
match self.tcx.describe_def(instance.def_id()) {
|
let mut locals = IndexVec::from_elem(Some(Value::ByVal(PrimVal::Undef)), &mir.local_decls);
|
||||||
// statics and constants don't have `Storage*` statements, no need to look for them
|
match self.tcx.describe_def(instance.def_id()) {
|
||||||
Some(Def::Static(..)) | Some(Def::Const(..)) | Some(Def::AssociatedConst(..)) => {},
|
// statics and constants don't have `Storage*` statements, no need to look for them
|
||||||
_ => {
|
Some(Def::Static(..)) | Some(Def::Const(..)) | Some(Def::AssociatedConst(..)) => {},
|
||||||
trace!("push_stack_frame: {:?}: num_bbs: {}", span, mir.basic_blocks().len());
|
_ => {
|
||||||
for block in mir.basic_blocks() {
|
trace!("push_stack_frame: {:?}: num_bbs: {}", span, mir.basic_blocks().len());
|
||||||
for stmt in block.statements.iter() {
|
for block in mir.basic_blocks() {
|
||||||
use rustc::mir::StatementKind::{StorageDead, StorageLive};
|
for stmt in block.statements.iter() {
|
||||||
match stmt.kind {
|
use rustc::mir::StatementKind::{StorageDead, StorageLive};
|
||||||
StorageLive(local) |
|
match stmt.kind {
|
||||||
StorageDead(local) => locals[local] = None,
|
StorageLive(local) |
|
||||||
_ => {}
|
StorageDead(local) => locals[local] = None,
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
}
|
||||||
}
|
locals
|
||||||
|
} else {
|
||||||
|
// don't allocate at all for trivial constants
|
||||||
|
IndexVec::new()
|
||||||
|
};
|
||||||
|
|
||||||
self.stack.push(Frame {
|
self.stack.push(Frame {
|
||||||
mir,
|
mir,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue