@@ -383,24 +383,30 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
383
383
) -> EvalResult < ' tcx > {
384
384
:: log_settings:: settings ( ) . indentation += 1 ;
385
385
386
- let mut locals = IndexVec :: from_elem ( Some ( Value :: ByVal ( PrimVal :: Undef ) ) , & mir. local_decls ) ;
387
- match self . tcx . describe_def ( instance. def_id ( ) ) {
388
- // statics and constants don't have `Storage*` statements, no need to look for them
389
- Some ( Def :: Static ( ..) ) | Some ( Def :: Const ( ..) ) | Some ( Def :: AssociatedConst ( ..) ) => { } ,
390
- _ => {
391
- trace ! ( "push_stack_frame: {:?}: num_bbs: {}" , span, mir. basic_blocks( ) . len( ) ) ;
392
- for block in mir. basic_blocks ( ) {
393
- for stmt in block. statements . iter ( ) {
394
- use rustc:: mir:: StatementKind :: { StorageDead , StorageLive } ;
395
- match stmt. kind {
396
- StorageLive ( local) |
397
- StorageDead ( local) => locals[ local] = None ,
398
- _ => { }
386
+ let locals = if mir. local_decls . len ( ) > 1 {
387
+ let mut locals = IndexVec :: from_elem ( Some ( Value :: ByVal ( PrimVal :: Undef ) ) , & mir. local_decls ) ;
388
+ match self . tcx . describe_def ( instance. def_id ( ) ) {
389
+ // statics and constants don't have `Storage*` statements, no need to look for them
390
+ Some ( Def :: Static ( ..) ) | Some ( Def :: Const ( ..) ) | Some ( Def :: AssociatedConst ( ..) ) => { } ,
391
+ _ => {
392
+ trace ! ( "push_stack_frame: {:?}: num_bbs: {}" , span, mir. basic_blocks( ) . len( ) ) ;
393
+ for block in mir. basic_blocks ( ) {
394
+ for stmt in block. statements . iter ( ) {
395
+ use rustc:: mir:: StatementKind :: { StorageDead , StorageLive } ;
396
+ match stmt. kind {
397
+ StorageLive ( local) |
398
+ StorageDead ( local) => locals[ local] = None ,
399
+ _ => { }
400
+ }
399
401
}
400
402
}
401
- }
402
- } ,
403
- }
403
+ } ,
404
+ }
405
+ locals
406
+ } else {
407
+ // don't allocate at all for trivial constants
408
+ IndexVec :: new ( )
409
+ } ;
404
410
405
411
self . stack . push ( Frame {
406
412
mir,
0 commit comments