1 //===-- llvm/CodeGen/DwarfDebug.h - Dwarf Debug Framework ------*- C++ -*--===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains support for writing dwarf debug info into asm files.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
15 #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
17 #include "DwarfFile.h"
18 #include "AsmPrinterHandler.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/CodeGen/MachineInstr.h"
31 #include "llvm/IR/DebugInfo.h"
32 #include "llvm/IR/DebugLoc.h"
33 #include "llvm/MC/MachineLocation.h"
34 #include "llvm/MC/MCDwarf.h"
35 #include "llvm/Support/Allocator.h"
45 class DwarfCompileUnit;
49 class MachineModuleInfo;
51 //===----------------------------------------------------------------------===//
52 /// \brief This class is used to record source line correspondence.
54 unsigned Line; // Source line number.
55 unsigned Column; // Source column.
56 unsigned SourceID; // Source ID number.
57 MCSymbol *Label; // Label in code ID number.
59 SrcLineInfo(unsigned L, unsigned C, unsigned S, MCSymbol *label)
60 : Line(L), Column(C), SourceID(S), Label(label) {}
63 unsigned getLine() const { return Line; }
64 unsigned getColumn() const { return Column; }
65 unsigned getSourceID() const { return SourceID; }
66 MCSymbol *getLabel() const { return Label; }
69 //===----------------------------------------------------------------------===//
70 /// \brief This class is used to track local variable information.
72 DIVariable Var; // Variable Descriptor.
73 DIE *TheDIE; // Variable DIE.
74 unsigned DotDebugLocOffset; // Offset in DotDebugLocEntries.
75 const MachineInstr *MInsn; // DBG_VALUE instruction of the variable.
80 /// Construct a DbgVariable from a DIVariable.
81 DbgVariable(DIVariable V, DwarfDebug *DD)
82 : Var(V), TheDIE(nullptr), DotDebugLocOffset(~0U), MInsn(nullptr),
83 FrameIndex(~0), DD(DD) {}
85 /// Construct a DbgVariable from a DEBUG_VALUE.
86 /// AbstractVar may be NULL.
87 DbgVariable(const MachineInstr *DbgValue, DwarfDebug *DD)
88 : Var(DbgValue->getDebugVariable()), TheDIE(nullptr),
89 DotDebugLocOffset(~0U), MInsn(DbgValue), FrameIndex(~0), DD(DD) {}
92 DIVariable getVariable() const { return Var; }
93 void setDIE(DIE &D) { TheDIE = &D; }
94 DIE *getDIE() const { return TheDIE; }
95 void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; }
96 unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; }
97 StringRef getName() const { return Var.getName(); }
98 const MachineInstr *getMInsn() const { return MInsn; }
99 int getFrameIndex() const { return FrameIndex; }
100 void setFrameIndex(int FI) { FrameIndex = FI; }
101 // Translate tag to proper Dwarf tag.
102 dwarf::Tag getTag() const {
103 if (Var.getTag() == dwarf::DW_TAG_arg_variable)
104 return dwarf::DW_TAG_formal_parameter;
106 return dwarf::DW_TAG_variable;
108 /// \brief Return true if DbgVariable is artificial.
109 bool isArtificial() const {
110 if (Var.isArtificial())
112 if (getType().isArtificial())
117 bool isObjectPointer() const {
118 if (Var.isObjectPointer())
120 if (getType().isObjectPointer())
125 bool variableHasComplexAddress() const {
126 assert(Var.isVariable() && "Invalid complex DbgVariable!");
127 return Var.hasComplexAddress();
129 bool isBlockByrefVariable() const;
130 unsigned getNumAddrElements() const {
131 assert(Var.isVariable() && "Invalid complex DbgVariable!");
132 return Var.getNumAddrElements();
134 uint64_t getAddrElement(unsigned i) const { return Var.getAddrElement(i); }
135 DIType getType() const;
138 /// resolve - Look in the DwarfDebug map for the MDNode that
139 /// corresponds to the reference.
140 template <typename T> T resolve(DIRef<T> Ref) const;
144 /// \brief Helper used to pair up a symbol and its DWARF compile unit.
146 SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
148 DwarfCompileUnit *CU;
151 /// \brief Collects and handles dwarf debug information.
152 class DwarfDebug : public AsmPrinterHandler {
153 // Target of Dwarf emission.
156 // Collected machine module information.
157 MachineModuleInfo *MMI;
159 // All DIEValues are allocated through this allocator.
160 BumpPtrAllocator DIEValueAllocator;
162 // Handle to the compile unit used for the inline extension handling,
163 // this is just so that the DIEValue allocator has a place to store
164 // the particular elements.
165 // FIXME: Store these off of DwarfDebug instead?
166 DwarfCompileUnit *FirstCU;
168 // Maps MDNode with its corresponding DwarfCompileUnit.
169 MapVector<const MDNode *, DwarfCompileUnit *> CUMap;
171 // Maps subprogram MDNode with its corresponding DwarfCompileUnit.
172 DenseMap<const MDNode *, DwarfCompileUnit *> SPMap;
174 // Maps a CU DIE with its corresponding DwarfCompileUnit.
175 DenseMap<const DIE *, DwarfCompileUnit *> CUDieMap;
177 /// Maps MDNodes for type system with the corresponding DIEs. These DIEs can
178 /// be shared across CUs, that is why we keep the map here instead
179 /// of in DwarfCompileUnit.
180 DenseMap<const MDNode *, DIE *> MDTypeNodeToDieMap;
182 // List of all labels used in aranges generation.
183 std::vector<SymbolCU> ArangeLabels;
185 // Size of each symbol emitted (for those symbols that have a specific size).
186 DenseMap<const MCSymbol *, uint64_t> SymSize;
188 // Provides a unique id per text section.
189 typedef DenseMap<const MCSection *, SmallVector<SymbolCU, 8> > SectionMapType;
190 SectionMapType SectionMap;
192 // List of arguments for current function.
193 SmallVector<DbgVariable *, 8> CurrentFnArguments;
195 LexicalScopes LScopes;
197 // Collection of abstract subprogram DIEs.
198 DenseMap<const MDNode *, DIE *> AbstractSPDies;
200 // Collection of dbg variables of a scope.
201 typedef DenseMap<LexicalScope *, SmallVector<DbgVariable *, 8> >
203 ScopeVariablesMap ScopeVariables;
205 // Collection of abstract variables.
206 DenseMap<const MDNode *, std::unique_ptr<DbgVariable>> AbstractVariables;
207 SmallVector<std::unique_ptr<DbgVariable>, 64> ConcreteVariables;
209 // Collection of DebugLocEntry. Stored in a linked list so that DIELocLists
210 // can refer to them in spite of insertions into this list.
211 SmallVector<DebugLocList, 4> DotDebugLocEntries;
213 // Collection of subprogram DIEs that are marked (at the end of the module)
215 SmallPtrSet<DIE *, 4> InlinedSubprogramDIEs;
217 // This is a collection of subprogram MDNodes that are processed to
219 SmallPtrSet<const MDNode *, 16> ProcessedSPNodes;
221 // Maps instruction with label emitted before instruction.
222 DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn;
224 // Maps instruction with label emitted after instruction.
225 DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn;
227 // History of DBG_VALUE and clobber instructions for each user variable.
228 // Variables are listed in order of appearance.
229 DbgValueHistoryMap DbgValues;
231 // Previous instruction's location information. This is used to determine
232 // label location to indicate scope boundries in dwarf debug info.
233 DebugLoc PrevInstLoc;
236 // This location indicates end of function prologue and beginning of function
238 DebugLoc PrologEndLoc;
240 // If nonnull, stores the current machine function we're processing.
241 const MachineFunction *CurFn;
243 // If nonnull, stores the current machine instruction we're processing.
244 const MachineInstr *CurMI;
246 // If nonnull, stores the CU in which the previous subprogram was contained.
247 const DwarfCompileUnit *PrevCU;
249 // Section Symbols: these are assembler temporary labels that are emitted at
250 // the beginning of each supported dwarf section. These are used to form
251 // section offsets and are created by EmitSectionLabels.
252 MCSymbol *DwarfInfoSectionSym, *DwarfAbbrevSectionSym;
253 MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym;
254 MCSymbol *DwarfDebugLocSectionSym, *DwarfLineSectionSym, *DwarfAddrSectionSym;
255 MCSymbol *FunctionBeginSym, *FunctionEndSym;
256 MCSymbol *DwarfInfoDWOSectionSym, *DwarfAbbrevDWOSectionSym;
257 MCSymbol *DwarfTypesDWOSectionSym;
258 MCSymbol *DwarfStrDWOSectionSym;
259 MCSymbol *DwarfGnuPubNamesSectionSym, *DwarfGnuPubTypesSectionSym;
261 // As an optimization, there is no need to emit an entry in the directory
262 // table for the same directory as DW_AT_comp_dir.
263 StringRef CompilationDir;
265 // Counter for assigning globally unique IDs for ranges.
266 unsigned GlobalRangeCount;
268 // Holder for the file specific debug information.
269 DwarfFile InfoHolder;
271 // Holders for the various debug information flags that we might need to
272 // have exposed. See accessor functions below for description.
274 // Holder for imported entities.
275 typedef SmallVector<std::pair<const MDNode *, const MDNode *>, 32>
277 ImportedEntityMap ScopesWithImportedEntities;
279 // Map from MDNodes for user-defined types to the type units that describe
281 DenseMap<const MDNode *, const DwarfTypeUnit *> DwarfTypeUnits;
283 SmallVector<std::pair<std::unique_ptr<DwarfTypeUnit>, DICompositeType>, 1> TypeUnitsUnderConstruction;
285 // Whether to emit the pubnames/pubtypes sections.
286 bool HasDwarfPubSections;
288 // Whether or not to use AT_ranges for compilation units.
291 // Whether we emitted a function into a section other than the default
293 bool UsedNonDefaultText;
295 // Version of dwarf we're emitting.
296 unsigned DwarfVersion;
298 // Maps from a type identifier to the actual MDNode.
299 DITypeIdentifierMap TypeIdentifierMap;
301 // DWARF5 Experimental Options
302 bool HasDwarfAccelTables;
305 // Separated Dwarf Variables
306 // In general these will all be for bits that are left in the
307 // original object file, rather than things that are meant
308 // to be in the .dwo sections.
310 // Holder for the skeleton information.
311 DwarfFile SkeletonHolder;
313 /// Store file names for type units under fission in a line table header that
314 /// will be emitted into debug_line.dwo.
315 // FIXME: replace this with a map from comp_dir to table so that we can emit
316 // multiple tables during LTO each of which uses directory 0, referencing the
317 // comp_dir of all the type units that use it.
318 MCDwarfDwoLineTable SplitTypeUnitFileTable;
320 // True iff there are multiple CUs in this module.
324 AddressPool AddrPool;
326 DwarfAccelTable AccelNames;
327 DwarfAccelTable AccelObjC;
328 DwarfAccelTable AccelNamespace;
329 DwarfAccelTable AccelTypes;
331 DenseMap<const Function *, DISubprogram> FunctionDIs;
333 MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
335 void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
337 const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() {
338 return InfoHolder.getUnits();
341 /// \brief Find abstract variable associated with Var.
342 DbgVariable *getExistingAbstractVariable(const DIVariable &DV,
343 DIVariable &Cleansed);
344 DbgVariable *getExistingAbstractVariable(const DIVariable &DV);
345 void createAbstractVariable(const DIVariable &DV, LexicalScope *Scope);
346 void ensureAbstractVariableIsCreated(const DIVariable &Var,
347 const MDNode *Scope);
348 void ensureAbstractVariableIsCreatedIfScoped(const DIVariable &Var,
349 const MDNode *Scope);
351 /// \brief Find DIE for the given subprogram and attach appropriate
352 /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
353 /// variables in this scope then create and insert DIEs for these
355 DIE &updateSubprogramScopeDIE(DwarfCompileUnit &SPCU, DISubprogram SP);
357 /// \brief A helper function to check whether the DIE for a given Scope is
358 /// going to be null.
359 bool isLexicalScopeDIENull(LexicalScope *Scope);
361 /// \brief A helper function to construct a RangeSpanList for a given
363 void addScopeRangeList(DwarfCompileUnit &TheCU, DIE &ScopeDIE,
364 const SmallVectorImpl<InsnRange> &Range);
366 /// \brief Construct new DW_TAG_lexical_block for this scope and
367 /// attach DW_AT_low_pc/DW_AT_high_pc labels.
368 std::unique_ptr<DIE> constructLexicalScopeDIE(DwarfCompileUnit &TheCU,
369 LexicalScope *Scope);
371 /// \brief This scope represents inlined body of a function. Construct
372 /// DIE to represent this concrete inlined copy of the function.
373 std::unique_ptr<DIE> constructInlinedScopeDIE(DwarfCompileUnit &TheCU,
374 LexicalScope *Scope);
376 /// \brief Construct a DIE for this scope.
377 void constructScopeDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope,
378 SmallVectorImpl<std::unique_ptr<DIE>> &FinalChildren);
379 DIE *createAndAddScopeChildren(DwarfCompileUnit &TheCU, LexicalScope *Scope,
381 /// \brief Construct a DIE for this abstract scope.
382 void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &TheCU,
383 LexicalScope *Scope);
384 /// \brief Construct a DIE for this subprogram scope.
385 DIE &constructSubprogramScopeDIE(DwarfCompileUnit &TheCU,
386 LexicalScope *Scope);
387 /// A helper function to create children of a Scope DIE.
388 DIE *createScopeChildrenDIE(DwarfCompileUnit &TheCU, LexicalScope *Scope,
389 SmallVectorImpl<std::unique_ptr<DIE>> &Children,
390 unsigned *ChildScopeCount = nullptr);
392 /// \brief Emit initial Dwarf sections with a label at the start of each one.
393 void emitSectionLabels();
395 /// \brief Compute the size and offset of a DIE given an incoming Offset.
396 unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
398 /// \brief Compute the size and offset of all the DIEs.
399 void computeSizeAndOffsets();
401 /// \brief Collect info for variables that were optimized out.
402 void collectDeadVariables();
404 void finishVariableDefinitions();
406 void finishSubprogramDefinitions();
408 /// \brief Finish off debug information after all functions have been
410 void finalizeModuleInfo();
412 /// \brief Emit labels to close any remaining sections that have been left
416 /// \brief Emit the debug info section.
417 void emitDebugInfo();
419 /// \brief Emit the abbreviation section.
420 void emitAbbreviations();
422 /// \brief Emit the last address of the section and the end of
424 void emitEndOfLineMatrix(unsigned SectionEnd);
426 /// \brief Emit a specified accelerator table.
427 void emitAccel(DwarfAccelTable &Accel, const MCSection *Section,
428 StringRef TableName, StringRef SymName);
430 /// \brief Emit visible names into a hashed accelerator table section.
431 void emitAccelNames();
433 /// \brief Emit objective C classes and categories into a hashed
434 /// accelerator table section.
435 void emitAccelObjC();
437 /// \brief Emit namespace dies into a hashed accelerator table.
438 void emitAccelNamespaces();
440 /// \brief Emit type dies into a hashed accelerator table.
441 void emitAccelTypes();
443 /// \brief Emit visible names into a debug pubnames section.
444 /// \param GnuStyle determines whether or not we want to emit
445 /// additional information into the table ala newer gcc for gdb
447 void emitDebugPubNames(bool GnuStyle = false);
449 /// \brief Emit visible types into a debug pubtypes section.
450 /// \param GnuStyle determines whether or not we want to emit
451 /// additional information into the table ala newer gcc for gdb
453 void emitDebugPubTypes(bool GnuStyle = false);
456 emitDebugPubSection(bool GnuStyle, const MCSection *PSec, StringRef Name,
457 const StringMap<const DIE *> &(DwarfUnit::*Accessor)()
460 /// \brief Emit visible names into a debug str section.
463 /// \brief Emit visible names into a debug loc section.
466 /// \brief Emit visible names into a debug loc dwo section.
467 void emitDebugLocDWO();
469 /// \brief Emit visible names into a debug aranges section.
470 void emitDebugARanges();
472 /// \brief Emit visible names into a debug ranges section.
473 void emitDebugRanges();
475 /// \brief Emit inline info using custom format.
476 void emitDebugInlineInfo();
478 /// DWARF 5 Experimental Split Dwarf Emitters
480 /// \brief Initialize common features of skeleton units.
481 void initSkeletonUnit(const DwarfUnit &U, DIE &Die,
482 std::unique_ptr<DwarfUnit> NewU);
484 /// \brief Construct the split debug info compile unit for the debug info
486 DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU);
488 /// \brief Construct the split debug info compile unit for the debug info
490 DwarfTypeUnit &constructSkeletonTU(DwarfTypeUnit &TU);
492 /// \brief Emit the debug info dwo section.
493 void emitDebugInfoDWO();
495 /// \brief Emit the debug abbrev dwo section.
496 void emitDebugAbbrevDWO();
498 /// \brief Emit the debug line dwo section.
499 void emitDebugLineDWO();
501 /// \brief Emit the debug str dwo section.
502 void emitDebugStrDWO();
504 /// Flags to let the linker know we have emitted new style pubnames. Only
505 /// emit it here if we don't have a skeleton CU for split dwarf.
506 void addGnuPubAttributes(DwarfUnit &U, DIE &D) const;
508 /// \brief Create new DwarfCompileUnit for the given metadata node with tag
509 /// DW_TAG_compile_unit.
510 DwarfCompileUnit &constructDwarfCompileUnit(DICompileUnit DIUnit);
512 /// \brief Construct imported_module or imported_declaration DIE.
513 void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
516 /// \brief Construct import_module DIE.
518 constructImportedEntityDIE(DwarfCompileUnit &TheCU,
519 const DIImportedEntity &Module);
521 /// \brief Register a source line with debug info. Returns the unique
522 /// label that was emitted and which provides correspondence to the
523 /// source line list.
524 void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
527 /// \brief Indentify instructions that are marking the beginning of or
528 /// ending of a scope.
529 void identifyScopeMarkers();
531 /// \brief If Var is an current function argument that add it in
532 /// CurrentFnArguments list.
533 bool addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope);
535 /// \brief Populate LexicalScope entries with variables' info.
536 void collectVariableInfo(SmallPtrSetImpl<const MDNode *> &ProcessedVars);
538 /// \brief Build the location list for all DBG_VALUEs in the
539 /// function that describe the same variable.
540 void buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
541 const DbgValueHistoryMap::InstrRanges &Ranges);
543 /// \brief Collect variable information from the side table maintained
545 void collectVariableInfoFromMMITable(SmallPtrSetImpl<const MDNode *> &P);
547 /// \brief Ensure that a label will be emitted before MI.
548 void requestLabelBeforeInsn(const MachineInstr *MI) {
549 LabelsBeforeInsn.insert(std::make_pair(MI, nullptr));
552 /// \brief Return Label preceding the instruction.
553 MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
555 /// \brief Ensure that a label will be emitted after MI.
556 void requestLabelAfterInsn(const MachineInstr *MI) {
557 LabelsAfterInsn.insert(std::make_pair(MI, nullptr));
560 /// \brief Return Label immediately following the instruction.
561 MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
563 void attachRangesOrLowHighPC(DwarfCompileUnit &Unit, DIE &D,
564 const SmallVectorImpl<InsnRange> &Ranges);
565 void attachLowHighPC(DwarfCompileUnit &Unit, DIE &D, const MCSymbol *Begin,
566 const MCSymbol *End);
569 //===--------------------------------------------------------------------===//
570 // Main entry points.
572 DwarfDebug(AsmPrinter *A, Module *M);
574 ~DwarfDebug() override;
576 void insertDIE(const MDNode *TypeMD, DIE *Die) {
577 MDTypeNodeToDieMap.insert(std::make_pair(TypeMD, Die));
579 DIE *getDIE(const MDNode *TypeMD) {
580 return MDTypeNodeToDieMap.lookup(TypeMD);
583 /// \brief Emit all Dwarf sections that should come prior to the
587 /// \brief Emit all Dwarf sections that should come after the content.
588 void endModule() override;
590 /// \brief Gather pre-function debug information.
591 void beginFunction(const MachineFunction *MF) override;
593 /// \brief Gather and emit post-function debug information.
594 void endFunction(const MachineFunction *MF) override;
596 /// \brief Process beginning of an instruction.
597 void beginInstruction(const MachineInstr *MI) override;
599 /// \brief Process end of an instruction.
600 void endInstruction() override;
602 /// \brief Add a DIE to the set of types that we're going to pull into
604 void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
605 DIE &Die, DICompositeType CTy);
607 /// \brief Add a label so that arange data can be generated for it.
608 void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
610 /// \brief For symbols that have a size designated (e.g. common symbols),
611 /// this tracks that size.
612 void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {
616 /// \brief Recursively Emits a debug information entry.
617 void emitDIE(DIE &Die);
619 // Experimental DWARF5 features.
621 /// \brief Returns whether or not to emit tables that dwarf consumers can
622 /// use to accelerate lookup.
623 bool useDwarfAccelTables() const { return HasDwarfAccelTables; }
625 /// \brief Returns whether or not to change the current debug info for the
626 /// split dwarf proposal support.
627 bool useSplitDwarf() const { return HasSplitDwarf; }
629 /// Returns the Dwarf Version.
630 unsigned getDwarfVersion() const { return DwarfVersion; }
632 /// Returns the section symbol for the .debug_loc section.
633 MCSymbol *getDebugLocSym() const { return DwarfDebugLocSectionSym; }
635 /// Returns the section symbol for the .debug_str section.
636 MCSymbol *getDebugStrSym() const { return DwarfStrSectionSym; }
638 /// Returns the previous CU that was being updated
639 const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
640 void setPrevCU(const DwarfCompileUnit *PrevCU) { this->PrevCU = PrevCU; }
642 /// Returns the entries for the .debug_loc section.
643 const SmallVectorImpl<DebugLocList> &
644 getDebugLocEntries() const {
645 return DotDebugLocEntries;
648 /// \brief Emit an entry for the debug loc section. This can be used to
649 /// handle an entry that's going to be emitted into the debug loc section.
650 void emitDebugLocEntry(ByteStreamer &Streamer, const DebugLocEntry &Entry);
651 /// \brief emit a single value for the debug loc section.
652 void emitDebugLocValue(ByteStreamer &Streamer,
653 const DebugLocEntry::Value &Value);
654 /// Emits an optimal (=sorted) sequence of DW_OP_pieces.
655 void emitLocPieces(ByteStreamer &Streamer,
656 const DITypeIdentifierMap &Map,
657 ArrayRef<DebugLocEntry::Value> Values);
659 /// Emit the location for a debug loc entry, including the size header.
660 void emitDebugLocEntryLocation(const DebugLocEntry &Entry);
662 /// Find the MDNode for the given reference.
663 template <typename T> T resolve(DIRef<T> Ref) const {
664 return Ref.resolve(TypeIdentifierMap);
667 /// \brief Return the TypeIdentifierMap.
668 const DITypeIdentifierMap &getTypeIdentifierMap() const {
669 return TypeIdentifierMap;
672 /// Find the DwarfCompileUnit for the given CU Die.
673 DwarfCompileUnit *lookupUnit(const DIE *CU) const {
674 return CUDieMap.lookup(CU);
676 /// isSubprogramContext - Return true if Context is either a subprogram
677 /// or another context nested inside a subprogram.
678 bool isSubprogramContext(const MDNode *Context);
680 void addSubprogramNames(DISubprogram SP, DIE &Die);
682 AddressPool &getAddressPool() { return AddrPool; }
684 void addAccelName(StringRef Name, const DIE &Die);
686 void addAccelObjC(StringRef Name, const DIE &Die);
688 void addAccelNamespace(StringRef Name, const DIE &Die);
690 void addAccelType(StringRef Name, const DIE &Die, char Flags);
692 } // End of namespace llvm