Skip to content

Commit f75278c

Browse files
alokkrsharmakiranchandramohan
authored andcommitted
Modification to incorporate comments from @bryanpkc .
1 parent 88d242c commit f75278c

File tree

3 files changed

+21
-76
lines changed

3 files changed

+21
-76
lines changed

llvm/include/llvm/IR/DebugInfoMetadata.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -783,12 +783,6 @@ class DIBasicType : public DIType {
783783
public:
784784
DEFINE_MDNODE_GET(DIBasicType, (unsigned Tag, StringRef Name),
785785
(Tag, Name, 0, 0, 0, FlagZero))
786-
DEFINE_MDNODE_GET(DIBasicType,
787-
(unsigned Tag, StringRef Name, uint64_t SizeInBits),
788-
(Tag, Name, SizeInBits, 0, 0, FlagZero))
789-
DEFINE_MDNODE_GET(DIBasicType,
790-
(unsigned Tag, MDString *Name, uint64_t SizeInBits),
791-
(Tag, Name, SizeInBits, 0, 0, FlagZero))
792786
DEFINE_MDNODE_GET(DIBasicType,
793787
(unsigned Tag, StringRef Name, uint64_t SizeInBits,
794788
uint32_t AlignInBits, unsigned Encoding, DIFlags Flags),

llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp

Lines changed: 21 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -623,28 +623,21 @@ DIE *DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV,
623623
}
624624

625625
// Add variable address.
626-
constructDieLocation(*VariableDie, dwarf::DW_AT_location, DV);
627-
return VariableDie;
628-
}
629626

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;
642635
}
643636

644637
// Check if variable has a single location description.
645638
if (auto *DVal = DV.getValueLoc()) {
646639
if (DVal->isLocation())
647-
addVariableAddress(DV, Die, DVal->getLoc());
640+
addVariableAddress(DV, *VariableDie, DVal->getLoc());
648641
else if (DVal->isInt()) {
649642
auto *Expr = DV.getSingleExpression();
650643
if (Expr && Expr->getNumElements()) {
@@ -654,23 +647,24 @@ void DwarfCompileUnit::constructDieLocation(
654647
DwarfExpr.addFragmentOffset(Expr);
655648
DwarfExpr.addUnsignedConstant(DVal->getInt());
656649
DwarfExpr.addExpression(Expr);
657-
addBlock(Die, dwarf::DW_AT_location, DwarfExpr.finalize());
650+
addBlock(*VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());
658651
if (DwarfExpr.TagOffset)
659-
addUInt(Die, dwarf::DW_AT_LLVM_tag_offset,
652+
addUInt(*VariableDie, dwarf::DW_AT_LLVM_tag_offset,
660653
dwarf::DW_FORM_data1, *DwarfExpr.TagOffset);
654+
661655
} else
662-
addConstantValue(Die, DVal->getInt(), DV.getType());
656+
addConstantValue(*VariableDie, DVal->getInt(), DV.getType());
663657
} else if (DVal->isConstantFP()) {
664-
addConstantFPValue(Die, DVal->getConstantFP());
658+
addConstantFPValue(*VariableDie, DVal->getConstantFP());
665659
} else if (DVal->isConstantInt()) {
666-
addConstantValue(Die, DVal->getConstantInt(), DV.getType());
660+
addConstantValue(*VariableDie, DVal->getConstantInt(), DV.getType());
667661
}
668-
return;
662+
return VariableDie;
669663
}
670664

671665
// .. else use frame index.
672666
if (!DV.hasFrameIndexExprs())
673-
return;
667+
return VariableDie;
674668

675669
Optional<unsigned> NVPTXAddressSpace;
676670
DIELoc *Loc = new (DIEValueAllocator) DIELoc;
@@ -715,52 +709,15 @@ void DwarfCompileUnit::constructDieLocation(
715709
// cuda-gdb requires DW_AT_address_class for all variables to be able to
716710
// correctly interpret address space of the variable address.
717711
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,
719713
NVPTXAddressSpace ? *NVPTXAddressSpace : NVPTX_ADDR_local_space);
720714
}
721-
addBlock(Die, dwarf::DW_AT_location, DwarfExpr.finalize());
715+
addBlock(*VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());
722716
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,
724718
*DwarfExpr.TagOffset);
725719

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;
764721
}
765722

766723
DIE *DwarfCompileUnit::constructVariableDIE(DbgVariable &DV,

llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -370,12 +370,6 @@ class DwarfCompileUnit final : public DwarfUnit {
370370
uint64_t getDWOId() const { return DWOId; }
371371
void setDWOId(uint64_t DwoId) { DWOId = DwoId; }
372372

373-
void constructDieLocation(DIE &Die, dwarf::Attribute Attribute,
374-
const DbgVariable &DV);
375-
void constructDieLocationAddExpr(DIE &Die, dwarf::Attribute Attribute,
376-
const DbgVariable &DV,
377-
DIExpression *SubExpr);
378-
379373
bool hasDwarfPubSections() const;
380374

381375
void addBaseTypeRef(DIEValueList &Die, int64_t Idx);

0 commit comments

Comments
 (0)