blob: 1ec5cf1b309ff8787025855832041c635d2b7e34 [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"
David Blaikie1275e4f2014-04-01 21:49:04 +000019#include "DebugLocEntry.h"
David Blaikie0a456de2014-04-02 01:43:18 +000020#include "DebugLocList.h"
David Blaikie2406a0622014-04-23 23:37:35 +000021#include "DwarfAccelTable.h"
Chandler Carruthd9903882015-01-14 11:23:27 +000022#include "DwarfFile.h"
Devang Patel018b29b2010-01-19 06:19:05 +000023#include "llvm/ADT/DenseMap.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;
Eric Christopherce4a9442014-03-18 20:37:10 +000044class DwarfCompileUnit;
45class DwarfDebug;
46class DwarfTypeUnit;
47class DwarfUnit;
Bill Wendling2f921f82009-05-15 09:23:25 +000048class MachineModuleInfo;
Bill Wendling2f921f82009-05-15 09:23:25 +000049
50//===----------------------------------------------------------------------===//
Eric Christopheracdcbdb2012-11-27 22:43:45 +000051/// \brief This class is used to record source line correspondence.
Benjamin Kramer079b96e2013-09-11 18:05:11 +000052class SrcLineInfo {
Eric Christophera5a79422013-12-09 23:32:48 +000053 unsigned Line; // Source line number.
54 unsigned Column; // Source column.
55 unsigned SourceID; // Source ID number.
56 MCSymbol *Label; // Label in code ID number.
Bill Wendling2f921f82009-05-15 09:23:25 +000057public:
Chris Lattnerb4666f42010-03-14 08:15:55 +000058 SrcLineInfo(unsigned L, unsigned C, unsigned S, MCSymbol *label)
Eric Christophera5a79422013-12-09 23:32:48 +000059 : Line(L), Column(C), SourceID(S), Label(label) {}
Bill Wendling2f921f82009-05-15 09:23:25 +000060
61 // Accessors
62 unsigned getLine() const { return Line; }
63 unsigned getColumn() const { return Column; }
64 unsigned getSourceID() const { return SourceID; }
Chris Lattnerb4666f42010-03-14 08:15:55 +000065 MCSymbol *getLabel() const { return Label; }
Bill Wendling2f921f82009-05-15 09:23:25 +000066};
67
Devang Patelf20c4f72011-04-12 22:53:02 +000068//===----------------------------------------------------------------------===//
Eric Christopheracdcbdb2012-11-27 22:43:45 +000069/// \brief This class is used to track local variable information.
Adrian Prantlca7e4702015-02-10 23:18:28 +000070///
Eric Christopherffc5ff32015-02-17 20:02:28 +000071/// - Variables whose location changes over time have a DotDebugLocOffset and
72/// the other fields are not used.
Adrian Prantlca7e4702015-02-10 23:18:28 +000073///
74/// - Variables that are described by multiple MMI table entries have multiple
75/// expressions and frame indices.
Benjamin Kramer079b96e2013-09-11 18:05:11 +000076class DbgVariable {
Adrian Prantlca7e4702015-02-10 23:18:28 +000077 DIVariable Var; /// Variable Descriptor.
78 SmallVector<DIExpression, 1> Expr; /// Complex address location expression.
79 DIE *TheDIE; /// Variable DIE.
80 unsigned DotDebugLocOffset; /// Offset in DotDebugLocEntries.
81 const MachineInstr *MInsn; /// DBG_VALUE instruction of the variable.
82 SmallVector<int, 1> FrameIndex; /// Frame index of the variable.
Manman Renb3388602013-10-05 01:43:03 +000083 DwarfDebug *DD;
Eric Christophera5a79422013-12-09 23:32:48 +000084
Devang Patelf20c4f72011-04-12 22:53:02 +000085public:
Adrian Prantlc1197542014-05-30 21:10:13 +000086 /// Construct a DbgVariable from a DIVariable.
Adrian Prantlca7e4702015-02-10 23:18:28 +000087 DbgVariable(DIVariable V, DIExpression E, DwarfDebug *DD, int FI = ~0)
88 : Var(V), Expr(1, E), TheDIE(nullptr), DotDebugLocOffset(~0U),
89 MInsn(nullptr), DD(DD) {
90 FrameIndex.push_back(FI);
Duncan P. N. Exon Smithe9d379c2015-03-16 21:03:55 +000091 assert(!E || E->isValid());
Adrian Prantl87b7eb92014-10-01 18:55:02 +000092 }
Devang Patelf20c4f72011-04-12 22:53:02 +000093
Adrian Prantlc1197542014-05-30 21:10:13 +000094 /// Construct a DbgVariable from a DEBUG_VALUE.
95 /// AbstractVar may be NULL.
David Blaikie6f9e8672014-06-13 23:52:55 +000096 DbgVariable(const MachineInstr *DbgValue, DwarfDebug *DD)
Eric Christopherffc5ff32015-02-17 20:02:28 +000097 : Var(DbgValue->getDebugVariable()),
98 Expr(1, DbgValue->getDebugExpression()), TheDIE(nullptr),
99 DotDebugLocOffset(~0U), MInsn(DbgValue), DD(DD) {
Adrian Prantlca7e4702015-02-10 23:18:28 +0000100 FrameIndex.push_back(~0);
101 }
Adrian Prantlc1197542014-05-30 21:10:13 +0000102
Devang Patelf20c4f72011-04-12 22:53:02 +0000103 // Accessors.
Eric Christophera5a79422013-12-09 23:32:48 +0000104 DIVariable getVariable() const { return Var; }
Adrian Prantlca7e4702015-02-10 23:18:28 +0000105 const ArrayRef<DIExpression> getExpression() const { return Expr; }
David Blaikiee071fc82014-04-25 17:32:19 +0000106 void setDIE(DIE &D) { TheDIE = &D; }
Eric Christophera5a79422013-12-09 23:32:48 +0000107 DIE *getDIE() const { return TheDIE; }
108 void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; }
109 unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; }
Duncan P. N. Exon Smith7348dda2015-04-14 02:22:36 +0000110 StringRef getName() const { return Var->getName(); }
Eric Christophera5a79422013-12-09 23:32:48 +0000111 const MachineInstr *getMInsn() const { return MInsn; }
Adrian Prantlca7e4702015-02-10 23:18:28 +0000112 const ArrayRef<int> getFrameIndex() const { return FrameIndex; }
113
114 void addMMIEntry(const DbgVariable &V) {
115 assert( DotDebugLocOffset == ~0U && !MInsn && "not an MMI entry");
116 assert(V.DotDebugLocOffset == ~0U && !V.MInsn && "not an MMI entry");
117 assert(V.Var == Var && "conflicting DIVariable");
118
119 if (V.getFrameIndex().back() != ~0) {
120 auto E = V.getExpression();
121 auto FI = V.getFrameIndex();
122 Expr.append(E.begin(), E.end());
123 FrameIndex.append(FI.begin(), FI.end());
124 }
125 assert(Expr.size() > 1
Duncan P. N. Exon Smith6a0320a2015-04-14 01:12:42 +0000126 ? std::all_of(Expr.begin(), Expr.end(),
127 [](DIExpression &E) { return E->isBitPiece(); })
128 : (true && "conflicting locations for variable"));
Adrian Prantlca7e4702015-02-10 23:18:28 +0000129 }
130
Eric Christopher27527b22012-11-21 00:03:28 +0000131 // Translate tag to proper Dwarf tag.
David Blaikieefc403b2014-04-12 02:24:04 +0000132 dwarf::Tag getTag() const {
Duncan P. N. Exon Smith7348dda2015-04-14 02:22:36 +0000133 if (Var->getTag() == dwarf::DW_TAG_arg_variable)
Devang Patel6e4d2c92011-08-15 18:35:42 +0000134 return dwarf::DW_TAG_formal_parameter;
Eric Christopher27527b22012-11-21 00:03:28 +0000135
Devang Patel6e4d2c92011-08-15 18:35:42 +0000136 return dwarf::DW_TAG_variable;
137 }
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000138 /// \brief Return true if DbgVariable is artificial.
Eric Christophera5a79422013-12-09 23:32:48 +0000139 bool isArtificial() const {
Duncan P. N. Exon Smith7348dda2015-04-14 02:22:36 +0000140 if (Var->isArtificial())
Devang Pateld7d80aa2011-08-15 18:40:16 +0000141 return true;
Eric Christopherc1c8a1b2012-09-21 22:18:52 +0000142 if (getType().isArtificial())
Devang Pateld7d80aa2011-08-15 18:40:16 +0000143 return true;
144 return false;
145 }
Eric Christophere3417762012-09-12 23:36:19 +0000146
Eric Christophera5a79422013-12-09 23:32:48 +0000147 bool isObjectPointer() const {
Duncan P. N. Exon Smith7348dda2015-04-14 02:22:36 +0000148 if (Var->isObjectPointer())
Eric Christophere3417762012-09-12 23:36:19 +0000149 return true;
Eric Christopherc1c8a1b2012-09-21 22:18:52 +0000150 if (getType().isObjectPointer())
Eric Christophere3417762012-09-12 23:36:19 +0000151 return true;
152 return false;
153 }
Eric Christopher27527b22012-11-21 00:03:28 +0000154
Eric Christophera5a79422013-12-09 23:32:48 +0000155 bool variableHasComplexAddress() const {
Duncan P. N. Exon Smithe686f152015-04-06 23:27:40 +0000156 assert(Var && "Invalid complex DbgVariable!");
Adrian Prantlca7e4702015-02-10 23:18:28 +0000157 assert(Expr.size() == 1 &&
158 "variableHasComplexAddress() invoked on multi-FI variable");
Duncan P. N. Exon Smith6a0320a2015-04-14 01:12:42 +0000159 return Expr.back()->getNumElements() > 0;
Devang Patelf20c4f72011-04-12 22:53:02 +0000160 }
Adrian Prantl1a1647c2014-03-18 02:34:58 +0000161 bool isBlockByrefVariable() const;
Devang Patelf20c4f72011-04-12 22:53:02 +0000162 DIType getType() const;
Manman Renbe5576f2013-10-08 19:07:44 +0000163
164private:
165 /// resolve - Look in the DwarfDebug map for the MDNode that
166 /// corresponds to the reference.
167 template <typename T> T resolve(DIRef<T> Ref) const;
Devang Patelf20c4f72011-04-12 22:53:02 +0000168};
169
Eric Christopherc8a310e2012-12-10 23:34:43 +0000170
Eric Christopher670ee0e2013-10-24 21:20:23 +0000171/// \brief Helper used to pair up a symbol and its DWARF compile unit.
Richard Mitton21101b32013-09-19 23:21:01 +0000172struct SymbolCU {
Eric Christopher4287a492013-12-09 23:57:44 +0000173 SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
Richard Mitton21101b32013-09-19 23:21:01 +0000174 const MCSymbol *Sym;
Eric Christopher4287a492013-12-09 23:57:44 +0000175 DwarfCompileUnit *CU;
Richard Mitton21101b32013-09-19 23:21:01 +0000176};
177
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000178/// \brief Collects and handles dwarf debug information.
Timur Iskhodzhanov1cd14442013-12-03 15:10:23 +0000179class DwarfDebug : public AsmPrinterHandler {
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000180 // Target of Dwarf emission.
Chris Lattner3a383cb2010-04-05 00:13:49 +0000181 AsmPrinter *Asm;
Chris Lattneracda87b2010-04-05 05:31:04 +0000182
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000183 // Collected machine module information.
Chris Lattner3a383cb2010-04-05 00:13:49 +0000184 MachineModuleInfo *MMI;
185
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000186 // All DIEValues are allocated through this allocator.
Benjamin Kramer07480082012-06-09 10:34:15 +0000187 BumpPtrAllocator DIEValueAllocator;
188
Eric Christopher4287a492013-12-09 23:57:44 +0000189 // Maps MDNode with its corresponding DwarfCompileUnit.
Eric Christopher179fba12014-01-29 22:06:23 +0000190 MapVector<const MDNode *, DwarfCompileUnit *> CUMap;
Bill Wendling2f921f82009-05-15 09:23:25 +0000191
Eric Christopher4287a492013-12-09 23:57:44 +0000192 // Maps subprogram MDNode with its corresponding DwarfCompileUnit.
David Blaikie7d6f29d2014-10-10 16:59:52 +0000193 MapVector<const MDNode *, DwarfCompileUnit *> SPMap;
Devang Pateleb1bb4e2011-08-16 22:09:43 +0000194
Eric Christopher4287a492013-12-09 23:57:44 +0000195 // Maps a CU DIE with its corresponding DwarfCompileUnit.
196 DenseMap<const DIE *, DwarfCompileUnit *> CUDieMap;
Manman Rence20d462013-10-29 22:57:10 +0000197
Alexey Samsonov4436bf02013-10-03 08:54:43 +0000198 // List of all labels used in aranges generation.
199 std::vector<SymbolCU> ArangeLabels;
Richard Mitton21101b32013-09-19 23:21:01 +0000200
Richard Mitton089ed892013-09-23 17:56:20 +0000201 // Size of each symbol emitted (for those symbols that have a specific size).
Eric Christophera5a79422013-12-09 23:32:48 +0000202 DenseMap<const MCSymbol *, uint64_t> SymSize;
Richard Mitton089ed892013-09-23 17:56:20 +0000203
Devang Patel7e623022011-08-10 20:55:27 +0000204 LexicalScopes LScopes;
Devang Patel95cd4b92010-03-25 15:09:44 +0000205
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000206 // Collection of abstract variables.
David Blaikie825bdd22014-05-21 22:41:17 +0000207 DenseMap<const MDNode *, std::unique_ptr<DbgVariable>> AbstractVariables;
David Blaikieeb1a2722014-06-13 22:18:23 +0000208 SmallVector<std::unique_ptr<DbgVariable>, 64> ConcreteVariables;
Devang Patelf6eeaeb2009-11-10 23:06:00 +0000209
David Blaikie0a456de2014-04-02 01:43:18 +0000210 // Collection of DebugLocEntry. Stored in a linked list so that DIELocLists
211 // can refer to them in spite of insertions into this list.
212 SmallVector<DebugLocList, 4> DotDebugLocEntries;
Devang Patel9fc11702010-05-25 23:40:22 +0000213
Eric Christopher48fef592012-12-20 21:58:40 +0000214 // This is a collection of subprogram MDNodes that are processed to
215 // create DIEs.
Devang Patelf3b2db62010-06-28 18:25:03 +0000216 SmallPtrSet<const MDNode *, 16> ProcessedSPNodes;
217
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000218 // Maps instruction with label emitted before instruction.
Devang Patel6c74a872010-04-27 19:46:33 +0000219 DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn;
Devang Patel3ebd8932010-04-08 16:50:29 +0000220
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000221 // Maps instruction with label emitted after instruction.
Devang Patel6c74a872010-04-27 19:46:33 +0000222 DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn;
Devang Patel3ebd8932010-04-08 16:50:29 +0000223
Alexey Samsonov414b6fb2014-04-30 21:34:11 +0000224 // History of DBG_VALUE and clobber instructions for each user variable.
Alexey Samsonov0436caa2014-04-30 23:02:40 +0000225 // Variables are listed in order of appearance.
Jakob Stoklund Olesen9a624fa2011-03-26 02:19:36 +0000226 DbgValueHistoryMap DbgValues;
Jakob Stoklund Olesenec0ac3c2011-03-22 22:33:08 +0000227
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000228 // Previous instruction's location information. This is used to determine
229 // label location to indicate scope boundries in dwarf debug info.
Chris Lattner915c5f92010-04-02 19:42:39 +0000230 DebugLoc PrevInstLoc;
Devang Patel12563b32010-04-16 23:33:45 +0000231 MCSymbol *PrevLabel;
Devang Patelbd477be2010-03-29 17:20:31 +0000232
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000233 // This location indicates end of function prologue and beginning of function
234 // body.
Devang Patel34a66202011-05-11 19:22:19 +0000235 DebugLoc PrologEndLoc;
236
Timur Iskhodzhanov1cd14442013-12-03 15:10:23 +0000237 // If nonnull, stores the current machine function we're processing.
238 const MachineFunction *CurFn;
239
240 // If nonnull, stores the current machine instruction we're processing.
241 const MachineInstr *CurMI;
242
Eric Christopher384f3fe2014-03-20 19:16:16 +0000243 // If nonnull, stores the CU in which the previous subprogram was contained.
244 const DwarfCompileUnit *PrevCU;
245
Nick Lewyckyd1ee7f82011-11-02 20:55:33 +0000246 // As an optimization, there is no need to emit an entry in the directory
Eric Christopher808fd7b2013-07-03 01:57:23 +0000247 // table for the same directory as DW_AT_comp_dir.
Nick Lewyckyd1ee7f82011-11-02 20:55:33 +0000248 StringRef CompilationDir;
249
Eric Christopherc8a310e2012-12-10 23:34:43 +0000250 // Holder for the file specific debug information.
Eric Christopherf8194852013-12-05 18:06:10 +0000251 DwarfFile InfoHolder;
Eric Christopherc8a310e2012-12-10 23:34:43 +0000252
Eric Christopher0aa4a672012-12-10 22:25:41 +0000253 // Holders for the various debug information flags that we might need to
254 // have exposed. See accessor functions below for description.
255
Eric Christopher070bf162013-07-03 01:57:26 +0000256 // Holder for imported entities.
257 typedef SmallVector<std::pair<const MDNode *, const MDNode *>, 32>
Eric Christophera5a79422013-12-09 23:32:48 +0000258 ImportedEntityMap;
Eric Christopher070bf162013-07-03 01:57:26 +0000259 ImportedEntityMap ScopesWithImportedEntities;
260
David Blaikie47f615e2013-12-17 23:32:35 +0000261 // Map from MDNodes for user-defined types to the type units that describe
262 // them.
263 DenseMap<const MDNode *, const DwarfTypeUnit *> DwarfTypeUnits;
Eric Christopher67646432013-07-26 17:02:41 +0000264
Eric Christopherffc5ff32015-02-17 20:02:28 +0000265 SmallVector<std::pair<std::unique_ptr<DwarfTypeUnit>, DICompositeType>, 1>
266 TypeUnitsUnderConstruction;
David Blaikiee12b49a2014-04-26 17:27:38 +0000267
Eric Christopher4d36ca02013-08-26 23:24:35 +0000268 // Whether to emit the pubnames/pubtypes sections.
269 bool HasDwarfPubSections;
270
Eric Christopher1ad84572014-01-15 00:04:29 +0000271 // Whether or not to use AT_ranges for compilation units.
272 bool HasCURanges;
273
Eric Christopher2037caf2014-01-28 00:49:26 +0000274 // Whether we emitted a function into a section other than the default
275 // text.
276 bool UsedNonDefaultText;
277
Paul Robinson78cc0822015-03-04 20:55:11 +0000278 // Whether to use the GNU TLS opcode (instead of the standard opcode).
279 bool UseGNUTLSOpcode;
280
Eric Christopher4d36ca02013-08-26 23:24:35 +0000281 // Version of dwarf we're emitting.
282 unsigned DwarfVersion;
283
Eric Christopher0a13eb32013-11-21 22:56:11 +0000284 // Maps from a type identifier to the actual MDNode.
285 DITypeIdentifierMap TypeIdentifierMap;
286
Eric Christopher42e39942012-11-29 22:56:13 +0000287 // DWARF5 Experimental Options
Eric Christopher7b30f2e42012-11-21 00:34:35 +0000288 bool HasDwarfAccelTables;
Eric Christophercdf218d2012-12-10 19:51:21 +0000289 bool HasSplitDwarf;
Manman Renac8062b2013-07-02 23:40:10 +0000290
Eric Christopherd692c1d2012-12-11 19:42:09 +0000291 // Separated Dwarf Variables
Eric Christopherd79f5482012-12-10 19:51:13 +0000292 // In general these will all be for bits that are left in the
293 // original object file, rather than things that are meant
294 // to be in the .dwo sections.
295
Eric Christopher3bf29fd2012-12-27 02:14:01 +0000296 // Holder for the skeleton information.
Eric Christopherf8194852013-12-05 18:06:10 +0000297 DwarfFile SkeletonHolder;
Eric Christopherd79f5482012-12-10 19:51:13 +0000298
David Blaikie47f4b822014-03-19 00:11:28 +0000299 /// Store file names for type units under fission in a line table header that
300 /// will be emitted into debug_line.dwo.
301 // FIXME: replace this with a map from comp_dir to table so that we can emit
302 // multiple tables during LTO each of which uses directory 0, referencing the
303 // comp_dir of all the type units that use it.
David Blaikie8287aff2014-03-18 02:13:23 +0000304 MCDwarfDwoLineTable SplitTypeUnitFileTable;
David Blaikie4a2f95f2014-03-18 01:17:26 +0000305
David Blaikie47f4b822014-03-19 00:11:28 +0000306 // True iff there are multiple CUs in this module.
307 bool SingleCU;
David Blaikiee1c79742014-09-30 21:28:32 +0000308 bool IsDarwin;
Paul Robinson78cc0822015-03-04 20:55:11 +0000309 bool IsPS4;
David Blaikie47f4b822014-03-19 00:11:28 +0000310
David Blaikied75fb282014-04-23 21:20:10 +0000311 AddressPool AddrPool;
312
David Blaikie2406a0622014-04-23 23:37:35 +0000313 DwarfAccelTable AccelNames;
David Blaikie0ee82b92014-04-24 00:53:32 +0000314 DwarfAccelTable AccelObjC;
David Blaikieecf04152014-04-24 01:02:42 +0000315 DwarfAccelTable AccelNamespace;
David Blaikie18d33752014-04-24 01:23:49 +0000316 DwarfAccelTable AccelTypes;
David Blaikie2406a0622014-04-23 23:37:35 +0000317
David Blaikie2f040112014-07-25 16:10:16 +0000318 DenseMap<const Function *, DISubprogram> FunctionDIs;
319
David Blaikie47f4b822014-03-19 00:11:28 +0000320 MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
321
David Blaikiec33b3cd2014-04-22 21:27:37 +0000322 const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() {
Eric Christophera5a79422013-12-09 23:32:48 +0000323 return InfoHolder.getUnits();
324 }
David Blaikiefd1eff52013-11-26 19:14:34 +0000325
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000326 /// \brief Find abstract variable associated with Var.
David Blaikiebe7c6772014-06-13 22:29:31 +0000327 DbgVariable *getExistingAbstractVariable(const DIVariable &DV,
David Blaikie36408e72014-06-04 23:50:52 +0000328 DIVariable &Cleansed);
David Blaikiee847f132014-06-13 22:35:44 +0000329 DbgVariable *getExistingAbstractVariable(const DIVariable &DV);
David Blaikie6f9e8672014-06-13 23:52:55 +0000330 void createAbstractVariable(const DIVariable &DV, LexicalScope *Scope);
331 void ensureAbstractVariableIsCreated(const DIVariable &Var,
332 const MDNode *Scope);
333 void ensureAbstractVariableIsCreatedIfScoped(const DIVariable &Var,
334 const MDNode *Scope);
Devang Patelf6eeaeb2009-11-10 23:06:00 +0000335
David Blaikiee872a6e2014-04-29 15:58:35 +0000336 /// \brief Construct a DIE for this abstract scope.
David Blaikie73cc7052014-10-09 20:36:27 +0000337 void constructAbstractSubprogramScopeDIE(LexicalScope *Scope);
338
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000339 /// \brief Compute the size and offset of a DIE given an incoming Offset.
Eric Christopher1f0cbb82012-11-20 22:14:13 +0000340 unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
Bill Wendling2f921f82009-05-15 09:23:25 +0000341
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000342 /// \brief Compute the size and offset of all the DIEs.
Devang Patel930143b2009-11-21 02:48:08 +0000343 void computeSizeAndOffsets();
Bill Wendling2f921f82009-05-15 09:23:25 +0000344
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000345 /// \brief Collect info for variables that were optimized out.
Eric Christopher960ac372012-11-22 00:59:49 +0000346 void collectDeadVariables();
347
David Blaikieeb1a2722014-06-13 22:18:23 +0000348 void finishVariableDefinitions();
349
David Blaikief7221ad2014-05-27 18:37:43 +0000350 void finishSubprogramDefinitions();
351
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000352 /// \brief Finish off debug information after all functions have been
353 /// processed.
Eric Christopher960ac372012-11-22 00:59:49 +0000354 void finalizeModuleInfo();
355
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000356 /// \brief Emit the debug info section.
Devang Patel930143b2009-11-21 02:48:08 +0000357 void emitDebugInfo();
Bill Wendling2f921f82009-05-15 09:23:25 +0000358
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000359 /// \brief Emit the abbreviation section.
Eric Christopher38371952012-11-20 23:30:11 +0000360 void emitAbbreviations();
Bill Wendling2f921f82009-05-15 09:23:25 +0000361
David Blaikie6741bb02014-09-11 21:12:48 +0000362 /// \brief Emit a specified accelerator table.
363 void emitAccel(DwarfAccelTable &Accel, const MCSection *Section,
Rafael Espindola6b9998b2015-03-10 22:00:25 +0000364 StringRef TableName);
David Blaikie6741bb02014-09-11 21:12:48 +0000365
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000366 /// \brief Emit visible names into a hashed accelerator table section.
Eric Christopher4996c702011-11-07 09:24:32 +0000367 void emitAccelNames();
Eric Christopher27527b22012-11-21 00:03:28 +0000368
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000369 /// \brief Emit objective C classes and categories into a hashed
Eric Christopher4996c702011-11-07 09:24:32 +0000370 /// accelerator table section.
371 void emitAccelObjC();
372
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000373 /// \brief Emit namespace dies into a hashed accelerator table.
Eric Christopher4996c702011-11-07 09:24:32 +0000374 void emitAccelNamespaces();
375
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000376 /// \brief Emit type dies into a hashed accelerator table.
Eric Christopher4996c702011-11-07 09:24:32 +0000377 void emitAccelTypes();
Eric Christopher27527b22012-11-21 00:03:28 +0000378
Krzysztof Parzyszek228daa62013-02-12 18:00:14 +0000379 /// \brief Emit visible names into a debug pubnames section.
Eric Christopherdd1a0122013-09-13 00:35:05 +0000380 /// \param GnuStyle determines whether or not we want to emit
381 /// additional information into the table ala newer gcc for gdb
382 /// index.
383 void emitDebugPubNames(bool GnuStyle = false);
Krzysztof Parzyszek228daa62013-02-12 18:00:14 +0000384
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000385 /// \brief Emit visible types into a debug pubtypes section.
Eric Christopherdd1a0122013-09-13 00:35:05 +0000386 /// \param GnuStyle determines whether or not we want to emit
387 /// additional information into the table ala newer gcc for gdb
388 /// index.
389 void emitDebugPubTypes(bool GnuStyle = false);
Devang Patel04d2f2d2009-11-24 01:14:22 +0000390
David Blaikie192b45c2014-11-02 06:16:39 +0000391 void emitDebugPubSection(
392 bool GnuStyle, const MCSection *PSec, StringRef Name,
393 const StringMap<const DIE *> &(DwarfCompileUnit::*Accessor)() const);
David Blaikie0f55e832014-03-11 23:18:15 +0000394
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000395 /// \brief Emit visible names into a debug str section.
Devang Patel930143b2009-11-21 02:48:08 +0000396 void emitDebugStr();
Bill Wendling2f921f82009-05-15 09:23:25 +0000397
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000398 /// \brief Emit visible names into a debug loc section.
Devang Patel930143b2009-11-21 02:48:08 +0000399 void emitDebugLoc();
Bill Wendling2f921f82009-05-15 09:23:25 +0000400
David Blaikie94c1d7f2014-04-02 01:50:20 +0000401 /// \brief Emit visible names into a debug loc dwo section.
402 void emitDebugLocDWO();
403
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000404 /// \brief Emit visible names into a debug aranges section.
Eric Christopher7b30f2e42012-11-21 00:34:35 +0000405 void emitDebugARanges();
Bill Wendling2f921f82009-05-15 09:23:25 +0000406
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000407 /// \brief Emit visible names into a debug ranges section.
Devang Patel930143b2009-11-21 02:48:08 +0000408 void emitDebugRanges();
Bill Wendling2f921f82009-05-15 09:23:25 +0000409
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000410 /// \brief Emit inline info using custom format.
Devang Patel930143b2009-11-21 02:48:08 +0000411 void emitDebugInlineInfo();
Bill Wendling2b128d72009-05-20 23:19:06 +0000412
Eric Christophercdf218d2012-12-10 19:51:21 +0000413 /// DWARF 5 Experimental Split Dwarf Emitters
Eric Christopher9c2ecd92012-11-30 23:59:06 +0000414
David Blaikie38fe6342014-01-09 04:28:46 +0000415 /// \brief Initialize common features of skeleton units.
David Blaikie65a74662014-04-25 18:26:14 +0000416 void initSkeletonUnit(const DwarfUnit &U, DIE &Die,
David Blaikief9b6a552014-04-22 22:39:41 +0000417 std::unique_ptr<DwarfUnit> NewU);
David Blaikie38fe6342014-01-09 04:28:46 +0000418
Eric Christophercdf218d2012-12-10 19:51:21 +0000419 /// \brief Construct the split debug info compile unit for the debug info
420 /// section.
David Blaikief9b6a552014-04-22 22:39:41 +0000421 DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU);
Eric Christopher9c2ecd92012-11-30 23:59:06 +0000422
David Blaikie15ed5eb2014-01-10 01:38:41 +0000423 /// \brief Construct the split debug info compile unit for the debug info
424 /// section.
David Blaikief9b6a552014-04-22 22:39:41 +0000425 DwarfTypeUnit &constructSkeletonTU(DwarfTypeUnit &TU);
David Blaikie15ed5eb2014-01-10 01:38:41 +0000426
Eric Christopher9c2ecd92012-11-30 23:59:06 +0000427 /// \brief Emit the debug info dwo section.
428 void emitDebugInfoDWO();
429
Eric Christopher3c5a1912012-12-19 22:02:53 +0000430 /// \brief Emit the debug abbrev dwo section.
431 void emitDebugAbbrevDWO();
432
David Blaikie4a2f95f2014-03-18 01:17:26 +0000433 /// \brief Emit the debug line dwo section.
434 void emitDebugLineDWO();
435
Eric Christopher3bf29fd2012-12-27 02:14:01 +0000436 /// \brief Emit the debug str dwo section.
437 void emitDebugStrDWO();
438
David Blaikie3c842622013-12-04 21:31:26 +0000439 /// Flags to let the linker know we have emitted new style pubnames. Only
440 /// emit it here if we don't have a skeleton CU for split dwarf.
David Blaikie65a74662014-04-25 18:26:14 +0000441 void addGnuPubAttributes(DwarfUnit &U, DIE &D) const;
David Blaikie3c842622013-12-04 21:31:26 +0000442
Eric Christopher4287a492013-12-09 23:57:44 +0000443 /// \brief Create new DwarfCompileUnit for the given metadata node with tag
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000444 /// DW_TAG_compile_unit.
David Blaikief9b6a552014-04-22 22:39:41 +0000445 DwarfCompileUnit &constructDwarfCompileUnit(DICompileUnit DIUnit);
Devang Patel1a0df9a2010-05-10 22:49:55 +0000446
David Blaikie1fd43652013-05-07 21:35:53 +0000447 /// \brief Construct imported_module or imported_declaration DIE.
David Blaikie8912df12014-08-31 05:41:15 +0000448 void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
449 const MDNode *N);
David Blaikie684fc532013-05-06 23:33:07 +0000450
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000451 /// \brief Register a source line with debug info. Returns the unique
452 /// label that was emitted and which provides correspondence to the
453 /// source line list.
Devang Patel34a66202011-05-11 19:22:19 +0000454 void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
455 unsigned Flags);
Eric Christopher27527b22012-11-21 00:03:28 +0000456
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000457 /// \brief Indentify instructions that are marking the beginning of or
458 /// ending of a scope.
Devang Patel359b0132010-04-08 18:43:56 +0000459 void identifyScopeMarkers();
Devang Patelf1d5a1e2010-04-08 15:37:09 +0000460
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000461 /// \brief Populate LexicalScope entries with variables' info.
David Blaikie263a0082014-10-23 00:06:27 +0000462 void collectVariableInfo(DwarfCompileUnit &TheCU, DISubprogram SP,
463 SmallPtrSetImpl<const MDNode *> &ProcessedVars);
Eric Christopher27527b22012-11-21 00:03:28 +0000464
Adrian Prantlb1416832014-08-01 22:11:58 +0000465 /// \brief Build the location list for all DBG_VALUEs in the
466 /// function that describe the same variable.
467 void buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
David Blaikiee1a26a62014-08-05 23:14:16 +0000468 const DbgValueHistoryMap::InstrRanges &Ranges);
Adrian Prantlb1416832014-08-01 22:11:58 +0000469
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000470 /// \brief Collect variable information from the side table maintained
471 /// by MMI.
Craig Topper71b7b682014-08-21 05:55:13 +0000472 void collectVariableInfoFromMMITable(SmallPtrSetImpl<const MDNode *> &P);
Jakob Stoklund Olesen9a624fa2011-03-26 02:19:36 +0000473
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000474 /// \brief Ensure that a label will be emitted before MI.
Jakob Stoklund Olesen9a624fa2011-03-26 02:19:36 +0000475 void requestLabelBeforeInsn(const MachineInstr *MI) {
Craig Toppere73658d2014-04-28 04:05:08 +0000476 LabelsBeforeInsn.insert(std::make_pair(MI, nullptr));
Jakob Stoklund Olesen9a624fa2011-03-26 02:19:36 +0000477 }
478
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000479 /// \brief Ensure that a label will be emitted after MI.
Jakob Stoklund Olesen9a624fa2011-03-26 02:19:36 +0000480 void requestLabelAfterInsn(const MachineInstr *MI) {
Craig Toppere73658d2014-04-28 04:05:08 +0000481 LabelsAfterInsn.insert(std::make_pair(MI, nullptr));
Jakob Stoklund Olesen9a624fa2011-03-26 02:19:36 +0000482 }
483
Bill Wendling2f921f82009-05-15 09:23:25 +0000484public:
485 //===--------------------------------------------------------------------===//
486 // Main entry points.
487 //
Chris Lattnerf0d6bd32010-04-05 05:11:15 +0000488 DwarfDebug(AsmPrinter *A, Module *M);
Bill Wendling2f921f82009-05-15 09:23:25 +0000489
Reid Klecknerdd2647e2014-04-30 20:34:31 +0000490 ~DwarfDebug() override;
491
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000492 /// \brief Emit all Dwarf sections that should come prior to the
Bill Wendling2f921f82009-05-15 09:23:25 +0000493 /// content.
Eric Christopher58f41952012-11-19 22:42:15 +0000494 void beginModule();
Bill Wendling2f921f82009-05-15 09:23:25 +0000495
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000496 /// \brief Emit all Dwarf sections that should come after the content.
Craig Topper7b883b32014-03-08 06:31:39 +0000497 void endModule() override;
Bill Wendling2f921f82009-05-15 09:23:25 +0000498
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000499 /// \brief Gather pre-function debug information.
Craig Topper7b883b32014-03-08 06:31:39 +0000500 void beginFunction(const MachineFunction *MF) override;
Bill Wendling2f921f82009-05-15 09:23:25 +0000501
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000502 /// \brief Gather and emit post-function debug information.
Craig Topper7b883b32014-03-08 06:31:39 +0000503 void endFunction(const MachineFunction *MF) override;
Bill Wendling2f921f82009-05-15 09:23:25 +0000504
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000505 /// \brief Process beginning of an instruction.
Craig Topper7b883b32014-03-08 06:31:39 +0000506 void beginInstruction(const MachineInstr *MI) override;
Bill Wendling2f921f82009-05-15 09:23:25 +0000507
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000508 /// \brief Process end of an instruction.
Craig Topper7b883b32014-03-08 06:31:39 +0000509 void endInstruction() override;
Devang Patelf20c4f72011-04-12 22:53:02 +0000510
Eric Christopher67646432013-07-26 17:02:41 +0000511 /// \brief Add a DIE to the set of types that we're going to pull into
512 /// type units.
David Blaikie15632ae2014-02-12 00:31:30 +0000513 void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
David Blaikie65a74662014-04-25 18:26:14 +0000514 DIE &Die, DICompositeType CTy);
Eric Christopher67646432013-07-26 17:02:41 +0000515
Richard Mitton21101b32013-09-19 23:21:01 +0000516 /// \brief Add a label so that arange data can be generated for it.
Alexey Samsonov4436bf02013-10-03 08:54:43 +0000517 void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
Richard Mitton21101b32013-09-19 23:21:01 +0000518
Richard Mitton089ed892013-09-23 17:56:20 +0000519 /// \brief For symbols that have a size designated (e.g. common symbols),
520 /// this tracks that size.
Craig Topper7b883b32014-03-08 06:31:39 +0000521 void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {
Eric Christophera5a79422013-12-09 23:32:48 +0000522 SymSize[Sym] = Size;
523 }
Richard Mitton089ed892013-09-23 17:56:20 +0000524
Paul Robinson78cc0822015-03-04 20:55:11 +0000525 /// \brief Returns whether to use DW_OP_GNU_push_tls_address, instead of the
526 /// standard DW_OP_form_tls_address opcode
527 bool useGNUTLSOpcode() const { return UseGNUTLSOpcode; }
528
Eric Christopher55c51812012-11-21 00:03:31 +0000529 // Experimental DWARF5 features.
530
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000531 /// \brief Returns whether or not to emit tables that dwarf consumers can
532 /// use to accelerate lookup.
Eric Christopher411bd592014-03-06 00:00:53 +0000533 bool useDwarfAccelTables() const { return HasDwarfAccelTables; }
Eric Christopher55c51812012-11-21 00:03:31 +0000534
Eric Christopheracdcbdb2012-11-27 22:43:45 +0000535 /// \brief Returns whether or not to change the current debug info for the
Eric Christophercdf218d2012-12-10 19:51:21 +0000536 /// split dwarf proposal support.
Eric Christopher411bd592014-03-06 00:00:53 +0000537 bool useSplitDwarf() const { return HasSplitDwarf; }
Manman Renac8062b2013-07-02 23:40:10 +0000538
539 /// Returns the Dwarf Version.
540 unsigned getDwarfVersion() const { return DwarfVersion; }
Manman Ren60352032013-09-05 18:48:31 +0000541
Eric Christopher384f3fe2014-03-20 19:16:16 +0000542 /// Returns the previous CU that was being updated
543 const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
David Blaikied0f10372014-09-09 23:13:01 +0000544 void setPrevCU(const DwarfCompileUnit *PrevCU) { this->PrevCU = PrevCU; }
Eric Christopher384f3fe2014-03-20 19:16:16 +0000545
Eric Christopher4f17ee02014-03-08 00:29:41 +0000546 /// Returns the entries for the .debug_loc section.
David Blaikie0a456de2014-04-02 01:43:18 +0000547 const SmallVectorImpl<DebugLocList> &
David Blaikie84d8e182014-03-24 22:38:38 +0000548 getDebugLocEntries() const {
Eric Christopher4f17ee02014-03-08 00:29:41 +0000549 return DotDebugLocEntries;
550 }
551
552 /// \brief Emit an entry for the debug loc section. This can be used to
553 /// handle an entry that's going to be emitted into the debug loc section.
Adrian Prantl92da14b2015-03-02 22:02:33 +0000554 void emitDebugLocEntry(ByteStreamer &Streamer,
555 const DebugLocEntry &Entry);
Adrian Prantlb1416832014-08-01 22:11:58 +0000556 /// \brief emit a single value for the debug loc section.
557 void emitDebugLocValue(ByteStreamer &Streamer,
Adrian Prantl092d9482015-01-13 23:39:11 +0000558 const DebugLocEntry::Value &Value,
559 unsigned PieceOffsetInBits = 0);
Adrian Prantlb1416832014-08-01 22:11:58 +0000560 /// Emits an optimal (=sorted) sequence of DW_OP_pieces.
561 void emitLocPieces(ByteStreamer &Streamer,
562 const DITypeIdentifierMap &Map,
563 ArrayRef<DebugLocEntry::Value> Values);
Eric Christopher4f17ee02014-03-08 00:29:41 +0000564
David Blaikie0e84adc2014-04-01 16:17:41 +0000565 /// Emit the location for a debug loc entry, including the size header.
566 void emitDebugLocEntryLocation(const DebugLocEntry &Entry);
567
Eric Christopher87b9c492013-10-05 00:32:34 +0000568 /// Find the MDNode for the given reference.
569 template <typename T> T resolve(DIRef<T> Ref) const {
Manman Ren34b3dcc2013-09-10 18:30:07 +0000570 return Ref.resolve(TypeIdentifierMap);
571 }
Duncan P. N. Exon Smith000fa2c2015-04-07 04:14:33 +0000572 template <typename T> T *resolve(TypedDebugNodeRef<T> Ref) const {
573 return Ref.resolve(TypeIdentifierMap);
574 }
Manman Ren60352032013-09-05 18:48:31 +0000575
Adrian Prantl1a1647c2014-03-18 02:34:58 +0000576 /// \brief Return the TypeIdentifierMap.
Eric Christopherc0bd5f82014-03-18 20:39:54 +0000577 const DITypeIdentifierMap &getTypeIdentifierMap() const {
Adrian Prantl1a1647c2014-03-18 02:34:58 +0000578 return TypeIdentifierMap;
579 }
580
Eric Christopherdd508382014-03-06 00:00:56 +0000581 /// Find the DwarfCompileUnit for the given CU Die.
582 DwarfCompileUnit *lookupUnit(const DIE *CU) const {
583 return CUDieMap.lookup(CU);
584 }
Manman Ren3eb9dff2013-09-09 19:05:21 +0000585 /// isSubprogramContext - Return true if Context is either a subprogram
586 /// or another context nested inside a subprogram.
587 bool isSubprogramContext(const MDNode *Context);
David Blaikied75fb282014-04-23 21:20:10 +0000588
David Blaikieb0b3fcf2014-04-25 18:52:29 +0000589 void addSubprogramNames(DISubprogram SP, DIE &Die);
David Blaikie2406a0622014-04-23 23:37:35 +0000590
David Blaikied75fb282014-04-23 21:20:10 +0000591 AddressPool &getAddressPool() { return AddrPool; }
David Blaikie2406a0622014-04-23 23:37:35 +0000592
David Blaikieb0b3fcf2014-04-25 18:52:29 +0000593 void addAccelName(StringRef Name, const DIE &Die);
David Blaikie0ee82b92014-04-24 00:53:32 +0000594
David Blaikieb0b3fcf2014-04-25 18:52:29 +0000595 void addAccelObjC(StringRef Name, const DIE &Die);
David Blaikieecf04152014-04-24 01:02:42 +0000596
David Blaikieb0b3fcf2014-04-25 18:52:29 +0000597 void addAccelNamespace(StringRef Name, const DIE &Die);
David Blaikie18d33752014-04-24 01:23:49 +0000598
David Blaikieb0b3fcf2014-04-25 18:52:29 +0000599 void addAccelType(StringRef Name, const DIE &Die, char Flags);
David Blaikiecda2aa82014-10-04 16:24:00 +0000600
601 const MachineFunction *getCurrentFunction() const { return CurFn; }
David Blaikie9c65b132014-10-08 22:20:02 +0000602
David Blaikie33702a32014-10-08 23:09:42 +0000603 iterator_range<ImportedEntityMap::const_iterator>
604 findImportedEntitiesForScope(const MDNode *Scope) const {
David Blaikie9c65b132014-10-08 22:20:02 +0000605 return make_range(std::equal_range(
606 ScopesWithImportedEntities.begin(), ScopesWithImportedEntities.end(),
David Blaikie33702a32014-10-08 23:09:42 +0000607 std::pair<const MDNode *, const MDNode *>(Scope, nullptr),
608 less_first()));
David Blaikie9c65b132014-10-08 22:20:02 +0000609 }
610
611 /// \brief A helper function to check whether the DIE for a given Scope is
612 /// going to be null.
613 bool isLexicalScopeDIENull(LexicalScope *Scope);
614
David Blaikie01b48a82014-10-09 16:50:53 +0000615 /// \brief Return Label preceding the instruction.
616 MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
617
618 /// \brief Return Label immediately following the instruction.
619 MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
620
David Blaikie9c65b132014-10-08 22:20:02 +0000621 // FIXME: Sink these functions down into DwarfFile/Dwarf*Unit.
622
David Blaikie1d072342014-10-09 20:21:36 +0000623 SmallPtrSet<const MDNode *, 16> &getProcessedSPNodes() {
624 return ProcessedSPNodes;
625 }
Devang Patelf6eeaeb2009-11-10 23:06:00 +0000626};
Bill Wendling2f921f82009-05-15 09:23:25 +0000627} // End of namespace llvm
628
629#endif