DebugInfo: Lazily attach definition attributes to definitions.
[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 CODEGEN_ASMPRINTER_DWARFDEBUG_H__
15 #define CODEGEN_ASMPRINTER_DWARFDEBUG_H__
16
17 #include "DwarfFile.h"
18 #include "AsmPrinterHandler.h"
19 #include "DIE.h"
20 #include "DbgValueHistoryCalculator.h"
21 #include "DebugLocEntry.h"
22 #include "DebugLocList.h"
23 #include "DwarfAccelTable.h"
24 #include "llvm/ADT/DenseMap.h"
25 #include "llvm/ADT/MapVector.h"
26 #include "llvm/ADT/SmallPtrSet.h"
27 #include "llvm/ADT/StringMap.h"
28 #include "llvm/ADT/FoldingSet.h"
29 #include "llvm/CodeGen/LexicalScopes.h"
30 #include "llvm/IR/DebugInfo.h"
31 #include "llvm/IR/DebugLoc.h"
32 #include "llvm/MC/MachineLocation.h"
33 #include "llvm/MC/MCDwarf.h"
34 #include "llvm/Support/Allocator.h"
35
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 class DbgVariable {
71   DIVariable Var;             // Variable Descriptor.
72   DIE *TheDIE;                // Variable DIE.
73   unsigned DotDebugLocOffset; // Offset in DotDebugLocEntries.
74   DbgVariable *AbsVar;        // Corresponding Abstract variable, if any.
75   const MachineInstr *MInsn;  // DBG_VALUE instruction of the variable.
76   int FrameIndex;
77   DwarfDebug *DD;
78
79 public:
80   // AbsVar may be NULL.
81   DbgVariable(DIVariable V, DbgVariable *AV, DwarfDebug *DD)
82       : Var(V), TheDIE(nullptr), DotDebugLocOffset(~0U), AbsVar(AV),
83         MInsn(nullptr), FrameIndex(~0), DD(DD) {}
84
85   // Accessors.
86   DIVariable getVariable() const { return Var; }
87   void setDIE(DIE &D) { TheDIE = &D; }
88   DIE *getDIE() const { return TheDIE; }
89   void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; }
90   unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; }
91   StringRef getName() const { return Var.getName(); }
92   DbgVariable *getAbstractVariable() const { return AbsVar; }
93   const MachineInstr *getMInsn() const { return MInsn; }
94   void setMInsn(const MachineInstr *M) { MInsn = M; }
95   int getFrameIndex() const { return FrameIndex; }
96   void setFrameIndex(int FI) { FrameIndex = FI; }
97   // Translate tag to proper Dwarf tag.
98   dwarf::Tag getTag() const {
99     if (Var.getTag() == dwarf::DW_TAG_arg_variable)
100       return dwarf::DW_TAG_formal_parameter;
101
102     return dwarf::DW_TAG_variable;
103   }
104   /// \brief Return true if DbgVariable is artificial.
105   bool isArtificial() const {
106     if (Var.isArtificial())
107       return true;
108     if (getType().isArtificial())
109       return true;
110     return false;
111   }
112
113   bool isObjectPointer() const {
114     if (Var.isObjectPointer())
115       return true;
116     if (getType().isObjectPointer())
117       return true;
118     return false;
119   }
120
121   bool variableHasComplexAddress() const {
122     assert(Var.isVariable() && "Invalid complex DbgVariable!");
123     return Var.hasComplexAddress();
124   }
125   bool isBlockByrefVariable() const;
126   unsigned getNumAddrElements() const {
127     assert(Var.isVariable() && "Invalid complex DbgVariable!");
128     return Var.getNumAddrElements();
129   }
130   uint64_t getAddrElement(unsigned i) const { return Var.getAddrElement(i); }
131   DIType getType() const;
132
133 private:
134   /// resolve - Look in the DwarfDebug map for the MDNode that
135   /// corresponds to the reference.
136   template <typename T> T resolve(DIRef<T> Ref) const;
137 };
138
139
140 /// \brief Helper used to pair up a symbol and its DWARF compile unit.
141 struct SymbolCU {
142   SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
143   const MCSymbol *Sym;
144   DwarfCompileUnit *CU;
145 };
146
147 /// \brief Collects and handles dwarf debug information.
148 class DwarfDebug : public AsmPrinterHandler {
149   // Target of Dwarf emission.
150   AsmPrinter *Asm;
151
152   // Collected machine module information.
153   MachineModuleInfo *MMI;
154
155   // All DIEValues are allocated through this allocator.
156   BumpPtrAllocator DIEValueAllocator;
157
158   // Handle to the compile unit used for the inline extension handling,
159   // this is just so that the DIEValue allocator has a place to store
160   // the particular elements.
161   // FIXME: Store these off of DwarfDebug instead?
162   DwarfCompileUnit *FirstCU;
163
164   // Maps MDNode with its corresponding DwarfCompileUnit.
165   MapVector<const MDNode *, DwarfCompileUnit *> CUMap;
166
167   // Maps subprogram MDNode with its corresponding DwarfCompileUnit.
168   DenseMap<const MDNode *, DwarfCompileUnit *> SPMap;
169
170   // Maps a CU DIE with its corresponding DwarfCompileUnit.
171   DenseMap<const DIE *, DwarfCompileUnit *> CUDieMap;
172
173   /// Maps MDNodes for type system with the corresponding DIEs. These DIEs can
174   /// be shared across CUs, that is why we keep the map here instead
175   /// of in DwarfCompileUnit.
176   DenseMap<const MDNode *, DIE *> MDTypeNodeToDieMap;
177
178   // List of all labels used in aranges generation.
179   std::vector<SymbolCU> ArangeLabels;
180
181   // Size of each symbol emitted (for those symbols that have a specific size).
182   DenseMap<const MCSymbol *, uint64_t> SymSize;
183
184   // Provides a unique id per text section.
185   typedef DenseMap<const MCSection *, SmallVector<SymbolCU, 8> > SectionMapType;
186   SectionMapType SectionMap;
187
188   // List of arguments for current function.
189   SmallVector<DbgVariable *, 8> CurrentFnArguments;
190
191   LexicalScopes LScopes;
192
193   // Collection of abstract subprogram DIEs.
194   DenseMap<const MDNode *, DIE *> AbstractSPDies;
195
196   // Collection of dbg variables of a scope.
197   typedef DenseMap<LexicalScope *, SmallVector<DbgVariable *, 8> >
198   ScopeVariablesMap;
199   ScopeVariablesMap ScopeVariables;
200
201   // Collection of abstract variables.
202   DenseMap<const MDNode *, std::unique_ptr<DbgVariable>> AbstractVariables;
203
204   // Collection of DebugLocEntry. Stored in a linked list so that DIELocLists
205   // can refer to them in spite of insertions into this list.
206   SmallVector<DebugLocList, 4> DotDebugLocEntries;
207
208   // Collection of subprogram DIEs that are marked (at the end of the module)
209   // as DW_AT_inline.
210   SmallPtrSet<DIE *, 4> InlinedSubprogramDIEs;
211
212   // This is a collection of subprogram MDNodes that are processed to
213   // create DIEs.
214   SmallPtrSet<const MDNode *, 16> ProcessedSPNodes;
215
216   // Maps instruction with label emitted before instruction.
217   DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn;
218
219   // Maps instruction with label emitted after instruction.
220   DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn;
221
222   // History of DBG_VALUE and clobber instructions for each user variable.
223   // Variables are listed in order of appearance.
224   DbgValueHistoryMap DbgValues;
225
226   // Previous instruction's location information. This is used to determine
227   // label location to indicate scope boundries in dwarf debug info.
228   DebugLoc PrevInstLoc;
229   MCSymbol *PrevLabel;
230
231   // This location indicates end of function prologue and beginning of function
232   // body.
233   DebugLoc PrologEndLoc;
234
235   // If nonnull, stores the current machine function we're processing.
236   const MachineFunction *CurFn;
237
238   // If nonnull, stores the current machine instruction we're processing.
239   const MachineInstr *CurMI;
240
241   // If nonnull, stores the section that the previous function was allocated to
242   // emitting.
243   const MCSection *PrevSection;
244
245   // If nonnull, stores the CU in which the previous subprogram was contained.
246   const DwarfCompileUnit *PrevCU;
247
248   // Section Symbols: these are assembler temporary labels that are emitted at
249   // the beginning of each supported dwarf section.  These are used to form
250   // section offsets and are created by EmitSectionLabels.
251   MCSymbol *DwarfInfoSectionSym, *DwarfAbbrevSectionSym;
252   MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym;
253   MCSymbol *DwarfDebugLocSectionSym, *DwarfLineSectionSym, *DwarfAddrSectionSym;
254   MCSymbol *FunctionBeginSym, *FunctionEndSym;
255   MCSymbol *DwarfInfoDWOSectionSym, *DwarfAbbrevDWOSectionSym;
256   MCSymbol *DwarfStrDWOSectionSym;
257   MCSymbol *DwarfGnuPubNamesSectionSym, *DwarfGnuPubTypesSectionSym;
258
259   // As an optimization, there is no need to emit an entry in the directory
260   // table for the same directory as DW_AT_comp_dir.
261   StringRef CompilationDir;
262
263   // Counter for assigning globally unique IDs for ranges.
264   unsigned GlobalRangeCount;
265
266   // Holder for the file specific debug information.
267   DwarfFile InfoHolder;
268
269   // Holders for the various debug information flags that we might need to
270   // have exposed. See accessor functions below for description.
271
272   // Holder for imported entities.
273   typedef SmallVector<std::pair<const MDNode *, const MDNode *>, 32>
274   ImportedEntityMap;
275   ImportedEntityMap ScopesWithImportedEntities;
276
277   // Map from MDNodes for user-defined types to the type units that describe
278   // them.
279   DenseMap<const MDNode *, const DwarfTypeUnit *> DwarfTypeUnits;
280
281   SmallVector<std::pair<std::unique_ptr<DwarfTypeUnit>, DICompositeType>, 1> 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
321   AddressPool AddrPool;
322
323   DwarfAccelTable AccelNames;
324   DwarfAccelTable AccelObjC;
325   DwarfAccelTable AccelNamespace;
326   DwarfAccelTable AccelTypes;
327
328   MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
329
330   void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
331
332   const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() {
333     return InfoHolder.getUnits();
334   }
335
336   /// \brief Find abstract variable associated with Var.
337   DbgVariable *findAbstractVariable(DIVariable &Var, DebugLoc Loc);
338   DbgVariable *findAbstractVariable(DIVariable &Var, const MDNode *Scope);
339
340   /// \brief Find DIE for the given subprogram and attach appropriate
341   /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
342   /// variables in this scope then create and insert DIEs for these
343   /// variables.
344   DIE &updateSubprogramScopeDIE(DwarfCompileUnit &SPCU, DISubprogram SP);
345
346   /// \brief A helper function to check whether the DIE for a given Scope is
347   /// going to be null.
348   bool isLexicalScopeDIENull(LexicalScope *Scope);
349
350   /// \brief A helper function to construct a RangeSpanList for a given
351   /// lexical scope.
352   void addScopeRangeList(DwarfCompileUnit &TheCU, DIE &ScopeDIE,
353                          const SmallVectorImpl<InsnRange> &Range);
354
355   /// \brief Construct new DW_TAG_lexical_block for this scope and
356   /// attach DW_AT_low_pc/DW_AT_high_pc labels.
357   std::unique_ptr<DIE> constructLexicalScopeDIE(DwarfCompileUnit &TheCU,
358                                                 LexicalScope *Scope);
359
360   /// \brief This scope represents inlined body of a function. Construct
361   /// DIE to represent this concrete inlined copy of the function.
362   std::unique_ptr<DIE> constructInlinedScopeDIE(DwarfCompileUnit &TheCU,
363                                                 LexicalScope *Scope);
364
365   /// \brief Construct a DIE for this scope.
366   std::unique_ptr<DIE> constructScopeDIE(DwarfCompileUnit &TheCU,
367                                          LexicalScope *Scope);
368   void createAndAddScopeChildren(DwarfCompileUnit &TheCU, LexicalScope *Scope,
369                                  DIE &ScopeDIE);
370   /// \brief Construct a DIE for this abstract scope.
371   void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &TheCU,
372                                            LexicalScope *Scope);
373   /// \brief Construct a DIE for this subprogram scope.
374   DIE &constructSubprogramScopeDIE(DwarfCompileUnit &TheCU,
375                                    LexicalScope *Scope);
376   /// A helper function to create children of a Scope DIE.
377   DIE *createScopeChildrenDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope,
378                               SmallVectorImpl<std::unique_ptr<DIE>> &Children);
379
380   /// \brief Emit initial Dwarf sections with a label at the start of each one.
381   void emitSectionLabels();
382
383   /// \brief Compute the size and offset of a DIE given an incoming Offset.
384   unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
385
386   /// \brief Compute the size and offset of all the DIEs.
387   void computeSizeAndOffsets();
388
389   /// \brief Collect info for variables that were optimized out.
390   void collectDeadVariables();
391
392   void finishSubprogramDefinitions();
393
394   /// \brief Finish off debug information after all functions have been
395   /// processed.
396   void finalizeModuleInfo();
397
398   /// \brief Emit labels to close any remaining sections that have been left
399   /// open.
400   void endSections();
401
402   /// \brief Emit the debug info section.
403   void emitDebugInfo();
404
405   /// \brief Emit the abbreviation section.
406   void emitAbbreviations();
407
408   /// \brief Emit the last address of the section and the end of
409   /// the line matrix.
410   void emitEndOfLineMatrix(unsigned SectionEnd);
411
412   /// \brief Emit visible names into a hashed accelerator table section.
413   void emitAccelNames();
414
415   /// \brief Emit objective C classes and categories into a hashed
416   /// accelerator table section.
417   void emitAccelObjC();
418
419   /// \brief Emit namespace dies into a hashed accelerator table.
420   void emitAccelNamespaces();
421
422   /// \brief Emit type dies into a hashed accelerator table.
423   void emitAccelTypes();
424
425   /// \brief Emit visible names into a debug pubnames section.
426   /// \param GnuStyle determines whether or not we want to emit
427   /// additional information into the table ala newer gcc for gdb
428   /// index.
429   void emitDebugPubNames(bool GnuStyle = false);
430
431   /// \brief Emit visible types into a debug pubtypes section.
432   /// \param GnuStyle determines whether or not we want to emit
433   /// additional information into the table ala newer gcc for gdb
434   /// index.
435   void emitDebugPubTypes(bool GnuStyle = false);
436
437   void
438   emitDebugPubSection(bool GnuStyle, const MCSection *PSec, StringRef Name,
439                       const StringMap<const DIE *> &(DwarfUnit::*Accessor)()
440                       const);
441
442   /// \brief Emit visible names into a debug str section.
443   void emitDebugStr();
444
445   /// \brief Emit visible names into a debug loc section.
446   void emitDebugLoc();
447
448   /// \brief Emit visible names into a debug loc dwo section.
449   void emitDebugLocDWO();
450
451   /// \brief Emit visible names into a debug aranges section.
452   void emitDebugARanges();
453
454   /// \brief Emit visible names into a debug ranges section.
455   void emitDebugRanges();
456
457   /// \brief Emit inline info using custom format.
458   void emitDebugInlineInfo();
459
460   /// DWARF 5 Experimental Split Dwarf Emitters
461
462   /// \brief Initialize common features of skeleton units.
463   void initSkeletonUnit(const DwarfUnit &U, DIE &Die,
464                         std::unique_ptr<DwarfUnit> NewU);
465
466   /// \brief Construct the split debug info compile unit for the debug info
467   /// section.
468   DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU);
469
470   /// \brief Construct the split debug info compile unit for the debug info
471   /// section.
472   DwarfTypeUnit &constructSkeletonTU(DwarfTypeUnit &TU);
473
474   /// \brief Emit the debug info dwo section.
475   void emitDebugInfoDWO();
476
477   /// \brief Emit the debug abbrev dwo section.
478   void emitDebugAbbrevDWO();
479
480   /// \brief Emit the debug line dwo section.
481   void emitDebugLineDWO();
482
483   /// \brief Emit the debug str dwo section.
484   void emitDebugStrDWO();
485
486   /// Flags to let the linker know we have emitted new style pubnames. Only
487   /// emit it here if we don't have a skeleton CU for split dwarf.
488   void addGnuPubAttributes(DwarfUnit &U, DIE &D) const;
489
490   /// \brief Create new DwarfCompileUnit for the given metadata node with tag
491   /// DW_TAG_compile_unit.
492   DwarfCompileUnit &constructDwarfCompileUnit(DICompileUnit DIUnit);
493
494   /// \brief Construct subprogram DIE.
495   void constructSubprogramDIE(DwarfCompileUnit &TheCU, const MDNode *N);
496
497   /// \brief Construct imported_module or imported_declaration DIE.
498   void constructImportedEntityDIE(DwarfCompileUnit &TheCU, const MDNode *N);
499
500   /// \brief Construct import_module DIE.
501   void constructImportedEntityDIE(DwarfCompileUnit &TheCU, const MDNode *N,
502                                   DIE &Context);
503
504   /// \brief Construct import_module DIE.
505   void constructImportedEntityDIE(DwarfCompileUnit &TheCU,
506                                   const DIImportedEntity &Module, DIE &Context);
507
508   /// \brief Register a source line with debug info. Returns the unique
509   /// label that was emitted and which provides correspondence to the
510   /// source line list.
511   void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
512                         unsigned Flags);
513
514   /// \brief Indentify instructions that are marking the beginning of or
515   /// ending of a scope.
516   void identifyScopeMarkers();
517
518   /// \brief If Var is an current function argument that add it in
519   /// CurrentFnArguments list.
520   bool addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope);
521
522   /// \brief Populate LexicalScope entries with variables' info.
523   void collectVariableInfo(SmallPtrSet<const MDNode *, 16> &ProcessedVars);
524
525   /// \brief Collect variable information from the side table maintained
526   /// by MMI.
527   void collectVariableInfoFromMMITable(SmallPtrSet<const MDNode *, 16> &P);
528
529   /// \brief Ensure that a label will be emitted before MI.
530   void requestLabelBeforeInsn(const MachineInstr *MI) {
531     LabelsBeforeInsn.insert(std::make_pair(MI, nullptr));
532   }
533
534   /// \brief Return Label preceding the instruction.
535   MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
536
537   /// \brief Ensure that a label will be emitted after MI.
538   void requestLabelAfterInsn(const MachineInstr *MI) {
539     LabelsAfterInsn.insert(std::make_pair(MI, nullptr));
540   }
541
542   /// \brief Return Label immediately following the instruction.
543   MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
544
545   void attachRangesOrLowHighPC(DwarfCompileUnit &Unit, DIE &D,
546                                const SmallVectorImpl<InsnRange> &Ranges);
547   void attachLowHighPC(DwarfCompileUnit &Unit, DIE &D, MCSymbol *Begin,
548                        MCSymbol *End);
549
550 public:
551   //===--------------------------------------------------------------------===//
552   // Main entry points.
553   //
554   DwarfDebug(AsmPrinter *A, Module *M);
555
556   ~DwarfDebug() override;
557
558   void insertDIE(const MDNode *TypeMD, DIE *Die) {
559     MDTypeNodeToDieMap.insert(std::make_pair(TypeMD, Die));
560   }
561   DIE *getDIE(const MDNode *TypeMD) {
562     return MDTypeNodeToDieMap.lookup(TypeMD);
563   }
564
565   /// \brief Emit all Dwarf sections that should come prior to the
566   /// content.
567   void beginModule();
568
569   /// \brief Emit all Dwarf sections that should come after the content.
570   void endModule() override;
571
572   /// \brief Gather pre-function debug information.
573   void beginFunction(const MachineFunction *MF) override;
574
575   /// \brief Gather and emit post-function debug information.
576   void endFunction(const MachineFunction *MF) override;
577
578   /// \brief Process beginning of an instruction.
579   void beginInstruction(const MachineInstr *MI) override;
580
581   /// \brief Process end of an instruction.
582   void endInstruction() override;
583
584   /// \brief Add a DIE to the set of types that we're going to pull into
585   /// type units.
586   void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
587                             DIE &Die, DICompositeType CTy);
588
589   /// \brief Add a label so that arange data can be generated for it.
590   void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
591
592   /// \brief For symbols that have a size designated (e.g. common symbols),
593   /// this tracks that size.
594   void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {
595     SymSize[Sym] = Size;
596   }
597
598   /// \brief Recursively Emits a debug information entry.
599   void emitDIE(DIE &Die);
600
601   // Experimental DWARF5 features.
602
603   /// \brief Returns whether or not to emit tables that dwarf consumers can
604   /// use to accelerate lookup.
605   bool useDwarfAccelTables() const { return HasDwarfAccelTables; }
606
607   /// \brief Returns whether or not to change the current debug info for the
608   /// split dwarf proposal support.
609   bool useSplitDwarf() const { return HasSplitDwarf; }
610
611   /// Returns the Dwarf Version.
612   unsigned getDwarfVersion() const { return DwarfVersion; }
613
614   /// Returns the section symbol for the .debug_loc section.
615   MCSymbol *getDebugLocSym() const { return DwarfDebugLocSectionSym; }
616
617   /// Returns the previous section that was emitted into.
618   const MCSection *getPrevSection() const { return PrevSection; }
619
620   /// Returns the previous CU that was being updated
621   const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
622
623   /// Returns the entries for the .debug_loc section.
624   const SmallVectorImpl<DebugLocList> &
625   getDebugLocEntries() const {
626     return DotDebugLocEntries;
627   }
628
629   /// \brief Emit an entry for the debug loc section. This can be used to
630   /// handle an entry that's going to be emitted into the debug loc section.
631   void emitDebugLocEntry(ByteStreamer &Streamer, const DebugLocEntry &Entry);
632
633   /// Emit the location for a debug loc entry, including the size header.
634   void emitDebugLocEntryLocation(const DebugLocEntry &Entry);
635
636   /// Find the MDNode for the given reference.
637   template <typename T> T resolve(DIRef<T> Ref) const {
638     return Ref.resolve(TypeIdentifierMap);
639   }
640
641   /// \brief Return the TypeIdentifierMap.
642   const DITypeIdentifierMap &getTypeIdentifierMap() const {
643     return TypeIdentifierMap;
644   }
645
646   /// Find the DwarfCompileUnit for the given CU Die.
647   DwarfCompileUnit *lookupUnit(const DIE *CU) const {
648     return CUDieMap.lookup(CU);
649   }
650   /// isSubprogramContext - Return true if Context is either a subprogram
651   /// or another context nested inside a subprogram.
652   bool isSubprogramContext(const MDNode *Context);
653
654   void addSubprogramNames(DISubprogram SP, DIE &Die);
655
656   AddressPool &getAddressPool() { return AddrPool; }
657
658   void addAccelName(StringRef Name, const DIE &Die);
659
660   void addAccelObjC(StringRef Name, const DIE &Die);
661
662   void addAccelNamespace(StringRef Name, const DIE &Die);
663
664   void addAccelType(StringRef Name, const DIE &Die, char Flags);
665 };
666 } // End of namespace llvm
667
668 #endif