Move logic for calculating DBG_VALUE history map into separate file/class.
[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 *, 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   // Every user variable mentioned by a DBG_VALUE instruction in order of
223   // appearance.
224   SmallVector<const MDNode *, 8> UserVariables;
225
226   // History of DBG_VALUE and clobber instructions for each user variable.
227   DbgValueHistoryMap DbgValues;
228
229   // Previous instruction's location information. This is used to determine
230   // label location to indicate scope boundries in dwarf debug info.
231   DebugLoc PrevInstLoc;
232   MCSymbol *PrevLabel;
233
234   // This location indicates end of function prologue and beginning of function
235   // body.
236   DebugLoc PrologEndLoc;
237
238   // If nonnull, stores the current machine function we're processing.
239   const MachineFunction *CurFn;
240
241   // If nonnull, stores the current machine instruction we're processing.
242   const MachineInstr *CurMI;
243
244   // If nonnull, stores the section that the previous function was allocated to
245   // emitting.
246   const MCSection *PrevSection;
247
248   // If nonnull, stores the CU in which the previous subprogram was contained.
249   const DwarfCompileUnit *PrevCU;
250
251   // Section Symbols: these are assembler temporary labels that are emitted at
252   // the beginning of each supported dwarf section.  These are used to form
253   // section offsets and are created by EmitSectionLabels.
254   MCSymbol *DwarfInfoSectionSym, *DwarfAbbrevSectionSym;
255   MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym;
256   MCSymbol *DwarfDebugLocSectionSym, *DwarfLineSectionSym, *DwarfAddrSectionSym;
257   MCSymbol *FunctionBeginSym, *FunctionEndSym;
258   MCSymbol *DwarfInfoDWOSectionSym, *DwarfAbbrevDWOSectionSym;
259   MCSymbol *DwarfStrDWOSectionSym;
260   MCSymbol *DwarfGnuPubNamesSectionSym, *DwarfGnuPubTypesSectionSym;
261
262   // As an optimization, there is no need to emit an entry in the directory
263   // table for the same directory as DW_AT_comp_dir.
264   StringRef CompilationDir;
265
266   // Counter for assigning globally unique IDs for ranges.
267   unsigned GlobalRangeCount;
268
269   // Holder for the file specific debug information.
270   DwarfFile InfoHolder;
271
272   // Holders for the various debug information flags that we might need to
273   // have exposed. See accessor functions below for description.
274
275   // Holder for imported entities.
276   typedef SmallVector<std::pair<const MDNode *, const MDNode *>, 32>
277   ImportedEntityMap;
278   ImportedEntityMap ScopesWithImportedEntities;
279
280   // Map from MDNodes for user-defined types to the type units that describe
281   // them.
282   DenseMap<const MDNode *, const DwarfTypeUnit *> DwarfTypeUnits;
283
284   SmallVector<std::pair<std::unique_ptr<DwarfTypeUnit>, DICompositeType>, 1> TypeUnitsUnderConstruction;
285
286   // Whether to emit the pubnames/pubtypes sections.
287   bool HasDwarfPubSections;
288
289   // Whether or not to use AT_ranges for compilation units.
290   bool HasCURanges;
291
292   // Whether we emitted a function into a section other than the default
293   // text.
294   bool UsedNonDefaultText;
295
296   // Version of dwarf we're emitting.
297   unsigned DwarfVersion;
298
299   // Maps from a type identifier to the actual MDNode.
300   DITypeIdentifierMap TypeIdentifierMap;
301
302   // DWARF5 Experimental Options
303   bool HasDwarfAccelTables;
304   bool HasSplitDwarf;
305
306   // Separated Dwarf Variables
307   // In general these will all be for bits that are left in the
308   // original object file, rather than things that are meant
309   // to be in the .dwo sections.
310
311   // Holder for the skeleton information.
312   DwarfFile SkeletonHolder;
313
314   /// Store file names for type units under fission in a line table header that
315   /// will be emitted into debug_line.dwo.
316   // FIXME: replace this with a map from comp_dir to table so that we can emit
317   // multiple tables during LTO each of which uses directory 0, referencing the
318   // comp_dir of all the type units that use it.
319   MCDwarfDwoLineTable SplitTypeUnitFileTable;
320
321   // True iff there are multiple CUs in this module.
322   bool SingleCU;
323
324   AddressPool AddrPool;
325
326   DwarfAccelTable AccelNames;
327   DwarfAccelTable AccelObjC;
328   DwarfAccelTable AccelNamespace;
329   DwarfAccelTable AccelTypes;
330
331   MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
332
333   void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
334
335   const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() {
336     return InfoHolder.getUnits();
337   }
338
339   /// \brief Find abstract variable associated with Var.
340   DbgVariable *findAbstractVariable(DIVariable &Var, DebugLoc Loc);
341
342   /// \brief Find DIE for the given subprogram and attach appropriate
343   /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
344   /// variables in this scope then create and insert DIEs for these
345   /// variables.
346   DIE &updateSubprogramScopeDIE(DwarfCompileUnit &SPCU, DISubprogram SP);
347
348   /// \brief A helper function to check whether the DIE for a given Scope is
349   /// going to be null.
350   bool isLexicalScopeDIENull(LexicalScope *Scope);
351
352   /// \brief A helper function to construct a RangeSpanList for a given
353   /// lexical scope.
354   void addScopeRangeList(DwarfCompileUnit &TheCU, DIE &ScopeDIE,
355                          const SmallVectorImpl<InsnRange> &Range);
356
357   /// \brief Construct new DW_TAG_lexical_block for this scope and
358   /// attach DW_AT_low_pc/DW_AT_high_pc labels.
359   std::unique_ptr<DIE> constructLexicalScopeDIE(DwarfCompileUnit &TheCU,
360                                                 LexicalScope *Scope);
361
362   /// \brief This scope represents inlined body of a function. Construct
363   /// DIE to represent this concrete inlined copy of the function.
364   std::unique_ptr<DIE> constructInlinedScopeDIE(DwarfCompileUnit &TheCU,
365                                                 LexicalScope *Scope);
366
367   /// \brief Construct a DIE for this scope.
368   std::unique_ptr<DIE> constructScopeDIE(DwarfCompileUnit &TheCU,
369                                          LexicalScope *Scope);
370   void createAndAddScopeChildren(DwarfCompileUnit &TheCU, LexicalScope *Scope,
371                                  DISubprogram Sub, DIE &ScopeDIE);
372   /// \brief Construct a DIE for this abstract scope.
373   void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &TheCU,
374                                            LexicalScope *Scope);
375   /// \brief Construct a DIE for this subprogram scope.
376   DIE &constructSubprogramScopeDIE(DwarfCompileUnit &TheCU,
377                                    LexicalScope *Scope);
378   /// A helper function to create children of a Scope DIE.
379   DIE *createScopeChildrenDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope,
380                               SmallVectorImpl<std::unique_ptr<DIE>> &Children);
381
382   /// \brief Emit initial Dwarf sections with a label at the start of each one.
383   void emitSectionLabels();
384
385   /// \brief Compute the size and offset of a DIE given an incoming Offset.
386   unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
387
388   /// \brief Compute the size and offset of all the DIEs.
389   void computeSizeAndOffsets();
390
391   /// \brief Attach DW_AT_inline attribute with inlined subprogram DIEs.
392   void computeInlinedDIEs();
393
394   /// \brief Collect info for variables that were optimized out.
395   void collectDeadVariables();
396
397   /// \brief Finish off debug information after all functions have been
398   /// processed.
399   void finalizeModuleInfo();
400
401   /// \brief Emit labels to close any remaining sections that have been left
402   /// open.
403   void endSections();
404
405   /// \brief Emit the debug info section.
406   void emitDebugInfo();
407
408   /// \brief Emit the abbreviation section.
409   void emitAbbreviations();
410
411   /// \brief Emit the last address of the section and the end of
412   /// the line matrix.
413   void emitEndOfLineMatrix(unsigned SectionEnd);
414
415   /// \brief Emit visible names into a hashed accelerator table section.
416   void emitAccelNames();
417
418   /// \brief Emit objective C classes and categories into a hashed
419   /// accelerator table section.
420   void emitAccelObjC();
421
422   /// \brief Emit namespace dies into a hashed accelerator table.
423   void emitAccelNamespaces();
424
425   /// \brief Emit type dies into a hashed accelerator table.
426   void emitAccelTypes();
427
428   /// \brief Emit visible names into a debug pubnames section.
429   /// \param GnuStyle determines whether or not we want to emit
430   /// additional information into the table ala newer gcc for gdb
431   /// index.
432   void emitDebugPubNames(bool GnuStyle = false);
433
434   /// \brief Emit visible types into a debug pubtypes section.
435   /// \param GnuStyle determines whether or not we want to emit
436   /// additional information into the table ala newer gcc for gdb
437   /// index.
438   void emitDebugPubTypes(bool GnuStyle = false);
439
440   void
441   emitDebugPubSection(bool GnuStyle, const MCSection *PSec, StringRef Name,
442                       const StringMap<const DIE *> &(DwarfUnit::*Accessor)()
443                       const);
444
445   /// \brief Emit visible names into a debug str section.
446   void emitDebugStr();
447
448   /// \brief Emit visible names into a debug loc section.
449   void emitDebugLoc();
450
451   /// \brief Emit visible names into a debug loc dwo section.
452   void emitDebugLocDWO();
453
454   /// \brief Emit visible names into a debug aranges section.
455   void emitDebugARanges();
456
457   /// \brief Emit visible names into a debug ranges section.
458   void emitDebugRanges();
459
460   /// \brief Emit inline info using custom format.
461   void emitDebugInlineInfo();
462
463   /// DWARF 5 Experimental Split Dwarf Emitters
464
465   /// \brief Initialize common features of skeleton units.
466   void initSkeletonUnit(const DwarfUnit &U, DIE &Die,
467                         std::unique_ptr<DwarfUnit> NewU);
468
469   /// \brief Construct the split debug info compile unit for the debug info
470   /// section.
471   DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU);
472
473   /// \brief Construct the split debug info compile unit for the debug info
474   /// section.
475   DwarfTypeUnit &constructSkeletonTU(DwarfTypeUnit &TU);
476
477   /// \brief Emit the debug info dwo section.
478   void emitDebugInfoDWO();
479
480   /// \brief Emit the debug abbrev dwo section.
481   void emitDebugAbbrevDWO();
482
483   /// \brief Emit the debug line dwo section.
484   void emitDebugLineDWO();
485
486   /// \brief Emit the debug str dwo section.
487   void emitDebugStrDWO();
488
489   /// Flags to let the linker know we have emitted new style pubnames. Only
490   /// emit it here if we don't have a skeleton CU for split dwarf.
491   void addGnuPubAttributes(DwarfUnit &U, DIE &D) const;
492
493   /// \brief Create new DwarfCompileUnit for the given metadata node with tag
494   /// DW_TAG_compile_unit.
495   DwarfCompileUnit &constructDwarfCompileUnit(DICompileUnit DIUnit);
496
497   /// \brief Construct subprogram DIE.
498   void constructSubprogramDIE(DwarfCompileUnit &TheCU, const MDNode *N);
499
500   /// \brief Construct imported_module or imported_declaration DIE.
501   void constructImportedEntityDIE(DwarfCompileUnit &TheCU, const MDNode *N);
502
503   /// \brief Construct import_module DIE.
504   void constructImportedEntityDIE(DwarfCompileUnit &TheCU, const MDNode *N,
505                                   DIE &Context);
506
507   /// \brief Construct import_module DIE.
508   void constructImportedEntityDIE(DwarfCompileUnit &TheCU,
509                                   const DIImportedEntity &Module, DIE &Context);
510
511   /// \brief Register a source line with debug info. Returns the unique
512   /// label that was emitted and which provides correspondence to the
513   /// source line list.
514   void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
515                         unsigned Flags);
516
517   /// \brief Indentify instructions that are marking the beginning of or
518   /// ending of a scope.
519   void identifyScopeMarkers();
520
521   /// \brief If Var is an current function argument that add it in
522   /// CurrentFnArguments list.
523   bool addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope);
524
525   /// \brief Populate LexicalScope entries with variables' info.
526   void collectVariableInfo(SmallPtrSet<const MDNode *, 16> &ProcessedVars);
527
528   /// \brief Collect variable information from the side table maintained
529   /// by MMI.
530   void collectVariableInfoFromMMITable(SmallPtrSet<const MDNode *, 16> &P);
531
532   /// \brief Ensure that a label will be emitted before MI.
533   void requestLabelBeforeInsn(const MachineInstr *MI) {
534     LabelsBeforeInsn.insert(std::make_pair(MI, nullptr));
535   }
536
537   /// \brief Return Label preceding the instruction.
538   MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
539
540   /// \brief Ensure that a label will be emitted after MI.
541   void requestLabelAfterInsn(const MachineInstr *MI) {
542     LabelsAfterInsn.insert(std::make_pair(MI, nullptr));
543   }
544
545   /// \brief Return Label immediately following the instruction.
546   MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
547
548   void attachLowHighPC(DwarfCompileUnit &Unit, DIE &D, MCSymbol *Begin,
549                        MCSymbol *End);
550
551 public:
552   //===--------------------------------------------------------------------===//
553   // Main entry points.
554   //
555   DwarfDebug(AsmPrinter *A, Module *M);
556
557   ~DwarfDebug() override;
558
559   void insertDIE(const MDNode *TypeMD, DIE *Die) {
560     MDTypeNodeToDieMap.insert(std::make_pair(TypeMD, Die));
561   }
562   DIE *getDIE(const MDNode *TypeMD) {
563     return MDTypeNodeToDieMap.lookup(TypeMD);
564   }
565
566   /// \brief Emit all Dwarf sections that should come prior to the
567   /// content.
568   void beginModule();
569
570   /// \brief Emit all Dwarf sections that should come after the content.
571   void endModule() override;
572
573   /// \brief Gather pre-function debug information.
574   void beginFunction(const MachineFunction *MF) override;
575
576   /// \brief Gather and emit post-function debug information.
577   void endFunction(const MachineFunction *MF) override;
578
579   /// \brief Process beginning of an instruction.
580   void beginInstruction(const MachineInstr *MI) override;
581
582   /// \brief Process end of an instruction.
583   void endInstruction() override;
584
585   /// \brief Add a DIE to the set of types that we're going to pull into
586   /// type units.
587   void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
588                             DIE &Die, DICompositeType CTy);
589
590   /// \brief Add a label so that arange data can be generated for it.
591   void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
592
593   /// \brief For symbols that have a size designated (e.g. common symbols),
594   /// this tracks that size.
595   void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {
596     SymSize[Sym] = Size;
597   }
598
599   /// \brief Recursively Emits a debug information entry.
600   void emitDIE(DIE &Die);
601
602   // Experimental DWARF5 features.
603
604   /// \brief Returns whether or not to emit tables that dwarf consumers can
605   /// use to accelerate lookup.
606   bool useDwarfAccelTables() const { return HasDwarfAccelTables; }
607
608   /// \brief Returns whether or not to change the current debug info for the
609   /// split dwarf proposal support.
610   bool useSplitDwarf() const { return HasSplitDwarf; }
611
612   /// Returns the Dwarf Version.
613   unsigned getDwarfVersion() const { return DwarfVersion; }
614
615   /// Returns the section symbol for the .debug_loc section.
616   MCSymbol *getDebugLocSym() const { return DwarfDebugLocSectionSym; }
617
618   /// Returns the previous section that was emitted into.
619   const MCSection *getPrevSection() const { return PrevSection; }
620
621   /// Returns the previous CU that was being updated
622   const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
623
624   /// Returns the entries for the .debug_loc section.
625   const SmallVectorImpl<DebugLocList> &
626   getDebugLocEntries() const {
627     return DotDebugLocEntries;
628   }
629
630   /// \brief Emit an entry for the debug loc section. This can be used to
631   /// handle an entry that's going to be emitted into the debug loc section.
632   void emitDebugLocEntry(ByteStreamer &Streamer, const DebugLocEntry &Entry);
633
634   /// Emit the location for a debug loc entry, including the size header.
635   void emitDebugLocEntryLocation(const DebugLocEntry &Entry);
636
637   /// Find the MDNode for the given reference.
638   template <typename T> T resolve(DIRef<T> Ref) const {
639     return Ref.resolve(TypeIdentifierMap);
640   }
641
642   /// \brief Return the TypeIdentifierMap.
643   const DITypeIdentifierMap &getTypeIdentifierMap() const {
644     return TypeIdentifierMap;
645   }
646
647   /// Find the DwarfCompileUnit for the given CU Die.
648   DwarfCompileUnit *lookupUnit(const DIE *CU) const {
649     return CUDieMap.lookup(CU);
650   }
651   /// isSubprogramContext - Return true if Context is either a subprogram
652   /// or another context nested inside a subprogram.
653   bool isSubprogramContext(const MDNode *Context);
654
655   void addSubprogramNames(DISubprogram SP, DIE &Die);
656
657   AddressPool &getAddressPool() { return AddrPool; }
658
659   void addAccelName(StringRef Name, const DIE &Die);
660
661   void addAccelObjC(StringRef Name, const DIE &Die);
662
663   void addAccelNamespace(StringRef Name, const DIE &Die);
664
665   void addAccelType(StringRef Name, const DIE &Die, char Flags);
666 };
667 } // End of namespace llvm
668
669 #endif