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.h136
1 files changed, 27 insertions, 109 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
index a8d74c92899..0c7be5d27df 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -15,7 +15,7 @@
#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
#include "AddressPool.h"
-#include "DbgEntityHistoryCalculator.h"
+#include "DbgValueHistoryCalculator.h"
#include "DebugHandlerBase.h"
#include "DebugLocStream.h"
#include "DwarfFile.h"
@@ -62,46 +62,6 @@ class MDNode;
class Module;
//===----------------------------------------------------------------------===//
-/// This class is defined as the common parent of DbgVariable and DbgLabel
-/// such that it could levarage polymorphism to extract common code for
-/// DbgVariable and DbgLabel.
-class DbgEntity {
- const DINode *Entity;
- const DILocation *InlinedAt;
- DIE *TheDIE = nullptr;
- unsigned SubclassID;
-
-public:
- enum DbgEntityKind {
- DbgVariableKind,
- DbgLabelKind
- };
-
- DbgEntity(const DINode *N, const DILocation *IA, unsigned ID)
- : Entity(N), InlinedAt(IA), SubclassID(ID) {}
-
- /// Accessors.
- /// @{
- const DINode *getEntity() const { return Entity; }
- const DILocation *getInlinedAt() const { return InlinedAt; }
- DIE *getDIE() const { return TheDIE; }
- unsigned getDbgEntityID() const { return SubclassID; }
- /// @}
-
- void setDIE(DIE &D) { TheDIE = &D; }
-
- static bool classof(const DbgEntity *N) {
- switch (N->getDbgEntityID()) {
- default:
- return false;
- case DbgVariableKind:
- case DbgLabelKind:
- return true;
- }
- }
-};
-
-//===----------------------------------------------------------------------===//
/// This class is used to track local variable information.
///
/// Variables can be created from allocas, in which case they're generated from
@@ -113,7 +73,10 @@ public:
/// single instruction use \a MInsn and (optionally) a single entry of \a Expr.
///
/// Variables that have been optimized out use none of these fields.
-class DbgVariable : public DbgEntity {
+class DbgVariable {
+ const DILocalVariable *Var; /// Variable Descriptor.
+ const DILocation *IA; /// Inlined at location.
+ DIE *TheDIE = nullptr; /// Variable DIE.
unsigned DebugLocListIndex = ~0u; /// Offset in DebugLocs.
const MachineInstr *MInsn = nullptr; /// DBG_VALUE instruction.
@@ -130,7 +93,7 @@ public:
/// Creates a variable without any DW_AT_location. Call \a initializeMMI()
/// for MMI entries, or \a initializeDbgValue() for DBG_VALUE instructions.
DbgVariable(const DILocalVariable *V, const DILocation *IA)
- : DbgEntity(V, IA, DbgVariableKind) {}
+ : Var(V), IA(IA) {}
/// Initialize from the MMI table.
void initializeMMI(const DIExpression *E, int FI) {
@@ -148,9 +111,8 @@ public:
assert(FrameIndexExprs.empty() && "Already initialized?");
assert(!MInsn && "Already initialized?");
- assert(getVariable() == DbgValue->getDebugVariable() && "Wrong variable");
- assert(getInlinedAt() == DbgValue->getDebugLoc()->getInlinedAt() &&
- "Wrong inlined-at");
+ assert(Var == DbgValue->getDebugVariable() && "Wrong variable");
+ assert(IA == DbgValue->getDebugLoc()->getInlinedAt() && "Wrong inlined-at");
MInsn = DbgValue;
if (auto *E = DbgValue->getDebugExpression())
@@ -159,18 +121,19 @@ public:
}
// Accessors.
- const DILocalVariable *getVariable() const {
- return cast<DILocalVariable>(getEntity());
- }
+ const DILocalVariable *getVariable() const { return Var; }
+ const DILocation *getInlinedAt() const { return IA; }
const DIExpression *getSingleExpression() const {
assert(MInsn && FrameIndexExprs.size() <= 1);
return FrameIndexExprs.size() ? FrameIndexExprs[0].Expr : nullptr;
}
+ void setDIE(DIE &D) { TheDIE = &D; }
+ DIE *getDIE() const { return TheDIE; }
void setDebugLocListIndex(unsigned O) { DebugLocListIndex = O; }
unsigned getDebugLocListIndex() const { return DebugLocListIndex; }
- StringRef getName() const { return getVariable()->getName(); }
+ StringRef getName() const { return Var->getName(); }
const MachineInstr *getMInsn() const { return MInsn; }
/// Get the FI entries, sorted by fragment offset.
ArrayRef<FrameIndexExpr> getFrameIndexExprs() const;
@@ -180,7 +143,7 @@ public:
// Translate tag to proper Dwarf tag.
dwarf::Tag getTag() const {
// FIXME: Why don't we just infer this tag and store it all along?
- if (getVariable()->isParameter())
+ if (Var->isParameter())
return dwarf::DW_TAG_formal_parameter;
return dwarf::DW_TAG_variable;
@@ -188,7 +151,7 @@ public:
/// Return true if DbgVariable is artificial.
bool isArtificial() const {
- if (getVariable()->isArtificial())
+ if (Var->isArtificial())
return true;
if (getType()->isArtificial())
return true;
@@ -196,7 +159,7 @@ public:
}
bool isObjectPointer() const {
- if (getVariable()->isObjectPointer())
+ if (Var->isObjectPointer())
return true;
if (getType()->isObjectPointer())
return true;
@@ -215,45 +178,6 @@ public:
bool isBlockByrefVariable() const;
const DIType *getType() const;
- static bool classof(const DbgEntity *N) {
- return N->getDbgEntityID() == DbgVariableKind;
- }
-
-private:
- template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
- return Ref.resolve();
- }
-};
-
-//===----------------------------------------------------------------------===//
-/// This class is used to track label information.
-///
-/// Labels are collected from \c DBG_LABEL instructions.
-class DbgLabel : public DbgEntity {
- const MCSymbol *Sym; /// Symbol before DBG_LABEL instruction.
-
-public:
- /// We need MCSymbol information to generate DW_AT_low_pc.
- DbgLabel(const DILabel *L, const DILocation *IA, const MCSymbol *Sym = nullptr)
- : DbgEntity(L, IA, DbgLabelKind), Sym(Sym) {}
-
- /// Accessors.
- /// @{
- const DILabel *getLabel() const { return cast<DILabel>(getEntity()); }
- const MCSymbol *getSymbol() const { return Sym; }
-
- StringRef getName() const { return getLabel()->getName(); }
- /// @}
-
- /// Translate tag to proper Dwarf tag.
- dwarf::Tag getTag() const {
- return dwarf::DW_TAG_label;
- }
-
- static bool classof(const DbgEntity *N) {
- return N->getDbgEntityID() == DbgLabelKind;
- }
-
private:
template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
return Ref.resolve();
@@ -293,8 +217,8 @@ class DwarfDebug : public DebugHandlerBase {
/// Size of each symbol emitted (for those symbols that have a specific size).
DenseMap<const MCSymbol *, uint64_t> SymSize;
- /// Collection of abstract variables/labels.
- SmallVector<std::unique_ptr<DbgEntity>, 64> ConcreteEntities;
+ /// Collection of abstract variables.
+ SmallVector<std::unique_ptr<DbgVariable>, 64> ConcreteVariables;
/// Collection of DebugLocEntry. Stored in a linked list so that DIELocLists
/// can refer to them in spite of insertions into this list.
@@ -409,20 +333,14 @@ class DwarfDebug : public DebugHandlerBase {
}
using InlinedVariable = DbgValueHistoryMap::InlinedVariable;
- using InlinedLabel = DbgLabelInstrMap::InlinedLabel;
- void ensureAbstractEntityIsCreated(DwarfCompileUnit &CU,
- const DINode *Node,
- const MDNode *Scope);
- void ensureAbstractEntityIsCreatedIfScoped(DwarfCompileUnit &CU,
- const DINode *Node,
- const MDNode *Scope);
+ void ensureAbstractVariableIsCreated(DwarfCompileUnit &CU, InlinedVariable IV,
+ const MDNode *Scope);
+ void ensureAbstractVariableIsCreatedIfScoped(DwarfCompileUnit &CU, InlinedVariable IV,
+ const MDNode *Scope);
- DbgEntity *createConcreteEntity(DwarfCompileUnit &TheCU,
- LexicalScope &Scope,
- const DINode *Node,
- const DILocation *Location,
- const MCSymbol *Sym = nullptr);
+ DbgVariable *createConcreteVariable(DwarfCompileUnit &TheCU,
+ LexicalScope &Scope, InlinedVariable IV);
/// Construct a DIE for this abstract scope.
void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU, LexicalScope *Scope);
@@ -431,7 +349,7 @@ class DwarfDebug : public DebugHandlerBase {
void addAccelNameImpl(AccelTable<DataT> &AppleAccel, StringRef Name,
const DIE &Die);
- void finishEntityDefinitions();
+ void finishVariableDefinitions();
void finishSubprogramDefinitions();
@@ -548,8 +466,8 @@ class DwarfDebug : public DebugHandlerBase {
unsigned Flags);
/// Populate LexicalScope entries with variables' info.
- void collectEntityInfo(DwarfCompileUnit &TheCU, const DISubprogram *SP,
- DenseSet<InlinedVariable> &ProcessedVars);
+ void collectVariableInfo(DwarfCompileUnit &TheCU, const DISubprogram *SP,
+ DenseSet<InlinedVariable> &ProcessedVars);
/// Build the location list for all DBG_VALUEs in the
/// function that describe the same variable.
OpenPOWER on IntegriCloud