summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
index 144635ef6a8..7e0ae22f519 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -326,6 +326,30 @@ class DwarfDebug {
// Maps subprogram MDNode with its corresponding CompileUnit.
DenseMap <const MDNode *, CompileUnit *> SPMap;
+ /// Maps type MDNode with its corresponding DIE. These DIEs can be
+ /// shared across CUs, that is why we keep the map here instead
+ /// of in CompileUnit.
+ DenseMap<const MDNode *, DIE *> MDTypeNodeToDieMap;
+ /// Maps subprogram MDNode with its corresponding DIE.
+ DenseMap<const MDNode *, DIE *> MDSPNodeToDieMap;
+ /// Maps static member MDNode with its corresponding DIE.
+ DenseMap<const MDNode *, DIE *> MDStaticMemberNodeToDieMap;
+
+ /// Specifies a worklist item. Sometimes, when we try to add an attribute to
+ /// a DIE, the DIE is not yet added to its owner yet, so we don't know whether
+ /// we should use ref_addr or ref4. We create a worklist that will be
+ /// processed during finalization to add attributes with the correct form
+ /// (ref_addr or ref4).
+ struct DIEEntryWorkItem {
+ DIE *Die;
+ uint16_t Attribute;
+ DIEEntry *Entry;
+ DIEEntryWorkItem(DIE *D, uint16_t A, DIEEntry *E) :
+ Die(D), Attribute(A), Entry(E) {
+ }
+ };
+ SmallVector<DIEEntryWorkItem, 64> DIEEntryWorklist;
+
// Used to uniquely define abbreviations.
FoldingSet<DIEAbbrev> AbbreviationsSet;
@@ -660,6 +684,28 @@ public:
DwarfDebug(AsmPrinter *A, Module *M);
~DwarfDebug();
+ void insertTypeDIE(const MDNode *TypeMD, DIE *Die) {
+ MDTypeNodeToDieMap.insert(std::make_pair(TypeMD, Die));
+ }
+ DIE *getTypeDIE(const MDNode *TypeMD) {
+ return MDTypeNodeToDieMap.lookup(TypeMD);
+ }
+ void insertSPDIE(const MDNode *SPMD, DIE *Die) {
+ MDSPNodeToDieMap.insert(std::make_pair(SPMD, Die));
+ }
+ DIE *getSPDIE(const MDNode *SPMD) {
+ return MDSPNodeToDieMap.lookup(SPMD);
+ }
+ void insertStaticMemberDIE(const MDNode *StaticMD, DIE *Die) {
+ MDStaticMemberNodeToDieMap.insert(std::make_pair(StaticMD, Die));
+ }
+ DIE *getStaticMemberDIE(const MDNode *StaticMD) {
+ return MDStaticMemberNodeToDieMap.lookup(StaticMD);
+ }
+ void insertDIEEntryWorklist(DIE *Die, uint16_t Attribute, DIEEntry *Entry) {
+ DIEEntryWorklist.push_back(DIEEntryWorkItem(Die, Attribute, Entry));
+ }
+
/// \brief Emit all Dwarf sections that should come prior to the
/// content.
void beginModule();
@@ -722,6 +768,11 @@ public:
return Ref.resolve(TypeIdentifierMap);
}
+ /// When we don't know whether the correct form is ref4 or ref_addr, we create
+ /// a worklist item and insert it to DIEEntryWorklist.
+ void addDIEEntry(DIE *Die, uint16_t Attribute, uint16_t Form,
+ DIEEntry *Entry);
+
/// isSubprogramContext - Return true if Context is either a subprogram
/// or another context nested inside a subprogram.
bool isSubprogramContext(const MDNode *Context);
OpenPOWER on IntegriCloud