Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 1 | //===-- llvm/CodeGen/DwarfDebug.h - Dwarf Debug Framework ------*- C++ -*--===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file contains support for writing dwarf debug info into asm files. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 14 | #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H |
| 15 | #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 16 | |
Timur Iskhodzhanov | 1cd1444 | 2013-12-03 15:10:23 +0000 | [diff] [blame] | 17 | #include "AsmPrinterHandler.h" |
Alexey Samsonov | 414b6fb | 2014-04-30 21:34:11 +0000 | [diff] [blame] | 18 | #include "DbgValueHistoryCalculator.h" |
Duncan P. N. Exon Smith | 364a300 | 2015-04-17 21:34:47 +0000 | [diff] [blame] | 19 | #include "DebugLocStream.h" |
David Blaikie | 2406a062 | 2014-04-23 23:37:35 +0000 | [diff] [blame] | 20 | #include "DwarfAccelTable.h" |
Chandler Carruth | d990388 | 2015-01-14 11:23:27 +0000 | [diff] [blame] | 21 | #include "DwarfFile.h" |
Devang Patel | 018b29b | 2010-01-19 06:19:05 +0000 | [diff] [blame] | 22 | #include "llvm/ADT/DenseMap.h" |
Duncan P. N. Exon Smith | 62e0f45 | 2015-04-15 22:29:27 +0000 | [diff] [blame] | 23 | #include "llvm/ADT/DenseSet.h" |
Chandler Carruth | d990388 | 2015-01-14 11:23:27 +0000 | [diff] [blame] | 24 | #include "llvm/ADT/FoldingSet.h" |
Eric Christopher | acbe42b | 2014-03-18 20:58:35 +0000 | [diff] [blame] | 25 | #include "llvm/ADT/MapVector.h" |
| 26 | #include "llvm/ADT/SmallPtrSet.h" |
| 27 | #include "llvm/ADT/StringMap.h" |
Frederic Riss | e541e0b | 2015-01-05 21:29:41 +0000 | [diff] [blame] | 28 | #include "llvm/CodeGen/DIE.h" |
Chandler Carruth | 802d755 | 2012-12-04 07:12:27 +0000 | [diff] [blame] | 29 | #include "llvm/CodeGen/LexicalScopes.h" |
Adrian Prantl | c119754 | 2014-05-30 21:10:13 +0000 | [diff] [blame] | 30 | #include "llvm/CodeGen/MachineInstr.h" |
Chandler Carruth | 9a4c9e5 | 2014-03-06 00:46:21 +0000 | [diff] [blame] | 31 | #include "llvm/IR/DebugInfo.h" |
Eric Christopher | acbe42b | 2014-03-18 20:58:35 +0000 | [diff] [blame] | 32 | #include "llvm/IR/DebugLoc.h" |
David Blaikie | 4a2f95f | 2014-03-18 01:17:26 +0000 | [diff] [blame] | 33 | #include "llvm/MC/MCDwarf.h" |
Chandler Carruth | d990388 | 2015-01-14 11:23:27 +0000 | [diff] [blame] | 34 | #include "llvm/MC/MachineLocation.h" |
Chris Lattner | 3f3fb97 | 2010-04-05 05:24:55 +0000 | [diff] [blame] | 35 | #include "llvm/Support/Allocator.h" |
David Blaikie | f9b6a55 | 2014-04-22 22:39:41 +0000 | [diff] [blame] | 36 | #include <memory> |
| 37 | |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 38 | namespace llvm { |
| 39 | |
Adrian Prantl | 702bf5a | 2014-03-18 02:34:52 +0000 | [diff] [blame] | 40 | class AsmPrinter; |
Eric Christopher | 29e874d | 2014-03-07 22:40:37 +0000 | [diff] [blame] | 41 | class ByteStreamer; |
Chris Lattner | 88fce10 | 2012-01-26 20:44:57 +0000 | [diff] [blame] | 42 | class ConstantInt; |
| 43 | class ConstantFP; |
Duncan P. N. Exon Smith | 364a300 | 2015-04-17 21:34:47 +0000 | [diff] [blame] | 44 | class DebugLocEntry; |
Eric Christopher | ce4a944 | 2014-03-18 20:37:10 +0000 | [diff] [blame] | 45 | class DwarfCompileUnit; |
| 46 | class DwarfDebug; |
| 47 | class DwarfTypeUnit; |
| 48 | class DwarfUnit; |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 49 | class MachineModuleInfo; |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 50 | |
| 51 | //===----------------------------------------------------------------------===// |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 52 | /// This class is used to record source line correspondence. |
Benjamin Kramer | 079b96e | 2013-09-11 18:05:11 +0000 | [diff] [blame] | 53 | class SrcLineInfo { |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 54 | unsigned Line; // Source line number. |
| 55 | unsigned Column; // Source column. |
| 56 | unsigned SourceID; // Source ID number. |
| 57 | MCSymbol *Label; // Label in code ID number. |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 58 | public: |
Chris Lattner | b4666f4 | 2010-03-14 08:15:55 +0000 | [diff] [blame] | 59 | SrcLineInfo(unsigned L, unsigned C, unsigned S, MCSymbol *label) |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 60 | : Line(L), Column(C), SourceID(S), Label(label) {} |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 61 | |
| 62 | // Accessors |
| 63 | unsigned getLine() const { return Line; } |
| 64 | unsigned getColumn() const { return Column; } |
| 65 | unsigned getSourceID() const { return SourceID; } |
Chris Lattner | b4666f4 | 2010-03-14 08:15:55 +0000 | [diff] [blame] | 66 | MCSymbol *getLabel() const { return Label; } |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 67 | }; |
| 68 | |
Devang Patel | f20c4f7 | 2011-04-12 22:53:02 +0000 | [diff] [blame] | 69 | //===----------------------------------------------------------------------===// |
Duncan P. N. Exon Smith | e6cc531 | 2015-06-21 16:50:43 +0000 | [diff] [blame] | 70 | /// This class is used to track local variable information. |
Adrian Prantl | ca7e470 | 2015-02-10 23:18:28 +0000 | [diff] [blame] | 71 | /// |
Duncan P. N. Exon Smith | e6cc531 | 2015-06-21 16:50:43 +0000 | [diff] [blame] | 72 | /// Variables can be created from allocas, in which case they're generated from |
| 73 | /// the MMI table. Such variables can have multiple expressions and frame |
| 74 | /// indices. The \a Expr and \a FrameIndices array must match. |
Adrian Prantl | ca7e470 | 2015-02-10 23:18:28 +0000 | [diff] [blame] | 75 | /// |
Duncan P. N. Exon Smith | e6cc531 | 2015-06-21 16:50:43 +0000 | [diff] [blame] | 76 | /// Variables can be created from \c DBG_VALUE instructions. Those whose |
| 77 | /// location changes over time use \a DebugLocListIndex, while those with a |
| 78 | /// single instruction use \a MInsn and (optionally) a single entry of \a Expr. |
| 79 | /// |
| 80 | /// Variables that have been optimized out use none of these fields. |
Benjamin Kramer | 079b96e | 2013-09-11 18:05:11 +0000 | [diff] [blame] | 81 | class DbgVariable { |
Duncan P. N. Exon Smith | e6cc531 | 2015-06-21 16:50:43 +0000 | [diff] [blame] | 82 | const DILocalVariable *Var; /// Variable Descriptor. |
| 83 | const DILocation *IA; /// Inlined at location. |
| 84 | SmallVector<const DIExpression *, 1> Expr; /// Complex address. |
| 85 | DIE *TheDIE = nullptr; /// Variable DIE. |
| 86 | unsigned DebugLocListIndex = ~0u; /// Offset in DebugLocs. |
| 87 | const MachineInstr *MInsn = nullptr; /// DBG_VALUE instruction. |
| 88 | SmallVector<int, 1> FrameIndex; /// Frame index. |
Manman Ren | b338860 | 2013-10-05 01:43:03 +0000 | [diff] [blame] | 89 | DwarfDebug *DD; |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 90 | |
Devang Patel | f20c4f7 | 2011-04-12 22:53:02 +0000 | [diff] [blame] | 91 | public: |
Duncan P. N. Exon Smith | e6cc531 | 2015-06-21 16:50:43 +0000 | [diff] [blame] | 92 | /// Construct a DbgVariable. |
| 93 | /// |
| 94 | /// Creates a variable without any DW_AT_location. Call \a initializeMMI() |
| 95 | /// for MMI entries, or \a initializeDbgValue() for DBG_VALUE instructions. |
| 96 | DbgVariable(const DILocalVariable *V, const DILocation *IA, DwarfDebug *DD) |
| 97 | : Var(V), IA(IA), DD(DD) {} |
| 98 | |
| 99 | /// Initialize from the MMI table. |
| 100 | void initializeMMI(const DIExpression *E, int FI) { |
| 101 | assert(Expr.empty() && "Already initialized?"); |
| 102 | assert(FrameIndex.empty() && "Already initialized?"); |
| 103 | assert(!MInsn && "Already initialized?"); |
| 104 | |
| 105 | assert((!E || E->isValid()) && "Expected valid expression"); |
| 106 | assert(~FI && "Expected valid index"); |
| 107 | |
| 108 | Expr.push_back(E); |
Adrian Prantl | ca7e470 | 2015-02-10 23:18:28 +0000 | [diff] [blame] | 109 | FrameIndex.push_back(FI); |
Adrian Prantl | 87b7eb9 | 2014-10-01 18:55:02 +0000 | [diff] [blame] | 110 | } |
Devang Patel | f20c4f7 | 2011-04-12 22:53:02 +0000 | [diff] [blame] | 111 | |
Duncan P. N. Exon Smith | e6cc531 | 2015-06-21 16:50:43 +0000 | [diff] [blame] | 112 | /// Initialize from a DBG_VALUE instruction. |
| 113 | void initializeDbgValue(const MachineInstr *DbgValue) { |
| 114 | assert(Expr.empty() && "Already initialized?"); |
| 115 | assert(FrameIndex.empty() && "Already initialized?"); |
| 116 | assert(!MInsn && "Already initialized?"); |
| 117 | |
| 118 | assert(Var == DbgValue->getDebugVariable() && "Wrong variable"); |
| 119 | assert(IA == DbgValue->getDebugLoc()->getInlinedAt() && "Wrong inlined-at"); |
| 120 | |
| 121 | MInsn = DbgValue; |
| 122 | if (auto *E = DbgValue->getDebugExpression()) |
| 123 | if (E->getNumElements()) |
| 124 | Expr.push_back(E); |
Adrian Prantl | ca7e470 | 2015-02-10 23:18:28 +0000 | [diff] [blame] | 125 | } |
Adrian Prantl | c119754 | 2014-05-30 21:10:13 +0000 | [diff] [blame] | 126 | |
Devang Patel | f20c4f7 | 2011-04-12 22:53:02 +0000 | [diff] [blame] | 127 | // Accessors. |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 128 | const DILocalVariable *getVariable() const { return Var; } |
| 129 | const DILocation *getInlinedAt() const { return IA; } |
| 130 | const ArrayRef<const DIExpression *> getExpression() const { return Expr; } |
David Blaikie | e071fc8 | 2014-04-25 17:32:19 +0000 | [diff] [blame] | 131 | void setDIE(DIE &D) { TheDIE = &D; } |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 132 | DIE *getDIE() const { return TheDIE; } |
Duncan P. N. Exon Smith | 364a300 | 2015-04-17 21:34:47 +0000 | [diff] [blame] | 133 | void setDebugLocListIndex(unsigned O) { DebugLocListIndex = O; } |
| 134 | unsigned getDebugLocListIndex() const { return DebugLocListIndex; } |
Duncan P. N. Exon Smith | 7348dda | 2015-04-14 02:22:36 +0000 | [diff] [blame] | 135 | StringRef getName() const { return Var->getName(); } |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 136 | const MachineInstr *getMInsn() const { return MInsn; } |
Adrian Prantl | ca7e470 | 2015-02-10 23:18:28 +0000 | [diff] [blame] | 137 | const ArrayRef<int> getFrameIndex() const { return FrameIndex; } |
| 138 | |
| 139 | void addMMIEntry(const DbgVariable &V) { |
Duncan P. N. Exon Smith | 364a300 | 2015-04-17 21:34:47 +0000 | [diff] [blame] | 140 | assert(DebugLocListIndex == ~0U && !MInsn && "not an MMI entry"); |
| 141 | assert(V.DebugLocListIndex == ~0U && !V.MInsn && "not an MMI entry"); |
Duncan P. N. Exon Smith | 60635e3 | 2015-04-21 18:44:06 +0000 | [diff] [blame] | 142 | assert(V.Var == Var && "conflicting variable"); |
Duncan P. N. Exon Smith | 62e0f45 | 2015-04-15 22:29:27 +0000 | [diff] [blame] | 143 | assert(V.IA == IA && "conflicting inlined-at location"); |
Adrian Prantl | ca7e470 | 2015-02-10 23:18:28 +0000 | [diff] [blame] | 144 | |
Duncan P. N. Exon Smith | e6cc531 | 2015-06-21 16:50:43 +0000 | [diff] [blame] | 145 | assert(!FrameIndex.empty() && "Expected an MMI entry"); |
| 146 | assert(!V.FrameIndex.empty() && "Expected an MMI entry"); |
| 147 | assert(Expr.size() == FrameIndex.size() && "Mismatched expressions"); |
| 148 | assert(V.Expr.size() == V.FrameIndex.size() && "Mismatched expressions"); |
| 149 | |
| 150 | Expr.append(V.Expr.begin(), V.Expr.end()); |
| 151 | FrameIndex.append(V.FrameIndex.begin(), V.FrameIndex.end()); |
| 152 | assert(std::all_of(Expr.begin(), Expr.end(), [](const DIExpression *E) { |
| 153 | return E && E->isBitPiece(); |
| 154 | }) && "conflicting locations for variable"); |
Adrian Prantl | ca7e470 | 2015-02-10 23:18:28 +0000 | [diff] [blame] | 155 | } |
| 156 | |
Eric Christopher | 27527b2 | 2012-11-21 00:03:28 +0000 | [diff] [blame] | 157 | // Translate tag to proper Dwarf tag. |
David Blaikie | efc403b | 2014-04-12 02:24:04 +0000 | [diff] [blame] | 158 | dwarf::Tag getTag() const { |
Duncan P. N. Exon Smith | 7348dda | 2015-04-14 02:22:36 +0000 | [diff] [blame] | 159 | if (Var->getTag() == dwarf::DW_TAG_arg_variable) |
Devang Patel | 6e4d2c9 | 2011-08-15 18:35:42 +0000 | [diff] [blame] | 160 | return dwarf::DW_TAG_formal_parameter; |
Eric Christopher | 27527b2 | 2012-11-21 00:03:28 +0000 | [diff] [blame] | 161 | |
Devang Patel | 6e4d2c9 | 2011-08-15 18:35:42 +0000 | [diff] [blame] | 162 | return dwarf::DW_TAG_variable; |
| 163 | } |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 164 | /// Return true if DbgVariable is artificial. |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 165 | bool isArtificial() const { |
Duncan P. N. Exon Smith | 7348dda | 2015-04-14 02:22:36 +0000 | [diff] [blame] | 166 | if (Var->isArtificial()) |
Devang Patel | d7d80aa | 2011-08-15 18:40:16 +0000 | [diff] [blame] | 167 | return true; |
Duncan P. N. Exon Smith | b105564 | 2015-04-16 01:01:28 +0000 | [diff] [blame] | 168 | if (getType()->isArtificial()) |
Devang Patel | d7d80aa | 2011-08-15 18:40:16 +0000 | [diff] [blame] | 169 | return true; |
| 170 | return false; |
| 171 | } |
Eric Christopher | e341776 | 2012-09-12 23:36:19 +0000 | [diff] [blame] | 172 | |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 173 | bool isObjectPointer() const { |
Duncan P. N. Exon Smith | 7348dda | 2015-04-14 02:22:36 +0000 | [diff] [blame] | 174 | if (Var->isObjectPointer()) |
Eric Christopher | e341776 | 2012-09-12 23:36:19 +0000 | [diff] [blame] | 175 | return true; |
Duncan P. N. Exon Smith | b105564 | 2015-04-16 01:01:28 +0000 | [diff] [blame] | 176 | if (getType()->isObjectPointer()) |
Eric Christopher | e341776 | 2012-09-12 23:36:19 +0000 | [diff] [blame] | 177 | return true; |
| 178 | return false; |
| 179 | } |
Eric Christopher | 27527b2 | 2012-11-21 00:03:28 +0000 | [diff] [blame] | 180 | |
Duncan P. N. Exon Smith | e6cc531 | 2015-06-21 16:50:43 +0000 | [diff] [blame] | 181 | bool hasComplexAddress() const { |
| 182 | assert(MInsn && "Expected DBG_VALUE, not MMI variable"); |
| 183 | assert(FrameIndex.empty() && "Expected DBG_VALUE, not MMI variable"); |
| 184 | assert( |
| 185 | (Expr.empty() || (Expr.size() == 1 && Expr.back()->getNumElements())) && |
| 186 | "Invalid Expr for DBG_VALUE"); |
| 187 | return !Expr.empty(); |
Devang Patel | f20c4f7 | 2011-04-12 22:53:02 +0000 | [diff] [blame] | 188 | } |
Adrian Prantl | 1a1647c | 2014-03-18 02:34:58 +0000 | [diff] [blame] | 189 | bool isBlockByrefVariable() const; |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 190 | const DIType *getType() const; |
Manman Ren | be5576f | 2013-10-08 19:07:44 +0000 | [diff] [blame] | 191 | |
| 192 | private: |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 193 | /// Look in the DwarfDebug map for the MDNode that |
Manman Ren | be5576f | 2013-10-08 19:07:44 +0000 | [diff] [blame] | 194 | /// corresponds to the reference. |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 195 | template <typename T> T *resolve(TypedDINodeRef<T> Ref) const; |
Devang Patel | f20c4f7 | 2011-04-12 22:53:02 +0000 | [diff] [blame] | 196 | }; |
| 197 | |
Eric Christopher | c8a310e | 2012-12-10 23:34:43 +0000 | [diff] [blame] | 198 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 199 | /// Helper used to pair up a symbol and its DWARF compile unit. |
Richard Mitton | 21101b3 | 2013-09-19 23:21:01 +0000 | [diff] [blame] | 200 | struct SymbolCU { |
Eric Christopher | 4287a49 | 2013-12-09 23:57:44 +0000 | [diff] [blame] | 201 | SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {} |
Richard Mitton | 21101b3 | 2013-09-19 23:21:01 +0000 | [diff] [blame] | 202 | const MCSymbol *Sym; |
Eric Christopher | 4287a49 | 2013-12-09 23:57:44 +0000 | [diff] [blame] | 203 | DwarfCompileUnit *CU; |
Richard Mitton | 21101b3 | 2013-09-19 23:21:01 +0000 | [diff] [blame] | 204 | }; |
| 205 | |
Paul Robinson | b9de106 | 2015-07-15 22:04:54 +0000 | [diff] [blame^] | 206 | /// Identify a debugger for "tuning" the debug info. |
| 207 | /// |
| 208 | /// The "debugger tuning" concept allows us to present a more intuitive |
| 209 | /// interface that unpacks into different sets of defaults for the various |
| 210 | /// individual feature-flag settings, that suit the preferences of the |
| 211 | /// various debuggers. However, it's worth remembering that debuggers are |
| 212 | /// not the only consumers of debug info, and some variations in DWARF might |
| 213 | /// better be treated as target/platform issues. Fundamentally, |
| 214 | /// o if the feature is useful (or not) to a particular debugger, regardless |
| 215 | /// of the target, that's a tuning decision; |
| 216 | /// o if the feature is useful (or not) on a particular platform, regardless |
| 217 | /// of the debugger, that's a target decision. |
| 218 | /// It's not impossible to see both factors in some specific case. |
| 219 | /// |
| 220 | /// The "tuning" should be used to set defaults for individual feature flags |
| 221 | /// in DwarfDebug; if a given feature has a more specific command-line option, |
| 222 | /// that option should take precedence over the tuning. |
| 223 | enum class DebuggerKind { |
| 224 | Default, // No specific tuning requested. |
| 225 | GDB, // Tune debug info for gdb. |
| 226 | LLDB, // Tune debug info for lldb. |
| 227 | SCE // Tune debug info for SCE targets (e.g. PS4). |
| 228 | }; |
| 229 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 230 | /// Collects and handles dwarf debug information. |
Timur Iskhodzhanov | 1cd1444 | 2013-12-03 15:10:23 +0000 | [diff] [blame] | 231 | class DwarfDebug : public AsmPrinterHandler { |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 232 | /// Target of Dwarf emission. |
Chris Lattner | 3a383cb | 2010-04-05 00:13:49 +0000 | [diff] [blame] | 233 | AsmPrinter *Asm; |
Chris Lattner | acda87b | 2010-04-05 05:31:04 +0000 | [diff] [blame] | 234 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 235 | /// Collected machine module information. |
Chris Lattner | 3a383cb | 2010-04-05 00:13:49 +0000 | [diff] [blame] | 236 | MachineModuleInfo *MMI; |
| 237 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 238 | /// All DIEValues are allocated through this allocator. |
Benjamin Kramer | 0748008 | 2012-06-09 10:34:15 +0000 | [diff] [blame] | 239 | BumpPtrAllocator DIEValueAllocator; |
| 240 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 241 | /// Maps MDNode with its corresponding DwarfCompileUnit. |
Eric Christopher | 179fba1 | 2014-01-29 22:06:23 +0000 | [diff] [blame] | 242 | MapVector<const MDNode *, DwarfCompileUnit *> CUMap; |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 243 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 244 | /// Maps subprogram MDNode with its corresponding DwarfCompileUnit. |
David Blaikie | 7d6f29d | 2014-10-10 16:59:52 +0000 | [diff] [blame] | 245 | MapVector<const MDNode *, DwarfCompileUnit *> SPMap; |
Devang Patel | eb1bb4e | 2011-08-16 22:09:43 +0000 | [diff] [blame] | 246 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 247 | /// Maps a CU DIE with its corresponding DwarfCompileUnit. |
Eric Christopher | 4287a49 | 2013-12-09 23:57:44 +0000 | [diff] [blame] | 248 | DenseMap<const DIE *, DwarfCompileUnit *> CUDieMap; |
Manman Ren | ce20d46 | 2013-10-29 22:57:10 +0000 | [diff] [blame] | 249 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 250 | /// List of all labels used in aranges generation. |
Alexey Samsonov | 4436bf0 | 2013-10-03 08:54:43 +0000 | [diff] [blame] | 251 | std::vector<SymbolCU> ArangeLabels; |
Richard Mitton | 21101b3 | 2013-09-19 23:21:01 +0000 | [diff] [blame] | 252 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 253 | /// Size of each symbol emitted (for those symbols that have a specific size). |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 254 | DenseMap<const MCSymbol *, uint64_t> SymSize; |
Richard Mitton | 089ed89 | 2013-09-23 17:56:20 +0000 | [diff] [blame] | 255 | |
Devang Patel | 7e62302 | 2011-08-10 20:55:27 +0000 | [diff] [blame] | 256 | LexicalScopes LScopes; |
Devang Patel | 95cd4b9 | 2010-03-25 15:09:44 +0000 | [diff] [blame] | 257 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 258 | /// Collection of abstract variables. |
David Blaikie | 825bdd2 | 2014-05-21 22:41:17 +0000 | [diff] [blame] | 259 | DenseMap<const MDNode *, std::unique_ptr<DbgVariable>> AbstractVariables; |
David Blaikie | eb1a272 | 2014-06-13 22:18:23 +0000 | [diff] [blame] | 260 | SmallVector<std::unique_ptr<DbgVariable>, 64> ConcreteVariables; |
Devang Patel | f6eeaeb | 2009-11-10 23:06:00 +0000 | [diff] [blame] | 261 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 262 | /// Collection of DebugLocEntry. Stored in a linked list so that DIELocLists |
| 263 | /// can refer to them in spite of insertions into this list. |
Duncan P. N. Exon Smith | 364a300 | 2015-04-17 21:34:47 +0000 | [diff] [blame] | 264 | DebugLocStream DebugLocs; |
Devang Patel | 9fc1170 | 2010-05-25 23:40:22 +0000 | [diff] [blame] | 265 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 266 | /// This is a collection of subprogram MDNodes that are processed to |
| 267 | /// create DIEs. |
Devang Patel | f3b2db6 | 2010-06-28 18:25:03 +0000 | [diff] [blame] | 268 | SmallPtrSet<const MDNode *, 16> ProcessedSPNodes; |
| 269 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 270 | /// Maps instruction with label emitted before instruction. |
Devang Patel | 6c74a87 | 2010-04-27 19:46:33 +0000 | [diff] [blame] | 271 | DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn; |
Devang Patel | 3ebd893 | 2010-04-08 16:50:29 +0000 | [diff] [blame] | 272 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 273 | /// Maps instruction with label emitted after instruction. |
Devang Patel | 6c74a87 | 2010-04-27 19:46:33 +0000 | [diff] [blame] | 274 | DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn; |
Devang Patel | 3ebd893 | 2010-04-08 16:50:29 +0000 | [diff] [blame] | 275 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 276 | /// History of DBG_VALUE and clobber instructions for each user |
| 277 | /// variable. Variables are listed in order of appearance. |
Jakob Stoklund Olesen | 9a624fa | 2011-03-26 02:19:36 +0000 | [diff] [blame] | 278 | DbgValueHistoryMap DbgValues; |
Jakob Stoklund Olesen | ec0ac3c | 2011-03-22 22:33:08 +0000 | [diff] [blame] | 279 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 280 | /// Previous instruction's location information. This is used to |
| 281 | /// determine label location to indicate scope boundries in dwarf |
| 282 | /// debug info. |
Chris Lattner | 915c5f9 | 2010-04-02 19:42:39 +0000 | [diff] [blame] | 283 | DebugLoc PrevInstLoc; |
Devang Patel | 12563b3 | 2010-04-16 23:33:45 +0000 | [diff] [blame] | 284 | MCSymbol *PrevLabel; |
Devang Patel | bd477be | 2010-03-29 17:20:31 +0000 | [diff] [blame] | 285 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 286 | /// This location indicates end of function prologue and beginning of |
| 287 | /// function body. |
Devang Patel | 34a6620 | 2011-05-11 19:22:19 +0000 | [diff] [blame] | 288 | DebugLoc PrologEndLoc; |
| 289 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 290 | /// If nonnull, stores the current machine function we're processing. |
Timur Iskhodzhanov | 1cd1444 | 2013-12-03 15:10:23 +0000 | [diff] [blame] | 291 | const MachineFunction *CurFn; |
| 292 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 293 | /// If nonnull, stores the current machine instruction we're processing. |
Timur Iskhodzhanov | 1cd1444 | 2013-12-03 15:10:23 +0000 | [diff] [blame] | 294 | const MachineInstr *CurMI; |
| 295 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 296 | /// If nonnull, stores the CU in which the previous subprogram was contained. |
Eric Christopher | 384f3fe | 2014-03-20 19:16:16 +0000 | [diff] [blame] | 297 | const DwarfCompileUnit *PrevCU; |
| 298 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 299 | /// As an optimization, there is no need to emit an entry in the directory |
| 300 | /// table for the same directory as DW_AT_comp_dir. |
Nick Lewycky | d1ee7f8 | 2011-11-02 20:55:33 +0000 | [diff] [blame] | 301 | StringRef CompilationDir; |
| 302 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 303 | /// Holder for the file specific debug information. |
Eric Christopher | f819485 | 2013-12-05 18:06:10 +0000 | [diff] [blame] | 304 | DwarfFile InfoHolder; |
Eric Christopher | c8a310e | 2012-12-10 23:34:43 +0000 | [diff] [blame] | 305 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 306 | /// Holders for the various debug information flags that we might need to |
| 307 | /// have exposed. See accessor functions below for description. |
David Blaikie | d51dea6 | 2015-07-01 18:07:16 +0000 | [diff] [blame] | 308 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 309 | /// Holder for imported entities. |
Eric Christopher | 070bf16 | 2013-07-03 01:57:26 +0000 | [diff] [blame] | 310 | typedef SmallVector<std::pair<const MDNode *, const MDNode *>, 32> |
David Blaikie | d51dea6 | 2015-07-01 18:07:16 +0000 | [diff] [blame] | 311 | ImportedEntityMap; |
| 312 | ImportedEntityMap ScopesWithImportedEntities; |
Eric Christopher | 070bf16 | 2013-07-03 01:57:26 +0000 | [diff] [blame] | 313 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 314 | /// Map from MDNodes for user-defined types to the type units that |
| 315 | /// describe them. |
David Blaikie | 47f615e | 2013-12-17 23:32:35 +0000 | [diff] [blame] | 316 | DenseMap<const MDNode *, const DwarfTypeUnit *> DwarfTypeUnits; |
Eric Christopher | 6764643 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 317 | |
Duncan P. N. Exon Smith | c624688 | 2015-04-20 21:17:32 +0000 | [diff] [blame] | 318 | SmallVector< |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 319 | std::pair<std::unique_ptr<DwarfTypeUnit>, const DICompositeType *>, 1> |
Eric Christopher | ffc5ff3 | 2015-02-17 20:02:28 +0000 | [diff] [blame] | 320 | TypeUnitsUnderConstruction; |
David Blaikie | e12b49a | 2014-04-26 17:27:38 +0000 | [diff] [blame] | 321 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 322 | /// Whether to emit the pubnames/pubtypes sections. |
Eric Christopher | 4d36ca0 | 2013-08-26 23:24:35 +0000 | [diff] [blame] | 323 | bool HasDwarfPubSections; |
| 324 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 325 | /// Whether or not to use AT_ranges for compilation units. |
Eric Christopher | 1ad8457 | 2014-01-15 00:04:29 +0000 | [diff] [blame] | 326 | bool HasCURanges; |
| 327 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 328 | /// Whether we emitted a function into a section other than the |
| 329 | /// default text. |
Eric Christopher | 2037caf | 2014-01-28 00:49:26 +0000 | [diff] [blame] | 330 | bool UsedNonDefaultText; |
| 331 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 332 | /// Whether to use the GNU TLS opcode (instead of the standard opcode). |
Paul Robinson | 78cc082 | 2015-03-04 20:55:11 +0000 | [diff] [blame] | 333 | bool UseGNUTLSOpcode; |
| 334 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 335 | /// Version of dwarf we're emitting. |
Eric Christopher | 4d36ca0 | 2013-08-26 23:24:35 +0000 | [diff] [blame] | 336 | unsigned DwarfVersion; |
| 337 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 338 | /// Maps from a type identifier to the actual MDNode. |
Eric Christopher | 0a13eb3 | 2013-11-21 22:56:11 +0000 | [diff] [blame] | 339 | DITypeIdentifierMap TypeIdentifierMap; |
| 340 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 341 | /// DWARF5 Experimental Options |
| 342 | /// @{ |
Eric Christopher | 7b30f2e4 | 2012-11-21 00:34:35 +0000 | [diff] [blame] | 343 | bool HasDwarfAccelTables; |
Eric Christopher | cdf218d | 2012-12-10 19:51:21 +0000 | [diff] [blame] | 344 | bool HasSplitDwarf; |
Manman Ren | ac8062b | 2013-07-02 23:40:10 +0000 | [diff] [blame] | 345 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 346 | /// Separated Dwarf Variables |
| 347 | /// In general these will all be for bits that are left in the |
| 348 | /// original object file, rather than things that are meant |
| 349 | /// to be in the .dwo sections. |
Eric Christopher | d79f548 | 2012-12-10 19:51:13 +0000 | [diff] [blame] | 350 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 351 | /// Holder for the skeleton information. |
Eric Christopher | f819485 | 2013-12-05 18:06:10 +0000 | [diff] [blame] | 352 | DwarfFile SkeletonHolder; |
Eric Christopher | d79f548 | 2012-12-10 19:51:13 +0000 | [diff] [blame] | 353 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 354 | /// Store file names for type units under fission in a line table |
| 355 | /// header that will be emitted into debug_line.dwo. |
| 356 | // FIXME: replace this with a map from comp_dir to table so that we |
| 357 | // can emit multiple tables during LTO each of which uses directory |
| 358 | // 0, referencing the comp_dir of all the type units that use it. |
David Blaikie | 8287aff | 2014-03-18 02:13:23 +0000 | [diff] [blame] | 359 | MCDwarfDwoLineTable SplitTypeUnitFileTable; |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 360 | /// @} |
| 361 | |
| 362 | /// True iff there are multiple CUs in this module. |
David Blaikie | 47f4b82 | 2014-03-19 00:11:28 +0000 | [diff] [blame] | 363 | bool SingleCU; |
David Blaikie | e1c7974 | 2014-09-30 21:28:32 +0000 | [diff] [blame] | 364 | bool IsDarwin; |
David Blaikie | 47f4b82 | 2014-03-19 00:11:28 +0000 | [diff] [blame] | 365 | |
David Blaikie | d75fb28 | 2014-04-23 21:20:10 +0000 | [diff] [blame] | 366 | AddressPool AddrPool; |
| 367 | |
David Blaikie | 2406a062 | 2014-04-23 23:37:35 +0000 | [diff] [blame] | 368 | DwarfAccelTable AccelNames; |
David Blaikie | 0ee82b9 | 2014-04-24 00:53:32 +0000 | [diff] [blame] | 369 | DwarfAccelTable AccelObjC; |
David Blaikie | ecf0415 | 2014-04-24 01:02:42 +0000 | [diff] [blame] | 370 | DwarfAccelTable AccelNamespace; |
David Blaikie | 18d3375 | 2014-04-24 01:23:49 +0000 | [diff] [blame] | 371 | DwarfAccelTable AccelTypes; |
David Blaikie | 2406a062 | 2014-04-23 23:37:35 +0000 | [diff] [blame] | 372 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 373 | DenseMap<const Function *, DISubprogram *> FunctionDIs; |
David Blaikie | 2f04011 | 2014-07-25 16:10:16 +0000 | [diff] [blame] | 374 | |
Paul Robinson | b9de106 | 2015-07-15 22:04:54 +0000 | [diff] [blame^] | 375 | // Identify a debugger for "tuning" the debug info. |
| 376 | DebuggerKind DebuggerTuning; |
| 377 | |
David Blaikie | 47f4b82 | 2014-03-19 00:11:28 +0000 | [diff] [blame] | 378 | MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &); |
| 379 | |
David Blaikie | c33b3cd | 2014-04-22 21:27:37 +0000 | [diff] [blame] | 380 | const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() { |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 381 | return InfoHolder.getUnits(); |
| 382 | } |
David Blaikie | fd1eff5 | 2013-11-26 19:14:34 +0000 | [diff] [blame] | 383 | |
Duncan P. N. Exon Smith | 62e0f45 | 2015-04-15 22:29:27 +0000 | [diff] [blame] | 384 | typedef DbgValueHistoryMap::InlinedVariable InlinedVariable; |
| 385 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 386 | /// Find abstract variable associated with Var. |
Duncan P. N. Exon Smith | 62e0f45 | 2015-04-15 22:29:27 +0000 | [diff] [blame] | 387 | DbgVariable *getExistingAbstractVariable(InlinedVariable IV, |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 388 | const DILocalVariable *&Cleansed); |
Duncan P. N. Exon Smith | 62e0f45 | 2015-04-15 22:29:27 +0000 | [diff] [blame] | 389 | DbgVariable *getExistingAbstractVariable(InlinedVariable IV); |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 390 | void createAbstractVariable(const DILocalVariable *DV, LexicalScope *Scope); |
Duncan P. N. Exon Smith | 62e0f45 | 2015-04-15 22:29:27 +0000 | [diff] [blame] | 391 | void ensureAbstractVariableIsCreated(InlinedVariable Var, |
David Blaikie | 6f9e867 | 2014-06-13 23:52:55 +0000 | [diff] [blame] | 392 | const MDNode *Scope); |
Duncan P. N. Exon Smith | 62e0f45 | 2015-04-15 22:29:27 +0000 | [diff] [blame] | 393 | void ensureAbstractVariableIsCreatedIfScoped(InlinedVariable Var, |
David Blaikie | 6f9e867 | 2014-06-13 23:52:55 +0000 | [diff] [blame] | 394 | const MDNode *Scope); |
Devang Patel | f6eeaeb | 2009-11-10 23:06:00 +0000 | [diff] [blame] | 395 | |
Duncan P. N. Exon Smith | e6cc531 | 2015-06-21 16:50:43 +0000 | [diff] [blame] | 396 | DbgVariable *createConcreteVariable(LexicalScope &Scope, InlinedVariable IV); |
| 397 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 398 | /// Construct a DIE for this abstract scope. |
David Blaikie | 73cc705 | 2014-10-09 20:36:27 +0000 | [diff] [blame] | 399 | void constructAbstractSubprogramScopeDIE(LexicalScope *Scope); |
| 400 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 401 | /// Compute the size and offset of a DIE given an incoming Offset. |
Eric Christopher | 1f0cbb8 | 2012-11-20 22:14:13 +0000 | [diff] [blame] | 402 | unsigned computeSizeAndOffset(DIE *Die, unsigned Offset); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 403 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 404 | /// Compute the size and offset of all the DIEs. |
Devang Patel | 930143b | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 405 | void computeSizeAndOffsets(); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 406 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 407 | /// Collect info for variables that were optimized out. |
Eric Christopher | 960ac37 | 2012-11-22 00:59:49 +0000 | [diff] [blame] | 408 | void collectDeadVariables(); |
| 409 | |
David Blaikie | eb1a272 | 2014-06-13 22:18:23 +0000 | [diff] [blame] | 410 | void finishVariableDefinitions(); |
| 411 | |
David Blaikie | f7221ad | 2014-05-27 18:37:43 +0000 | [diff] [blame] | 412 | void finishSubprogramDefinitions(); |
| 413 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 414 | /// Finish off debug information after all functions have been |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 415 | /// processed. |
Eric Christopher | 960ac37 | 2012-11-22 00:59:49 +0000 | [diff] [blame] | 416 | void finalizeModuleInfo(); |
| 417 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 418 | /// Emit the debug info section. |
Devang Patel | 930143b | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 419 | void emitDebugInfo(); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 420 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 421 | /// Emit the abbreviation section. |
Eric Christopher | 3837195 | 2012-11-20 23:30:11 +0000 | [diff] [blame] | 422 | void emitAbbreviations(); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 423 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 424 | /// Emit a specified accelerator table. |
Rafael Espindola | 0709a7b | 2015-05-21 19:20:38 +0000 | [diff] [blame] | 425 | void emitAccel(DwarfAccelTable &Accel, MCSection *Section, |
Rafael Espindola | 6b9998b | 2015-03-10 22:00:25 +0000 | [diff] [blame] | 426 | StringRef TableName); |
David Blaikie | 6741bb0 | 2014-09-11 21:12:48 +0000 | [diff] [blame] | 427 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 428 | /// Emit visible names into a hashed accelerator table section. |
Eric Christopher | 4996c70 | 2011-11-07 09:24:32 +0000 | [diff] [blame] | 429 | void emitAccelNames(); |
Eric Christopher | 27527b2 | 2012-11-21 00:03:28 +0000 | [diff] [blame] | 430 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 431 | /// Emit objective C classes and categories into a hashed |
Eric Christopher | 4996c70 | 2011-11-07 09:24:32 +0000 | [diff] [blame] | 432 | /// accelerator table section. |
| 433 | void emitAccelObjC(); |
| 434 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 435 | /// Emit namespace dies into a hashed accelerator table. |
Eric Christopher | 4996c70 | 2011-11-07 09:24:32 +0000 | [diff] [blame] | 436 | void emitAccelNamespaces(); |
| 437 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 438 | /// Emit type dies into a hashed accelerator table. |
Eric Christopher | 4996c70 | 2011-11-07 09:24:32 +0000 | [diff] [blame] | 439 | void emitAccelTypes(); |
Eric Christopher | 27527b2 | 2012-11-21 00:03:28 +0000 | [diff] [blame] | 440 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 441 | /// Emit visible names into a debug pubnames section. |
Eric Christopher | dd1a012 | 2013-09-13 00:35:05 +0000 | [diff] [blame] | 442 | /// \param GnuStyle determines whether or not we want to emit |
| 443 | /// additional information into the table ala newer gcc for gdb |
| 444 | /// index. |
| 445 | void emitDebugPubNames(bool GnuStyle = false); |
Krzysztof Parzyszek | 228daa6 | 2013-02-12 18:00:14 +0000 | [diff] [blame] | 446 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 447 | /// Emit visible types into a debug pubtypes section. |
Eric Christopher | dd1a012 | 2013-09-13 00:35:05 +0000 | [diff] [blame] | 448 | /// \param GnuStyle determines whether or not we want to emit |
| 449 | /// additional information into the table ala newer gcc for gdb |
| 450 | /// index. |
| 451 | void emitDebugPubTypes(bool GnuStyle = false); |
Devang Patel | 04d2f2d | 2009-11-24 01:14:22 +0000 | [diff] [blame] | 452 | |
David Blaikie | 192b45c | 2014-11-02 06:16:39 +0000 | [diff] [blame] | 453 | void emitDebugPubSection( |
Rafael Espindola | 0709a7b | 2015-05-21 19:20:38 +0000 | [diff] [blame] | 454 | bool GnuStyle, MCSection *PSec, StringRef Name, |
David Blaikie | 192b45c | 2014-11-02 06:16:39 +0000 | [diff] [blame] | 455 | const StringMap<const DIE *> &(DwarfCompileUnit::*Accessor)() const); |
David Blaikie | 0f55e83 | 2014-03-11 23:18:15 +0000 | [diff] [blame] | 456 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 457 | /// Emit visible names into a debug str section. |
Devang Patel | 930143b | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 458 | void emitDebugStr(); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 459 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 460 | /// Emit visible names into a debug loc section. |
Devang Patel | 930143b | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 461 | void emitDebugLoc(); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 462 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 463 | /// Emit visible names into a debug loc dwo section. |
David Blaikie | 94c1d7f | 2014-04-02 01:50:20 +0000 | [diff] [blame] | 464 | void emitDebugLocDWO(); |
| 465 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 466 | /// Emit visible names into a debug aranges section. |
Eric Christopher | 7b30f2e4 | 2012-11-21 00:34:35 +0000 | [diff] [blame] | 467 | void emitDebugARanges(); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 468 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 469 | /// Emit visible names into a debug ranges section. |
Devang Patel | 930143b | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 470 | void emitDebugRanges(); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 471 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 472 | /// Emit inline info using custom format. |
Devang Patel | 930143b | 2009-11-21 02:48:08 +0000 | [diff] [blame] | 473 | void emitDebugInlineInfo(); |
Bill Wendling | 2b128d7 | 2009-05-20 23:19:06 +0000 | [diff] [blame] | 474 | |
Eric Christopher | cdf218d | 2012-12-10 19:51:21 +0000 | [diff] [blame] | 475 | /// DWARF 5 Experimental Split Dwarf Emitters |
Eric Christopher | 9c2ecd9 | 2012-11-30 23:59:06 +0000 | [diff] [blame] | 476 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 477 | /// Initialize common features of skeleton units. |
David Blaikie | 65a7466 | 2014-04-25 18:26:14 +0000 | [diff] [blame] | 478 | void initSkeletonUnit(const DwarfUnit &U, DIE &Die, |
David Blaikie | f9b6a55 | 2014-04-22 22:39:41 +0000 | [diff] [blame] | 479 | std::unique_ptr<DwarfUnit> NewU); |
David Blaikie | 38fe634 | 2014-01-09 04:28:46 +0000 | [diff] [blame] | 480 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 481 | /// Construct the split debug info compile unit for the debug info |
Eric Christopher | cdf218d | 2012-12-10 19:51:21 +0000 | [diff] [blame] | 482 | /// section. |
David Blaikie | f9b6a55 | 2014-04-22 22:39:41 +0000 | [diff] [blame] | 483 | DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU); |
Eric Christopher | 9c2ecd9 | 2012-11-30 23:59:06 +0000 | [diff] [blame] | 484 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 485 | /// Construct the split debug info compile unit for the debug info |
David Blaikie | 15ed5eb | 2014-01-10 01:38:41 +0000 | [diff] [blame] | 486 | /// section. |
David Blaikie | f9b6a55 | 2014-04-22 22:39:41 +0000 | [diff] [blame] | 487 | DwarfTypeUnit &constructSkeletonTU(DwarfTypeUnit &TU); |
David Blaikie | 15ed5eb | 2014-01-10 01:38:41 +0000 | [diff] [blame] | 488 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 489 | /// Emit the debug info dwo section. |
Eric Christopher | 9c2ecd9 | 2012-11-30 23:59:06 +0000 | [diff] [blame] | 490 | void emitDebugInfoDWO(); |
| 491 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 492 | /// Emit the debug abbrev dwo section. |
Eric Christopher | 3c5a191 | 2012-12-19 22:02:53 +0000 | [diff] [blame] | 493 | void emitDebugAbbrevDWO(); |
| 494 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 495 | /// Emit the debug line dwo section. |
David Blaikie | 4a2f95f | 2014-03-18 01:17:26 +0000 | [diff] [blame] | 496 | void emitDebugLineDWO(); |
| 497 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 498 | /// Emit the debug str dwo section. |
Eric Christopher | 3bf29fd | 2012-12-27 02:14:01 +0000 | [diff] [blame] | 499 | void emitDebugStrDWO(); |
| 500 | |
David Blaikie | 3c84262 | 2013-12-04 21:31:26 +0000 | [diff] [blame] | 501 | /// Flags to let the linker know we have emitted new style pubnames. Only |
| 502 | /// emit it here if we don't have a skeleton CU for split dwarf. |
David Blaikie | 65a7466 | 2014-04-25 18:26:14 +0000 | [diff] [blame] | 503 | void addGnuPubAttributes(DwarfUnit &U, DIE &D) const; |
David Blaikie | 3c84262 | 2013-12-04 21:31:26 +0000 | [diff] [blame] | 504 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 505 | /// Create new DwarfCompileUnit for the given metadata node with tag |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 506 | /// DW_TAG_compile_unit. |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 507 | DwarfCompileUnit &constructDwarfCompileUnit(const DICompileUnit *DIUnit); |
Devang Patel | 1a0df9a | 2010-05-10 22:49:55 +0000 | [diff] [blame] | 508 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 509 | /// Construct imported_module or imported_declaration DIE. |
David Blaikie | 8912df1 | 2014-08-31 05:41:15 +0000 | [diff] [blame] | 510 | void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU, |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 511 | const DIImportedEntity *N); |
David Blaikie | 684fc53 | 2013-05-06 23:33:07 +0000 | [diff] [blame] | 512 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 513 | /// Register a source line with debug info. Returns the unique |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 514 | /// label that was emitted and which provides correspondence to the |
| 515 | /// source line list. |
Devang Patel | 34a6620 | 2011-05-11 19:22:19 +0000 | [diff] [blame] | 516 | void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope, |
| 517 | unsigned Flags); |
Eric Christopher | 27527b2 | 2012-11-21 00:03:28 +0000 | [diff] [blame] | 518 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 519 | /// Indentify instructions that are marking the beginning of or |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 520 | /// ending of a scope. |
Devang Patel | 359b013 | 2010-04-08 18:43:56 +0000 | [diff] [blame] | 521 | void identifyScopeMarkers(); |
Devang Patel | f1d5a1e | 2010-04-08 15:37:09 +0000 | [diff] [blame] | 522 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 523 | /// Populate LexicalScope entries with variables' info. |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 524 | void collectVariableInfo(DwarfCompileUnit &TheCU, const DISubprogram *SP, |
Duncan P. N. Exon Smith | 62e0f45 | 2015-04-15 22:29:27 +0000 | [diff] [blame] | 525 | DenseSet<InlinedVariable> &ProcessedVars); |
Eric Christopher | 27527b2 | 2012-11-21 00:03:28 +0000 | [diff] [blame] | 526 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 527 | /// Build the location list for all DBG_VALUEs in the |
Adrian Prantl | b141683 | 2014-08-01 22:11:58 +0000 | [diff] [blame] | 528 | /// function that describe the same variable. |
| 529 | void buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc, |
David Blaikie | e1a26a6 | 2014-08-05 23:14:16 +0000 | [diff] [blame] | 530 | const DbgValueHistoryMap::InstrRanges &Ranges); |
Adrian Prantl | b141683 | 2014-08-01 22:11:58 +0000 | [diff] [blame] | 531 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 532 | /// Collect variable information from the side table maintained |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 533 | /// by MMI. |
Duncan P. N. Exon Smith | 62e0f45 | 2015-04-15 22:29:27 +0000 | [diff] [blame] | 534 | void collectVariableInfoFromMMITable(DenseSet<InlinedVariable> &P); |
Jakob Stoklund Olesen | 9a624fa | 2011-03-26 02:19:36 +0000 | [diff] [blame] | 535 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 536 | /// Ensure that a label will be emitted before MI. |
Jakob Stoklund Olesen | 9a624fa | 2011-03-26 02:19:36 +0000 | [diff] [blame] | 537 | void requestLabelBeforeInsn(const MachineInstr *MI) { |
Craig Topper | e73658d | 2014-04-28 04:05:08 +0000 | [diff] [blame] | 538 | LabelsBeforeInsn.insert(std::make_pair(MI, nullptr)); |
Jakob Stoklund Olesen | 9a624fa | 2011-03-26 02:19:36 +0000 | [diff] [blame] | 539 | } |
| 540 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 541 | /// Ensure that a label will be emitted after MI. |
Jakob Stoklund Olesen | 9a624fa | 2011-03-26 02:19:36 +0000 | [diff] [blame] | 542 | void requestLabelAfterInsn(const MachineInstr *MI) { |
Craig Topper | e73658d | 2014-04-28 04:05:08 +0000 | [diff] [blame] | 543 | LabelsAfterInsn.insert(std::make_pair(MI, nullptr)); |
Jakob Stoklund Olesen | 9a624fa | 2011-03-26 02:19:36 +0000 | [diff] [blame] | 544 | } |
| 545 | |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 546 | public: |
| 547 | //===--------------------------------------------------------------------===// |
| 548 | // Main entry points. |
| 549 | // |
Chris Lattner | f0d6bd3 | 2010-04-05 05:11:15 +0000 | [diff] [blame] | 550 | DwarfDebug(AsmPrinter *A, Module *M); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 551 | |
Reid Kleckner | dd2647e | 2014-04-30 20:34:31 +0000 | [diff] [blame] | 552 | ~DwarfDebug() override; |
| 553 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 554 | /// Emit all Dwarf sections that should come prior to the |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 555 | /// content. |
Eric Christopher | 58f4195 | 2012-11-19 22:42:15 +0000 | [diff] [blame] | 556 | void beginModule(); |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 557 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 558 | /// Emit all Dwarf sections that should come after the content. |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 559 | void endModule() override; |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 560 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 561 | /// Gather pre-function debug information. |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 562 | void beginFunction(const MachineFunction *MF) override; |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 563 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 564 | /// Gather and emit post-function debug information. |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 565 | void endFunction(const MachineFunction *MF) override; |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 566 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 567 | /// Process beginning of an instruction. |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 568 | void beginInstruction(const MachineInstr *MI) override; |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 569 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 570 | /// Process end of an instruction. |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 571 | void endInstruction() override; |
Devang Patel | f20c4f7 | 2011-04-12 22:53:02 +0000 | [diff] [blame] | 572 | |
Adrian Prantl | ee5feaf | 2015-07-15 17:01:41 +0000 | [diff] [blame] | 573 | /// Perform an MD5 checksum of \p Identifier and return the lower 64 bits. |
| 574 | static uint64_t makeTypeSignature(StringRef Identifier); |
| 575 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 576 | /// Add a DIE to the set of types that we're going to pull into |
Eric Christopher | 6764643 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 577 | /// type units. |
David Blaikie | 15632ae | 2014-02-12 00:31:30 +0000 | [diff] [blame] | 578 | void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier, |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 579 | DIE &Die, const DICompositeType *CTy); |
Eric Christopher | 6764643 | 2013-07-26 17:02:41 +0000 | [diff] [blame] | 580 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 581 | /// Add a label so that arange data can be generated for it. |
Alexey Samsonov | 4436bf0 | 2013-10-03 08:54:43 +0000 | [diff] [blame] | 582 | void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); } |
Richard Mitton | 21101b3 | 2013-09-19 23:21:01 +0000 | [diff] [blame] | 583 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 584 | /// For symbols that have a size designated (e.g. common symbols), |
Richard Mitton | 089ed89 | 2013-09-23 17:56:20 +0000 | [diff] [blame] | 585 | /// this tracks that size. |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 586 | void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override { |
Eric Christopher | a5a7942 | 2013-12-09 23:32:48 +0000 | [diff] [blame] | 587 | SymSize[Sym] = Size; |
| 588 | } |
Richard Mitton | 089ed89 | 2013-09-23 17:56:20 +0000 | [diff] [blame] | 589 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 590 | /// Returns whether to use DW_OP_GNU_push_tls_address, instead of the |
Paul Robinson | 78cc082 | 2015-03-04 20:55:11 +0000 | [diff] [blame] | 591 | /// standard DW_OP_form_tls_address opcode |
| 592 | bool useGNUTLSOpcode() const { return UseGNUTLSOpcode; } |
| 593 | |
Paul Robinson | b9de106 | 2015-07-15 22:04:54 +0000 | [diff] [blame^] | 594 | /// \defgroup DebuggerTuning Predicates to tune DWARF for a given debugger. |
| 595 | /// |
| 596 | /// Returns whether we are "tuning" for a given debugger. |
| 597 | /// @{ |
| 598 | bool tuneForGDB() const { return DebuggerTuning == DebuggerKind::GDB; } |
| 599 | bool tuneForLLDB() const { return DebuggerTuning == DebuggerKind::LLDB; } |
| 600 | bool tuneForSCE() const { return DebuggerTuning == DebuggerKind::SCE; } |
| 601 | /// @} |
| 602 | |
Eric Christopher | 55c5181 | 2012-11-21 00:03:31 +0000 | [diff] [blame] | 603 | // Experimental DWARF5 features. |
| 604 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 605 | /// Returns whether or not to emit tables that dwarf consumers can |
Eric Christopher | acdcbdb | 2012-11-27 22:43:45 +0000 | [diff] [blame] | 606 | /// use to accelerate lookup. |
Eric Christopher | 411bd59 | 2014-03-06 00:00:53 +0000 | [diff] [blame] | 607 | bool useDwarfAccelTables() const { return HasDwarfAccelTables; } |
Eric Christopher | 55c5181 | 2012-11-21 00:03:31 +0000 | [diff] [blame] | 608 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 609 | /// Returns whether or not to change the current debug info for the |
Eric Christopher | cdf218d | 2012-12-10 19:51:21 +0000 | [diff] [blame] | 610 | /// split dwarf proposal support. |
Eric Christopher | 411bd59 | 2014-03-06 00:00:53 +0000 | [diff] [blame] | 611 | bool useSplitDwarf() const { return HasSplitDwarf; } |
Manman Ren | ac8062b | 2013-07-02 23:40:10 +0000 | [diff] [blame] | 612 | |
| 613 | /// Returns the Dwarf Version. |
| 614 | unsigned getDwarfVersion() const { return DwarfVersion; } |
Manman Ren | 6035203 | 2013-09-05 18:48:31 +0000 | [diff] [blame] | 615 | |
Eric Christopher | 384f3fe | 2014-03-20 19:16:16 +0000 | [diff] [blame] | 616 | /// Returns the previous CU that was being updated |
| 617 | const DwarfCompileUnit *getPrevCU() const { return PrevCU; } |
David Blaikie | d0f1037 | 2014-09-09 23:13:01 +0000 | [diff] [blame] | 618 | void setPrevCU(const DwarfCompileUnit *PrevCU) { this->PrevCU = PrevCU; } |
Eric Christopher | 384f3fe | 2014-03-20 19:16:16 +0000 | [diff] [blame] | 619 | |
Eric Christopher | 4f17ee0 | 2014-03-08 00:29:41 +0000 | [diff] [blame] | 620 | /// Returns the entries for the .debug_loc section. |
Duncan P. N. Exon Smith | 364a300 | 2015-04-17 21:34:47 +0000 | [diff] [blame] | 621 | const DebugLocStream &getDebugLocs() const { return DebugLocs; } |
Eric Christopher | 4f17ee0 | 2014-03-08 00:29:41 +0000 | [diff] [blame] | 622 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 623 | /// Emit an entry for the debug loc section. This can be used to |
Eric Christopher | 4f17ee0 | 2014-03-08 00:29:41 +0000 | [diff] [blame] | 624 | /// handle an entry that's going to be emitted into the debug loc section. |
Adrian Prantl | 92da14b | 2015-03-02 22:02:33 +0000 | [diff] [blame] | 625 | void emitDebugLocEntry(ByteStreamer &Streamer, |
Duncan P. N. Exon Smith | 364a300 | 2015-04-17 21:34:47 +0000 | [diff] [blame] | 626 | const DebugLocStream::Entry &Entry); |
Eric Christopher | 4f17ee0 | 2014-03-08 00:29:41 +0000 | [diff] [blame] | 627 | |
David Blaikie | 0e84adc | 2014-04-01 16:17:41 +0000 | [diff] [blame] | 628 | /// Emit the location for a debug loc entry, including the size header. |
Duncan P. N. Exon Smith | 364a300 | 2015-04-17 21:34:47 +0000 | [diff] [blame] | 629 | void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry); |
David Blaikie | 0e84adc | 2014-04-01 16:17:41 +0000 | [diff] [blame] | 630 | |
Eric Christopher | 87b9c49 | 2013-10-05 00:32:34 +0000 | [diff] [blame] | 631 | /// Find the MDNode for the given reference. |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 632 | template <typename T> T *resolve(TypedDINodeRef<T> Ref) const { |
Duncan P. N. Exon Smith | 000fa2c | 2015-04-07 04:14:33 +0000 | [diff] [blame] | 633 | return Ref.resolve(TypeIdentifierMap); |
| 634 | } |
Manman Ren | 6035203 | 2013-09-05 18:48:31 +0000 | [diff] [blame] | 635 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 636 | /// Return the TypeIdentifierMap. |
Eric Christopher | c0bd5f8 | 2014-03-18 20:39:54 +0000 | [diff] [blame] | 637 | const DITypeIdentifierMap &getTypeIdentifierMap() const { |
Adrian Prantl | 1a1647c | 2014-03-18 02:34:58 +0000 | [diff] [blame] | 638 | return TypeIdentifierMap; |
| 639 | } |
| 640 | |
Eric Christopher | dd50838 | 2014-03-06 00:00:56 +0000 | [diff] [blame] | 641 | /// Find the DwarfCompileUnit for the given CU Die. |
| 642 | DwarfCompileUnit *lookupUnit(const DIE *CU) const { |
| 643 | return CUDieMap.lookup(CU); |
| 644 | } |
Manman Ren | 3eb9dff | 2013-09-09 19:05:21 +0000 | [diff] [blame] | 645 | /// isSubprogramContext - Return true if Context is either a subprogram |
| 646 | /// or another context nested inside a subprogram. |
| 647 | bool isSubprogramContext(const MDNode *Context); |
David Blaikie | d75fb28 | 2014-04-23 21:20:10 +0000 | [diff] [blame] | 648 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 649 | void addSubprogramNames(const DISubprogram *SP, DIE &Die); |
David Blaikie | 2406a062 | 2014-04-23 23:37:35 +0000 | [diff] [blame] | 650 | |
David Blaikie | d75fb28 | 2014-04-23 21:20:10 +0000 | [diff] [blame] | 651 | AddressPool &getAddressPool() { return AddrPool; } |
David Blaikie | 2406a062 | 2014-04-23 23:37:35 +0000 | [diff] [blame] | 652 | |
David Blaikie | b0b3fcf | 2014-04-25 18:52:29 +0000 | [diff] [blame] | 653 | void addAccelName(StringRef Name, const DIE &Die); |
David Blaikie | 0ee82b9 | 2014-04-24 00:53:32 +0000 | [diff] [blame] | 654 | |
David Blaikie | b0b3fcf | 2014-04-25 18:52:29 +0000 | [diff] [blame] | 655 | void addAccelObjC(StringRef Name, const DIE &Die); |
David Blaikie | ecf0415 | 2014-04-24 01:02:42 +0000 | [diff] [blame] | 656 | |
David Blaikie | b0b3fcf | 2014-04-25 18:52:29 +0000 | [diff] [blame] | 657 | void addAccelNamespace(StringRef Name, const DIE &Die); |
David Blaikie | 18d3375 | 2014-04-24 01:23:49 +0000 | [diff] [blame] | 658 | |
David Blaikie | b0b3fcf | 2014-04-25 18:52:29 +0000 | [diff] [blame] | 659 | void addAccelType(StringRef Name, const DIE &Die, char Flags); |
David Blaikie | cda2aa8 | 2014-10-04 16:24:00 +0000 | [diff] [blame] | 660 | |
| 661 | const MachineFunction *getCurrentFunction() const { return CurFn; } |
David Blaikie | 9c65b13 | 2014-10-08 22:20:02 +0000 | [diff] [blame] | 662 | |
David Blaikie | d51dea6 | 2015-07-01 18:07:16 +0000 | [diff] [blame] | 663 | iterator_range<ImportedEntityMap::const_iterator> |
| 664 | findImportedEntitiesForScope(const MDNode *Scope) const { |
David Blaikie | 9c65b13 | 2014-10-08 22:20:02 +0000 | [diff] [blame] | 665 | return make_range(std::equal_range( |
David Blaikie | d51dea6 | 2015-07-01 18:07:16 +0000 | [diff] [blame] | 666 | ScopesWithImportedEntities.begin(), ScopesWithImportedEntities.end(), |
David Blaikie | 33702a3 | 2014-10-08 23:09:42 +0000 | [diff] [blame] | 667 | std::pair<const MDNode *, const MDNode *>(Scope, nullptr), |
| 668 | less_first())); |
David Blaikie | 9c65b13 | 2014-10-08 22:20:02 +0000 | [diff] [blame] | 669 | } |
| 670 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 671 | /// A helper function to check whether the DIE for a given Scope is |
David Blaikie | 9c65b13 | 2014-10-08 22:20:02 +0000 | [diff] [blame] | 672 | /// going to be null. |
| 673 | bool isLexicalScopeDIENull(LexicalScope *Scope); |
| 674 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 675 | /// Return Label preceding the instruction. |
David Blaikie | 01b48a8 | 2014-10-09 16:50:53 +0000 | [diff] [blame] | 676 | MCSymbol *getLabelBeforeInsn(const MachineInstr *MI); |
| 677 | |
Adrian Prantl | 857237e | 2015-07-13 18:25:29 +0000 | [diff] [blame] | 678 | /// Return Label immediately following the instruction. |
David Blaikie | 01b48a8 | 2014-10-09 16:50:53 +0000 | [diff] [blame] | 679 | MCSymbol *getLabelAfterInsn(const MachineInstr *MI); |
| 680 | |
David Blaikie | 9c65b13 | 2014-10-08 22:20:02 +0000 | [diff] [blame] | 681 | // FIXME: Sink these functions down into DwarfFile/Dwarf*Unit. |
| 682 | |
David Blaikie | 1d07234 | 2014-10-09 20:21:36 +0000 | [diff] [blame] | 683 | SmallPtrSet<const MDNode *, 16> &getProcessedSPNodes() { |
| 684 | return ProcessedSPNodes; |
| 685 | } |
Devang Patel | f6eeaeb | 2009-11-10 23:06:00 +0000 | [diff] [blame] | 686 | }; |
Bill Wendling | 2f921f8 | 2009-05-15 09:23:25 +0000 | [diff] [blame] | 687 | } // End of namespace llvm |
| 688 | |
| 689 | #endif |