Refactor DebugLocDWARFExpression so it doesn't require access to the
[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 "DebugLocEntry.h"
20 #include "DebugLocList.h"
21 #include "DwarfAccelTable.h"
22 #include "DwarfFile.h"
23 #include "llvm/ADT/DenseMap.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 DwarfCompileUnit;
45 class DwarfDebug;
46 class DwarfTypeUnit;
47 class DwarfUnit;
48 class MachineModuleInfo;
49
50 //===----------------------------------------------------------------------===//
51 /// \brief This class is used to record source line correspondence.
52 class SrcLineInfo {
53   unsigned Line;     // Source line number.
54   unsigned Column;   // Source column.
55   unsigned SourceID; // Source ID number.
56   MCSymbol *Label;   // Label in code ID number.
57 public:
58   SrcLineInfo(unsigned L, unsigned C, unsigned S, MCSymbol *label)
59       : Line(L), Column(C), SourceID(S), Label(label) {}
60
61   // Accessors
62   unsigned getLine() const { return Line; }
63   unsigned getColumn() const { return Column; }
64   unsigned getSourceID() const { return SourceID; }
65   MCSymbol *getLabel() const { return Label; }
66 };
67
68 //===----------------------------------------------------------------------===//
69 /// \brief This class is used to track local variable information.
70 ///
71 /// - Variables whose location changes over time have a DotDebugLocOffset and
72 ///   the other fields are not used.
73 ///
74 /// - Variables that are described by multiple MMI table entries have multiple
75 ///   expressions and frame indices.
76 class DbgVariable {
77   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.
83   DwarfDebug *DD;
84
85 public:
86   /// Construct a DbgVariable from a DIVariable.
87     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);
91     assert(Var.Verify() && E.Verify());
92   }
93
94   /// Construct a DbgVariable from a DEBUG_VALUE.
95   /// AbstractVar may be NULL.
96   DbgVariable(const MachineInstr *DbgValue, DwarfDebug *DD)
97       : Var(DbgValue->getDebugVariable()),
98         Expr(1, DbgValue->getDebugExpression()), TheDIE(nullptr),
99         DotDebugLocOffset(~0U), MInsn(DbgValue), DD(DD) {
100     FrameIndex.push_back(~0);
101   }
102
103   // Accessors.
104   DIVariable getVariable() const { return Var; }
105   const ArrayRef<DIExpression> getExpression() const { return Expr; }
106   void setDIE(DIE &D) { TheDIE = &D; }
107   DIE *getDIE() const { return TheDIE; }
108   void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; }
109   unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; }
110   StringRef getName() const { return Var.getName(); }
111   const MachineInstr *getMInsn() const { return MInsn; }
112   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
126            ? std::all_of(Expr.begin(), Expr.end(),
127                          [](DIExpression &E) { return E.isBitPiece(); })
128            : (true && "conflicting locations for variable"));
129   }
130
131   // Translate tag to proper Dwarf tag.
132   dwarf::Tag getTag() const {
133     if (Var.getTag() == dwarf::DW_TAG_arg_variable)
134       return dwarf::DW_TAG_formal_parameter;
135
136     return dwarf::DW_TAG_variable;
137   }
138   /// \brief Return true if DbgVariable is artificial.
139   bool isArtificial() const {
140     if (Var.isArtificial())
141       return true;
142     if (getType().isArtificial())
143       return true;
144     return false;
145   }
146
147   bool isObjectPointer() const {
148     if (Var.isObjectPointer())
149       return true;
150     if (getType().isObjectPointer())
151       return true;
152     return false;
153   }
154
155   bool variableHasComplexAddress() const {
156     assert(Var.isVariable() && "Invalid complex DbgVariable!");
157     assert(Expr.size() == 1 &&
158            "variableHasComplexAddress() invoked on multi-FI variable");
159     return Expr.back().getNumElements() > 0;
160   }
161   bool isBlockByrefVariable() const;
162   DIType getType() const;
163
164 private:
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;
168 };
169
170
171 /// \brief Helper used to pair up a symbol and its DWARF compile unit.
172 struct SymbolCU {
173   SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
174   const MCSymbol *Sym;
175   DwarfCompileUnit *CU;
176 };
177
178 /// \brief Collects and handles dwarf debug information.
179 class DwarfDebug : public AsmPrinterHandler {
180   // Target of Dwarf emission.
181   AsmPrinter *Asm;
182
183   // Collected machine module information.
184   MachineModuleInfo *MMI;
185
186   // All DIEValues are allocated through this allocator.
187   BumpPtrAllocator DIEValueAllocator;
188
189   // Maps MDNode with its corresponding DwarfCompileUnit.
190   MapVector<const MDNode *, DwarfCompileUnit *> CUMap;
191
192   // Maps subprogram MDNode with its corresponding DwarfCompileUnit.
193   MapVector<const MDNode *, DwarfCompileUnit *> SPMap;
194
195   // Maps a CU DIE with its corresponding DwarfCompileUnit.
196   DenseMap<const DIE *, DwarfCompileUnit *> CUDieMap;
197
198   // List of all labels used in aranges generation.
199   std::vector<SymbolCU> ArangeLabels;
200
201   // Size of each symbol emitted (for those symbols that have a specific size).
202   DenseMap<const MCSymbol *, uint64_t> SymSize;
203
204   LexicalScopes LScopes;
205
206   // Collection of abstract variables.
207   DenseMap<const MDNode *, std::unique_ptr<DbgVariable>> AbstractVariables;
208   SmallVector<std::unique_ptr<DbgVariable>, 64> ConcreteVariables;
209
210   // 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;
213
214   // This is a collection of subprogram MDNodes that are processed to
215   // create DIEs.
216   SmallPtrSet<const MDNode *, 16> ProcessedSPNodes;
217
218   // Maps instruction with label emitted before instruction.
219   DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn;
220
221   // Maps instruction with label emitted after instruction.
222   DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn;
223
224   // History of DBG_VALUE and clobber instructions for each user variable.
225   // Variables are listed in order of appearance.
226   DbgValueHistoryMap DbgValues;
227
228   // Previous instruction's location information. This is used to determine
229   // label location to indicate scope boundries in dwarf debug info.
230   DebugLoc PrevInstLoc;
231   MCSymbol *PrevLabel;
232
233   // This location indicates end of function prologue and beginning of function
234   // body.
235   DebugLoc PrologEndLoc;
236
237   // 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
243   // If nonnull, stores the CU in which the previous subprogram was contained.
244   const DwarfCompileUnit *PrevCU;
245
246   // Section Symbols: these are assembler temporary labels that are emitted at
247   // the beginning of each supported dwarf section.  These are used to form
248   // section offsets and are created by EmitSectionLabels.
249   MCSymbol *DwarfInfoSectionSym, *DwarfAbbrevSectionSym;
250   MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym;
251   MCSymbol *DwarfDebugLocSectionSym, *DwarfLineSectionSym, *DwarfAddrSectionSym;
252   MCSymbol *FunctionBeginSym, *FunctionEndSym;
253   MCSymbol *DwarfInfoDWOSectionSym, *DwarfAbbrevDWOSectionSym;
254   MCSymbol *DwarfTypesDWOSectionSym;
255   MCSymbol *DwarfStrDWOSectionSym;
256   MCSymbol *DwarfGnuPubNamesSectionSym, *DwarfGnuPubTypesSectionSym;
257
258   // As an optimization, there is no need to emit an entry in the directory
259   // table for the same directory as DW_AT_comp_dir.
260   StringRef CompilationDir;
261
262   // Counter for assigning globally unique IDs for ranges.
263   unsigned GlobalRangeCount;
264
265   // Holder for the file specific debug information.
266   DwarfFile InfoHolder;
267
268   // Holders for the various debug information flags that we might need to
269   // have exposed. See accessor functions below for description.
270
271   // Holder for imported entities.
272   typedef SmallVector<std::pair<const MDNode *, const MDNode *>, 32>
273   ImportedEntityMap;
274   ImportedEntityMap ScopesWithImportedEntities;
275
276   // Map from MDNodes for user-defined types to the type units that describe
277   // them.
278   DenseMap<const MDNode *, const DwarfTypeUnit *> DwarfTypeUnits;
279
280   SmallVector<std::pair<std::unique_ptr<DwarfTypeUnit>, DICompositeType>, 1>
281       TypeUnitsUnderConstruction;
282
283   // Whether to emit the pubnames/pubtypes sections.
284   bool HasDwarfPubSections;
285
286   // Whether or not to use AT_ranges for compilation units.
287   bool HasCURanges;
288
289   // Whether we emitted a function into a section other than the default
290   // text.
291   bool UsedNonDefaultText;
292
293   // Version of dwarf we're emitting.
294   unsigned DwarfVersion;
295
296   // Maps from a type identifier to the actual MDNode.
297   DITypeIdentifierMap TypeIdentifierMap;
298
299   // DWARF5 Experimental Options
300   bool HasDwarfAccelTables;
301   bool HasSplitDwarf;
302
303   // Separated Dwarf Variables
304   // In general these will all be for bits that are left in the
305   // original object file, rather than things that are meant
306   // to be in the .dwo sections.
307
308   // Holder for the skeleton information.
309   DwarfFile SkeletonHolder;
310
311   /// Store file names for type units under fission in a line table header that
312   /// will be emitted into debug_line.dwo.
313   // FIXME: replace this with a map from comp_dir to table so that we can emit
314   // multiple tables during LTO each of which uses directory 0, referencing the
315   // comp_dir of all the type units that use it.
316   MCDwarfDwoLineTable SplitTypeUnitFileTable;
317
318   // True iff there are multiple CUs in this module.
319   bool SingleCU;
320   bool IsDarwin;
321
322   AddressPool AddrPool;
323
324   DwarfAccelTable AccelNames;
325   DwarfAccelTable AccelObjC;
326   DwarfAccelTable AccelNamespace;
327   DwarfAccelTable AccelTypes;
328
329   DenseMap<const Function *, DISubprogram> FunctionDIs;
330
331   MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
332
333   const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() {
334     return InfoHolder.getUnits();
335   }
336
337   /// \brief Find abstract variable associated with Var.
338   DbgVariable *getExistingAbstractVariable(const DIVariable &DV,
339                                            DIVariable &Cleansed);
340   DbgVariable *getExistingAbstractVariable(const DIVariable &DV);
341   void createAbstractVariable(const DIVariable &DV, LexicalScope *Scope);
342   void ensureAbstractVariableIsCreated(const DIVariable &Var,
343                                        const MDNode *Scope);
344   void ensureAbstractVariableIsCreatedIfScoped(const DIVariable &Var,
345                                                const MDNode *Scope);
346
347   /// \brief Construct a DIE for this abstract scope.
348   void constructAbstractSubprogramScopeDIE(LexicalScope *Scope);
349
350   /// \brief Emit initial Dwarf sections with a label at the start of each one.
351   void emitSectionLabels();
352
353   /// \brief Compute the size and offset of a DIE given an incoming Offset.
354   unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
355
356   /// \brief Compute the size and offset of all the DIEs.
357   void computeSizeAndOffsets();
358
359   /// \brief Collect info for variables that were optimized out.
360   void collectDeadVariables();
361
362   void finishVariableDefinitions();
363
364   void finishSubprogramDefinitions();
365
366   /// \brief Finish off debug information after all functions have been
367   /// processed.
368   void finalizeModuleInfo();
369
370   /// \brief Emit the debug info section.
371   void emitDebugInfo();
372
373   /// \brief Emit the abbreviation section.
374   void emitAbbreviations();
375
376   /// \brief Emit the last address of the section and the end of
377   /// the line matrix.
378   void emitEndOfLineMatrix(unsigned SectionEnd);
379
380   /// \brief Emit a specified accelerator table.
381   void emitAccel(DwarfAccelTable &Accel, const MCSection *Section,
382                  StringRef TableName, StringRef SymName);
383
384   /// \brief Emit visible names into a hashed accelerator table section.
385   void emitAccelNames();
386
387   /// \brief Emit objective C classes and categories into a hashed
388   /// accelerator table section.
389   void emitAccelObjC();
390
391   /// \brief Emit namespace dies into a hashed accelerator table.
392   void emitAccelNamespaces();
393
394   /// \brief Emit type dies into a hashed accelerator table.
395   void emitAccelTypes();
396
397   /// \brief Emit visible names into a debug pubnames section.
398   /// \param GnuStyle determines whether or not we want to emit
399   /// additional information into the table ala newer gcc for gdb
400   /// index.
401   void emitDebugPubNames(bool GnuStyle = false);
402
403   /// \brief Emit visible types into a debug pubtypes section.
404   /// \param GnuStyle determines whether or not we want to emit
405   /// additional information into the table ala newer gcc for gdb
406   /// index.
407   void emitDebugPubTypes(bool GnuStyle = false);
408
409   void emitDebugPubSection(
410       bool GnuStyle, const MCSection *PSec, StringRef Name,
411       const StringMap<const DIE *> &(DwarfCompileUnit::*Accessor)() const);
412
413   /// \brief Emit visible names into a debug str section.
414   void emitDebugStr();
415
416   /// \brief Emit visible names into a debug loc section.
417   void emitDebugLoc();
418
419   /// \brief Emit visible names into a debug loc dwo section.
420   void emitDebugLocDWO();
421
422   /// \brief Emit visible names into a debug aranges section.
423   void emitDebugARanges();
424
425   /// \brief Emit visible names into a debug ranges section.
426   void emitDebugRanges();
427
428   /// \brief Emit inline info using custom format.
429   void emitDebugInlineInfo();
430
431   /// DWARF 5 Experimental Split Dwarf Emitters
432
433   /// \brief Initialize common features of skeleton units.
434   void initSkeletonUnit(const DwarfUnit &U, DIE &Die,
435                         std::unique_ptr<DwarfUnit> NewU);
436
437   /// \brief Construct the split debug info compile unit for the debug info
438   /// section.
439   DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU);
440
441   /// \brief Construct the split debug info compile unit for the debug info
442   /// section.
443   DwarfTypeUnit &constructSkeletonTU(DwarfTypeUnit &TU);
444
445   /// \brief Emit the debug info dwo section.
446   void emitDebugInfoDWO();
447
448   /// \brief Emit the debug abbrev dwo section.
449   void emitDebugAbbrevDWO();
450
451   /// \brief Emit the debug line dwo section.
452   void emitDebugLineDWO();
453
454   /// \brief Emit the debug str dwo section.
455   void emitDebugStrDWO();
456
457   /// Flags to let the linker know we have emitted new style pubnames. Only
458   /// emit it here if we don't have a skeleton CU for split dwarf.
459   void addGnuPubAttributes(DwarfUnit &U, DIE &D) const;
460
461   /// \brief Create new DwarfCompileUnit for the given metadata node with tag
462   /// DW_TAG_compile_unit.
463   DwarfCompileUnit &constructDwarfCompileUnit(DICompileUnit DIUnit);
464
465   /// \brief Construct imported_module or imported_declaration DIE.
466   void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
467                                         const MDNode *N);
468
469   /// \brief Register a source line with debug info. Returns the unique
470   /// label that was emitted and which provides correspondence to the
471   /// source line list.
472   void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
473                         unsigned Flags);
474
475   /// \brief Indentify instructions that are marking the beginning of or
476   /// ending of a scope.
477   void identifyScopeMarkers();
478
479   /// \brief Populate LexicalScope entries with variables' info.
480   void collectVariableInfo(DwarfCompileUnit &TheCU, DISubprogram SP,
481                            SmallPtrSetImpl<const MDNode *> &ProcessedVars);
482
483   /// \brief Build the location list for all DBG_VALUEs in the
484   /// function that describe the same variable.
485   void buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
486                          const DbgValueHistoryMap::InstrRanges &Ranges);
487
488   /// \brief Collect variable information from the side table maintained
489   /// by MMI.
490   void collectVariableInfoFromMMITable(SmallPtrSetImpl<const MDNode *> &P);
491
492   /// \brief Ensure that a label will be emitted before MI.
493   void requestLabelBeforeInsn(const MachineInstr *MI) {
494     LabelsBeforeInsn.insert(std::make_pair(MI, nullptr));
495   }
496
497   /// \brief Ensure that a label will be emitted after MI.
498   void requestLabelAfterInsn(const MachineInstr *MI) {
499     LabelsAfterInsn.insert(std::make_pair(MI, nullptr));
500   }
501
502 public:
503   //===--------------------------------------------------------------------===//
504   // Main entry points.
505   //
506   DwarfDebug(AsmPrinter *A, Module *M);
507
508   ~DwarfDebug() override;
509
510   /// \brief Emit all Dwarf sections that should come prior to the
511   /// content.
512   void beginModule();
513
514   /// \brief Emit all Dwarf sections that should come after the content.
515   void endModule() override;
516
517   /// \brief Gather pre-function debug information.
518   void beginFunction(const MachineFunction *MF) override;
519
520   /// \brief Gather and emit post-function debug information.
521   void endFunction(const MachineFunction *MF) override;
522
523   /// \brief Process beginning of an instruction.
524   void beginInstruction(const MachineInstr *MI) override;
525
526   /// \brief Process end of an instruction.
527   void endInstruction() override;
528
529   /// \brief Add a DIE to the set of types that we're going to pull into
530   /// type units.
531   void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
532                             DIE &Die, DICompositeType CTy);
533
534   /// \brief Add a label so that arange data can be generated for it.
535   void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
536
537   /// \brief For symbols that have a size designated (e.g. common symbols),
538   /// this tracks that size.
539   void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {
540     SymSize[Sym] = Size;
541   }
542
543   /// \brief Recursively Emits a debug information entry.
544   void emitDIE(DIE &Die);
545
546   // Experimental DWARF5 features.
547
548   /// \brief Returns whether or not to emit tables that dwarf consumers can
549   /// use to accelerate lookup.
550   bool useDwarfAccelTables() const { return HasDwarfAccelTables; }
551
552   /// \brief Returns whether or not to change the current debug info for the
553   /// split dwarf proposal support.
554   bool useSplitDwarf() const { return HasSplitDwarf; }
555
556   /// Returns the Dwarf Version.
557   unsigned getDwarfVersion() const { return DwarfVersion; }
558
559   /// Returns the section symbol for the .debug_loc section.
560   MCSymbol *getDebugLocSym() const { return DwarfDebugLocSectionSym; }
561
562   /// Returns the section symbol for the .debug_str section.
563   MCSymbol *getDebugStrSym() const { return DwarfStrSectionSym; }
564
565   /// Returns the section symbol for the .debug_ranges section.
566   MCSymbol *getRangeSectionSym() const { return DwarfDebugRangeSectionSym; }
567
568   /// Returns the previous CU that was being updated
569   const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
570   void setPrevCU(const DwarfCompileUnit *PrevCU) { this->PrevCU = PrevCU; }
571
572   /// Returns the entries for the .debug_loc section.
573   const SmallVectorImpl<DebugLocList> &
574   getDebugLocEntries() const {
575     return DotDebugLocEntries;
576   }
577
578   /// \brief Emit an entry for the debug loc section. This can be used to
579   /// handle an entry that's going to be emitted into the debug loc section.
580   void emitDebugLocEntry(ByteStreamer &Streamer,
581                          const DebugLocEntry &Entry);
582   /// \brief emit a single value for the debug loc section.
583   void emitDebugLocValue(ByteStreamer &Streamer,
584                          const DebugLocEntry::Value &Value,
585                          unsigned PieceOffsetInBits = 0);
586   /// Emits an optimal (=sorted) sequence of DW_OP_pieces.
587   void emitLocPieces(ByteStreamer &Streamer,
588                      const DITypeIdentifierMap &Map,
589                      ArrayRef<DebugLocEntry::Value> Values);
590
591   /// Emit the location for a debug loc entry, including the size header.
592   void emitDebugLocEntryLocation(const DebugLocEntry &Entry);
593
594   /// Find the MDNode for the given reference.
595   template <typename T> T resolve(DIRef<T> Ref) const {
596     return Ref.resolve(TypeIdentifierMap);
597   }
598
599   /// \brief Return the TypeIdentifierMap.
600   const DITypeIdentifierMap &getTypeIdentifierMap() const {
601     return TypeIdentifierMap;
602   }
603
604   /// Find the DwarfCompileUnit for the given CU Die.
605   DwarfCompileUnit *lookupUnit(const DIE *CU) const {
606     return CUDieMap.lookup(CU);
607   }
608   /// isSubprogramContext - Return true if Context is either a subprogram
609   /// or another context nested inside a subprogram.
610   bool isSubprogramContext(const MDNode *Context);
611
612   void addSubprogramNames(DISubprogram SP, DIE &Die);
613
614   AddressPool &getAddressPool() { return AddrPool; }
615
616   void addAccelName(StringRef Name, const DIE &Die);
617
618   void addAccelObjC(StringRef Name, const DIE &Die);
619
620   void addAccelNamespace(StringRef Name, const DIE &Die);
621
622   void addAccelType(StringRef Name, const DIE &Die, char Flags);
623
624   const MachineFunction *getCurrentFunction() const { return CurFn; }
625   const MCSymbol *getFunctionBeginSym() const { return FunctionBeginSym; }
626   const MCSymbol *getFunctionEndSym() const { return FunctionEndSym; }
627
628   iterator_range<ImportedEntityMap::const_iterator>
629   findImportedEntitiesForScope(const MDNode *Scope) const {
630     return make_range(std::equal_range(
631         ScopesWithImportedEntities.begin(), ScopesWithImportedEntities.end(),
632         std::pair<const MDNode *, const MDNode *>(Scope, nullptr),
633         less_first()));
634   }
635
636   /// \brief A helper function to check whether the DIE for a given Scope is
637   /// going to be null.
638   bool isLexicalScopeDIENull(LexicalScope *Scope);
639
640   /// \brief Return Label preceding the instruction.
641   MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
642
643   /// \brief Return Label immediately following the instruction.
644   MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
645
646   // FIXME: Consider rolling ranges up into DwarfDebug since we use a single
647   // range_base anyway, so there's no need to keep them as separate per-CU range
648   // lists. (though one day we might end up with a range.dwo section, in which
649   // case it'd go to DwarfFile)
650   unsigned getNextRangeNumber() { return GlobalRangeCount++; }
651
652   // FIXME: Sink these functions down into DwarfFile/Dwarf*Unit.
653
654   SmallPtrSet<const MDNode *, 16> &getProcessedSPNodes() {
655     return ProcessedSPNodes;
656   }
657 };
658 } // End of namespace llvm
659
660 #endif