#include "AsmPrinterHandler.h"
#include "DbgValueHistoryCalculator.h"
-#include "DebugLocEntry.h"
-#include "DebugLocList.h"
+#include "DebugLocStream.h"
#include "DwarfAccelTable.h"
#include "DwarfFile.h"
#include "llvm/ADT/DenseMap.h"
class ByteStreamer;
class ConstantInt;
class ConstantFP;
+class DebugLocEntry;
class DwarfCompileUnit;
class DwarfDebug;
class DwarfTypeUnit;
//===----------------------------------------------------------------------===//
/// \brief This class is used to track local variable information.
///
-/// - Variables whose location changes over time have a DotDebugLocOffset and
+/// - Variables whose location changes over time have a DebugLocListIndex and
/// the other fields are not used.
///
/// - Variables that are described by multiple MMI table entries have multiple
/// expressions and frame indices.
class DbgVariable {
- DIVariable Var; /// Variable Descriptor.
- DILocation IA; /// Inlined at location.
- SmallVector<DIExpression, 1> Expr; /// Complex address location expression.
+ const DILocalVariable *Var; /// Variable Descriptor.
+ const DILocation *IA; /// Inlined at location.
+ SmallVector<const DIExpression *, 1>
+ Expr; /// Complex address location expression.
DIE *TheDIE; /// Variable DIE.
- unsigned DotDebugLocOffset; /// Offset in DotDebugLocEntries.
+ unsigned DebugLocListIndex; /// Offset in DebugLocs.
const MachineInstr *MInsn; /// DBG_VALUE instruction of the variable.
SmallVector<int, 1> FrameIndex; /// Frame index of the variable.
DwarfDebug *DD;
public:
- /// Construct a DbgVariable from a DIVariable.
- DbgVariable(DIVariable V, DILocation IA, DIExpression E, DwarfDebug *DD,
- int FI = ~0)
- : Var(V), IA(IA), Expr(1, E), TheDIE(nullptr), DotDebugLocOffset(~0U),
+ /// Construct a DbgVariable from a variable.
+ DbgVariable(const DILocalVariable *V, const DILocation *IA,
+ const DIExpression *E, DwarfDebug *DD, int FI = ~0)
+ : Var(V), IA(IA), Expr(1, E), TheDIE(nullptr), DebugLocListIndex(~0U),
MInsn(nullptr), DD(DD) {
FrameIndex.push_back(FI);
assert(!E || E->isValid());
/// AbstractVar may be NULL.
DbgVariable(const MachineInstr *DbgValue, DwarfDebug *DD)
: Var(DbgValue->getDebugVariable()),
- IA(DbgValue->getDebugLoc() ? DbgValue->getDebugLoc()->getInlinedAt()
- : nullptr),
+ IA(DbgValue->getDebugLoc()->getInlinedAt()),
Expr(1, DbgValue->getDebugExpression()), TheDIE(nullptr),
- DotDebugLocOffset(~0U), MInsn(DbgValue), DD(DD) {
+ DebugLocListIndex(~0U), MInsn(DbgValue), DD(DD) {
FrameIndex.push_back(~0);
- if (MDLocation *Loc = DbgValue->getDebugLoc())
- IA = Loc->getInlinedAt();
}
// Accessors.
- DIVariable getVariable() const { return Var; }
- DILocation getInlinedAt() const { return IA; }
- const ArrayRef<DIExpression> getExpression() const { return Expr; }
+ const DILocalVariable *getVariable() const { return Var; }
+ const DILocation *getInlinedAt() const { return IA; }
+ const ArrayRef<const DIExpression *> getExpression() const { return Expr; }
void setDIE(DIE &D) { TheDIE = &D; }
DIE *getDIE() const { return TheDIE; }
- void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; }
- unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; }
+ void setDebugLocListIndex(unsigned O) { DebugLocListIndex = O; }
+ unsigned getDebugLocListIndex() const { return DebugLocListIndex; }
StringRef getName() const { return Var->getName(); }
const MachineInstr *getMInsn() const { return MInsn; }
const ArrayRef<int> getFrameIndex() const { return FrameIndex; }
void addMMIEntry(const DbgVariable &V) {
- assert( DotDebugLocOffset == ~0U && !MInsn && "not an MMI entry");
- assert(V.DotDebugLocOffset == ~0U && !V.MInsn && "not an MMI entry");
- assert(V.Var == Var && "conflicting DIVariable");
+ assert(DebugLocListIndex == ~0U && !MInsn && "not an MMI entry");
+ assert(V.DebugLocListIndex == ~0U && !V.MInsn && "not an MMI entry");
+ assert(V.Var == Var && "conflicting variable");
assert(V.IA == IA && "conflicting inlined-at location");
if (V.getFrameIndex().back() != ~0) {
Expr.append(E.begin(), E.end());
FrameIndex.append(FI.begin(), FI.end());
}
- assert(Expr.size() > 1
- ? std::all_of(Expr.begin(), Expr.end(),
- [](DIExpression &E) { return E->isBitPiece(); })
- : (true && "conflicting locations for variable"));
+ assert(Expr.size() > 1 ? std::all_of(Expr.begin(), Expr.end(),
+ [](const DIExpression *E) {
+ return E->isBitPiece();
+ })
+ : (true && "conflicting locations for variable"));
}
// Translate tag to proper Dwarf tag.
return Expr.back()->getNumElements() > 0;
}
bool isBlockByrefVariable() const;
- DIType getType() const;
+ const DIType *getType() const;
private:
/// resolve - Look in the DwarfDebug map for the MDNode that
/// corresponds to the reference.
- template <typename T> T resolve(DIRef<T> Ref) const;
+ template <typename T> T *resolve(TypedDINodeRef<T> Ref) const;
};
// Collection of DebugLocEntry. Stored in a linked list so that DIELocLists
// can refer to them in spite of insertions into this list.
- SmallVector<DebugLocList, 4> DotDebugLocEntries;
+ DebugLocStream DebugLocs;
// This is a collection of subprogram MDNodes that are processed to
// create DIEs.
// them.
DenseMap<const MDNode *, const DwarfTypeUnit *> DwarfTypeUnits;
- SmallVector<std::pair<std::unique_ptr<DwarfTypeUnit>, DICompositeType>, 1>
+ SmallVector<
+ std::pair<std::unique_ptr<DwarfTypeUnit>, const DICompositeType *>, 1>
TypeUnitsUnderConstruction;
// Whether to emit the pubnames/pubtypes sections.
DwarfAccelTable AccelNamespace;
DwarfAccelTable AccelTypes;
- DenseMap<const Function *, DISubprogram> FunctionDIs;
+ DenseMap<const Function *, DISubprogram *> FunctionDIs;
MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
/// \brief Find abstract variable associated with Var.
DbgVariable *getExistingAbstractVariable(InlinedVariable IV,
- DIVariable &Cleansed);
+ const DILocalVariable *&Cleansed);
DbgVariable *getExistingAbstractVariable(InlinedVariable IV);
- void createAbstractVariable(const DIVariable &DV, LexicalScope *Scope);
+ void createAbstractVariable(const DILocalVariable *DV, LexicalScope *Scope);
void ensureAbstractVariableIsCreated(InlinedVariable Var,
const MDNode *Scope);
void ensureAbstractVariableIsCreatedIfScoped(InlinedVariable Var,
/// \brief Create new DwarfCompileUnit for the given metadata node with tag
/// DW_TAG_compile_unit.
- DwarfCompileUnit &constructDwarfCompileUnit(DICompileUnit DIUnit);
+ DwarfCompileUnit &constructDwarfCompileUnit(const DICompileUnit *DIUnit);
/// \brief Construct imported_module or imported_declaration DIE.
void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
- const MDNode *N);
+ const DIImportedEntity *N);
/// \brief Register a source line with debug info. Returns the unique
/// label that was emitted and which provides correspondence to the
void identifyScopeMarkers();
/// \brief Populate LexicalScope entries with variables' info.
- void collectVariableInfo(DwarfCompileUnit &TheCU, DISubprogram SP,
+ void collectVariableInfo(DwarfCompileUnit &TheCU, const DISubprogram *SP,
DenseSet<InlinedVariable> &ProcessedVars);
/// \brief Build the location list for all DBG_VALUEs in the
/// \brief Add a DIE to the set of types that we're going to pull into
/// type units.
void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
- DIE &Die, DICompositeType CTy);
+ DIE &Die, const DICompositeType *CTy);
/// \brief Add a label so that arange data can be generated for it.
void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
void setPrevCU(const DwarfCompileUnit *PrevCU) { this->PrevCU = PrevCU; }
/// Returns the entries for the .debug_loc section.
- const SmallVectorImpl<DebugLocList> &
- getDebugLocEntries() const {
- return DotDebugLocEntries;
- }
+ const DebugLocStream &getDebugLocs() const { return DebugLocs; }
/// \brief Emit an entry for the debug loc section. This can be used to
/// handle an entry that's going to be emitted into the debug loc section.
void emitDebugLocEntry(ByteStreamer &Streamer,
- const DebugLocEntry &Entry);
- /// \brief emit a single value for the debug loc section.
- void emitDebugLocValue(ByteStreamer &Streamer,
- const DebugLocEntry::Value &Value,
- unsigned PieceOffsetInBits = 0);
- /// Emits an optimal (=sorted) sequence of DW_OP_pieces.
- void emitLocPieces(ByteStreamer &Streamer,
- const DITypeIdentifierMap &Map,
- ArrayRef<DebugLocEntry::Value> Values);
+ const DebugLocStream::Entry &Entry);
/// Emit the location for a debug loc entry, including the size header.
- void emitDebugLocEntryLocation(const DebugLocEntry &Entry);
+ void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry);
/// Find the MDNode for the given reference.
- template <typename T> T resolve(DIRef<T> Ref) const {
- return Ref.resolve(TypeIdentifierMap);
- }
- template <typename T> T *resolve(TypedDebugNodeRef<T> Ref) const {
+ template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
return Ref.resolve(TypeIdentifierMap);
}
/// or another context nested inside a subprogram.
bool isSubprogramContext(const MDNode *Context);
- void addSubprogramNames(DISubprogram SP, DIE &Die);
+ void addSubprogramNames(const DISubprogram *SP, DIE &Die);
AddressPool &getAddressPool() { return AddrPool; }