@@ -109,50 +109,54 @@ 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 place_ref = match self . locals [ place. local ] {
113- LocalRef :: Place ( place_ref) | LocalRef :: UnsizedPlace ( place_ref) => {
114- Some ( place_ref)
115- }
116- LocalRef :: Operand ( operand_ref) => match operand_ref. val {
117- OperandValue :: Immediate ( v) => {
118- Some ( PlaceRef :: new_sized ( v, operand_ref. layout ) )
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)
119116 }
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 ( ) ) &&
130- // Only pointers can calculate addresses.
131- bx. type_kind ( bx. val_ty ( place_ref. val . llval ) ) == TypeKind :: Pointer
132- } ) ;
133- let ( val, layout, projection) =
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 ,
126+ }
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 ( ) ) &&
131+ // Only pointers can calculate addresses.
132+ bx. type_kind ( bx. val_ty ( place_ref. val . llval ) ) == TypeKind :: Pointer
133+ } ) ;
134134 match ( place_ref, place. is_indirect_first_projection ( ) ) {
135135 ( Some ( place_ref) , false ) => {
136- ( place_ref. val , place_ref. layout , place. projection . as_slice ( ) )
136+ Some ( ( place_ref. val , place_ref. layout , place. projection . as_slice ( ) ) )
137137 }
138138 ( Some ( place_ref) , true ) => {
139139 let projected_ty =
140140 place_ref. layout . ty . builtin_deref ( true ) . unwrap_or_else ( || {
141141 bug ! ( "deref of non-pointer {:?}" , place_ref)
142142 } ) ;
143143 let layout = bx. cx ( ) . layout_of ( projected_ty) ;
144- ( place_ref. val , layout, & place. projection [ 1 ..] )
144+ Some ( ( place_ref. val , layout, & place. projection [ 1 ..] ) )
145145 }
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- } ;
146+ _ => None ,
147+ }
148+ } else {
149+ None
150+ } ;
151+ let ( val, layout, projection) = assign_ref. unwrap_or_else ( || {
152+ // If the address cannot be computed, use poison to indicate that the value has been optimized out.
153+ let ty = self . monomorphize ( self . mir . local_decls [ * dest] . ty ) ;
154+ let layout = bx. cx ( ) . layout_of ( ty) ;
155+ let to_backend_ty = bx. cx ( ) . immediate_backend_type ( layout) ;
156+ let place_ref =
157+ PlaceRef :: new_sized ( bx. cx ( ) . const_poison ( to_backend_ty) , layout) ;
158+ ( place_ref. val , layout, [ ] . as_slice ( ) )
159+ } ) ;
156160 self . debug_new_value_to_local ( bx, * dest, val, layout, projection) ;
157161 }
158162 }
0 commit comments