[llvm] r203018 - Add a DIELocList class to handle pointers into the location list.
Eric Christopher
echristo at gmail.com
Wed Mar 5 14:41:21 PST 2014
Author: echristo
Date: Wed Mar 5 16:41:20 2014
New Revision: 203018
URL: http://llvm.org/viewvc/llvm-project?rev=203018&view=rev
Log:
Add a DIELocList class to handle pointers into the location list.
This enables us to figure out where in the debug_loc section our
locations are so that we can eventually hash them. It also helps
remove some special case code in emission. No functional change.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp?rev=203018&r1=203017&r2=203018&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp Wed Mar 5 16:41:20 2014
@@ -524,3 +524,34 @@ void DIEBlock::print(raw_ostream &O) con
DIE::print(O, 5);
}
#endif
+
+//===----------------------------------------------------------------------===//
+// DIELocList Implementation
+//===----------------------------------------------------------------------===//
+
+unsigned DIELocList::SizeOf(AsmPrinter *AP, dwarf::Form Form) const {
+ if (Form == dwarf::DW_FORM_data4)
+ return 4;
+ if (Form == dwarf::DW_FORM_sec_offset)
+ return 4;
+ return AP->getDataLayout().getPointerSize();
+}
+
+/// EmitValue - Emit label value.
+///
+void DIELocList::EmitValue(AsmPrinter *AP, dwarf::Form Form) const {
+ MCSymbol *Label = AP->GetTempSymbol("debug_loc", Index);
+ MCSymbol *DwarfDebugLocSectionSym = AP->getDwarfDebug()->getDebugLocSym();
+
+ if (AP->MAI->doesDwarfUseRelocationsAcrossSections())
+ AP->EmitSectionOffset(Label, DwarfDebugLocSectionSym);
+ else
+ AP->EmitLabelDifference(Label, DwarfDebugLocSectionSym, 4);
+}
+
+#ifndef NDEBUG
+void DIELocList::print(raw_ostream &O) const {
+ O << "LocList: " << Index;
+
+}
+#endif
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h?rev=203018&r1=203017&r2=203018&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h Wed Mar 5 16:41:20 2014
@@ -202,7 +202,8 @@ public:
isEntry,
isTypeSignature,
isBlock,
- isLoc
+ isLoc,
+ isLocList,
};
protected:
@@ -541,6 +542,37 @@ public:
virtual void print(raw_ostream &O) const;
#endif
};
+
+//===--------------------------------------------------------------------===//
+/// DIELocList - Represents a pointer to a location list in the debug_loc
+/// section.
+//
+class DIELocList : public DIEValue {
+ // Index into the .debug_loc vector.
+ size_t Index;
+
+public:
+ DIELocList(size_t I) : DIEValue(isLocList), Index(I) {}
+
+ /// getValue - Grab the current index out.
+ size_t getValue() const { return Index; }
+
+ /// EmitValue - Emit location data.
+ ///
+ virtual void EmitValue(AsmPrinter *AP, dwarf::Form Form) const;
+
+ /// SizeOf - Determine size of location data in bytes.
+ ///
+ virtual unsigned SizeOf(AsmPrinter *AP, dwarf::Form Form) const;
+
+ // Implement isa/cast/dyncast.
+ static bool classof(const DIEValue *E) { return E->getType() == isLocList; }
+
+#ifndef NDEBUG
+ virtual void print(raw_ostream &O) const;
+#endif
+};
+
} // end llvm namespace
#endif
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=203018&r1=203017&r2=203018&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Mar 5 16:41:20 2014
@@ -2032,17 +2032,6 @@ void DwarfDebug::emitDIE(DIE *Die) {
}
break;
}
- case dwarf::DW_AT_location: {
- if (DIELabel *L = dyn_cast<DIELabel>(Values[i])) {
- if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
- Asm->EmitSectionOffset(L->getValue(), DwarfDebugLocSectionSym);
- else
- Asm->EmitLabelDifference(L->getValue(), DwarfDebugLocSectionSym, 4);
- } else {
- Values[i]->EmitValue(Asm, Form);
- }
- break;
- }
case dwarf::DW_AT_accessibility: {
if (Asm->isVerbose()) {
DIEInteger *V = cast<DIEInteger>(Values[i]);
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=203018&r1=203017&r2=203018&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Wed Mar 5 16:41:20 2014
@@ -751,6 +751,9 @@ public:
/// Returns the Dwarf Version.
unsigned getDwarfVersion() const { return DwarfVersion; }
+ /// Returns the section symbol for the .debug_loc section.
+ MCSymbol *getDebugLocSym() const { return DwarfDebugLocSectionSym; }
+
/// Find the MDNode for the given reference.
template <typename T> T resolve(DIRef<T> Ref) const {
return Ref.resolve(TypeIdentifierMap);
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=203018&r1=203017&r2=203018&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Wed Mar 5 16:41:20 2014
@@ -231,6 +231,16 @@ void DwarfUnit::addExpr(DIELoc *Die, dwa
Die->addValue((dwarf::Attribute)0, Form, Value);
}
+/// addLocationList - Add a Dwarf loclistptr attribute data and value.
+///
+void DwarfUnit::addLocationList(DIE *Die, dwarf::Attribute Attribute,
+ unsigned Index) {
+ DIEValue *Value = new (DIEValueAllocator) DIELocList(Index);
+ dwarf::Form Form = DD->getDwarfVersion() >= 4 ? dwarf::DW_FORM_sec_offset
+ : dwarf::DW_FORM_data4;
+ Die->addValue(Attribute, Form, Value);
+}
+
/// addLabel - Add a Dwarf label attribute data and value.
///
void DwarfUnit::addLabel(DIE *Die, dwarf::Attribute Attribute, dwarf::Form Form,
@@ -1796,8 +1806,7 @@ DIE *DwarfUnit::constructVariableDIE(Dbg
unsigned Offset = DV.getDotDebugLocOffset();
if (Offset != ~0U) {
- addSectionLabel(VariableDie, dwarf::DW_AT_location,
- Asm->GetTempSymbol("debug_loc", Offset));
+ addLocationList(VariableDie, dwarf::DW_AT_location, Offset);
DV.setDIE(VariableDie);
return VariableDie;
}
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h?rev=203018&r1=203017&r2=203018&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h Wed Mar 5 16:41:20 2014
@@ -340,6 +340,9 @@ public:
void addLabel(DIELoc *Die, dwarf::Form Form, const MCSymbol *Label);
+ /// addLocationList - Add a Dwarf loclistptr attribute data and value.
+ void addLocationList(DIE *Die, dwarf::Attribute Attribute, unsigned Index);
+
/// addSectionLabel - Add a Dwarf section label attribute data and value.
///
void addSectionLabel(DIE *Die, dwarf::Attribute Attribute,
More information about the llvm-commits
mailing list