@@ -158,16 +158,15 @@ fn calculate_debuginfo_offset<
158
158
L : DebugInfoOffsetLocation < ' tcx , Bx > ,
159
159
> (
160
160
bx : & mut Bx ,
161
- local : mir:: Local ,
162
- var : & PerLocalVarDebugInfo < ' tcx , Bx :: DIVariable > ,
161
+ projection : & [ mir:: PlaceElem < ' tcx > ] ,
163
162
base : L ,
164
163
) -> DebugInfoOffset < L > {
165
164
let mut direct_offset = Size :: ZERO ;
166
165
// FIXME(eddyb) use smallvec here.
167
166
let mut indirect_offsets = vec ! [ ] ;
168
167
let mut place = base;
169
168
170
- for elem in & var . projection [ .. ] {
169
+ for elem in projection {
171
170
match * elem {
172
171
mir:: ProjectionElem :: Deref => {
173
172
indirect_offsets. push ( Size :: ZERO ) ;
@@ -188,23 +187,15 @@ fn calculate_debuginfo_offset<
188
187
} => {
189
188
let offset = indirect_offsets. last_mut ( ) . unwrap_or ( & mut direct_offset) ;
190
189
let FieldsShape :: Array { stride, count : _ } = place. layout ( ) . fields else {
191
- span_bug ! (
192
- var. source_info. span,
193
- "ConstantIndex on non-array type {:?}" ,
194
- place. layout( )
195
- )
190
+ bug ! ( "ConstantIndex on non-array type {:?}" , place. layout( ) )
196
191
} ;
197
192
* offset += stride * index;
198
193
place = place. project_constant_index ( bx, index) ;
199
194
}
200
195
_ => {
201
196
// Sanity check for `can_use_in_debuginfo`.
202
197
debug_assert ! ( !elem. can_use_in_debuginfo( ) ) ;
203
- span_bug ! (
204
- var. source_info. span,
205
- "unsupported var debuginfo place `{:?}`" ,
206
- mir:: Place { local, projection: var. projection } ,
207
- )
198
+ bug ! ( "unsupported var debuginfo projection `{:?}`" , projection)
208
199
}
209
200
}
210
201
}
@@ -407,7 +398,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
407
398
let Some ( dbg_loc) = self . dbg_loc ( var. source_info ) else { return } ;
408
399
409
400
let DebugInfoOffset { direct_offset, indirect_offsets, result : _ } =
410
- calculate_debuginfo_offset ( bx, local , & var, base. layout ) ;
401
+ calculate_debuginfo_offset ( bx, & var. projection , base. layout ) ;
411
402
412
403
// When targeting MSVC, create extra allocas for arguments instead of pointing multiple
413
404
// dbg_var_addr() calls into the same alloca with offsets. MSVC uses CodeView records
@@ -425,7 +416,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
425
416
426
417
if should_create_individual_allocas {
427
418
let DebugInfoOffset { direct_offset : _, indirect_offsets : _, result : place } =
428
- calculate_debuginfo_offset ( bx, local , & var, base) ;
419
+ calculate_debuginfo_offset ( bx, & var. projection , base) ;
429
420
430
421
// Create a variable which will be a pointer to the actual value
431
422
let ptr_ty = Ty :: new_ptr (
@@ -532,23 +523,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
532
523
let fragment = if let Some ( ref fragment) = var. composite {
533
524
let var_layout = self . cx . layout_of ( var_ty) ;
534
525
535
- let mut fragment_start = Size :: ZERO ;
536
- let mut fragment_layout = var_layout;
537
-
538
- for elem in & fragment. projection {
539
- match * elem {
540
- mir:: ProjectionElem :: Field ( field, _) => {
541
- let i = field. index ( ) ;
542
- fragment_start += fragment_layout. fields . offset ( i) ;
543
- fragment_layout = fragment_layout. field ( self . cx , i) ;
544
- }
545
- _ => span_bug ! (
546
- var. source_info. span,
547
- "unsupported fragment projection `{:?}`" ,
548
- elem,
549
- ) ,
550
- }
551
- }
526
+ let DebugInfoOffset { direct_offset, indirect_offsets, result : fragment_layout } =
527
+ calculate_debuginfo_offset ( bx, & fragment. projection , var_layout) ;
528
+ debug_assert ! ( indirect_offsets. is_empty( ) ) ;
552
529
553
530
if fragment_layout. size == Size :: ZERO {
554
531
// Fragment is a ZST, so does not represent anything. Avoid generating anything
@@ -559,7 +536,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
559
536
// DWARF is concerned, it's not really a fragment.
560
537
None
561
538
} else {
562
- Some ( fragment_start..fragment_start + fragment_layout. size )
539
+ Some ( direct_offset..direct_offset + fragment_layout. size )
563
540
}
564
541
} else {
565
542
None
0 commit comments