@@ -42,9 +42,6 @@ pub struct PerLocalVarDebugInfo<'tcx, D> {
4242
4343 /// `.place.projection` from `mir::VarDebugInfo`.
4444 pub projection : & ' tcx ty:: List < mir:: PlaceElem < ' tcx > > ,
45-
46- /// `references` from `mir::VarDebugInfo`.
47- pub references : u8 ,
4845}
4946
5047#[ derive( Clone , Copy , Debug ) ]
@@ -323,7 +320,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
323320 dbg_var,
324321 fragment : None ,
325322 projection : ty:: List :: empty ( ) ,
326- references : 0 ,
327323 } )
328324 }
329325 } else {
@@ -399,15 +395,14 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
399395 & self ,
400396 bx : & mut Bx ,
401397 local : mir:: Local ,
402- mut base : PlaceRef < ' tcx , Bx :: Value > ,
398+ base : PlaceRef < ' tcx , Bx :: Value > ,
403399 var : PerLocalVarDebugInfo < ' tcx , Bx :: DIVariable > ,
404400 ) {
405401 let Some ( dbg_var) = var. dbg_var else { return } ;
406402 let Some ( dbg_loc) = self . dbg_loc ( var. source_info ) else { return } ;
407403
408- let DebugInfoOffset { mut direct_offset, indirect_offsets, result : _ } =
404+ let DebugInfoOffset { direct_offset, indirect_offsets, result : _ } =
409405 calculate_debuginfo_offset ( bx, local, & var, base. layout ) ;
410- let mut indirect_offsets = & indirect_offsets[ ..] ;
411406
412407 // When targeting MSVC, create extra allocas for arguments instead of pointing multiple
413408 // 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> {
421416 // LLVM can handle simple things but anything more complex than just a direct
422417 // offset or one indirect offset of 0 is too complex for it to generate CV records
423418 // 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) ;
425424
426- let create_alloca = |bx : & mut Bx , place : PlaceRef < ' tcx , Bx :: Value > , refcount| {
427425 // Create a variable which will be a pointer to the actual value
428426 let ptr_ty = Ty :: new_ptr (
429427 bx. tcx ( ) ,
430428 ty:: TypeAndMut { mutbl : mir:: Mutability :: Mut , ty : place. layout . ty } ,
431429 ) ;
432430 let ptr_layout = bx. layout_of ( ptr_ty) ;
433431 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") ) ;
435433
436434 // Write the pointer to the variable
437435 bx. store ( place. llval , alloca. llval , alloca. align ) ;
438436
439437 // 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 ) ;
460441 }
461-
462- bx. dbg_var_addr ( dbg_var, dbg_loc, base. llval , direct_offset, indirect_offsets, None ) ;
463442 }
464443
465444 pub fn debug_introduce_locals ( & self , bx : & mut Bx ) {
@@ -492,7 +471,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
492471 } ;
493472
494473 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 {
496475 mir:: VarDebugInfoContents :: Place ( place) => {
497476 let var_ty = self . monomorphized_place_ty ( place. as_ref ( ) ) ;
498477 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> {
529508 }
530509 } ;
531510
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-
539511 self . cx . create_dbg_var ( var. name , var_ty, dbg_scope, var_kind, span)
540512 } ) ;
541513
@@ -547,7 +519,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
547519 dbg_var,
548520 fragment : None ,
549521 projection : place. projection ,
550- references : var. references ,
551522 } ) ;
552523 }
553524 mir:: VarDebugInfoContents :: Const ( c) => {
@@ -601,7 +572,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
601572 Some ( fragment_start..fragment_start + fragment_layout. size )
602573 } ,
603574 projection : place. projection ,
604- references : var. references ,
605575 } ) ;
606576 }
607577 }
0 commit comments