@@ -109,44 +109,41 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
109109 pub ( crate ) fn codegen_stmt_debuginfo ( & mut self , bx : & mut Bx , debuginfo : & StmtDebugInfo < ' tcx > ) {
110110 match debuginfo {
111111 StmtDebugInfo :: AssignRef ( dest, place) => {
112- let assign_ref = if let Some ( place) = place {
113- let place_ref = match self . locals [ place. local ] {
114- LocalRef :: Place ( place_ref) | LocalRef :: UnsizedPlace ( place_ref) => {
115- Some ( place_ref)
116- }
117- LocalRef :: Operand ( operand_ref) => match operand_ref. val {
118- OperandValue :: Immediate ( v) => {
119- Some ( PlaceRef :: new_sized ( v, operand_ref. layout ) )
120- }
121- OperandValue :: Ref ( _)
122- | OperandValue :: Pair ( _, _)
123- | OperandValue :: ZeroSized => None ,
124- } ,
125- LocalRef :: PendingOperand => None ,
112+ let place_ref = match self . locals [ place. local ] {
113+ LocalRef :: Place ( place_ref) | LocalRef :: UnsizedPlace ( place_ref) => {
114+ Some ( place_ref)
126115 }
127- . filter ( |place_ref| {
128- // Drop unsupported projections.
129- // FIXME: Add a test case.
130- place. projection . iter ( ) . all ( |p| p. can_use_in_debuginfo ( ) ) &&
116+ LocalRef :: Operand ( operand_ref) => match operand_ref. val {
117+ OperandValue :: Immediate ( v) => {
118+ Some ( PlaceRef :: new_sized ( v, operand_ref. layout ) )
119+ }
120+ OperandValue :: Ref ( _)
121+ | OperandValue :: Pair ( _, _)
122+ | OperandValue :: ZeroSized => None ,
123+ } ,
124+ LocalRef :: PendingOperand => None ,
125+ }
126+ . filter ( |place_ref| {
127+ // Drop unsupported projections.
128+ // FIXME: Add a test case.
129+ place. projection . iter ( ) . all ( |p| p. can_use_in_debuginfo ( ) ) &&
131130 // Only pointers can calculate addresses.
132131 bx. type_kind ( bx. val_ty ( place_ref. val . llval ) ) == TypeKind :: Pointer
133- } ) ;
134- match ( place_ref, place. is_indirect_first_projection ( ) ) {
135- ( Some ( place_ref) , false ) => {
136- Some ( ( place_ref. val , place_ref. layout , place. projection . as_slice ( ) ) )
137- }
138- ( Some ( place_ref) , true ) => {
139- let projected_ty =
140- place_ref. layout . ty . builtin_deref ( true ) . unwrap_or_else ( || {
141- bug ! ( "deref of non-pointer {:?}" , place_ref)
142- } ) ;
143- let layout = bx. cx ( ) . layout_of ( projected_ty) ;
144- Some ( ( place_ref. val , layout, & place. projection [ 1 ..] ) )
145- }
146- _ => None ,
132+ } ) ;
133+ let assign_ref = match ( place_ref, place. is_indirect_first_projection ( ) ) {
134+ ( Some ( place_ref) , false ) => {
135+ Some ( ( place_ref. val , place_ref. layout , place. projection . as_slice ( ) ) )
147136 }
148- } else {
149- None
137+ ( Some ( place_ref) , true ) => {
138+ let projected_ty = place_ref
139+ . layout
140+ . ty
141+ . builtin_deref ( true )
142+ . unwrap_or_else ( || bug ! ( "deref of non-pointer {:?}" , place_ref) ) ;
143+ let layout = bx. cx ( ) . layout_of ( projected_ty) ;
144+ Some ( ( place_ref. val , layout, & place. projection [ 1 ..] ) )
145+ }
146+ _ => None ,
150147 } ;
151148 let ( val, layout, projection) = assign_ref. unwrap_or_else ( || {
152149 // If the address cannot be computed, use poison to indicate that the value has been optimized out.
@@ -159,6 +156,13 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
159156 } ) ;
160157 self . debug_new_value_to_local ( bx, * dest, val, layout, projection) ;
161158 }
159+ StmtDebugInfo :: InvalidAssign ( local) => {
160+ let ty = self . monomorphize ( self . mir . local_decls [ * local] . ty ) ;
161+ let layout = bx. cx ( ) . layout_of ( ty) ;
162+ let to_backend_ty = bx. cx ( ) . immediate_backend_type ( layout) ;
163+ let place_ref = PlaceRef :: new_sized ( bx. cx ( ) . const_poison ( to_backend_ty) , layout) ;
164+ self . debug_new_value_to_local ( bx, * local, place_ref. val , layout, & [ ] ) ;
165+ }
162166 }
163167 }
164168
0 commit comments