@@ -127,34 +127,42 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
127127 // Drop unsupported projections.
128128 // FIXME: Add a test case.
129129 place. projection . iter ( ) . all ( |p| p. can_use_in_debuginfo ( ) ) &&
130- // Only pointers can calculate addresses.
131- bx. type_kind ( bx. val_ty ( place_ref. val . llval ) ) == TypeKind :: Pointer
130+ // Only pointers can calculate addresses.
131+ bx. type_kind ( bx. val_ty ( place_ref. val . llval ) ) == TypeKind :: Pointer
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 ( ) ) )
136+ }
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 ,
147+ } ;
148+ let ( val, layout, projection) = assign_ref. unwrap_or_else ( || {
149+ // If the address cannot be computed, use poison to indicate that the value has been optimized out.
150+ let ty = self . monomorphize ( self . mir . local_decls [ * dest] . ty ) ;
151+ let layout = bx. cx ( ) . layout_of ( ty) ;
152+ let to_backend_ty = bx. cx ( ) . immediate_backend_type ( layout) ;
153+ let place_ref =
154+ PlaceRef :: new_sized ( bx. cx ( ) . const_poison ( to_backend_ty) , layout) ;
155+ ( place_ref. val , layout, [ ] . as_slice ( ) )
132156 } ) ;
133- let ( val, layout, projection) =
134- match ( place_ref, place. is_indirect_first_projection ( ) ) {
135- ( Some ( place_ref) , false ) => {
136- ( 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- ( place_ref. val , layout, & place. projection [ 1 ..] )
145- }
146- _ => {
147- // If the address cannot be computed, use poison to indicate that the value has been optimized out.
148- let ty = self . monomorphize ( self . mir . local_decls [ * dest] . ty ) ;
149- let layout = bx. cx ( ) . layout_of ( ty) ;
150- let to_backend_ty = bx. cx ( ) . immediate_backend_type ( layout) ;
151- let place_ref =
152- PlaceRef :: new_sized ( bx. cx ( ) . const_poison ( to_backend_ty) , layout) ;
153- ( place_ref. val , layout, [ ] . as_slice ( ) )
154- }
155- } ;
156157 self . debug_new_value_to_local ( bx, * dest, val, layout, projection) ;
157158 }
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+ }
158166 }
159167 }
160168
0 commit comments