summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/CodeGen/AccelTable.h8
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp6
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp65
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h6
4 files changed, 34 insertions, 51 deletions
diff --git a/llvm/include/llvm/CodeGen/AccelTable.h b/llvm/include/llvm/CodeGen/AccelTable.h
index 14b9fbac4d9..13928582f2d 100644
--- a/llvm/include/llvm/CodeGen/AccelTable.h
+++ b/llvm/include/llvm/CodeGen/AccelTable.h
@@ -323,7 +323,7 @@ void emitDWARF5AccelTable(
/// with just a DIE reference.
class AppleAccelTableOffsetData : public AppleAccelTableData {
public:
- AppleAccelTableOffsetData(const DIE *D) : Die(D) {}
+ AppleAccelTableOffsetData(const DIE &D) : Die(D) {}
void emit(AsmPrinter *Asm) const override;
@@ -340,15 +340,15 @@ public:
void print(raw_ostream &OS) const override;
#endif
protected:
- uint64_t order() const override { return Die->getOffset(); }
+ uint64_t order() const override { return Die.getOffset(); }
- const DIE *Die;
+ const DIE &Die;
};
/// Accelerator table data implementation for Apple type accelerator tables.
class AppleAccelTableTypeData : public AppleAccelTableOffsetData {
public:
- AppleAccelTableTypeData(const DIE *D) : AppleAccelTableOffsetData(D) {}
+ AppleAccelTableTypeData(const DIE &D) : AppleAccelTableOffsetData(D) {}
void emit(AsmPrinter *Asm) const override;
diff --git a/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp b/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
index c663646f75f..886e7b150bc 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
@@ -582,12 +582,12 @@ void llvm::emitDWARF5AccelTable(
}
void AppleAccelTableOffsetData::emit(AsmPrinter *Asm) const {
- Asm->emitInt32(Die->getDebugSectionOffset());
+ Asm->emitInt32(Die.getDebugSectionOffset());
}
void AppleAccelTableTypeData::emit(AsmPrinter *Asm) const {
- Asm->emitInt32(Die->getDebugSectionOffset());
- Asm->emitInt16(Die->getTag());
+ Asm->emitInt32(Die.getDebugSectionOffset());
+ Asm->emitInt16(Die.getTag());
Asm->emitInt8(0);
}
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 40fe0e9cb49..f1e61b488a2 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2407,67 +2407,50 @@ void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
CU.addDIETypeSignature(RefDie, Signature);
}
-void DwarfDebug::addAccelDebugName(StringRef Name, const DIE &Die) {
- assert(getAccelTableKind() == AccelTableKind::Dwarf);
+// Add the Name along with its companion DIE to the appropriate accelerator
+// table (for AccelTableKind::Dwarf it's always AccelDebugNames, for
+// AccelTableKind::Apple, we use the table we got as an argument). If
+// accelerator tables are disabled, this function does nothing.
+template <typename DataT>
+void DwarfDebug::addAccelNameImpl(AccelTable<DataT> &AppleAccel, StringRef Name,
+ const DIE &Die) {
+ if (getAccelTableKind() == AccelTableKind::None)
+ return;
DwarfFile &Holder = useSplitDwarf() ? SkeletonHolder : InfoHolder;
- AccelDebugNames.addName(Holder.getStringPool().getEntry(*Asm, Name), Die);
-}
+ DwarfStringPoolEntryRef Ref =
+ Holder.getStringPool().getEntry(*Asm, Name);
-// Accelerator table mutators - add each name along with its companion
-// DIE to the proper table while ensuring that the name that we're going
-// to reference is in the string table. We do this since the names we
-// add may not only be identical to the names in the DIE.
-void DwarfDebug::addAccelName(StringRef Name, const DIE &Die) {
switch (getAccelTableKind()) {
case AccelTableKind::Apple:
- AccelNames.addName(InfoHolder.getStringPool().getEntry(*Asm, Name), &Die);
+ AppleAccel.addName(Ref, Die);
break;
case AccelTableKind::Dwarf:
- addAccelDebugName(Name, Die);
+ AccelDebugNames.addName(Ref, Die);
break;
- case AccelTableKind::None:
- return;
case AccelTableKind::Default:
llvm_unreachable("Default should have already been resolved.");
+ case AccelTableKind::None:
+ llvm_unreachable("None handled above");
}
}
+void DwarfDebug::addAccelName(StringRef Name, const DIE &Die) {
+ addAccelNameImpl(AccelNames, Name, Die);
+}
+
void DwarfDebug::addAccelObjC(StringRef Name, const DIE &Die) {
- if (getAccelTableKind() != AccelTableKind::Apple)
- return;
- AccelObjC.addName(InfoHolder.getStringPool().getEntry(*Asm, Name), &Die);
+ // ObjC names go only into the Apple accelerator tables.
+ if (getAccelTableKind() == AccelTableKind::Apple)
+ addAccelNameImpl(AccelObjC, Name, Die);
}
void DwarfDebug::addAccelNamespace(StringRef Name, const DIE &Die) {
- switch (getAccelTableKind()) {
- case AccelTableKind::Apple:
- AccelNamespace.addName(InfoHolder.getStringPool().getEntry(*Asm, Name),
- &Die);
- break;
- case AccelTableKind::Dwarf:
- addAccelDebugName(Name, Die);
- break;
- case AccelTableKind::None:
- return;
- case AccelTableKind::Default:
- llvm_unreachable("Default should have already been resolved.");
- }
+ addAccelNameImpl(AccelNamespace, Name, Die);
}
void DwarfDebug::addAccelType(StringRef Name, const DIE &Die, char Flags) {
- switch (getAccelTableKind()) {
- case AccelTableKind::Apple:
- AccelTypes.addName(InfoHolder.getStringPool().getEntry(*Asm, Name), &Die);
- break;
- case AccelTableKind::Dwarf:
- addAccelDebugName(Name, Die);
- break;
- case AccelTableKind::None:
- return;
- case AccelTableKind::Default:
- llvm_unreachable("Default should have already been resolved.");
- }
+ addAccelNameImpl(AccelTypes, Name, Die);
}
uint16_t DwarfDebug::getDwarfVersion() const {
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
index 6f4cefe6107..99dbac14c08 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -345,9 +345,9 @@ class DwarfDebug : public DebugHandlerBase {
/// Construct a DIE for this abstract scope.
void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU, LexicalScope *Scope);
- /// Helper function to add a name to the .debug_names table, using the
- /// appropriate string pool.
- void addAccelDebugName(StringRef Name, const DIE &Die);
+ template <typename DataT>
+ void addAccelNameImpl(AccelTable<DataT> &AppleAccel, StringRef Name,
+ const DIE &Die);
void finishVariableDefinitions();
OpenPOWER on IntegriCloud