@@ -623,28 +623,21 @@ DIE *DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV,
623
623
}
624
624
625
625
// Add variable address.
626
- constructDieLocation (*VariableDie, dwarf::DW_AT_location, DV);
627
- return VariableDie;
628
- }
629
626
630
- void DwarfCompileUnit::constructDieLocation (
631
- DIE &Die, dwarf::Attribute Attribute, const DbgVariable &DV) {
632
- if (Attribute == dwarf::DW_AT_location) {
633
- unsigned Offset = DV.getDebugLocListIndex ();
634
- if (Offset != ~0U ) {
635
- addLocationList (Die, Attribute, Offset);
636
- auto TagOffset = DV.getDebugLocListTagOffset ();
637
- if (TagOffset)
638
- addUInt (Die, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
639
- *TagOffset);
640
- return ;
641
- }
627
+ unsigned Offset = DV.getDebugLocListIndex ();
628
+ if (Offset != ~0U ) {
629
+ addLocationList (*VariableDie, dwarf::DW_AT_location, Offset);
630
+ auto TagOffset = DV.getDebugLocListTagOffset ();
631
+ if (TagOffset)
632
+ addUInt (*VariableDie, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
633
+ *TagOffset);
634
+ return VariableDie;
642
635
}
643
636
644
637
// Check if variable has a single location description.
645
638
if (auto *DVal = DV.getValueLoc ()) {
646
639
if (DVal->isLocation ())
647
- addVariableAddress (DV, Die , DVal->getLoc ());
640
+ addVariableAddress (DV, *VariableDie , DVal->getLoc ());
648
641
else if (DVal->isInt ()) {
649
642
auto *Expr = DV.getSingleExpression ();
650
643
if (Expr && Expr->getNumElements ()) {
@@ -654,23 +647,24 @@ void DwarfCompileUnit::constructDieLocation(
654
647
DwarfExpr.addFragmentOffset (Expr);
655
648
DwarfExpr.addUnsignedConstant (DVal->getInt ());
656
649
DwarfExpr.addExpression (Expr);
657
- addBlock (Die , dwarf::DW_AT_location, DwarfExpr.finalize ());
650
+ addBlock (*VariableDie , dwarf::DW_AT_location, DwarfExpr.finalize ());
658
651
if (DwarfExpr.TagOffset )
659
- addUInt (Die , dwarf::DW_AT_LLVM_tag_offset,
652
+ addUInt (*VariableDie , dwarf::DW_AT_LLVM_tag_offset,
660
653
dwarf::DW_FORM_data1, *DwarfExpr.TagOffset );
654
+
661
655
} else
662
- addConstantValue (Die , DVal->getInt (), DV.getType ());
656
+ addConstantValue (*VariableDie , DVal->getInt (), DV.getType ());
663
657
} else if (DVal->isConstantFP ()) {
664
- addConstantFPValue (Die , DVal->getConstantFP ());
658
+ addConstantFPValue (*VariableDie , DVal->getConstantFP ());
665
659
} else if (DVal->isConstantInt ()) {
666
- addConstantValue (Die , DVal->getConstantInt (), DV.getType ());
660
+ addConstantValue (*VariableDie , DVal->getConstantInt (), DV.getType ());
667
661
}
668
- return ;
662
+ return VariableDie ;
669
663
}
670
664
671
665
// .. else use frame index.
672
666
if (!DV.hasFrameIndexExprs ())
673
- return ;
667
+ return VariableDie ;
674
668
675
669
Optional<unsigned > NVPTXAddressSpace;
676
670
DIELoc *Loc = new (DIEValueAllocator) DIELoc;
@@ -715,52 +709,15 @@ void DwarfCompileUnit::constructDieLocation(
715
709
// cuda-gdb requires DW_AT_address_class for all variables to be able to
716
710
// correctly interpret address space of the variable address.
717
711
const unsigned NVPTX_ADDR_local_space = 6 ;
718
- addUInt (Die , dwarf::DW_AT_address_class, dwarf::DW_FORM_data1,
712
+ addUInt (*VariableDie , dwarf::DW_AT_address_class, dwarf::DW_FORM_data1,
719
713
NVPTXAddressSpace ? *NVPTXAddressSpace : NVPTX_ADDR_local_space);
720
714
}
721
- addBlock (Die , dwarf::DW_AT_location, DwarfExpr.finalize ());
715
+ addBlock (*VariableDie , dwarf::DW_AT_location, DwarfExpr.finalize ());
722
716
if (DwarfExpr.TagOffset )
723
- addUInt (Die , dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
717
+ addUInt (*VariableDie , dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
724
718
*DwarfExpr.TagOffset );
725
719
726
- return ;
727
- }
728
-
729
- void DwarfCompileUnit::constructDieLocationAddExpr (
730
- DIE &Die, dwarf::Attribute Attribute, const DbgVariable &DV,
731
- DIExpression *SubExpr) {
732
- if (Attribute == dwarf::DW_AT_location)
733
- return ; // clients like gdb don't handle location lists correctly
734
- if (DV.getValueLoc ())
735
- return ; // temp should not have a DBG_VALUE instruction
736
- if (!DV.hasFrameIndexExprs ())
737
- return ; // but it should have a frame index expression
738
-
739
- DIELoc *Loc = new (DIEValueAllocator) DIELoc;
740
- DIEDwarfExpression DwarfExpr (*Asm, *this , *Loc);
741
- for (auto &Fragment : DV.getFrameIndexExprs ()) {
742
- unsigned FrameReg = 0 ;
743
- const DIExpression *Expr = Fragment.Expr ;
744
- const TargetFrameLowering *TFI = Asm->MF ->getSubtarget ().getFrameLowering ();
745
- int Offset = TFI->getFrameIndexReference (*Asm->MF , Fragment.FI , FrameReg);
746
- DwarfExpr.addFragmentOffset (Expr);
747
- SmallVector<uint64_t , 8 > Ops;
748
- Ops.push_back (dwarf::DW_OP_plus_uconst);
749
- Ops.push_back (Offset);
750
- Ops.append (Expr->elements_begin (), Expr->elements_end ());
751
- if (SubExpr) {
752
- for (unsigned SEOp : SubExpr->getElements ())
753
- Ops.push_back (SEOp);
754
- } else {
755
- Ops.push_back (dwarf::DW_OP_deref);
756
- }
757
- DIExpressionCursor Cursor (Ops);
758
- DwarfExpr.setMemoryLocationKind ();
759
- DwarfExpr.addMachineRegExpression (
760
- *Asm->MF ->getSubtarget ().getRegisterInfo (), Cursor, FrameReg);
761
- DwarfExpr.addExpression (std::move (Cursor));
762
- }
763
- addBlock (Die, Attribute, DwarfExpr.finalize ());
720
+ return VariableDie;
764
721
}
765
722
766
723
DIE *DwarfCompileUnit::constructVariableDIE (DbgVariable &DV,
0 commit comments