[AsmPrinter] Prune dead code. NFC.
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DwarfDebug.h
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
14 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
15 #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
16
17 #include "AsmPrinterHandler.h"
18 #include "DbgValueHistoryCalculator.h"
19 #include "DebugLocStream.h"
20 #include "DwarfAccelTable.h"
21 #include "DwarfFile.h"
22 #include "llvm/ADT/DenseMap.h"
23 #include "llvm/ADT/DenseSet.h"
24 #include "llvm/ADT/FoldingSet.h"
25 #include "llvm/ADT/MapVector.h"
26 #include "llvm/ADT/SmallPtrSet.h"
27 #include "llvm/ADT/StringMap.h"
28 #include "llvm/CodeGen/DIE.h"
29 #include "llvm/CodeGen/LexicalScopes.h"
30 #include "llvm/CodeGen/MachineInstr.h"
31 #include "llvm/IR/DebugInfo.h"
32 #include "llvm/IR/DebugLoc.h"
33 #include "llvm/MC/MCDwarf.h"
34 #include "llvm/MC/MachineLocation.h"
35 #include "llvm/Support/Allocator.h"
36 #include <memory>
37
38 namespace llvm {
39
40 class AsmPrinter;
41 class ByteStreamer;
42 class ConstantInt;
43 class ConstantFP;
44 class DebugLocEntry;
45 class DwarfCompileUnit;
46 class DwarfDebug;
47 class DwarfTypeUnit;
48 class DwarfUnit;
49 class MachineModuleInfo;
50
51 //===----------------------------------------------------------------------===//
52 /// This class is used to track local variable information.
53 ///
54 /// Variables can be created from allocas, in which case they're generated from
55 /// the MMI table.  Such variables can have multiple expressions and frame
56 /// indices.  The \a Expr and \a FrameIndices array must match.
57 ///
58 /// Variables can be created from \c DBG_VALUE instructions.  Those whose
59 /// location changes over time use \a DebugLocListIndex, while those with a
60 /// single instruction use \a MInsn and (optionally) a single entry of \a Expr.
61 ///
62 /// Variables that have been optimized out use none of these fields.
63 class DbgVariable {
64   const DILocalVariable *Var;                /// Variable Descriptor.
65   const DILocation *IA;                      /// Inlined at location.
66   SmallVector<const DIExpression *, 1> Expr; /// Complex address.
67   DIE *TheDIE = nullptr;                     /// Variable DIE.
68   unsigned DebugLocListIndex = ~0u;          /// Offset in DebugLocs.
69   const MachineInstr *MInsn = nullptr;       /// DBG_VALUE instruction.
70   SmallVector<int, 1> FrameIndex;            /// Frame index.
71   DwarfDebug *DD;
72
73 public:
74   /// Construct a DbgVariable.
75   ///
76   /// Creates a variable without any DW_AT_location.  Call \a initializeMMI()
77   /// for MMI entries, or \a initializeDbgValue() for DBG_VALUE instructions.
78   DbgVariable(const DILocalVariable *V, const DILocation *IA, DwarfDebug *DD)
79       : Var(V), IA(IA), DD(DD) {}
80
81   /// Initialize from the MMI table.
82   void initializeMMI(const DIExpression *E, int FI) {
83     assert(Expr.empty() && "Already initialized?");
84     assert(FrameIndex.empty() && "Already initialized?");
85     assert(!MInsn && "Already initialized?");
86
87     assert((!E || E->isValid()) && "Expected valid expression");
88     assert(~FI && "Expected valid index");
89
90     Expr.push_back(E);
91     FrameIndex.push_back(FI);
92   }
93
94   /// Initialize from a DBG_VALUE instruction.
95   void initializeDbgValue(const MachineInstr *DbgValue) {
96     assert(Expr.empty() && "Already initialized?");
97     assert(FrameIndex.empty() && "Already initialized?");
98     assert(!MInsn && "Already initialized?");
99
100     assert(Var == DbgValue->getDebugVariable() && "Wrong variable");
101     assert(IA == DbgValue->getDebugLoc()->getInlinedAt() && "Wrong inlined-at");
102
103     MInsn = DbgValue;
104     if (auto *E = DbgValue->getDebugExpression())
105       if (E->getNumElements())
106         Expr.push_back(E);
107   }
108
109   // Accessors.
110   const DILocalVariable *getVariable() const { return Var; }
111   const DILocation *getInlinedAt() const { return IA; }
112   ArrayRef<const DIExpression *> getExpression() const { return Expr; }
113   void setDIE(DIE &D) { TheDIE = &D; }
114   DIE *getDIE() const { return TheDIE; }
115   void setDebugLocListIndex(unsigned O) { DebugLocListIndex = O; }
116   unsigned getDebugLocListIndex() const { return DebugLocListIndex; }
117   StringRef getName() const { return Var->getName(); }
118   const MachineInstr *getMInsn() const { return MInsn; }
119   ArrayRef<int> getFrameIndex() const { return FrameIndex; }
120
121   void addMMIEntry(const DbgVariable &V) {
122     assert(DebugLocListIndex == ~0U && !MInsn && "not an MMI entry");
123     assert(V.DebugLocListIndex == ~0U && !V.MInsn && "not an MMI entry");
124     assert(V.Var == Var && "conflicting variable");
125     assert(V.IA == IA && "conflicting inlined-at location");
126
127     assert(!FrameIndex.empty() && "Expected an MMI entry");
128     assert(!V.FrameIndex.empty() && "Expected an MMI entry");
129     assert(Expr.size() == FrameIndex.size() && "Mismatched expressions");
130     assert(V.Expr.size() == V.FrameIndex.size() && "Mismatched expressions");
131
132     Expr.append(V.Expr.begin(), V.Expr.end());
133     FrameIndex.append(V.FrameIndex.begin(), V.FrameIndex.end());
134     assert(std::all_of(Expr.begin(), Expr.end(), [](const DIExpression *E) {
135              return E && E->isBitPiece();
136            }) && "conflicting locations for variable");
137   }
138
139   // Translate tag to proper Dwarf tag.
140   dwarf::Tag getTag() const {
141     // FIXME: Why don't we just infer this tag and store it all along?
142     if (Var->isParameter())
143       return dwarf::DW_TAG_formal_parameter;
144
145     return dwarf::DW_TAG_variable;
146   }
147   /// Return true if DbgVariable is artificial.
148   bool isArtificial() const {
149     if (Var->isArtificial())
150       return true;
151     if (getType()->isArtificial())
152       return true;
153     return false;
154   }
155
156   bool isObjectPointer() const {
157     if (Var->isObjectPointer())
158       return true;
159     if (getType()->isObjectPointer())
160       return true;
161     return false;
162   }
163
164   bool hasComplexAddress() const {
165     assert(MInsn && "Expected DBG_VALUE, not MMI variable");
166     assert(FrameIndex.empty() && "Expected DBG_VALUE, not MMI variable");
167     assert(
168         (Expr.empty() || (Expr.size() == 1 && Expr.back()->getNumElements())) &&
169         "Invalid Expr for DBG_VALUE");
170     return !Expr.empty();
171   }
172   bool isBlockByrefVariable() const;
173   const DIType *getType() const;
174
175 private:
176   /// Look in the DwarfDebug map for the MDNode that
177   /// corresponds to the reference.
178   template <typename T> T *resolve(TypedDINodeRef<T> Ref) const;
179 };
180
181
182 /// Helper used to pair up a symbol and its DWARF compile unit.
183 struct SymbolCU {
184   SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
185   const MCSymbol *Sym;
186   DwarfCompileUnit *CU;
187 };
188
189 /// Identify a debugger for "tuning" the debug info.
190 ///
191 /// The "debugger tuning" concept allows us to present a more intuitive
192 /// interface that unpacks into different sets of defaults for the various
193 /// individual feature-flag settings, that suit the preferences of the
194 /// various debuggers.  However, it's worth remembering that debuggers are
195 /// not the only consumers of debug info, and some variations in DWARF might
196 /// better be treated as target/platform issues. Fundamentally,
197 /// o if the feature is useful (or not) to a particular debugger, regardless
198 ///   of the target, that's a tuning decision;
199 /// o if the feature is useful (or not) on a particular platform, regardless
200 ///   of the debugger, that's a target decision.
201 /// It's not impossible to see both factors in some specific case.
202 ///
203 /// The "tuning" should be used to set defaults for individual feature flags
204 /// in DwarfDebug; if a given feature has a more specific command-line option,
205 /// that option should take precedence over the tuning.
206 enum class DebuggerKind {
207   Default,  // No specific tuning requested.
208   GDB,      // Tune debug info for gdb.
209   LLDB,     // Tune debug info for lldb.
210   SCE       // Tune debug info for SCE targets (e.g. PS4).
211 };
212
213 /// Collects and handles dwarf debug information.
214 class DwarfDebug : public AsmPrinterHandler {
215   /// Target of Dwarf emission.
216   AsmPrinter *Asm;
217
218   /// Collected machine module information.
219   MachineModuleInfo *MMI;
220
221   /// All DIEValues are allocated through this allocator.
222   BumpPtrAllocator DIEValueAllocator;
223
224   /// Maps MDNode with its corresponding DwarfCompileUnit.
225   MapVector<const MDNode *, DwarfCompileUnit *> CUMap;
226
227   /// Maps subprogram MDNode with its corresponding DwarfCompileUnit.
228   MapVector<const MDNode *, DwarfCompileUnit *> SPMap;
229
230   /// Maps a CU DIE with its corresponding DwarfCompileUnit.
231   DenseMap<const DIE *, DwarfCompileUnit *> CUDieMap;
232
233   /// List of all labels used in aranges generation.
234   std::vector<SymbolCU> ArangeLabels;
235
236   /// Size of each symbol emitted (for those symbols that have a specific size).
237   DenseMap<const MCSymbol *, uint64_t> SymSize;
238
239   LexicalScopes LScopes;
240
241   /// Collection of abstract variables.
242   DenseMap<const MDNode *, std::unique_ptr<DbgVariable>> AbstractVariables;
243   SmallVector<std::unique_ptr<DbgVariable>, 64> ConcreteVariables;
244
245   /// Collection of DebugLocEntry. Stored in a linked list so that DIELocLists
246   /// can refer to them in spite of insertions into this list.
247   DebugLocStream DebugLocs;
248
249   /// This is a collection of subprogram MDNodes that are processed to
250   /// create DIEs.
251   SmallPtrSet<const MDNode *, 16> ProcessedSPNodes;
252
253   /// Maps instruction with label emitted before instruction.
254   DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn;
255
256   /// Maps instruction with label emitted after instruction.
257   DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn;
258
259   /// History of DBG_VALUE and clobber instructions for each user
260   /// variable.  Variables are listed in order of appearance.
261   DbgValueHistoryMap DbgValues;
262
263   /// Previous instruction's location information. This is used to
264   /// determine label location to indicate scope boundries in dwarf
265   /// debug info.
266   DebugLoc PrevInstLoc;
267   MCSymbol *PrevLabel;
268
269   /// This location indicates end of function prologue and beginning of
270   /// function body.
271   DebugLoc PrologEndLoc;
272
273   /// If nonnull, stores the current machine function we're processing.
274   const MachineFunction *CurFn;
275
276   /// If nonnull, stores the current machine instruction we're processing.
277   const MachineInstr *CurMI;
278
279   /// If nonnull, stores the CU in which the previous subprogram was contained.
280   const DwarfCompileUnit *PrevCU;
281
282   /// As an optimization, there is no need to emit an entry in the directory
283   /// table for the same directory as DW_AT_comp_dir.
284   StringRef CompilationDir;
285
286   /// Holder for the file specific debug information.
287   DwarfFile InfoHolder;
288
289   /// Holders for the various debug information flags that we might need to
290   /// have exposed. See accessor functions below for description.
291
292   /// Holder for imported entities.
293   typedef SmallVector<std::pair<const MDNode *, const MDNode *>, 32>
294   ImportedEntityMap;
295   ImportedEntityMap ScopesWithImportedEntities;
296
297   /// Map from MDNodes for user-defined types to the type units that
298   /// describe them.
299   DenseMap<const MDNode *, const DwarfTypeUnit *> DwarfTypeUnits;
300
301   SmallVector<
302       std::pair<std::unique_ptr<DwarfTypeUnit>, const DICompositeType *>, 1>
303       TypeUnitsUnderConstruction;
304
305   /// Whether to emit the pubnames/pubtypes sections.
306   bool HasDwarfPubSections;
307
308   /// Whether to use the GNU TLS opcode (instead of the standard opcode).
309   bool UseGNUTLSOpcode;
310
311   /// Whether to emit DW_AT_[MIPS_]linkage_name.
312   bool UseLinkageNames;
313
314   /// Version of dwarf we're emitting.
315   unsigned DwarfVersion;
316
317   /// Maps from a type identifier to the actual MDNode.
318   DITypeIdentifierMap TypeIdentifierMap;
319
320   /// DWARF5 Experimental Options
321   /// @{
322   bool HasDwarfAccelTables;
323   bool HasSplitDwarf;
324
325   /// Separated Dwarf Variables
326   /// In general these will all be for bits that are left in the
327   /// original object file, rather than things that are meant
328   /// to be in the .dwo sections.
329
330   /// Holder for the skeleton information.
331   DwarfFile SkeletonHolder;
332
333   /// Store file names for type units under fission in a line table
334   /// header that will be emitted into debug_line.dwo.
335   // FIXME: replace this with a map from comp_dir to table so that we
336   // can emit multiple tables during LTO each of which uses directory
337   // 0, referencing the comp_dir of all the type units that use it.
338   MCDwarfDwoLineTable SplitTypeUnitFileTable;
339   /// @}
340   
341   /// True iff there are multiple CUs in this module.
342   bool SingleCU;
343   bool IsDarwin;
344
345   AddressPool AddrPool;
346
347   DwarfAccelTable AccelNames;
348   DwarfAccelTable AccelObjC;
349   DwarfAccelTable AccelNamespace;
350   DwarfAccelTable AccelTypes;
351
352   DenseMap<const Function *, DISubprogram *> FunctionDIs;
353
354   // Identify a debugger for "tuning" the debug info.
355   DebuggerKind DebuggerTuning;
356
357   MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
358
359   const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() {
360     return InfoHolder.getUnits();
361   }
362
363   typedef DbgValueHistoryMap::InlinedVariable InlinedVariable;
364
365   /// Find abstract variable associated with Var.
366   DbgVariable *getExistingAbstractVariable(InlinedVariable IV,
367                                            const DILocalVariable *&Cleansed);
368   DbgVariable *getExistingAbstractVariable(InlinedVariable IV);
369   void createAbstractVariable(const DILocalVariable *DV, LexicalScope *Scope);
370   void ensureAbstractVariableIsCreated(InlinedVariable Var,
371                                        const MDNode *Scope);
372   void ensureAbstractVariableIsCreatedIfScoped(InlinedVariable Var,
373                                                const MDNode *Scope);
374
375   DbgVariable *createConcreteVariable(LexicalScope &Scope, InlinedVariable IV);
376
377   /// Construct a DIE for this abstract scope.
378   void constructAbstractSubprogramScopeDIE(LexicalScope *Scope);
379
380   /// Collect info for variables that were optimized out.
381   void collectDeadVariables();
382
383   void finishVariableDefinitions();
384
385   void finishSubprogramDefinitions();
386
387   /// Finish off debug information after all functions have been
388   /// processed.
389   void finalizeModuleInfo();
390
391   /// Emit the debug info section.
392   void emitDebugInfo();
393
394   /// Emit the abbreviation section.
395   void emitAbbreviations();
396
397   /// Emit a specified accelerator table.
398   void emitAccel(DwarfAccelTable &Accel, MCSection *Section,
399                  StringRef TableName);
400
401   /// Emit visible names into a hashed accelerator table section.
402   void emitAccelNames();
403
404   /// Emit objective C classes and categories into a hashed
405   /// accelerator table section.
406   void emitAccelObjC();
407
408   /// Emit namespace dies into a hashed accelerator table.
409   void emitAccelNamespaces();
410
411   /// Emit type dies into a hashed accelerator table.
412   void emitAccelTypes();
413
414   /// Emit visible names into a debug pubnames section.
415   /// \param GnuStyle determines whether or not we want to emit
416   /// additional information into the table ala newer gcc for gdb
417   /// index.
418   void emitDebugPubNames(bool GnuStyle = false);
419
420   /// Emit visible types into a debug pubtypes section.
421   /// \param GnuStyle determines whether or not we want to emit
422   /// additional information into the table ala newer gcc for gdb
423   /// index.
424   void emitDebugPubTypes(bool GnuStyle = false);
425
426   void emitDebugPubSection(
427       bool GnuStyle, MCSection *PSec, StringRef Name,
428       const StringMap<const DIE *> &(DwarfCompileUnit::*Accessor)() const);
429
430   /// Emit visible names into a debug str section.
431   void emitDebugStr();
432
433   /// Emit visible names into a debug loc section.
434   void emitDebugLoc();
435
436   /// Emit visible names into a debug loc dwo section.
437   void emitDebugLocDWO();
438
439   /// Emit visible names into a debug aranges section.
440   void emitDebugARanges();
441
442   /// Emit visible names into a debug ranges section.
443   void emitDebugRanges();
444
445   /// DWARF 5 Experimental Split Dwarf Emitters
446
447   /// Initialize common features of skeleton units.
448   void initSkeletonUnit(const DwarfUnit &U, DIE &Die,
449                         std::unique_ptr<DwarfUnit> NewU);
450
451   /// Construct the split debug info compile unit for the debug info
452   /// section.
453   DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU);
454
455   /// Emit the debug info dwo section.
456   void emitDebugInfoDWO();
457
458   /// Emit the debug abbrev dwo section.
459   void emitDebugAbbrevDWO();
460
461   /// Emit the debug line dwo section.
462   void emitDebugLineDWO();
463
464   /// Emit the debug str dwo section.
465   void emitDebugStrDWO();
466
467   /// Flags to let the linker know we have emitted new style pubnames. Only
468   /// emit it here if we don't have a skeleton CU for split dwarf.
469   void addGnuPubAttributes(DwarfUnit &U, DIE &D) const;
470
471   /// Create new DwarfCompileUnit for the given metadata node with tag
472   /// DW_TAG_compile_unit.
473   DwarfCompileUnit &constructDwarfCompileUnit(const DICompileUnit *DIUnit);
474
475   /// Construct imported_module or imported_declaration DIE.
476   void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
477                                         const DIImportedEntity *N);
478
479   /// Register a source line with debug info. Returns the unique
480   /// label that was emitted and which provides correspondence to the
481   /// source line list.
482   void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
483                         unsigned Flags);
484
485   /// Indentify instructions that are marking the beginning of or
486   /// ending of a scope.
487   void identifyScopeMarkers();
488
489   /// Populate LexicalScope entries with variables' info.
490   void collectVariableInfo(DwarfCompileUnit &TheCU, const DISubprogram *SP,
491                            DenseSet<InlinedVariable> &ProcessedVars);
492
493   /// Build the location list for all DBG_VALUEs in the
494   /// function that describe the same variable.
495   void buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
496                          const DbgValueHistoryMap::InstrRanges &Ranges);
497
498   /// Collect variable information from the side table maintained
499   /// by MMI.
500   void collectVariableInfoFromMMITable(DenseSet<InlinedVariable> &P);
501
502   /// Ensure that a label will be emitted before MI.
503   void requestLabelBeforeInsn(const MachineInstr *MI) {
504     LabelsBeforeInsn.insert(std::make_pair(MI, nullptr));
505   }
506
507   /// Ensure that a label will be emitted after MI.
508   void requestLabelAfterInsn(const MachineInstr *MI) {
509     LabelsAfterInsn.insert(std::make_pair(MI, nullptr));
510   }
511
512 public:
513   //===--------------------------------------------------------------------===//
514   // Main entry points.
515   //
516   DwarfDebug(AsmPrinter *A, Module *M);
517
518   ~DwarfDebug() override;
519
520   /// Emit all Dwarf sections that should come prior to the
521   /// content.
522   void beginModule();
523
524   /// Emit all Dwarf sections that should come after the content.
525   void endModule() override;
526
527   /// Gather pre-function debug information.
528   void beginFunction(const MachineFunction *MF) override;
529
530   /// Gather and emit post-function debug information.
531   void endFunction(const MachineFunction *MF) override;
532
533   /// Process beginning of an instruction.
534   void beginInstruction(const MachineInstr *MI) override;
535
536   /// Process end of an instruction.
537   void endInstruction() override;
538
539   /// Perform an MD5 checksum of \p Identifier and return the lower 64 bits.
540   static uint64_t makeTypeSignature(StringRef Identifier);
541
542   /// Add a DIE to the set of types that we're going to pull into
543   /// type units.
544   void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
545                             DIE &Die, const DICompositeType *CTy);
546
547   /// Add a label so that arange data can be generated for it.
548   void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
549
550   /// For symbols that have a size designated (e.g. common symbols),
551   /// this tracks that size.
552   void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {
553     SymSize[Sym] = Size;
554   }
555
556   /// Returns whether to emit DW_AT_[MIPS_]linkage_name.
557   bool useLinkageNames() const { return UseLinkageNames; }
558
559   /// Returns whether to use DW_OP_GNU_push_tls_address, instead of the
560   /// standard DW_OP_form_tls_address opcode
561   bool useGNUTLSOpcode() const { return UseGNUTLSOpcode; }
562
563   /// \defgroup DebuggerTuning Predicates to tune DWARF for a given debugger.
564   ///
565   /// Returns whether we are "tuning" for a given debugger.
566   /// @{
567   bool tuneForGDB() const { return DebuggerTuning == DebuggerKind::GDB; }
568   bool tuneForLLDB() const { return DebuggerTuning == DebuggerKind::LLDB; }
569   bool tuneForSCE() const { return DebuggerTuning == DebuggerKind::SCE; }
570   /// @}
571
572   // Experimental DWARF5 features.
573
574   /// Returns whether or not to emit tables that dwarf consumers can
575   /// use to accelerate lookup.
576   bool useDwarfAccelTables() const { return HasDwarfAccelTables; }
577
578   /// Returns whether or not to change the current debug info for the
579   /// split dwarf proposal support.
580   bool useSplitDwarf() const { return HasSplitDwarf; }
581
582   /// Returns the Dwarf Version.
583   unsigned getDwarfVersion() const { return DwarfVersion; }
584
585   /// Returns the previous CU that was being updated
586   const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
587   void setPrevCU(const DwarfCompileUnit *PrevCU) { this->PrevCU = PrevCU; }
588
589   /// Returns the entries for the .debug_loc section.
590   const DebugLocStream &getDebugLocs() const { return DebugLocs; }
591
592   /// Emit an entry for the debug loc section. This can be used to
593   /// handle an entry that's going to be emitted into the debug loc section.
594   void emitDebugLocEntry(ByteStreamer &Streamer,
595                          const DebugLocStream::Entry &Entry);
596
597   /// Emit the location for a debug loc entry, including the size header.
598   void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry);
599
600   /// Find the MDNode for the given reference.
601   template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
602     return Ref.resolve(TypeIdentifierMap);
603   }
604
605   /// Return the TypeIdentifierMap.
606   const DITypeIdentifierMap &getTypeIdentifierMap() const {
607     return TypeIdentifierMap;
608   }
609
610   /// Find the DwarfCompileUnit for the given CU Die.
611   DwarfCompileUnit *lookupUnit(const DIE *CU) const {
612     return CUDieMap.lookup(CU);
613   }
614
615   void addSubprogramNames(const DISubprogram *SP, DIE &Die);
616
617   AddressPool &getAddressPool() { return AddrPool; }
618
619   void addAccelName(StringRef Name, const DIE &Die);
620
621   void addAccelObjC(StringRef Name, const DIE &Die);
622
623   void addAccelNamespace(StringRef Name, const DIE &Die);
624
625   void addAccelType(StringRef Name, const DIE &Die, char Flags);
626
627   const MachineFunction *getCurrentFunction() const { return CurFn; }
628
629   iterator_range<ImportedEntityMap::const_iterator>
630   findImportedEntitiesForScope(const MDNode *Scope) const {
631     return make_range(std::equal_range(
632         ScopesWithImportedEntities.begin(), ScopesWithImportedEntities.end(),
633         std::pair<const MDNode *, const MDNode *>(Scope, nullptr),
634         less_first()));
635   }
636
637   /// A helper function to check whether the DIE for a given Scope is
638   /// going to be null.
639   bool isLexicalScopeDIENull(LexicalScope *Scope);
640
641   /// Return Label preceding the instruction.
642   MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
643
644   /// Return Label immediately following the instruction.
645   MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
646
647   // FIXME: Sink these functions down into DwarfFile/Dwarf*Unit.
648
649   SmallPtrSet<const MDNode *, 16> &getProcessedSPNodes() {
650     return ProcessedSPNodes;
651   }
652 };
653 } // End of namespace llvm
654
655 #endif