blob: 4b0506f4c10565230c2a6e598ce45a3fbd844ddf [file] [log] [blame]
Bill Wendling2f921f82009-05-15 09:23:25 +00001//===-- 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 Kramera7c40ef2014-08-13 16:26:38 +000014#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
15#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
Bill Wendling2f921f82009-05-15 09:23:25 +000016
Timur Iskhodzhanov1cd14442013-12-03 15:10:23 +000017#include "AsmPrinterHandler.h"
Alexey Samsonov414b6fb2014-04-30 21:34:11 +000018#include "DbgValueHistoryCalculator.h"
Duncan P. N. Exon Smith364a3002015-04-17 21:34:47 +000019#include "DebugLocStream.h"
David Blaikie2406a0622014-04-23 23:37:35 +000020#include "DwarfAccelTable.h"
Chandler Carruthd9903882015-01-14 11:23:27 +000021#include "DwarfFile.h"
Devang Patel018b29b2010-01-19 06:19:05 +000022#include "llvm/ADT/DenseMap.h"
Duncan P. N. Exon Smith62e0f452015-04-15 22:29:27 +000023#include "llvm/ADT/DenseSet.h"
Chandler Carruthd9903882015-01-14 11:23:27 +000024#include "llvm/ADT/FoldingSet.h"
Eric Christopheracbe42b2014-03-18 20:58:35 +000025#include "llvm/ADT/MapVector.h"
26#include "llvm/ADT/SmallPtrSet.h"
27#include "llvm/ADT/StringMap.h"
Frederic Risse541e0b2015-01-05 21:29:41 +000028#include "llvm/CodeGen/DIE.h"
Chandler Carruth802d7552012-12-04 07:12:27 +000029#include "llvm/CodeGen/LexicalScopes.h"
Adrian Prantlc1197542014-05-30 21:10:13 +000030#include "llvm/CodeGen/MachineInstr.h"
Chandler Carruth9a4c9e52014-03-06 00:46:21 +000031#include "llvm/IR/DebugInfo.h"
Eric Christopheracbe42b2014-03-18 20:58:35 +000032#include "llvm/IR/DebugLoc.h"
David Blaikie4a2f95f2014-03-18 01:17:26 +000033#include "llvm/MC/MCDwarf.h"
Chandler Carruthd9903882015-01-14 11:23:27 +000034#include "llvm/MC/MachineLocation.h"
Chris Lattner3f3fb972010-04-05 05:24:55 +000035#include "llvm/Support/Allocator.h"
David Blaikief9b6a552014-04-22 22:39:41 +000036#include <memory>
37
Bill Wendling2f921f82009-05-15 09:23:25 +000038namespace llvm {
39
Adrian Prantl702bf5a2014-03-18 02:34:52 +000040class AsmPrinter;
Eric Christopher29e874d2014-03-07 22:40:37 +000041class ByteStreamer;
Chris Lattner88fce102012-01-26 20:44:57 +000042class ConstantInt;
43class ConstantFP;
Duncan P. N. Exon Smith364a3002015-04-17 21:34:47 +000044class DebugLocEntry;
Eric Christopherce4a9442014-03-18 20:37:10 +000045class DwarfCompileUnit;
46class DwarfDebug;
47class DwarfTypeUnit;
48class DwarfUnit;
Bill Wendling2f921f82009-05-15 09:23:25 +000049class MachineModuleInfo;
Bill Wendling2f921f82009-05-15 09:23:25 +000050
51//===----------------------------------------------------------------------===//
Eric Christopheracdcbdb2012-11-27 22:43:45 +000052/// \brief This class is used to record source line correspondence.
Benjamin Kramer079b96e2013-09-11 18:05:11 +000053class SrcLineInfo {
Eric Christophera5a79422013-12-09 23:32:48 +000054 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 Wendling2f921f82009-05-15 09:23:25 +000058public:
Chris Lattnerb4666f42010-03-14 08:15:55 +000059 SrcLineInfo(unsigned L, unsigned C, unsigned S, MCSymbol *label)
Eric Christophera5a79422013-12-09 23:32:48 +000060 : Line(L), Column(C), SourceID(S), Label(label) {}
Bill Wendling2f921f82009-05-15 09:23:25 +000061
62 // Accessors
63 unsigned getLine() const { return Line; }
64 unsigned getColumn() const { return Column; }
65 unsigned getSourceID() const { return SourceID; }
Chris Lattnerb4666f42010-03-14 08:15:55 +000066 MCSymbol *getLabel() const { return Label; }
Bill Wendling2f921f82009-05-15 09:23:25 +000067};
68
Devang Patelf20c4f72011-04-12 22:53:02 +000069//===----------------------------------------------------------------------===//
Eric Christopheracdcbdb2012-11-27 22:43:45 +000070/// \brief This class is used to track local variable information.
Adrian Prantlca7e4702015-02-10 23:18:28 +000071///
Duncan P. N. Exon Smith364a3002015-04-17 21:34:47 +000072/// - Variables whose location changes over time have a DebugLocListIndex and
Eric Christopherffc5ff32015-02-17 20:02:28 +000073/// the other fields are not used.
Adrian Prantlca7e4702015-02-10 23:18:28 +000074///
75/// - Variables that are described by multiple MMI table entries have multiple
76/// expressions and frame indices.
Benjamin Kramer079b96e2013-09-11 18:05:11 +000077class DbgVariable {
Duncan P. N. Exon Smith62e0f452015-04-15 22:29:27 +000078 DIVariable Var; /// Variable Descriptor.
79 DILocation IA; /// Inlined at location.
Adrian Prantlca7e4702015-02-10 23:18:28 +000080 SmallVector<DIExpression, 1> Expr; /// Complex address location expression.
81 DIE *TheDIE; /// Variable DIE.
Duncan P. N. Exon Smith364a3002015-04-17 21:34:47 +000082 unsigned DebugLocListIndex; /// Offset in DebugLocs.
Adrian Prantlca7e4702015-02-10 23:18:28 +000083 const MachineInstr *MInsn; /// DBG_VALUE instruction of the variable.
84 SmallVector<int, 1> FrameIndex; /// Frame index of the variable.
Manman Renb3388602013-10-05 01:43:03 +000085 DwarfDebug *DD;
Eric Christophera5a79422013-12-09 23:32:48 +000086
Devang Patelf20c4f72011-04-12 22:53:02 +000087public:
Adrian Prantlc1197542014-05-30 21:10:13 +000088 /// Construct a DbgVariable from a DIVariable.
Duncan P. N. Exon Smith62e0f452015-04-15 22:29:27 +000089 DbgVariable(DIVariable V, DILocation IA, DIExpression E, DwarfDebug *DD,
90 int FI = ~0)
Duncan P. N. Exon Smith364a3002015-04-17 21:34:47 +000091 : Var(V), IA(IA), Expr(1, E), TheDIE(nullptr), DebugLocListIndex(~0U),
Duncan P. N. Exon Smith62e0f452015-04-15 22:29:27 +000092 MInsn(nullptr), DD(DD) {
Adrian Prantlca7e4702015-02-10 23:18:28 +000093 FrameIndex.push_back(FI);
Duncan P. N. Exon Smithe9d379c2015-03-16 21:03:55 +000094 assert(!E || E->isValid());
Adrian Prantl87b7eb92014-10-01 18:55:02 +000095 }
Devang Patelf20c4f72011-04-12 22:53:02 +000096
Adrian Prantlc1197542014-05-30 21:10:13 +000097 /// Construct a DbgVariable from a DEBUG_VALUE.
98 /// AbstractVar may be NULL.
David Blaikie6f9e8672014-06-13 23:52:55 +000099 DbgVariable(const MachineInstr *DbgValue, DwarfDebug *DD)
Eric Christopherffc5ff32015-02-17 20:02:28 +0000100 : Var(DbgValue->getDebugVariable()),
Duncan P. N. Exon Smith78a95272015-04-16 22:12:59 +0000101 IA(DbgValue->getDebugLoc()->getInlinedAt()),
Eric Christopherffc5ff32015-02-17 20:02:28 +0000102 Expr(1, DbgValue->getDebugExpression()), TheDIE(nullptr),
Duncan P. N. Exon Smith364a3002015-04-17 21:34:47 +0000103 DebugLocListIndex(~0U), MInsn(DbgValue), DD(DD) {
Adrian Prantlca7e4702015-02-10 23:18:28 +0000104 FrameIndex.push_back(~0);
105 }
Adrian Prantlc1197542014-05-30 21:10:13 +0000106
Devang Patelf20c4f72011-04-12 22:53:02 +0000107 // Accessors.
Eric Christophera5a79422013-12-09 23:32:48 +0000108 DIVariable getVariable() const { return Var; }
Duncan P. N. Exon Smith62e0f452015-04-15 22:29:27 +0000109 DILocation getInlinedAt() const { return IA; }
Adrian Prantlca7e4702015-02-10 23:18:28 +0000110 const ArrayRef<DIExpression> getExpression() const { return Expr; }
David Blaikiee071fc82014-04-25 17:32:19 +0000111 void setDIE(DIE &D) { TheDIE = &D; }
Eric Christophera5a79422013-12-09 23:32:48 +0000112 DIE *getDIE() const { return TheDIE; }
Duncan P. N. Exon Smith364a3002015-04-17 21:34:47 +0000113 void setDebugLocListIndex(unsigned O) { DebugLocListIndex = O; }
114 unsigned getDebugLocListIndex() const { return DebugLocListIndex; }
Duncan P. N. Exon Smith7348dda2015-04-14 02:22:36 +0000115 StringRef getName() const { return Var->getName(); }
Eric Christophera5a79422013-12-09 23:32:48 +0000116 const MachineInstr *getMInsn() const { return MInsn; }
Adrian Prantlca7e4702015-02-10 23:18:28 +0000117 const ArrayRef<int> getFrameIndex() const { return FrameIndex; }
118
119 void addMMIEntry(const DbgVariable &V) {
Duncan P. N. Exon Smith364a3002015-04-17 21:34:47 +0000120 assert(DebugLocListIndex == ~0U && !MInsn && "not an MMI entry");
121 assert(V.DebugLocListIndex == ~0U && !V.MInsn && "not an MMI entry");
Adrian Prantlca7e4702015-02-10 23:18:28 +0000122 assert(V.Var == Var && "conflicting DIVariable");
Duncan P. N. Exon Smith62e0f452015-04-15 22:29:27 +0000123 assert(V.IA == IA && "conflicting inlined-at location");
Adrian Prantlca7e4702015-02-10 23:18:28 +0000124
125 if (V.getFrameIndex().back() != ~0) {
126 auto E = V.getExpression();
127 auto FI = V.getFrameIndex();
128 Expr.append(E.begin(), E.end());
129 FrameIndex.append(FI.begin(), FI.end());
130 }
131 assert(Expr.size() > 1
Duncan P. N. Exon Smith6a0320a2015-04-14 01:12:42 +0000132 ? std::all_of(Expr.begin(), Expr.end(),
133 [](DIExpression &E) { return E->isBitPiece(); })
134 : (true && "conflicting locations for variable"));
Adrian Prantlca7e4702015-02-10 23:18:28 +0000135 }
136
Eric Christopher27527b22012-11-21 00:03:28 +0000137 // Translate tag to proper Dwarf tag.
David Blaikieefc403b2014-04-12 02:24:04 +0000138 dwarf::Tag getTag() const {
Duncan P. N. Exon Smith7348dda2015-04-14 02:22:36 +0000139 if (Var->getTag() == dwarf::DW_TAG_arg_variable)
Devang Patel6e4d2c92011-08-15 18:35:42 +0000140 return dwarf::DW_TAG_formal_parameter;
Eric Christopher27527b22012-11-21 00:03:28 +0000141
Devang Patel6e4d2c92011-08-15 18:35:42 +0000142 return dwarf::DW_TAG_variable;
143 }
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000144 /// \brief Return true if DbgVariable is artificial.
Eric Christophera5a79422013-12-09 23:32:48 +0000145 bool isArtificial() const {
Duncan P. N. Exon Smith7348dda2015-04-14 02:22:36 +0000146 if (Var->isArtificial())
Devang Pateld7d80aa2011-08-15 18:40:16 +0000147 return true;
Duncan P. N. Exon Smithb1055642015-04-16 01:01:28 +0000148 if (getType()->isArtificial())
Devang Pateld7d80aa2011-08-15 18:40:16 +0000149 return true;
150 return false;
151 }
Eric Christophere3417762012-09-12 23:36:19 +0000152
Eric Christophera5a79422013-12-09 23:32:48 +0000153 bool isObjectPointer() const {
Duncan P. N. Exon Smith7348dda2015-04-14 02:22:36 +0000154 if (Var->isObjectPointer())
Eric Christophere3417762012-09-12 23:36:19 +0000155 return true;
Duncan P. N. Exon Smithb1055642015-04-16 01:01:28 +0000156 if (getType()->isObjectPointer())
Eric Christophere3417762012-09-12 23:36:19 +0000157 return true;
158 return false;
159 }
Eric Christopher27527b22012-11-21 00:03:28 +0000160
Eric Christophera5a79422013-12-09 23:32:48 +0000161 bool variableHasComplexAddress() const {
Duncan P. N. Exon Smithe686f152015-04-06 23:27:40 +0000162 assert(Var && "Invalid complex DbgVariable!");
Adrian Prantlca7e4702015-02-10 23:18:28 +0000163 assert(Expr.size() == 1 &&
164 "variableHasComplexAddress() invoked on multi-FI variable");
Duncan P. N. Exon Smith6a0320a2015-04-14 01:12:42 +0000165 return Expr.back()->getNumElements() > 0;
Devang Patelf20c4f72011-04-12 22:53:02 +0000166 }
Adrian Prantl1a1647c2014-03-18 02:34:58 +0000167 bool isBlockByrefVariable() const;
Devang Patelf20c4f72011-04-12 22:53:02 +0000168 DIType getType() const;
Manman Renbe5576f2013-10-08 19:07:44 +0000169
170private:
171 /// resolve - Look in the DwarfDebug map for the MDNode that
172 /// corresponds to the reference.
Duncan P. N. Exon Smithb0b0e492015-04-16 02:24:01 +0000173 template <typename T> T *resolve(TypedDebugNodeRef<T> Ref) const;
Devang Patelf20c4f72011-04-12 22:53:02 +0000174};
175
Eric Christopherc8a310e2012-12-10 23:34:43 +0000176
Eric Christopher670ee0e2013-10-24 21:20:23 +0000177/// \brief Helper used to pair up a symbol and its DWARF compile unit.
Richard Mitton21101b32013-09-19 23:21:01 +0000178struct SymbolCU {
Eric Christopher4287a492013-12-09 23:57:44 +0000179 SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
Richard Mitton21101b32013-09-19 23:21:01 +0000180 const MCSymbol *Sym;
Eric Christopher4287a492013-12-09 23:57:44 +0000181 DwarfCompileUnit *CU;
Richard Mitton21101b32013-09-19 23:21:01 +0000182};
183
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000184/// \brief Collects and handles dwarf debug information.
Timur Iskhodzhanov1cd14442013-12-03 15:10:23 +0000185class DwarfDebug : public AsmPrinterHandler {
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000186 // Target of Dwarf emission.
Chris Lattner3a383cb2010-04-05 00:13:49 +0000187 AsmPrinter *Asm;
Chris Lattneracda87b2010-04-05 05:31:04 +0000188
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000189 // Collected machine module information.
Chris Lattner3a383cb2010-04-05 00:13:49 +0000190 MachineModuleInfo *MMI;
191
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000192 // All DIEValues are allocated through this allocator.
Benjamin Kramer07480082012-06-09 10:34:15 +0000193 BumpPtrAllocator DIEValueAllocator;
194
Eric Christopher4287a492013-12-09 23:57:44 +0000195 // Maps MDNode with its corresponding DwarfCompileUnit.
Eric Christopher179fba12014-01-29 22:06:23 +0000196 MapVector<const MDNode *, DwarfCompileUnit *> CUMap;
Bill Wendling2f921f82009-05-15 09:23:25 +0000197
Eric Christopher4287a492013-12-09 23:57:44 +0000198 // Maps subprogram MDNode with its corresponding DwarfCompileUnit.
David Blaikie7d6f29d2014-10-10 16:59:52 +0000199 MapVector<const MDNode *, DwarfCompileUnit *> SPMap;
Devang Pateleb1bb4e2011-08-16 22:09:43 +0000200
Eric Christopher4287a492013-12-09 23:57:44 +0000201 // Maps a CU DIE with its corresponding DwarfCompileUnit.
202 DenseMap<const DIE *, DwarfCompileUnit *> CUDieMap;
Manman Rence20d462013-10-29 22:57:10 +0000203
Alexey Samsonov4436bf02013-10-03 08:54:43 +0000204 // List of all labels used in aranges generation.
205 std::vector<SymbolCU> ArangeLabels;
Richard Mitton21101b32013-09-19 23:21:01 +0000206
Richard Mitton089ed892013-09-23 17:56:20 +0000207 // Size of each symbol emitted (for those symbols that have a specific size).
Eric Christophera5a79422013-12-09 23:32:48 +0000208 DenseMap<const MCSymbol *, uint64_t> SymSize;
Richard Mitton089ed892013-09-23 17:56:20 +0000209
Devang Patel7e623022011-08-10 20:55:27 +0000210 LexicalScopes LScopes;
Devang Patel95cd4b92010-03-25 15:09:44 +0000211
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000212 // Collection of abstract variables.
David Blaikie825bdd22014-05-21 22:41:17 +0000213 DenseMap<const MDNode *, std::unique_ptr<DbgVariable>> AbstractVariables;
David Blaikieeb1a2722014-06-13 22:18:23 +0000214 SmallVector<std::unique_ptr<DbgVariable>, 64> ConcreteVariables;
Devang Patelf6eeaeb2009-11-10 23:06:00 +0000215
David Blaikie0a456de2014-04-02 01:43:18 +0000216 // Collection of DebugLocEntry. Stored in a linked list so that DIELocLists
217 // can refer to them in spite of insertions into this list.
Duncan P. N. Exon Smith364a3002015-04-17 21:34:47 +0000218 DebugLocStream DebugLocs;
Devang Patel9fc11702010-05-25 23:40:22 +0000219
Eric Christopher48fef592012-12-20 21:58:40 +0000220 // This is a collection of subprogram MDNodes that are processed to
221 // create DIEs.
Devang Patelf3b2db62010-06-28 18:25:03 +0000222 SmallPtrSet<const MDNode *, 16> ProcessedSPNodes;
223
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000224 // Maps instruction with label emitted before instruction.
Devang Patel6c74a872010-04-27 19:46:33 +0000225 DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn;
Devang Patel3ebd8932010-04-08 16:50:29 +0000226
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000227 // Maps instruction with label emitted after instruction.
Devang Patel6c74a872010-04-27 19:46:33 +0000228 DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn;
Devang Patel3ebd8932010-04-08 16:50:29 +0000229
Alexey Samsonov414b6fb2014-04-30 21:34:11 +0000230 // History of DBG_VALUE and clobber instructions for each user variable.
Alexey Samsonov0436caa2014-04-30 23:02:40 +0000231 // Variables are listed in order of appearance.
Jakob Stoklund Olesen9a624fa2011-03-26 02:19:36 +0000232 DbgValueHistoryMap DbgValues;
Jakob Stoklund Olesenec0ac3c2011-03-22 22:33:08 +0000233
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000234 // Previous instruction's location information. This is used to determine
235 // label location to indicate scope boundries in dwarf debug info.
Chris Lattner915c5f92010-04-02 19:42:39 +0000236 DebugLoc PrevInstLoc;
Devang Patel12563b32010-04-16 23:33:45 +0000237 MCSymbol *PrevLabel;
Devang Patelbd477be2010-03-29 17:20:31 +0000238
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000239 // This location indicates end of function prologue and beginning of function
240 // body.
Devang Patel34a66202011-05-11 19:22:19 +0000241 DebugLoc PrologEndLoc;
242
Timur Iskhodzhanov1cd14442013-12-03 15:10:23 +0000243 // If nonnull, stores the current machine function we're processing.
244 const MachineFunction *CurFn;
245
246 // If nonnull, stores the current machine instruction we're processing.
247 const MachineInstr *CurMI;
248
Eric Christopher384f3fe2014-03-20 19:16:16 +0000249 // If nonnull, stores the CU in which the previous subprogram was contained.
250 const DwarfCompileUnit *PrevCU;
251
Nick Lewyckyd1ee7f82011-11-02 20:55:33 +0000252 // As an optimization, there is no need to emit an entry in the directory
Eric Christopher808fd7b2013-07-03 01:57:23 +0000253 // table for the same directory as DW_AT_comp_dir.
Nick Lewyckyd1ee7f82011-11-02 20:55:33 +0000254 StringRef CompilationDir;
255
Eric Christopherc8a310e2012-12-10 23:34:43 +0000256 // Holder for the file specific debug information.
Eric Christopherf8194852013-12-05 18:06:10 +0000257 DwarfFile InfoHolder;
Eric Christopherc8a310e2012-12-10 23:34:43 +0000258
Eric Christopher0aa4a672012-12-10 22:25:41 +0000259 // Holders for the various debug information flags that we might need to
260 // have exposed. See accessor functions below for description.
261
Eric Christopher070bf162013-07-03 01:57:26 +0000262 // Holder for imported entities.
263 typedef SmallVector<std::pair<const MDNode *, const MDNode *>, 32>
Eric Christophera5a79422013-12-09 23:32:48 +0000264 ImportedEntityMap;
Eric Christopher070bf162013-07-03 01:57:26 +0000265 ImportedEntityMap ScopesWithImportedEntities;
266
David Blaikie47f615e2013-12-17 23:32:35 +0000267 // Map from MDNodes for user-defined types to the type units that describe
268 // them.
269 DenseMap<const MDNode *, const DwarfTypeUnit *> DwarfTypeUnits;
Eric Christopher67646432013-07-26 17:02:41 +0000270
Eric Christopherffc5ff32015-02-17 20:02:28 +0000271 SmallVector<std::pair<std::unique_ptr<DwarfTypeUnit>, DICompositeType>, 1>
272 TypeUnitsUnderConstruction;
David Blaikiee12b49a2014-04-26 17:27:38 +0000273
Eric Christopher4d36ca02013-08-26 23:24:35 +0000274 // Whether to emit the pubnames/pubtypes sections.
275 bool HasDwarfPubSections;
276
Eric Christopher1ad84572014-01-15 00:04:29 +0000277 // Whether or not to use AT_ranges for compilation units.
278 bool HasCURanges;
279
Eric Christopher2037caf2014-01-28 00:49:26 +0000280 // Whether we emitted a function into a section other than the default
281 // text.
282 bool UsedNonDefaultText;
283
Paul Robinson78cc0822015-03-04 20:55:11 +0000284 // Whether to use the GNU TLS opcode (instead of the standard opcode).
285 bool UseGNUTLSOpcode;
286
Eric Christopher4d36ca02013-08-26 23:24:35 +0000287 // Version of dwarf we're emitting.
288 unsigned DwarfVersion;
289
Eric Christopher0a13eb32013-11-21 22:56:11 +0000290 // Maps from a type identifier to the actual MDNode.
291 DITypeIdentifierMap TypeIdentifierMap;
292
Eric Christopher42e39942012-11-29 22:56:13 +0000293 // DWARF5 Experimental Options
Eric Christopher7b30f2e42012-11-21 00:34:35 +0000294 bool HasDwarfAccelTables;
Eric Christophercdf218d2012-12-10 19:51:21 +0000295 bool HasSplitDwarf;
Manman Renac8062b2013-07-02 23:40:10 +0000296
Eric Christopherd692c1d2012-12-11 19:42:09 +0000297 // Separated Dwarf Variables
Eric Christopherd79f5482012-12-10 19:51:13 +0000298 // In general these will all be for bits that are left in the
299 // original object file, rather than things that are meant
300 // to be in the .dwo sections.
301
Eric Christopher3bf29fd2012-12-27 02:14:01 +0000302 // Holder for the skeleton information.
Eric Christopherf8194852013-12-05 18:06:10 +0000303 DwarfFile SkeletonHolder;
Eric Christopherd79f5482012-12-10 19:51:13 +0000304
David Blaikie47f4b822014-03-19 00:11:28 +0000305 /// Store file names for type units under fission in a line table header that
306 /// will be emitted into debug_line.dwo.
307 // FIXME: replace this with a map from comp_dir to table so that we can emit
308 // multiple tables during LTO each of which uses directory 0, referencing the
309 // comp_dir of all the type units that use it.
David Blaikie8287aff2014-03-18 02:13:23 +0000310 MCDwarfDwoLineTable SplitTypeUnitFileTable;
David Blaikie4a2f95f2014-03-18 01:17:26 +0000311
David Blaikie47f4b822014-03-19 00:11:28 +0000312 // True iff there are multiple CUs in this module.
313 bool SingleCU;
David Blaikiee1c79742014-09-30 21:28:32 +0000314 bool IsDarwin;
Paul Robinson78cc0822015-03-04 20:55:11 +0000315 bool IsPS4;
David Blaikie47f4b822014-03-19 00:11:28 +0000316
David Blaikied75fb282014-04-23 21:20:10 +0000317 AddressPool AddrPool;
318
David Blaikie2406a0622014-04-23 23:37:35 +0000319 DwarfAccelTable AccelNames;
David Blaikie0ee82b92014-04-24 00:53:32 +0000320 DwarfAccelTable AccelObjC;
David Blaikieecf04152014-04-24 01:02:42 +0000321 DwarfAccelTable AccelNamespace;
David Blaikie18d33752014-04-24 01:23:49 +0000322 DwarfAccelTable AccelTypes;
David Blaikie2406a0622014-04-23 23:37:35 +0000323
David Blaikie2f040112014-07-25 16:10:16 +0000324 DenseMap<const Function *, DISubprogram> FunctionDIs;
325
David Blaikie47f4b822014-03-19 00:11:28 +0000326 MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
327
David Blaikiec33b3cd2014-04-22 21:27:37 +0000328 const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() {
Eric Christophera5a79422013-12-09 23:32:48 +0000329 return InfoHolder.getUnits();
330 }
David Blaikiefd1eff52013-11-26 19:14:34 +0000331
Duncan P. N. Exon Smith62e0f452015-04-15 22:29:27 +0000332 typedef DbgValueHistoryMap::InlinedVariable InlinedVariable;
333
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000334 /// \brief Find abstract variable associated with Var.
Duncan P. N. Exon Smith62e0f452015-04-15 22:29:27 +0000335 DbgVariable *getExistingAbstractVariable(InlinedVariable IV,
David Blaikie36408e72014-06-04 23:50:52 +0000336 DIVariable &Cleansed);
Duncan P. N. Exon Smith62e0f452015-04-15 22:29:27 +0000337 DbgVariable *getExistingAbstractVariable(InlinedVariable IV);
David Blaikie6f9e8672014-06-13 23:52:55 +0000338 void createAbstractVariable(const DIVariable &DV, LexicalScope *Scope);
Duncan P. N. Exon Smith62e0f452015-04-15 22:29:27 +0000339 void ensureAbstractVariableIsCreated(InlinedVariable Var,
David Blaikie6f9e8672014-06-13 23:52:55 +0000340 const MDNode *Scope);
Duncan P. N. Exon Smith62e0f452015-04-15 22:29:27 +0000341 void ensureAbstractVariableIsCreatedIfScoped(InlinedVariable Var,
David Blaikie6f9e8672014-06-13 23:52:55 +0000342 const MDNode *Scope);
Devang Patelf6eeaeb2009-11-10 23:06:00 +0000343
David Blaikiee872a6e2014-04-29 15:58:35 +0000344 /// \brief Construct a DIE for this abstract scope.
David Blaikie73cc7052014-10-09 20:36:27 +0000345 void constructAbstractSubprogramScopeDIE(LexicalScope *Scope);
346
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000347 /// \brief Compute the size and offset of a DIE given an incoming Offset.
Eric Christopher1f0cbb82012-11-20 22:14:13 +0000348 unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
Bill Wendling2f921f82009-05-15 09:23:25 +0000349
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000350 /// \brief Compute the size and offset of all the DIEs.
Devang Patel930143b2009-11-21 02:48:08 +0000351 void computeSizeAndOffsets();
Bill Wendling2f921f82009-05-15 09:23:25 +0000352
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000353 /// \brief Collect info for variables that were optimized out.
Eric Christopher960ac372012-11-22 00:59:49 +0000354 void collectDeadVariables();
355
David Blaikieeb1a2722014-06-13 22:18:23 +0000356 void finishVariableDefinitions();
357
David Blaikief7221ad2014-05-27 18:37:43 +0000358 void finishSubprogramDefinitions();
359
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000360 /// \brief Finish off debug information after all functions have been
361 /// processed.
Eric Christopher960ac372012-11-22 00:59:49 +0000362 void finalizeModuleInfo();
363
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000364 /// \brief Emit the debug info section.
Devang Patel930143b2009-11-21 02:48:08 +0000365 void emitDebugInfo();
Bill Wendling2f921f82009-05-15 09:23:25 +0000366
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000367 /// \brief Emit the abbreviation section.
Eric Christopher38371952012-11-20 23:30:11 +0000368 void emitAbbreviations();
Bill Wendling2f921f82009-05-15 09:23:25 +0000369
David Blaikie6741bb02014-09-11 21:12:48 +0000370 /// \brief Emit a specified accelerator table.
371 void emitAccel(DwarfAccelTable &Accel, const MCSection *Section,
Rafael Espindola6b9998b2015-03-10 22:00:25 +0000372 StringRef TableName);
David Blaikie6741bb02014-09-11 21:12:48 +0000373
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000374 /// \brief Emit visible names into a hashed accelerator table section.
Eric Christopher4996c702011-11-07 09:24:32 +0000375 void emitAccelNames();
Eric Christopher27527b22012-11-21 00:03:28 +0000376
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000377 /// \brief Emit objective C classes and categories into a hashed
Eric Christopher4996c702011-11-07 09:24:32 +0000378 /// accelerator table section.
379 void emitAccelObjC();
380
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000381 /// \brief Emit namespace dies into a hashed accelerator table.
Eric Christopher4996c702011-11-07 09:24:32 +0000382 void emitAccelNamespaces();
383
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000384 /// \brief Emit type dies into a hashed accelerator table.
Eric Christopher4996c702011-11-07 09:24:32 +0000385 void emitAccelTypes();
Eric Christopher27527b22012-11-21 00:03:28 +0000386
Krzysztof Parzyszek228daa62013-02-12 18:00:14 +0000387 /// \brief Emit visible names into a debug pubnames section.
Eric Christopherdd1a0122013-09-13 00:35:05 +0000388 /// \param GnuStyle determines whether or not we want to emit
389 /// additional information into the table ala newer gcc for gdb
390 /// index.
391 void emitDebugPubNames(bool GnuStyle = false);
Krzysztof Parzyszek228daa62013-02-12 18:00:14 +0000392
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000393 /// \brief Emit visible types into a debug pubtypes section.
Eric Christopherdd1a0122013-09-13 00:35:05 +0000394 /// \param GnuStyle determines whether or not we want to emit
395 /// additional information into the table ala newer gcc for gdb
396 /// index.
397 void emitDebugPubTypes(bool GnuStyle = false);
Devang Patel04d2f2d2009-11-24 01:14:22 +0000398
David Blaikie192b45c2014-11-02 06:16:39 +0000399 void emitDebugPubSection(
400 bool GnuStyle, const MCSection *PSec, StringRef Name,
401 const StringMap<const DIE *> &(DwarfCompileUnit::*Accessor)() const);
David Blaikie0f55e832014-03-11 23:18:15 +0000402
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000403 /// \brief Emit visible names into a debug str section.
Devang Patel930143b2009-11-21 02:48:08 +0000404 void emitDebugStr();
Bill Wendling2f921f82009-05-15 09:23:25 +0000405
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000406 /// \brief Emit visible names into a debug loc section.
Devang Patel930143b2009-11-21 02:48:08 +0000407 void emitDebugLoc();
Bill Wendling2f921f82009-05-15 09:23:25 +0000408
David Blaikie94c1d7f2014-04-02 01:50:20 +0000409 /// \brief Emit visible names into a debug loc dwo section.
410 void emitDebugLocDWO();
411
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000412 /// \brief Emit visible names into a debug aranges section.
Eric Christopher7b30f2e42012-11-21 00:34:35 +0000413 void emitDebugARanges();
Bill Wendling2f921f82009-05-15 09:23:25 +0000414
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000415 /// \brief Emit visible names into a debug ranges section.
Devang Patel930143b2009-11-21 02:48:08 +0000416 void emitDebugRanges();
Bill Wendling2f921f82009-05-15 09:23:25 +0000417
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000418 /// \brief Emit inline info using custom format.
Devang Patel930143b2009-11-21 02:48:08 +0000419 void emitDebugInlineInfo();
Bill Wendling2b128d72009-05-20 23:19:06 +0000420
Eric Christophercdf218d2012-12-10 19:51:21 +0000421 /// DWARF 5 Experimental Split Dwarf Emitters
Eric Christopher9c2ecd92012-11-30 23:59:06 +0000422
David Blaikie38fe6342014-01-09 04:28:46 +0000423 /// \brief Initialize common features of skeleton units.
David Blaikie65a74662014-04-25 18:26:14 +0000424 void initSkeletonUnit(const DwarfUnit &U, DIE &Die,
David Blaikief9b6a552014-04-22 22:39:41 +0000425 std::unique_ptr<DwarfUnit> NewU);
David Blaikie38fe6342014-01-09 04:28:46 +0000426
Eric Christophercdf218d2012-12-10 19:51:21 +0000427 /// \brief Construct the split debug info compile unit for the debug info
428 /// section.
David Blaikief9b6a552014-04-22 22:39:41 +0000429 DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU);
Eric Christopher9c2ecd92012-11-30 23:59:06 +0000430
David Blaikie15ed5eb2014-01-10 01:38:41 +0000431 /// \brief Construct the split debug info compile unit for the debug info
432 /// section.
David Blaikief9b6a552014-04-22 22:39:41 +0000433 DwarfTypeUnit &constructSkeletonTU(DwarfTypeUnit &TU);
David Blaikie15ed5eb2014-01-10 01:38:41 +0000434
Eric Christopher9c2ecd92012-11-30 23:59:06 +0000435 /// \brief Emit the debug info dwo section.
436 void emitDebugInfoDWO();
437
Eric Christopher3c5a1912012-12-19 22:02:53 +0000438 /// \brief Emit the debug abbrev dwo section.
439 void emitDebugAbbrevDWO();
440
David Blaikie4a2f95f2014-03-18 01:17:26 +0000441 /// \brief Emit the debug line dwo section.
442 void emitDebugLineDWO();
443
Eric Christopher3bf29fd2012-12-27 02:14:01 +0000444 /// \brief Emit the debug str dwo section.
445 void emitDebugStrDWO();
446
David Blaikie3c842622013-12-04 21:31:26 +0000447 /// Flags to let the linker know we have emitted new style pubnames. Only
448 /// emit it here if we don't have a skeleton CU for split dwarf.
David Blaikie65a74662014-04-25 18:26:14 +0000449 void addGnuPubAttributes(DwarfUnit &U, DIE &D) const;
David Blaikie3c842622013-12-04 21:31:26 +0000450
Eric Christopher4287a492013-12-09 23:57:44 +0000451 /// \brief Create new DwarfCompileUnit for the given metadata node with tag
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000452 /// DW_TAG_compile_unit.
David Blaikief9b6a552014-04-22 22:39:41 +0000453 DwarfCompileUnit &constructDwarfCompileUnit(DICompileUnit DIUnit);
Devang Patel1a0df9a2010-05-10 22:49:55 +0000454
David Blaikie1fd43652013-05-07 21:35:53 +0000455 /// \brief Construct imported_module or imported_declaration DIE.
David Blaikie8912df12014-08-31 05:41:15 +0000456 void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
457 const MDNode *N);
David Blaikie684fc532013-05-06 23:33:07 +0000458
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000459 /// \brief Register a source line with debug info. Returns the unique
460 /// label that was emitted and which provides correspondence to the
461 /// source line list.
Devang Patel34a66202011-05-11 19:22:19 +0000462 void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
463 unsigned Flags);
Eric Christopher27527b22012-11-21 00:03:28 +0000464
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000465 /// \brief Indentify instructions that are marking the beginning of or
466 /// ending of a scope.
Devang Patel359b0132010-04-08 18:43:56 +0000467 void identifyScopeMarkers();
Devang Patelf1d5a1e2010-04-08 15:37:09 +0000468
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000469 /// \brief Populate LexicalScope entries with variables' info.
David Blaikie263a0082014-10-23 00:06:27 +0000470 void collectVariableInfo(DwarfCompileUnit &TheCU, DISubprogram SP,
Duncan P. N. Exon Smith62e0f452015-04-15 22:29:27 +0000471 DenseSet<InlinedVariable> &ProcessedVars);
Eric Christopher27527b22012-11-21 00:03:28 +0000472
Adrian Prantlb1416832014-08-01 22:11:58 +0000473 /// \brief Build the location list for all DBG_VALUEs in the
474 /// function that describe the same variable.
475 void buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
David Blaikiee1a26a62014-08-05 23:14:16 +0000476 const DbgValueHistoryMap::InstrRanges &Ranges);
Adrian Prantlb1416832014-08-01 22:11:58 +0000477
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000478 /// \brief Collect variable information from the side table maintained
479 /// by MMI.
Duncan P. N. Exon Smith62e0f452015-04-15 22:29:27 +0000480 void collectVariableInfoFromMMITable(DenseSet<InlinedVariable> &P);
Jakob Stoklund Olesen9a624fa2011-03-26 02:19:36 +0000481
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000482 /// \brief Ensure that a label will be emitted before MI.
Jakob Stoklund Olesen9a624fa2011-03-26 02:19:36 +0000483 void requestLabelBeforeInsn(const MachineInstr *MI) {
Craig Toppere73658d2014-04-28 04:05:08 +0000484 LabelsBeforeInsn.insert(std::make_pair(MI, nullptr));
Jakob Stoklund Olesen9a624fa2011-03-26 02:19:36 +0000485 }
486
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000487 /// \brief Ensure that a label will be emitted after MI.
Jakob Stoklund Olesen9a624fa2011-03-26 02:19:36 +0000488 void requestLabelAfterInsn(const MachineInstr *MI) {
Craig Toppere73658d2014-04-28 04:05:08 +0000489 LabelsAfterInsn.insert(std::make_pair(MI, nullptr));
Jakob Stoklund Olesen9a624fa2011-03-26 02:19:36 +0000490 }
491
Bill Wendling2f921f82009-05-15 09:23:25 +0000492public:
493 //===--------------------------------------------------------------------===//
494 // Main entry points.
495 //
Chris Lattnerf0d6bd32010-04-05 05:11:15 +0000496 DwarfDebug(AsmPrinter *A, Module *M);
Bill Wendling2f921f82009-05-15 09:23:25 +0000497
Reid Klecknerdd2647e2014-04-30 20:34:31 +0000498 ~DwarfDebug() override;
499
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000500 /// \brief Emit all Dwarf sections that should come prior to the
Bill Wendling2f921f82009-05-15 09:23:25 +0000501 /// content.
Eric Christopher58f41952012-11-19 22:42:15 +0000502 void beginModule();
Bill Wendling2f921f82009-05-15 09:23:25 +0000503
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000504 /// \brief Emit all Dwarf sections that should come after the content.
Craig Topper7b883b32014-03-08 06:31:39 +0000505 void endModule() override;
Bill Wendling2f921f82009-05-15 09:23:25 +0000506
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000507 /// \brief Gather pre-function debug information.
Craig Topper7b883b32014-03-08 06:31:39 +0000508 void beginFunction(const MachineFunction *MF) override;
Bill Wendling2f921f82009-05-15 09:23:25 +0000509
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000510 /// \brief Gather and emit post-function debug information.
Craig Topper7b883b32014-03-08 06:31:39 +0000511 void endFunction(const MachineFunction *MF) override;
Bill Wendling2f921f82009-05-15 09:23:25 +0000512
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000513 /// \brief Process beginning of an instruction.
Craig Topper7b883b32014-03-08 06:31:39 +0000514 void beginInstruction(const MachineInstr *MI) override;
Bill Wendling2f921f82009-05-15 09:23:25 +0000515
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000516 /// \brief Process end of an instruction.
Craig Topper7b883b32014-03-08 06:31:39 +0000517 void endInstruction() override;
Devang Patelf20c4f72011-04-12 22:53:02 +0000518
Eric Christopher67646432013-07-26 17:02:41 +0000519 /// \brief Add a DIE to the set of types that we're going to pull into
520 /// type units.
David Blaikie15632ae2014-02-12 00:31:30 +0000521 void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
David Blaikie65a74662014-04-25 18:26:14 +0000522 DIE &Die, DICompositeType CTy);
Eric Christopher67646432013-07-26 17:02:41 +0000523
Richard Mitton21101b32013-09-19 23:21:01 +0000524 /// \brief Add a label so that arange data can be generated for it.
Alexey Samsonov4436bf02013-10-03 08:54:43 +0000525 void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
Richard Mitton21101b32013-09-19 23:21:01 +0000526
Richard Mitton089ed892013-09-23 17:56:20 +0000527 /// \brief For symbols that have a size designated (e.g. common symbols),
528 /// this tracks that size.
Craig Topper7b883b32014-03-08 06:31:39 +0000529 void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {
Eric Christophera5a79422013-12-09 23:32:48 +0000530 SymSize[Sym] = Size;
531 }
Richard Mitton089ed892013-09-23 17:56:20 +0000532
Paul Robinson78cc0822015-03-04 20:55:11 +0000533 /// \brief Returns whether to use DW_OP_GNU_push_tls_address, instead of the
534 /// standard DW_OP_form_tls_address opcode
535 bool useGNUTLSOpcode() const { return UseGNUTLSOpcode; }
536
Eric Christopher55c51812012-11-21 00:03:31 +0000537 // Experimental DWARF5 features.
538
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000539 /// \brief Returns whether or not to emit tables that dwarf consumers can
540 /// use to accelerate lookup.
Eric Christopher411bd592014-03-06 00:00:53 +0000541 bool useDwarfAccelTables() const { return HasDwarfAccelTables; }
Eric Christopher55c51812012-11-21 00:03:31 +0000542
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000543 /// \brief Returns whether or not to change the current debug info for the
Eric Christophercdf218d2012-12-10 19:51:21 +0000544 /// split dwarf proposal support.
Eric Christopher411bd592014-03-06 00:00:53 +0000545 bool useSplitDwarf() const { return HasSplitDwarf; }
Manman Renac8062b2013-07-02 23:40:10 +0000546
547 /// Returns the Dwarf Version.
548 unsigned getDwarfVersion() const { return DwarfVersion; }
Manman Ren60352032013-09-05 18:48:31 +0000549
Eric Christopher384f3fe2014-03-20 19:16:16 +0000550 /// Returns the previous CU that was being updated
551 const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
David Blaikied0f10372014-09-09 23:13:01 +0000552 void setPrevCU(const DwarfCompileUnit *PrevCU) { this->PrevCU = PrevCU; }
Eric Christopher384f3fe2014-03-20 19:16:16 +0000553
Eric Christopher4f17ee02014-03-08 00:29:41 +0000554 /// Returns the entries for the .debug_loc section.
Duncan P. N. Exon Smith364a3002015-04-17 21:34:47 +0000555 const DebugLocStream &getDebugLocs() const { return DebugLocs; }
Eric Christopher4f17ee02014-03-08 00:29:41 +0000556
557 /// \brief Emit an entry for the debug loc section. This can be used to
558 /// handle an entry that's going to be emitted into the debug loc section.
Adrian Prantl92da14b2015-03-02 22:02:33 +0000559 void emitDebugLocEntry(ByteStreamer &Streamer,
Duncan P. N. Exon Smith364a3002015-04-17 21:34:47 +0000560 const DebugLocStream::Entry &Entry);
Eric Christopher4f17ee02014-03-08 00:29:41 +0000561
David Blaikie0e84adc2014-04-01 16:17:41 +0000562 /// Emit the location for a debug loc entry, including the size header.
Duncan P. N. Exon Smith364a3002015-04-17 21:34:47 +0000563 void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry);
David Blaikie0e84adc2014-04-01 16:17:41 +0000564
Eric Christopher87b9c492013-10-05 00:32:34 +0000565 /// Find the MDNode for the given reference.
Duncan P. N. Exon Smith000fa2c2015-04-07 04:14:33 +0000566 template <typename T> T *resolve(TypedDebugNodeRef<T> Ref) const {
567 return Ref.resolve(TypeIdentifierMap);
568 }
Manman Ren60352032013-09-05 18:48:31 +0000569
Adrian Prantl1a1647c2014-03-18 02:34:58 +0000570 /// \brief Return the TypeIdentifierMap.
Eric Christopherc0bd5f82014-03-18 20:39:54 +0000571 const DITypeIdentifierMap &getTypeIdentifierMap() const {
Adrian Prantl1a1647c2014-03-18 02:34:58 +0000572 return TypeIdentifierMap;
573 }
574
Eric Christopherdd508382014-03-06 00:00:56 +0000575 /// Find the DwarfCompileUnit for the given CU Die.
576 DwarfCompileUnit *lookupUnit(const DIE *CU) const {
577 return CUDieMap.lookup(CU);
578 }
Manman Ren3eb9dff2013-09-09 19:05:21 +0000579 /// isSubprogramContext - Return true if Context is either a subprogram
580 /// or another context nested inside a subprogram.
581 bool isSubprogramContext(const MDNode *Context);
David Blaikied75fb282014-04-23 21:20:10 +0000582
David Blaikieb0b3fcf2014-04-25 18:52:29 +0000583 void addSubprogramNames(DISubprogram SP, DIE &Die);
David Blaikie2406a0622014-04-23 23:37:35 +0000584
David Blaikied75fb282014-04-23 21:20:10 +0000585 AddressPool &getAddressPool() { return AddrPool; }
David Blaikie2406a0622014-04-23 23:37:35 +0000586
David Blaikieb0b3fcf2014-04-25 18:52:29 +0000587 void addAccelName(StringRef Name, const DIE &Die);
David Blaikie0ee82b92014-04-24 00:53:32 +0000588
David Blaikieb0b3fcf2014-04-25 18:52:29 +0000589 void addAccelObjC(StringRef Name, const DIE &Die);
David Blaikieecf04152014-04-24 01:02:42 +0000590
David Blaikieb0b3fcf2014-04-25 18:52:29 +0000591 void addAccelNamespace(StringRef Name, const DIE &Die);
David Blaikie18d33752014-04-24 01:23:49 +0000592
David Blaikieb0b3fcf2014-04-25 18:52:29 +0000593 void addAccelType(StringRef Name, const DIE &Die, char Flags);
David Blaikiecda2aa82014-10-04 16:24:00 +0000594
595 const MachineFunction *getCurrentFunction() const { return CurFn; }
David Blaikie9c65b132014-10-08 22:20:02 +0000596
David Blaikie33702a32014-10-08 23:09:42 +0000597 iterator_range<ImportedEntityMap::const_iterator>
598 findImportedEntitiesForScope(const MDNode *Scope) const {
David Blaikie9c65b132014-10-08 22:20:02 +0000599 return make_range(std::equal_range(
600 ScopesWithImportedEntities.begin(), ScopesWithImportedEntities.end(),
David Blaikie33702a32014-10-08 23:09:42 +0000601 std::pair<const MDNode *, const MDNode *>(Scope, nullptr),
602 less_first()));
David Blaikie9c65b132014-10-08 22:20:02 +0000603 }
604
605 /// \brief A helper function to check whether the DIE for a given Scope is
606 /// going to be null.
607 bool isLexicalScopeDIENull(LexicalScope *Scope);
608
David Blaikie01b48a82014-10-09 16:50:53 +0000609 /// \brief Return Label preceding the instruction.
610 MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
611
612 /// \brief Return Label immediately following the instruction.
613 MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
614
David Blaikie9c65b132014-10-08 22:20:02 +0000615 // FIXME: Sink these functions down into DwarfFile/Dwarf*Unit.
616
David Blaikie1d072342014-10-09 20:21:36 +0000617 SmallPtrSet<const MDNode *, 16> &getProcessedSPNodes() {
618 return ProcessedSPNodes;
619 }
Devang Patelf6eeaeb2009-11-10 23:06:00 +0000620};
Bill Wendling2f921f82009-05-15 09:23:25 +0000621} // End of namespace llvm
622
623#endif