diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:41:05 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:41:05 +0000 |
commit | 01095a5d43bbfde13731688ddcf6048ebb8b7721 (patch) | |
tree | 4def12e759965de927d963ac65840d663ef9d1ea /lib/CodeGen/AsmPrinter/DwarfDebug.h | |
parent | f0f4822ed4b66e3579e92a89f368f8fb860e218e (diff) |
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DwarfDebug.h')
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfDebug.h | 148 |
1 files changed, 47 insertions, 101 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.h b/lib/CodeGen/AsmPrinter/DwarfDebug.h index 460c186683fc1..6b06757628b6e 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -14,14 +14,13 @@ #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H -#include "AsmPrinterHandler.h" #include "DbgValueHistoryCalculator.h" +#include "DebugHandlerBase.h" #include "DebugLocStream.h" #include "DwarfAccelTable.h" #include "DwarfFile.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseSet.h" -#include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/MapVector.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/StringMap.h" @@ -69,15 +68,14 @@ class DbgVariable { unsigned DebugLocListIndex = ~0u; /// Offset in DebugLocs. const MachineInstr *MInsn = nullptr; /// DBG_VALUE instruction. SmallVector<int, 1> FrameIndex; /// Frame index. - DwarfDebug *DD; public: /// Construct a DbgVariable. /// /// 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, DwarfDebug *DD) - : Var(V), IA(IA), DD(DD) {} + DbgVariable(const DILocalVariable *V, const DILocation *IA) + : Var(V), IA(IA) {} /// Initialize from the MMI table. void initializeMMI(const DIExpression *E, int FI) { @@ -111,6 +109,10 @@ public: const DILocalVariable *getVariable() const { return Var; } const DILocation *getInlinedAt() const { return IA; } ArrayRef<const DIExpression *> getExpression() const { return Expr; } + const DIExpression *getSingleExpression() const { + assert(MInsn && Expr.size() <= 1); + return Expr.size() ? Expr[0] : nullptr; + } void setDIE(DIE &D) { TheDIE = &D; } DIE *getDIE() const { return TheDIE; } void setDebugLocListIndex(unsigned O) { DebugLocListIndex = O; } @@ -174,9 +176,9 @@ public: const DIType *getType() const; private: - /// Look in the DwarfDebug map for the MDNode that - /// corresponds to the reference. - template <typename T> T *resolve(TypedDINodeRef<T> Ref) const; + template <typename T> T *resolve(TypedDINodeRef<T> Ref) const { + return Ref.resolve(); + } }; @@ -188,22 +190,13 @@ struct SymbolCU { }; /// Collects and handles dwarf debug information. -class DwarfDebug : public AsmPrinterHandler { - /// Target of Dwarf emission. - AsmPrinter *Asm; - - /// Collected machine module information. - MachineModuleInfo *MMI; - +class DwarfDebug : public DebugHandlerBase { /// All DIEValues are allocated through this allocator. BumpPtrAllocator DIEValueAllocator; /// Maps MDNode with its corresponding DwarfCompileUnit. MapVector<const MDNode *, DwarfCompileUnit *> CUMap; - /// Maps subprogram MDNode with its corresponding DwarfCompileUnit. - MapVector<const MDNode *, DwarfCompileUnit *> SPMap; - /// Maps a CU DIE with its corresponding DwarfCompileUnit. DenseMap<const DIE *, DwarfCompileUnit *> CUDieMap; @@ -213,8 +206,6 @@ class DwarfDebug : public AsmPrinterHandler { /// Size of each symbol emitted (for those symbols that have a specific size). DenseMap<const MCSymbol *, uint64_t> SymSize; - LexicalScopes LScopes; - /// Collection of abstract variables. DenseMap<const MDNode *, std::unique_ptr<DbgVariable>> AbstractVariables; SmallVector<std::unique_ptr<DbgVariable>, 64> ConcreteVariables; @@ -227,32 +218,9 @@ class DwarfDebug : public AsmPrinterHandler { /// create DIEs. SmallPtrSet<const MDNode *, 16> ProcessedSPNodes; - /// Maps instruction with label emitted before instruction. - DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn; - - /// Maps instruction with label emitted after instruction. - DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn; - - /// History of DBG_VALUE and clobber instructions for each user - /// variable. Variables are listed in order of appearance. - DbgValueHistoryMap DbgValues; - - /// Previous instruction's location information. This is used to - /// determine label location to indicate scope boundries in dwarf - /// debug info. - DebugLoc PrevInstLoc; - MCSymbol *PrevLabel; - - /// This location indicates end of function prologue and beginning of - /// function body. - DebugLoc PrologEndLoc; - /// If nonnull, stores the current machine function we're processing. const MachineFunction *CurFn; - /// If nonnull, stores the current machine instruction we're processing. - const MachineInstr *CurMI; - /// If nonnull, stores the CU in which the previous subprogram was contained. const DwarfCompileUnit *PrevCU; @@ -266,9 +234,9 @@ class DwarfDebug : public AsmPrinterHandler { /// Holders for the various debug information flags that we might need to /// have exposed. See accessor functions below for description. - /// Map from MDNodes for user-defined types to the type units that - /// describe them. - DenseMap<const MDNode *, const DwarfTypeUnit *> DwarfTypeUnits; + /// Map from MDNodes for user-defined types to their type signatures. Also + /// used to keep track of which types we have emitted type units for. + DenseMap<const MDNode *, uint64_t> TypeSignatures; SmallVector< std::pair<std::unique_ptr<DwarfTypeUnit>, const DICompositeType *>, 1> @@ -280,18 +248,19 @@ class DwarfDebug : public AsmPrinterHandler { /// Whether to use the GNU TLS opcode (instead of the standard opcode). bool UseGNUTLSOpcode; - /// Whether to emit DW_AT_[MIPS_]linkage_name. - bool UseLinkageNames; + /// Whether to use DWARF 2 bitfields (instead of the DWARF 4 format). + bool UseDWARF2Bitfields; + + /// Whether to emit all linkage names, or just abstract subprograms. + bool UseAllLinkageNames; /// Version of dwarf we're emitting. unsigned DwarfVersion; - /// Maps from a type identifier to the actual MDNode. - DITypeIdentifierMap TypeIdentifierMap; - /// DWARF5 Experimental Options /// @{ bool HasDwarfAccelTables; + bool HasAppleExtensionAttributes; bool HasSplitDwarf; /// Separated Dwarf Variables @@ -324,9 +293,19 @@ class DwarfDebug : public AsmPrinterHandler { // Identify a debugger for "tuning" the debug info. DebuggerKind DebuggerTuning; + /// \defgroup DebuggerTuning Predicates to tune DWARF for a given debugger. + /// + /// Returns whether we are "tuning" for a given debugger. + /// Should be used only within the constructor, to set feature flags. + /// @{ + bool tuneForGDB() const { return DebuggerTuning == DebuggerKind::GDB; } + bool tuneForLLDB() const { return DebuggerTuning == DebuggerKind::LLDB; } + bool tuneForSCE() const { return DebuggerTuning == DebuggerKind::SCE; } + /// @} + MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &); - const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() { + const SmallVectorImpl<std::unique_ptr<DwarfCompileUnit>> &getUnits() { return InfoHolder.getUnits(); } @@ -347,9 +326,6 @@ class DwarfDebug : public AsmPrinterHandler { /// Construct a DIE for this abstract scope. void constructAbstractSubprogramScopeDIE(LexicalScope *Scope); - /// Collect info for variables that were optimized out. - void collectDeadVariables(); - void finishVariableDefinitions(); void finishSubprogramDefinitions(); @@ -397,7 +373,7 @@ class DwarfDebug : public AsmPrinterHandler { bool GnuStyle, MCSection *PSec, StringRef Name, const StringMap<const DIE *> &(DwarfCompileUnit::*Accessor)() const); - /// Emit visible names into a debug str section. + /// Emit null-terminated strings into a debug str section. void emitDebugStr(); /// Emit variable locations into a debug loc section. @@ -414,17 +390,15 @@ class DwarfDebug : public AsmPrinterHandler { /// Emit macros into a debug macinfo section. void emitDebugMacinfo(); - unsigned emitMacro(AsmStreamerBase *AS, DIMacro &M); - unsigned emitMacroFile(AsmStreamerBase *AS, DIMacroFile &F, - DwarfCompileUnit &U); - unsigned handleMacroNodes(AsmStreamerBase *AS, DIMacroNodeArray Nodes, - DwarfCompileUnit &U); + void emitMacro(DIMacro &M); + void emitMacroFile(DIMacroFile &F, DwarfCompileUnit &U); + void handleMacroNodes(DIMacroNodeArray Nodes, DwarfCompileUnit &U); /// DWARF 5 Experimental Split Dwarf Emitters /// Initialize common features of skeleton units. void initSkeletonUnit(const DwarfUnit &U, DIE &Die, - std::unique_ptr<DwarfUnit> NewU); + std::unique_ptr<DwarfCompileUnit> NewU); /// Construct the split debug info compile unit for the debug info /// section. @@ -460,10 +434,6 @@ class DwarfDebug : public AsmPrinterHandler { void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope, unsigned Flags); - /// Indentify instructions that are marking the beginning of or - /// ending of a scope. - void identifyScopeMarkers(); - /// Populate LexicalScope entries with variables' info. void collectVariableInfo(DwarfCompileUnit &TheCU, const DISubprogram *SP, DenseSet<InlinedVariable> &ProcessedVars); @@ -477,16 +447,6 @@ class DwarfDebug : public AsmPrinterHandler { /// by MMI. void collectVariableInfoFromMMITable(DenseSet<InlinedVariable> &P); - /// Ensure that a label will be emitted before MI. - void requestLabelBeforeInsn(const MachineInstr *MI) { - LabelsBeforeInsn.insert(std::make_pair(MI, nullptr)); - } - - /// Ensure that a label will be emitted after MI. - void requestLabelAfterInsn(const MachineInstr *MI) { - LabelsAfterInsn.insert(std::make_pair(MI, nullptr)); - } - public: //===--------------------------------------------------------------------===// // Main entry points. @@ -511,9 +471,6 @@ public: /// Process beginning of an instruction. void beginInstruction(const MachineInstr *MI) override; - /// Process end of an instruction. - void endInstruction() override; - /// Perform an MD5 checksum of \p Identifier and return the lower 64 bits. static uint64_t makeTypeSignature(StringRef Identifier); @@ -531,21 +488,17 @@ public: SymSize[Sym] = Size; } - /// Returns whether to emit DW_AT_[MIPS_]linkage_name. - bool useLinkageNames() const { return UseLinkageNames; } + /// Returns whether we should emit all DW_AT_[MIPS_]linkage_name. + /// If not, we still might emit certain cases. + bool useAllLinkageNames() const { return UseAllLinkageNames; } /// Returns whether to use DW_OP_GNU_push_tls_address, instead of the /// standard DW_OP_form_tls_address opcode bool useGNUTLSOpcode() const { return UseGNUTLSOpcode; } - /// \defgroup DebuggerTuning Predicates to tune DWARF for a given debugger. - /// - /// Returns whether we are "tuning" for a given debugger. - /// @{ - bool tuneForGDB() const { return DebuggerTuning == DebuggerKind::GDB; } - bool tuneForLLDB() const { return DebuggerTuning == DebuggerKind::LLDB; } - bool tuneForSCE() const { return DebuggerTuning == DebuggerKind::SCE; } - /// @} + /// Returns whether to use the DWARF2 format for bitfields instyead of the + /// DWARF4 format. + bool useDWARF2Bitfields() const { return UseDWARF2Bitfields; } // Experimental DWARF5 features. @@ -553,6 +506,10 @@ public: /// use to accelerate lookup. bool useDwarfAccelTables() const { return HasDwarfAccelTables; } + bool useAppleExtensionAttributes() const { + return HasAppleExtensionAttributes; + } + /// Returns whether or not to change the current debug info for the /// split dwarf proposal support. bool useSplitDwarf() const { return HasSplitDwarf; } @@ -577,12 +534,7 @@ public: /// Find the MDNode for the given reference. template <typename T> T *resolve(TypedDINodeRef<T> Ref) const { - return Ref.resolve(TypeIdentifierMap); - } - - /// Return the TypeIdentifierMap. - const DITypeIdentifierMap &getTypeIdentifierMap() const { - return TypeIdentifierMap; + return Ref.resolve(); } /// Find the DwarfCompileUnit for the given CU Die. @@ -608,12 +560,6 @@ public: /// going to be null. bool isLexicalScopeDIENull(LexicalScope *Scope); - /// Return Label preceding the instruction. - MCSymbol *getLabelBeforeInsn(const MachineInstr *MI); - - /// Return Label immediately following the instruction. - MCSymbol *getLabelAfterInsn(const MachineInstr *MI); - // FIXME: Sink these functions down into DwarfFile/Dwarf*Unit. SmallPtrSet<const MDNode *, 16> &getProcessedSPNodes() { |