|
1 | | -use std::collections::HashSet; |
2 | 1 | use std::fmt::Write; |
3 | 2 |
|
4 | 3 | use rustc::hir::def_id::DefId; |
@@ -383,40 +382,23 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M |
383 | 382 | ) -> EvalResult<'tcx> { |
384 | 383 | ::log_settings::settings().indentation += 1; |
385 | 384 |
|
386 | | - /// Return the set of locals that have a storage annotation anywhere |
387 | | - fn collect_storage_annotations<'mir, 'tcx>(mir: &'mir mir::Mir<'tcx>) -> HashSet<mir::Local> { |
388 | | - use rustc::mir::StatementKind::*; |
389 | | - |
390 | | - let mut set = HashSet::new(); |
391 | | - for block in mir.basic_blocks() { |
392 | | - for stmt in block.statements.iter() { |
393 | | - match stmt.kind { |
394 | | - StorageLive(local) | |
395 | | - StorageDead(local) => { |
396 | | - set.insert(local); |
397 | | - } |
398 | | - _ => {} |
399 | | - } |
400 | | - } |
401 | | - } |
402 | | - set |
403 | | - } |
404 | | - |
405 | 385 | // Subtract 1 because `local_decls` includes the ReturnMemoryPointer, but we don't store a local |
406 | 386 | // `Value` for that. |
407 | 387 | let num_locals = mir.local_decls.len() - 1; |
408 | 388 |
|
409 | | - let locals = { |
410 | | - let annotated_locals = collect_storage_annotations(mir); |
411 | | - let mut locals = vec![None; num_locals]; |
412 | | - for i in 0..num_locals { |
413 | | - let local = mir::Local::new(i + 1); |
414 | | - if !annotated_locals.contains(&local) { |
415 | | - locals[i] = Some(Value::ByVal(PrimVal::Undef)); |
| 389 | + let mut locals = vec![Some(Value::ByVal(PrimVal::Undef)); num_locals]; |
| 390 | + trace!("push_stack_frame: {:?}: num_bbs: {}", span, mir.basic_blocks().len()); |
| 391 | + for block in mir.basic_blocks() { |
| 392 | + for stmt in block.statements.iter() { |
| 393 | + use rustc::mir::StatementKind::{StorageDead, StorageLive}; |
| 394 | + match stmt.kind { |
| 395 | + StorageLive(local) | StorageDead(local) => if local.index() > 0 { |
| 396 | + locals[local.index() - 1] = None; |
| 397 | + }, |
| 398 | + _ => {} |
416 | 399 | } |
417 | 400 | } |
418 | | - locals |
419 | | - }; |
| 401 | + } |
420 | 402 |
|
421 | 403 | self.stack.push(Frame { |
422 | 404 | mir, |
|
0 commit comments