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 CODEGEN_ASMPRINTER_DWARFDEBUG_H__
15 #define CODEGEN_ASMPRINTER_DWARFDEBUG_H__
18 #include "llvm/ADT/DenseMap.h"
19 #include "llvm/ADT/FoldingSet.h"
20 #include "llvm/ADT/SetVector.h"
21 #include "llvm/ADT/SmallPtrSet.h"
22 #include "llvm/ADT/StringMap.h"
23 #include "llvm/CodeGen/AsmPrinter.h"
24 #include "llvm/CodeGen/LexicalScopes.h"
25 #include "llvm/DebugInfo.h"
26 #include "llvm/MC/MachineLocation.h"
27 #include "llvm/Support/Allocator.h"
28 #include "llvm/Support/DebugLoc.h"
37 class MachineFrameInfo;
38 class MachineModuleInfo;
41 class MCObjectFileInfo;
47 //===----------------------------------------------------------------------===//
48 /// \brief This class is used to record source line correspondence.
50 unsigned Line; // Source line number.
51 unsigned Column; // Source column.
52 unsigned SourceID; // Source ID number.
53 MCSymbol *Label; // Label in code ID number.
55 SrcLineInfo(unsigned L, unsigned C, unsigned S, MCSymbol *label)
56 : Line(L), Column(C), SourceID(S), Label(label) {}
59 unsigned getLine() const { return Line; }
60 unsigned getColumn() const { return Column; }
61 unsigned getSourceID() const { return SourceID; }
62 MCSymbol *getLabel() const { return Label; }
65 /// \brief This struct describes location entries emitted in the .debug_loc
67 class DotDebugLocEntry {
68 // Begin and end symbols for the address range that this location is valid.
69 const MCSymbol *Begin;
72 // Type of entry that this represents.
79 enum EntryType EntryKind;
83 const ConstantFP *CFP;
84 const ConstantInt *CIP;
87 // The location in the machine frame.
90 // The variable to which this location entry corresponds.
91 const MDNode *Variable;
93 // Whether this location has been merged.
97 DotDebugLocEntry() : Begin(0), End(0), Variable(0), Merged(false) {
100 DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, MachineLocation &L,
102 : Begin(B), End(E), Loc(L), Variable(V), Merged(false) {
104 EntryKind = E_Location;
106 DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, int64_t i)
107 : Begin(B), End(E), Variable(0), Merged(false) {
109 EntryKind = E_Integer;
111 DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, const ConstantFP *FPtr)
112 : Begin(B), End(E), Variable(0), Merged(false) {
113 Constants.CFP = FPtr;
114 EntryKind = E_ConstantFP;
116 DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E,
117 const ConstantInt *IPtr)
118 : Begin(B), End(E), Variable(0), Merged(false) {
119 Constants.CIP = IPtr;
120 EntryKind = E_ConstantInt;
123 /// \brief Empty entries are also used as a trigger to emit temp label. Such
124 /// labels are referenced is used to find debug_loc offset for a given DIE.
125 bool isEmpty() { return Begin == 0 && End == 0; }
126 bool isMerged() { return Merged; }
127 void Merge(DotDebugLocEntry *Next) {
128 if (!(Begin && Loc == Next->Loc && End == Next->Begin))
133 bool isLocation() const { return EntryKind == E_Location; }
134 bool isInt() const { return EntryKind == E_Integer; }
135 bool isConstantFP() const { return EntryKind == E_ConstantFP; }
136 bool isConstantInt() const { return EntryKind == E_ConstantInt; }
137 int64_t getInt() const { return Constants.Int; }
138 const ConstantFP *getConstantFP() const { return Constants.CFP; }
139 const ConstantInt *getConstantInt() const { return Constants.CIP; }
140 const MDNode *getVariable() const { return Variable; }
141 const MCSymbol *getBeginSym() const { return Begin; }
142 const MCSymbol *getEndSym() const { return End; }
143 MachineLocation getLoc() const { return Loc; }
146 //===----------------------------------------------------------------------===//
147 /// \brief This class is used to track local variable information.
149 DIVariable Var; // Variable Descriptor.
150 DIE *TheDIE; // Variable DIE.
151 unsigned DotDebugLocOffset; // Offset in DotDebugLocEntries.
152 DbgVariable *AbsVar; // Corresponding Abstract variable, if any.
153 const MachineInstr *MInsn; // DBG_VALUE instruction of the variable.
157 // AbsVar may be NULL.
158 DbgVariable(DIVariable V, DbgVariable *AV, DwarfDebug *DD)
159 : Var(V), TheDIE(0), DotDebugLocOffset(~0U), AbsVar(AV), MInsn(0),
160 FrameIndex(~0), DD(DD) {}
163 DIVariable getVariable() const { return Var; }
164 void setDIE(DIE *D) { TheDIE = D; }
165 DIE *getDIE() const { return TheDIE; }
166 void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; }
167 unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; }
168 StringRef getName() const { return Var.getName(); }
169 DbgVariable *getAbstractVariable() const { return AbsVar; }
170 const MachineInstr *getMInsn() const { return MInsn; }
171 void setMInsn(const MachineInstr *M) { MInsn = M; }
172 int getFrameIndex() const { return FrameIndex; }
173 void setFrameIndex(int FI) { FrameIndex = FI; }
174 // Translate tag to proper Dwarf tag.
175 uint16_t getTag() const {
176 if (Var.getTag() == dwarf::DW_TAG_arg_variable)
177 return dwarf::DW_TAG_formal_parameter;
179 return dwarf::DW_TAG_variable;
181 /// \brief Return true if DbgVariable is artificial.
182 bool isArtificial() const {
183 if (Var.isArtificial())
185 if (getType().isArtificial())
190 bool isObjectPointer() const {
191 if (Var.isObjectPointer())
193 if (getType().isObjectPointer())
198 bool variableHasComplexAddress() const {
199 assert(Var.isVariable() && "Invalid complex DbgVariable!");
200 return Var.hasComplexAddress();
202 bool isBlockByrefVariable() const {
203 assert(Var.isVariable() && "Invalid complex DbgVariable!");
204 return Var.isBlockByrefVariable();
206 unsigned getNumAddrElements() const {
207 assert(Var.isVariable() && "Invalid complex DbgVariable!");
208 return Var.getNumAddrElements();
210 uint64_t getAddrElement(unsigned i) const {
211 return Var.getAddrElement(i);
213 DIType getType() const;
216 /// resolve - Look in the DwarfDebug map for the MDNode that
217 /// corresponds to the reference.
218 template <typename T> T resolve(DIRef<T> Ref) const;
221 /// \brief Collects and handles information specific to a particular
222 /// collection of units.
224 // Target of Dwarf emission, used for sizing of abbreviations.
227 // Used to uniquely define abbreviations.
228 FoldingSet<DIEAbbrev> *AbbreviationsSet;
230 // A list of all the unique abbreviations in use.
231 std::vector<DIEAbbrev *> &Abbreviations;
233 // A pointer to all units in the section.
234 SmallVector<Unit *, 1> CUs;
236 // Collection of strings for this unit and assorted symbols.
237 // A String->Symbol mapping of strings used by indirect
239 typedef StringMap<std::pair<MCSymbol*, unsigned>,
240 BumpPtrAllocator&> StrPool;
242 unsigned NextStringPoolNumber;
243 std::string StringPref;
245 // Collection of addresses for this unit and assorted labels.
246 // A Symbol->unsigned mapping of addresses used by indirect
248 typedef DenseMap<const MCExpr *, unsigned> AddrPool;
249 AddrPool AddressPool;
250 unsigned NextAddrPoolNumber;
253 DwarfUnits(AsmPrinter *AP, FoldingSet<DIEAbbrev> *AS,
254 std::vector<DIEAbbrev *> &A, const char *Pref,
255 BumpPtrAllocator &DA)
256 : Asm(AP), AbbreviationsSet(AS), Abbreviations(A), StringPool(DA),
257 NextStringPoolNumber(0), StringPref(Pref), AddressPool(),
258 NextAddrPoolNumber(0) {}
262 const SmallVectorImpl<Unit *> &getUnits() { return CUs; }
264 /// \brief Compute the size and offset of a DIE given an incoming Offset.
265 unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
267 /// \brief Compute the size and offset of all the DIEs.
268 void computeSizeAndOffsets();
270 /// \brief Define a unique number for the abbreviation.
271 void assignAbbrevNumber(DIEAbbrev &Abbrev);
273 /// \brief Add a unit to the list of CUs.
274 void addUnit(Unit *CU) { CUs.push_back(CU); }
276 /// \brief Emit all of the units to the section listed with the given
277 /// abbreviation section.
278 void emitUnits(DwarfDebug *DD, const MCSection *USection,
279 const MCSection *ASection, const MCSymbol *ASectionSym);
281 /// \brief Emit all of the strings to the section given.
282 void emitStrings(const MCSection *StrSection, const MCSection *OffsetSection,
283 const MCSymbol *StrSecSym);
285 /// \brief Emit all of the addresses to the section given.
286 void emitAddresses(const MCSection *AddrSection);
288 /// \brief Returns the entry into the start of the pool.
289 MCSymbol *getStringPoolSym();
291 /// \brief Returns an entry into the string pool with the given
293 MCSymbol *getStringPoolEntry(StringRef Str);
295 /// \brief Returns the index into the string pool with the given
297 unsigned getStringPoolIndex(StringRef Str);
299 /// \brief Returns the string pool.
300 StrPool *getStringPool() { return &StringPool; }
302 /// \brief Returns the index into the address pool with the given
304 unsigned getAddrPoolIndex(const MCExpr *Sym);
305 unsigned getAddrPoolIndex(const MCSymbol *Sym);
307 /// \brief Returns the address pool.
308 AddrPool *getAddrPool() { return &AddressPool; }
311 /// \brief Helper used to pair up a symbol and its DWARF compile unit.
313 SymbolCU(CompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
318 /// \brief Collects and handles dwarf debug information.
320 // Target of Dwarf emission.
323 // Collected machine module information.
324 MachineModuleInfo *MMI;
326 // All DIEValues are allocated through this allocator.
327 BumpPtrAllocator DIEValueAllocator;
329 // Handle to the a compile unit used for the inline extension handling.
330 CompileUnit *FirstCU;
332 // Maps MDNode with its corresponding CompileUnit.
333 DenseMap <const MDNode *, CompileUnit *> CUMap;
335 // Maps subprogram MDNode with its corresponding CompileUnit.
336 DenseMap <const MDNode *, CompileUnit *> SPMap;
338 // Maps a CU DIE with its corresponding CompileUnit.
339 DenseMap <const DIE *, CompileUnit *> CUDieMap;
341 /// Maps MDNodes for type sysstem with the corresponding DIEs. These DIEs can
342 /// be shared across CUs, that is why we keep the map here instead
343 /// of in CompileUnit.
344 DenseMap<const MDNode *, DIE *> MDTypeNodeToDieMap;
346 // Used to uniquely define abbreviations.
347 FoldingSet<DIEAbbrev> AbbreviationsSet;
349 // A list of all the unique abbreviations in use.
350 std::vector<DIEAbbrev *> Abbreviations;
352 // Stores the current file ID for a given compile unit.
353 DenseMap <unsigned, unsigned> FileIDCUMap;
354 // Source id map, i.e. CUID, source filename and directory,
355 // separated by a zero byte, mapped to a unique id.
356 StringMap<unsigned, BumpPtrAllocator&> SourceIdMap;
358 // List of all labels used in aranges generation.
359 std::vector<SymbolCU> ArangeLabels;
361 // Size of each symbol emitted (for those symbols that have a specific size).
362 DenseMap <const MCSymbol *, uint64_t> SymSize;
364 // Provides a unique id per text section.
365 typedef DenseMap<const MCSection *, SmallVector<SymbolCU, 8> > SectionMapType;
366 SectionMapType SectionMap;
368 // List of arguments for current function.
369 SmallVector<DbgVariable *, 8> CurrentFnArguments;
371 LexicalScopes LScopes;
373 // Collection of abstract subprogram DIEs.
374 DenseMap<const MDNode *, DIE *> AbstractSPDies;
376 // Collection of dbg variables of a scope.
377 typedef DenseMap<LexicalScope *,
378 SmallVector<DbgVariable *, 8> > ScopeVariablesMap;
379 ScopeVariablesMap ScopeVariables;
381 // Collection of abstract variables.
382 DenseMap<const MDNode *, DbgVariable *> AbstractVariables;
384 // Collection of DotDebugLocEntry.
385 SmallVector<DotDebugLocEntry, 4> DotDebugLocEntries;
387 // Collection of subprogram DIEs that are marked (at the end of the module)
389 SmallPtrSet<DIE *, 4> InlinedSubprogramDIEs;
391 // This is a collection of subprogram MDNodes that are processed to
393 SmallPtrSet<const MDNode *, 16> ProcessedSPNodes;
395 // Maps instruction with label emitted before instruction.
396 DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn;
398 // Maps instruction with label emitted after instruction.
399 DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn;
401 // Every user variable mentioned by a DBG_VALUE instruction in order of
403 SmallVector<const MDNode*, 8> UserVariables;
405 // For each user variable, keep a list of DBG_VALUE instructions in order.
406 // The list can also contain normal instructions that clobber the previous
408 typedef DenseMap<const MDNode*, SmallVector<const MachineInstr*, 4> >
410 DbgValueHistoryMap DbgValues;
412 // Previous instruction's location information. This is used to determine
413 // label location to indicate scope boundries in dwarf debug info.
414 DebugLoc PrevInstLoc;
417 // This location indicates end of function prologue and beginning of function
419 DebugLoc PrologEndLoc;
421 // Section Symbols: these are assembler temporary labels that are emitted at
422 // the beginning of each supported dwarf section. These are used to form
423 // section offsets and are created by EmitSectionLabels.
424 MCSymbol *DwarfInfoSectionSym, *DwarfAbbrevSectionSym;
425 MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym;
426 MCSymbol *DwarfDebugLocSectionSym, *DwarfLineSectionSym, *DwarfAddrSectionSym;
427 MCSymbol *FunctionBeginSym, *FunctionEndSym;
428 MCSymbol *DwarfAbbrevDWOSectionSym, *DwarfStrDWOSectionSym;
429 MCSymbol *DwarfGnuPubNamesSectionSym, *DwarfGnuPubTypesSectionSym;
431 // As an optimization, there is no need to emit an entry in the directory
432 // table for the same directory as DW_AT_comp_dir.
433 StringRef CompilationDir;
435 // Counter for assigning globally unique IDs for CUs.
436 unsigned GlobalCUIndexCount;
438 // Counter for assigning globally unique IDs for ranges.
439 unsigned GlobalRangeCount;
441 // Holder for the file specific debug information.
442 DwarfUnits InfoHolder;
444 // Holders for the various debug information flags that we might need to
445 // have exposed. See accessor functions below for description.
447 // Holder for imported entities.
448 typedef SmallVector<std::pair<const MDNode *, const MDNode *>, 32>
450 ImportedEntityMap ScopesWithImportedEntities;
452 // Map from type MDNodes to a pair used as a union. If the pointer is
453 // non-null, proxy DIEs in CUs meant to reference this type should be stored
454 // in the vector. The hash will be added to these DIEs once it is computed. If
455 // the pointer is null, the hash is immediately available in the uint64_t and
456 // should be directly used for proxy DIEs.
457 DenseMap<const MDNode *, std::pair<uint64_t, SmallVectorImpl<DIE *> *> >
460 // Whether to emit the pubnames/pubtypes sections.
461 bool HasDwarfPubSections;
463 // Version of dwarf we're emitting.
464 unsigned DwarfVersion;
466 // Maps from a type identifier to the actual MDNode.
467 DITypeIdentifierMap TypeIdentifierMap;
469 // DWARF5 Experimental Options
470 bool HasDwarfAccelTables;
473 // Separated Dwarf Variables
474 // In general these will all be for bits that are left in the
475 // original object file, rather than things that are meant
476 // to be in the .dwo sections.
478 // Used to uniquely define abbreviations for the skeleton emission.
479 FoldingSet<DIEAbbrev> SkeletonAbbrevSet;
481 // A list of all the unique abbreviations in use.
482 std::vector<DIEAbbrev *> SkeletonAbbrevs;
484 // Holder for the skeleton information.
485 DwarfUnits SkeletonHolder;
487 void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
489 const SmallVectorImpl<Unit *> &getUnits() { return InfoHolder.getUnits(); }
491 /// \brief Find abstract variable associated with Var.
492 DbgVariable *findAbstractVariable(DIVariable &Var, DebugLoc Loc);
494 /// \brief Find DIE for the given subprogram and attach appropriate
495 /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
496 /// variables in this scope then create and insert DIEs for these
498 DIE *updateSubprogramScopeDIE(CompileUnit *SPCU, DISubprogram SP);
500 /// \brief A helper function to check whether the DIE for a given Scope is
501 /// going to be null.
502 bool isLexicalScopeDIENull(LexicalScope *Scope);
504 /// \brief A helper function to construct a RangeSpanList for a given
506 void addScopeRangeList(CompileUnit *TheCU, DIE *ScopeDIE,
507 const SmallVectorImpl<InsnRange> &Range);
509 /// \brief Construct new DW_TAG_lexical_block for this scope and
510 /// attach DW_AT_low_pc/DW_AT_high_pc labels.
511 DIE *constructLexicalScopeDIE(CompileUnit *TheCU, LexicalScope *Scope);
513 /// \brief This scope represents inlined body of a function. Construct
514 /// DIE to represent this concrete inlined copy of the function.
515 DIE *constructInlinedScopeDIE(CompileUnit *TheCU, LexicalScope *Scope);
517 /// \brief Construct a DIE for this scope.
518 DIE *constructScopeDIE(CompileUnit *TheCU, LexicalScope *Scope);
519 /// A helper function to create children of a Scope DIE.
520 DIE *createScopeChildrenDIE(CompileUnit *TheCU, LexicalScope *Scope,
521 SmallVectorImpl<DIE*> &Children);
523 /// \brief Emit initial Dwarf sections with a label at the start of each one.
524 void emitSectionLabels();
526 /// \brief Compute the size and offset of a DIE given an incoming Offset.
527 unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
529 /// \brief Compute the size and offset of all the DIEs.
530 void computeSizeAndOffsets();
532 /// \brief Attach DW_AT_inline attribute with inlined subprogram DIEs.
533 void computeInlinedDIEs();
535 /// \brief Collect info for variables that were optimized out.
536 void collectDeadVariables();
538 /// \brief Finish off debug information after all functions have been
540 void finalizeModuleInfo();
542 /// \brief Emit labels to close any remaining sections that have been left
546 /// \brief Emit a set of abbreviations to the specific section.
547 void emitAbbrevs(const MCSection *, std::vector<DIEAbbrev*> *);
549 /// \brief Emit the debug info section.
550 void emitDebugInfo();
552 /// \brief Emit the abbreviation section.
553 void emitAbbreviations();
555 /// \brief Emit the last address of the section and the end of
557 void emitEndOfLineMatrix(unsigned SectionEnd);
559 /// \brief Emit visible names into a hashed accelerator table section.
560 void emitAccelNames();
562 /// \brief Emit objective C classes and categories into a hashed
563 /// accelerator table section.
564 void emitAccelObjC();
566 /// \brief Emit namespace dies into a hashed accelerator table.
567 void emitAccelNamespaces();
569 /// \brief Emit type dies into a hashed accelerator table.
570 void emitAccelTypes();
572 /// \brief Emit visible names into a debug pubnames section.
573 /// \param GnuStyle determines whether or not we want to emit
574 /// additional information into the table ala newer gcc for gdb
576 void emitDebugPubNames(bool GnuStyle = false);
578 /// \brief Emit visible types into a debug pubtypes section.
579 /// \param GnuStyle determines whether or not we want to emit
580 /// additional information into the table ala newer gcc for gdb
582 void emitDebugPubTypes(bool GnuStyle = false);
584 /// \brief Emit visible names into a debug str section.
587 /// \brief Emit visible names into a debug loc section.
590 /// \brief Emit visible names into a debug aranges section.
591 void emitDebugARanges();
593 /// \brief Emit visible names into a debug ranges section.
594 void emitDebugRanges();
596 /// \brief Emit visible names into a debug macinfo section.
597 void emitDebugMacInfo();
599 /// \brief Emit inline info using custom format.
600 void emitDebugInlineInfo();
602 /// DWARF 5 Experimental Split Dwarf Emitters
604 /// \brief Construct the split debug info compile unit for the debug info
606 CompileUnit *constructSkeletonCU(const CompileUnit *CU);
608 /// \brief Emit the local split abbreviations.
609 void emitSkeletonAbbrevs(const MCSection *);
611 /// \brief Emit the debug info dwo section.
612 void emitDebugInfoDWO();
614 /// \brief Emit the debug abbrev dwo section.
615 void emitDebugAbbrevDWO();
617 /// \brief Emit the debug str dwo section.
618 void emitDebugStrDWO();
620 /// \brief Create new CompileUnit for the given metadata node with tag
621 /// DW_TAG_compile_unit.
622 CompileUnit *constructCompileUnit(DICompileUnit DIUnit);
624 /// \brief Construct subprogram DIE.
625 void constructSubprogramDIE(CompileUnit *TheCU, const MDNode *N);
627 /// \brief Construct imported_module or imported_declaration DIE.
628 void constructImportedEntityDIE(CompileUnit *TheCU, const MDNode *N);
630 /// \brief Construct import_module DIE.
631 void constructImportedEntityDIE(CompileUnit *TheCU, const MDNode *N,
634 /// \brief Construct import_module DIE.
635 void constructImportedEntityDIE(CompileUnit *TheCU,
636 const DIImportedEntity &Module,
639 /// \brief Register a source line with debug info. Returns the unique
640 /// label that was emitted and which provides correspondence to the
641 /// source line list.
642 void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
645 /// \brief Indentify instructions that are marking the beginning of or
646 /// ending of a scope.
647 void identifyScopeMarkers();
649 /// \brief If Var is an current function argument that add it in
650 /// CurrentFnArguments list.
651 bool addCurrentFnArgument(const MachineFunction *MF,
652 DbgVariable *Var, LexicalScope *Scope);
654 /// \brief Populate LexicalScope entries with variables' info.
655 void collectVariableInfo(const MachineFunction *,
656 SmallPtrSet<const MDNode *, 16> &ProcessedVars);
658 /// \brief Collect variable information from the side table maintained
660 void collectVariableInfoFromMMITable(const MachineFunction * MF,
661 SmallPtrSet<const MDNode *, 16> &P);
663 /// \brief Ensure that a label will be emitted before MI.
664 void requestLabelBeforeInsn(const MachineInstr *MI) {
665 LabelsBeforeInsn.insert(std::make_pair(MI, (MCSymbol*)0));
668 /// \brief Return Label preceding the instruction.
669 MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
671 /// \brief Ensure that a label will be emitted after MI.
672 void requestLabelAfterInsn(const MachineInstr *MI) {
673 LabelsAfterInsn.insert(std::make_pair(MI, (MCSymbol*)0));
676 /// \brief Return Label immediately following the instruction.
677 MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
680 //===--------------------------------------------------------------------===//
681 // Main entry points.
683 DwarfDebug(AsmPrinter *A, Module *M);
685 void insertDIE(const MDNode *TypeMD, DIE *Die) {
686 MDTypeNodeToDieMap.insert(std::make_pair(TypeMD, Die));
688 DIE *getDIE(const MDNode *TypeMD) {
689 return MDTypeNodeToDieMap.lookup(TypeMD);
692 /// \brief Emit all Dwarf sections that should come prior to the
696 /// \brief Emit all Dwarf sections that should come after the content.
699 /// \brief Gather pre-function debug information.
700 void beginFunction(const MachineFunction *MF);
702 /// \brief Gather and emit post-function debug information.
703 void endFunction(const MachineFunction *MF);
705 /// \brief Process beginning of an instruction.
706 void beginInstruction(const MachineInstr *MI);
708 /// \brief Process end of an instruction.
709 void endInstruction(const MachineInstr *MI);
711 /// \brief Add a DIE to the set of types that we're going to pull into
713 void addTypeUnitType(uint16_t Language, DIE *Die, DICompositeType CTy);
715 /// \brief Add a label so that arange data can be generated for it.
716 void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
718 /// \brief For symbols that have a size designated (e.g. common symbols),
719 /// this tracks that size.
720 void setSymbolSize(const MCSymbol *Sym, uint64_t Size) { SymSize[Sym] = Size;}
722 /// \brief Look up the source id with the given directory and source file
723 /// names. If none currently exists, create a new id and insert it in the
725 unsigned getOrCreateSourceID(StringRef DirName, StringRef FullName,
728 /// \brief Recursively Emits a debug information entry.
729 void emitDIE(DIE *Die, ArrayRef<DIEAbbrev *> Abbrevs);
731 // Experimental DWARF5 features.
733 /// \brief Returns whether or not to emit tables that dwarf consumers can
734 /// use to accelerate lookup.
735 bool useDwarfAccelTables() { return HasDwarfAccelTables; }
737 /// \brief Returns whether or not to change the current debug info for the
738 /// split dwarf proposal support.
739 bool useSplitDwarf() { return HasSplitDwarf; }
741 /// Returns the Dwarf Version.
742 unsigned getDwarfVersion() const { return DwarfVersion; }
744 /// Find the MDNode for the given reference.
745 template <typename T> T resolve(DIRef<T> Ref) const {
746 return Ref.resolve(TypeIdentifierMap);
749 /// isSubprogramContext - Return true if Context is either a subprogram
750 /// or another context nested inside a subprogram.
751 bool isSubprogramContext(const MDNode *Context);
754 } // End of namespace llvm