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