@@ -42,9 +42,6 @@ pub struct PerLocalVarDebugInfo<'tcx, D> {
42
42
43
43
/// `.place.projection` from `mir::VarDebugInfo`.
44
44
pub projection : & ' tcx ty:: List < mir:: PlaceElem < ' tcx > > ,
45
-
46
- /// `references` from `mir::VarDebugInfo`.
47
- pub references : u8 ,
48
45
}
49
46
50
47
#[ derive( Clone , Copy , Debug ) ]
@@ -323,7 +320,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
323
320
dbg_var,
324
321
fragment : None ,
325
322
projection : ty:: List :: empty ( ) ,
326
- references : 0 ,
327
323
} )
328
324
}
329
325
} else {
@@ -399,15 +395,14 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
399
395
& self ,
400
396
bx : & mut Bx ,
401
397
local : mir:: Local ,
402
- mut base : PlaceRef < ' tcx , Bx :: Value > ,
398
+ base : PlaceRef < ' tcx , Bx :: Value > ,
403
399
var : PerLocalVarDebugInfo < ' tcx , Bx :: DIVariable > ,
404
400
) {
405
401
let Some ( dbg_var) = var. dbg_var else { return } ;
406
402
let Some ( dbg_loc) = self . dbg_loc ( var. source_info ) else { return } ;
407
403
408
- let DebugInfoOffset { mut direct_offset, indirect_offsets, result : _ } =
404
+ let DebugInfoOffset { direct_offset, indirect_offsets, result : _ } =
409
405
calculate_debuginfo_offset ( bx, local, & var, base. layout ) ;
410
- let mut indirect_offsets = & indirect_offsets[ ..] ;
411
406
412
407
// When targeting MSVC, create extra allocas for arguments instead of pointing multiple
413
408
// dbg_var_addr() calls into the same alloca with offsets. MSVC uses CodeView records
@@ -421,45 +416,29 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
421
416
// LLVM can handle simple things but anything more complex than just a direct
422
417
// offset or one indirect offset of 0 is too complex for it to generate CV records
423
418
// correctly.
424
- && ( direct_offset != Size :: ZERO || !matches ! ( indirect_offsets, [ Size :: ZERO ] | [ ] ) ) ;
419
+ && ( direct_offset != Size :: ZERO || !matches ! ( & indirect_offsets[ ..] , [ Size :: ZERO ] | [ ] ) ) ;
420
+
421
+ if should_create_individual_allocas {
422
+ let DebugInfoOffset { direct_offset : _, indirect_offsets : _, result : place } =
423
+ calculate_debuginfo_offset ( bx, local, & var, base) ;
425
424
426
- let create_alloca = |bx : & mut Bx , place : PlaceRef < ' tcx , Bx :: Value > , refcount| {
427
425
// Create a variable which will be a pointer to the actual value
428
426
let ptr_ty = Ty :: new_ptr (
429
427
bx. tcx ( ) ,
430
428
ty:: TypeAndMut { mutbl : mir:: Mutability :: Mut , ty : place. layout . ty } ,
431
429
) ;
432
430
let ptr_layout = bx. layout_of ( ptr_ty) ;
433
431
let alloca = PlaceRef :: alloca ( bx, ptr_layout) ;
434
- bx. set_var_name ( alloca. llval , & format ! ( "{}.ref{}. dbg.spill", var . name , refcount ) ) ;
432
+ bx. set_var_name ( alloca. llval , & ( var . name . to_string ( ) + ". dbg.spill") ) ;
435
433
436
434
// Write the pointer to the variable
437
435
bx. store ( place. llval , alloca. llval , alloca. align ) ;
438
436
439
437
// Point the debug info to `*alloca` for the current variable
440
- alloca
441
- } ;
442
-
443
- if var. references > 0 {
444
- base = calculate_debuginfo_offset ( bx, local, & var, base) . result ;
445
-
446
- // Point the debug info to `&...&base == alloca` for the current variable
447
- for refcount in 0 ..var. references {
448
- base = create_alloca ( bx, base, refcount) ;
449
- }
450
-
451
- direct_offset = Size :: ZERO ;
452
- indirect_offsets = & [ ] ;
453
- } else if should_create_individual_allocas {
454
- let place = calculate_debuginfo_offset ( bx, local, & var, base) . result ;
455
-
456
- // Point the debug info to `*alloca` for the current variable
457
- base = create_alloca ( bx, place, 0 ) ;
458
- direct_offset = Size :: ZERO ;
459
- indirect_offsets = & [ Size :: ZERO ] ;
438
+ bx. dbg_var_addr ( dbg_var, dbg_loc, alloca. llval , Size :: ZERO , & [ Size :: ZERO ] , None ) ;
439
+ } else {
440
+ bx. dbg_var_addr ( dbg_var, dbg_loc, base. llval , direct_offset, & indirect_offsets, None ) ;
460
441
}
461
-
462
- bx. dbg_var_addr ( dbg_var, dbg_loc, base. llval , direct_offset, indirect_offsets, None ) ;
463
442
}
464
443
465
444
pub fn debug_introduce_locals ( & self , bx : & mut Bx ) {
@@ -492,7 +471,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
492
471
} ;
493
472
494
473
let dbg_var = dbg_scope_and_span. map ( |( dbg_scope, _, span) | {
495
- let ( mut var_ty, var_kind) = match var. value {
474
+ let ( var_ty, var_kind) = match var. value {
496
475
mir:: VarDebugInfoContents :: Place ( place) => {
497
476
let var_ty = self . monomorphized_place_ty ( place. as_ref ( ) ) ;
498
477
let var_kind = if let Some ( arg_index) = var. argument_index
@@ -529,13 +508,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
529
508
}
530
509
} ;
531
510
532
- for _ in 0 ..var. references {
533
- var_ty = Ty :: new_ptr (
534
- bx. tcx ( ) ,
535
- ty:: TypeAndMut { mutbl : mir:: Mutability :: Mut , ty : var_ty } ,
536
- ) ;
537
- }
538
-
539
511
self . cx . create_dbg_var ( var. name , var_ty, dbg_scope, var_kind, span)
540
512
} ) ;
541
513
@@ -547,7 +519,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
547
519
dbg_var,
548
520
fragment : None ,
549
521
projection : place. projection ,
550
- references : var. references ,
551
522
} ) ;
552
523
}
553
524
mir:: VarDebugInfoContents :: Const ( c) => {
@@ -601,7 +572,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
601
572
Some ( fragment_start..fragment_start + fragment_layout. size )
602
573
} ,
603
574
projection : place. projection ,
604
- references : var. references ,
605
575
} ) ;
606
576
}
607
577
}
0 commit comments