@@ -30,7 +30,7 @@ use crate::interpret::{
3030 self , InterpCx , ScalarMaybeUndef , Immediate , OpTy ,
3131 StackPopCleanup , LocalValue , LocalState , AllocId , Frame ,
3232 Allocation , MemoryKind , ImmTy , Pointer , Memory , PlaceTy ,
33- Operand as InterpOperand ,
33+ Operand as InterpOperand , intern_const_alloc_recursive ,
3434} ;
3535use crate :: const_eval:: error_to_const_error;
3636use crate :: transform:: { MirPass , MirSource } ;
@@ -655,14 +655,27 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
655655 return false ;
656656 }
657657
658- match * op {
658+ let is_scalar = match * op {
659659 interpret:: Operand :: Immediate ( Immediate :: Scalar ( ScalarMaybeUndef :: Scalar ( s) ) ) =>
660660 s. is_bits ( ) ,
661661 interpret:: Operand :: Immediate ( Immediate :: ScalarPair ( ScalarMaybeUndef :: Scalar ( l) ,
662662 ScalarMaybeUndef :: Scalar ( r) ) ) =>
663663 l. is_bits ( ) && r. is_bits ( ) ,
664664 _ => false
665+ } ;
666+
667+ if let interpret:: Operand :: Indirect ( _) = * op {
668+ if self . tcx . sess . opts . debugging_opts . mir_opt_level >= 2 {
669+ intern_const_alloc_recursive (
670+ & mut self . ecx ,
671+ None ,
672+ op. assert_mem_place ( )
673+ ) . expect ( "failed to intern alloc" ) ;
674+ return true ;
675+ }
665676 }
677+
678+ return is_scalar;
666679 }
667680}
668681
0 commit comments