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__
17 #include "AsmPrinterHandler.h"
19 #include "llvm/ADT/DenseMap.h"
20 #include "llvm/ADT/FoldingSet.h"
21 #include "llvm/ADT/SetVector.h"
22 #include "llvm/ADT/SmallPtrSet.h"
23 #include "llvm/ADT/StringMap.h"
24 #include "llvm/CodeGen/AsmPrinter.h"
25 #include "llvm/CodeGen/LexicalScopes.h"
26 #include "llvm/DebugInfo.h"
27 #include "llvm/MC/MachineLocation.h"
28 #include "llvm/Support/Allocator.h"
29 #include "llvm/Support/DebugLoc.h"
38 class MachineFrameInfo;
39 class MachineModuleInfo;
42 class MCObjectFileInfo;
48 //===----------------------------------------------------------------------===//
49 /// \brief This class is used to record source line correspondence.
51 unsigned Line; // Source line number.
52 unsigned Column; // Source column.
53 unsigned SourceID; // Source ID number.
54 MCSymbol *Label; // Label in code ID number.
56 SrcLineInfo(unsigned L, unsigned C, unsigned S, MCSymbol *label)
57 : Line(L), Column(C), SourceID(S), Label(label) {}
60 unsigned getLine() const { return Line; }
61 unsigned getColumn() const { return Column; }
62 unsigned getSourceID() const { return SourceID; }
63 MCSymbol *getLabel() const { return Label; }
66 /// \brief This struct describes location entries emitted in the .debug_loc
68 class DotDebugLocEntry {
69 // Begin and end symbols for the address range that this location is valid.
70 const MCSymbol *Begin;
73 // Type of entry that this represents.
80 enum EntryType EntryKind;
84 const ConstantFP *CFP;
85 const ConstantInt *CIP;
88 // The location in the machine frame.
91 // The variable to which this location entry corresponds.
92 const MDNode *Variable;
94 // Whether this location has been merged.
98 DotDebugLocEntry() : Begin(0), End(0), Variable(0), Merged(false) {
101 DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, MachineLocation &L,
103 : Begin(B), End(E), Loc(L), Variable(V), Merged(false) {
105 EntryKind = E_Location;
107 DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, int64_t i)
108 : Begin(B), End(E), Variable(0), Merged(false) {
110 EntryKind = E_Integer;
112 DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, const ConstantFP *FPtr)
113 : Begin(B), End(E), Variable(0), Merged(false) {
114 Constants.CFP = FPtr;
115 EntryKind = E_ConstantFP;
117 DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E,
118 const ConstantInt *IPtr)
119 : Begin(B), End(E), Variable(0), Merged(false) {
120 Constants.CIP = IPtr;
121 EntryKind = E_ConstantInt;
124 /// \brief Empty entries are also used as a trigger to emit temp label. Such
125 /// labels are referenced is used to find debug_loc offset for a given DIE.
126 bool isEmpty() { return Begin == 0 && End == 0; }
127 bool isMerged() { return Merged; }
128 void Merge(DotDebugLocEntry *Next) {
129 if (!(Begin && Loc == Next->Loc && End == Next->Begin))
134 bool isLocation() const { return EntryKind == E_Location; }
135 bool isInt() const { return EntryKind == E_Integer; }
136 bool isConstantFP() const { return EntryKind == E_ConstantFP; }
137 bool isConstantInt() const { return EntryKind == E_ConstantInt; }
138 int64_t getInt() const { return Constants.Int; }
139 const ConstantFP *getConstantFP() const { return Constants.CFP; }
140 const ConstantInt *getConstantInt() const { return Constants.CIP; }
141 const MDNode *getVariable() const { return Variable; }
142 const MCSymbol *getBeginSym() const { return Begin; }
143 const MCSymbol *getEndSym() const { return End; }
144 MachineLocation getLoc() const { return Loc; }
147 //===----------------------------------------------------------------------===//
148 /// \brief This class is used to track local variable information.
150 DIVariable Var; // Variable Descriptor.
151 DIE *TheDIE; // Variable DIE.
152 unsigned DotDebugLocOffset; // Offset in DotDebugLocEntries.
153 DbgVariable *AbsVar; // Corresponding Abstract variable, if any.
154 const MachineInstr *MInsn; // DBG_VALUE instruction of the variable.
158 // AbsVar may be NULL.
159 DbgVariable(DIVariable V, DbgVariable *AV, DwarfDebug *DD)
160 : Var(V), TheDIE(0), DotDebugLocOffset(~0U), AbsVar(AV), MInsn(0),
161 FrameIndex(~0), DD(DD) {}
164 DIVariable getVariable() const { return Var; }
165 void setDIE(DIE *D) { TheDIE = D; }
166 DIE *getDIE() const { return TheDIE; }
167 void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; }
168 unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; }
169 StringRef getName() const { return Var.getName(); }
170 DbgVariable *getAbstractVariable() const { return AbsVar; }
171 const MachineInstr *getMInsn() const { return MInsn; }
172 void setMInsn(const MachineInstr *M) { MInsn = M; }
173 int getFrameIndex() const { return FrameIndex; }
174 void setFrameIndex(int FI) { FrameIndex = FI; }
175 // Translate tag to proper Dwarf tag.
176 uint16_t getTag() const {
177 if (Var.getTag() == dwarf::DW_TAG_arg_variable)
178 return dwarf::DW_TAG_formal_parameter;
180 return dwarf::DW_TAG_variable;
182 /// \brief Return true if DbgVariable is artificial.
183 bool isArtificial() const {
184 if (Var.isArtificial())
186 if (getType().isArtificial())
191 bool isObjectPointer() const {
192 if (Var.isObjectPointer())
194 if (getType().isObjectPointer())
199 bool variableHasComplexAddress() const {
200 assert(Var.isVariable() && "Invalid complex DbgVariable!");
201 return Var.hasComplexAddress();
203 bool isBlockByrefVariable() const {
204 assert(Var.isVariable() && "Invalid complex DbgVariable!");
205 return Var.isBlockByrefVariable();
207 unsigned getNumAddrElements() const {
208 assert(Var.isVariable() && "Invalid complex DbgVariable!");
209 return Var.getNumAddrElements();
211 uint64_t getAddrElement(unsigned i) const {
212 return Var.getAddrElement(i);
214 DIType getType() const;
217 /// resolve - Look in the DwarfDebug map for the MDNode that
218 /// corresponds to the reference.
219 template <typename T> T resolve(DIRef<T> Ref) const;
222 /// \brief Collects and handles information specific to a particular
223 /// collection of units. This collection represents all of the units
224 /// that will be ultimately output into a single object file.
226 // Target of Dwarf emission, used for sizing of abbreviations.
229 // Used to uniquely define abbreviations.
230 FoldingSet<DIEAbbrev> AbbreviationsSet;
232 // A list of all the unique abbreviations in use.
233 std::vector<DIEAbbrev *> Abbreviations;
235 // A pointer to all units in the section.
236 SmallVector<Unit *, 1> CUs;
238 // Collection of strings for this unit and assorted symbols.
239 // A String->Symbol mapping of strings used by indirect
241 typedef StringMap<std::pair<MCSymbol*, unsigned>,
242 BumpPtrAllocator&> StrPool;
244 unsigned NextStringPoolNumber;
245 std::string StringPref;
247 // Collection of addresses for this unit and assorted labels.
248 // A Symbol->unsigned mapping of addresses used by indirect
250 typedef DenseMap<const MCExpr *, unsigned> AddrPool;
251 AddrPool AddressPool;
252 unsigned NextAddrPoolNumber;
255 DwarfFile(AsmPrinter *AP, const char *Pref, BumpPtrAllocator &DA)
256 : Asm(AP), StringPool(DA), NextStringPoolNumber(0), StringPref(Pref),
257 AddressPool(), NextAddrPoolNumber(0) {}
261 const SmallVectorImpl<Unit *> &getUnits() { return CUs; }
263 /// \brief Compute the size and offset of a DIE given an incoming Offset.
264 unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
266 /// \brief Compute the size and offset of all the DIEs.
267 void computeSizeAndOffsets();
269 /// \brief Define a unique number for the abbreviation.
270 void assignAbbrevNumber(DIEAbbrev &Abbrev);
272 /// \brief Add a unit to the list of CUs.
273 void addUnit(Unit *CU) { CUs.push_back(CU); }
275 /// \brief Emit all of the units to the section listed with the given
276 /// abbreviation section.
277 void emitUnits(DwarfDebug *DD, const MCSection *USection,
278 const MCSection *ASection, const MCSymbol *ASectionSym);
280 /// \brief Emit a set of abbreviations to the specific section.
281 void emitAbbrevs(const MCSection *);
283 /// \brief Emit all of the strings to the section given.
284 void emitStrings(const MCSection *StrSection, const MCSection *OffsetSection,
285 const MCSymbol *StrSecSym);
287 /// \brief Emit all of the addresses to the section given.
288 void emitAddresses(const MCSection *AddrSection);
290 /// \brief Returns the entry into the start of the pool.
291 MCSymbol *getStringPoolSym();
293 /// \brief Returns an entry into the string pool with the given
295 MCSymbol *getStringPoolEntry(StringRef Str);
297 /// \brief Returns the index into the string pool with the given
299 unsigned getStringPoolIndex(StringRef Str);
301 /// \brief Returns the string pool.
302 StrPool *getStringPool() { return &StringPool; }
304 /// \brief Returns the index into the address pool with the given
306 unsigned getAddrPoolIndex(const MCExpr *Sym);
307 unsigned getAddrPoolIndex(const MCSymbol *Sym);
309 /// \brief Returns the address pool.
310 AddrPool *getAddrPool() { return &AddressPool; }
313 /// \brief Helper used to pair up a symbol and its DWARF compile unit.
315 SymbolCU(CompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
320 /// \brief Collects and handles dwarf debug information.
321 class DwarfDebug : public AsmPrinterHandler {
322 // Target of Dwarf emission.
325 // Collected machine module information.
326 MachineModuleInfo *MMI;
328 // All DIEValues are allocated through this allocator.
329 BumpPtrAllocator DIEValueAllocator;
331 // Handle to the compile unit used for the inline extension handling,
332 // this is just so that the DIEValue allocator has a place to store
333 // the particular elements.
334 // FIXME: Store these off of DwarfDebug instead?
335 CompileUnit *FirstCU;
337 // Maps MDNode with its corresponding CompileUnit.
338 DenseMap <const MDNode *, CompileUnit *> CUMap;
340 // Maps subprogram MDNode with its corresponding CompileUnit.
341 DenseMap <const MDNode *, CompileUnit *> SPMap;
343 // Maps a CU DIE with its corresponding CompileUnit.
344 DenseMap <const DIE *, CompileUnit *> CUDieMap;
346 /// Maps MDNodes for type sysstem with the corresponding DIEs. These DIEs can
347 /// be shared across CUs, that is why we keep the map here instead
348 /// of in CompileUnit.
349 DenseMap<const MDNode *, DIE *> MDTypeNodeToDieMap;
351 // Stores the current file ID for a given compile unit.
352 DenseMap <unsigned, unsigned> FileIDCUMap;
353 // Source id map, i.e. CUID, source filename and directory,
354 // separated by a zero byte, mapped to a unique id.
355 StringMap<unsigned, BumpPtrAllocator&> SourceIdMap;
357 // List of all labels used in aranges generation.
358 std::vector<SymbolCU> ArangeLabels;
360 // Size of each symbol emitted (for those symbols that have a specific size).
361 DenseMap <const MCSymbol *, uint64_t> SymSize;
363 // Provides a unique id per text section.
364 typedef DenseMap<const MCSection *, SmallVector<SymbolCU, 8> > SectionMapType;
365 SectionMapType SectionMap;
367 // List of arguments for current function.
368 SmallVector<DbgVariable *, 8> CurrentFnArguments;
370 LexicalScopes LScopes;
372 // Collection of abstract subprogram DIEs.
373 DenseMap<const MDNode *, DIE *> AbstractSPDies;
375 // Collection of dbg variables of a scope.
376 typedef DenseMap<LexicalScope *,
377 SmallVector<DbgVariable *, 8> > ScopeVariablesMap;
378 ScopeVariablesMap ScopeVariables;
380 // Collection of abstract variables.
381 DenseMap<const MDNode *, DbgVariable *> AbstractVariables;
383 // Collection of DotDebugLocEntry.
384 SmallVector<DotDebugLocEntry, 4> DotDebugLocEntries;
386 // Collection of subprogram DIEs that are marked (at the end of the module)
388 SmallPtrSet<DIE *, 4> InlinedSubprogramDIEs;
390 // This is a collection of subprogram MDNodes that are processed to
392 SmallPtrSet<const MDNode *, 16> ProcessedSPNodes;
394 // Maps instruction with label emitted before instruction.
395 DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn;
397 // Maps instruction with label emitted after instruction.
398 DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn;
400 // Every user variable mentioned by a DBG_VALUE instruction in order of
402 SmallVector<const MDNode*, 8> UserVariables;
404 // For each user variable, keep a list of DBG_VALUE instructions in order.
405 // The list can also contain normal instructions that clobber the previous
407 typedef DenseMap<const MDNode*, SmallVector<const MachineInstr*, 4> >
409 DbgValueHistoryMap DbgValues;
411 // Previous instruction's location information. This is used to determine
412 // label location to indicate scope boundries in dwarf debug info.
413 DebugLoc PrevInstLoc;
416 // This location indicates end of function prologue and beginning of function
418 DebugLoc PrologEndLoc;
420 // If nonnull, stores the current machine function we're processing.
421 const MachineFunction *CurFn;
423 // If nonnull, stores the current machine instruction we're processing.
424 const MachineInstr *CurMI;
426 // Section Symbols: these are assembler temporary labels that are emitted at
427 // the beginning of each supported dwarf section. These are used to form
428 // section offsets and are created by EmitSectionLabels.
429 MCSymbol *DwarfInfoSectionSym, *DwarfAbbrevSectionSym;
430 MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym;
431 MCSymbol *DwarfDebugLocSectionSym, *DwarfLineSectionSym, *DwarfAddrSectionSym;
432 MCSymbol *FunctionBeginSym, *FunctionEndSym;
433 MCSymbol *DwarfAbbrevDWOSectionSym, *DwarfStrDWOSectionSym;
434 MCSymbol *DwarfGnuPubNamesSectionSym, *DwarfGnuPubTypesSectionSym;
436 // As an optimization, there is no need to emit an entry in the directory
437 // table for the same directory as DW_AT_comp_dir.
438 StringRef CompilationDir;
440 // Counter for assigning globally unique IDs for CUs.
441 unsigned GlobalCUIndexCount;
443 // Counter for assigning globally unique IDs for ranges.
444 unsigned GlobalRangeCount;
446 // Holder for the file specific debug information.
447 DwarfFile InfoHolder;
449 // Holders for the various debug information flags that we might need to
450 // have exposed. See accessor functions below for description.
452 // Holder for imported entities.
453 typedef SmallVector<std::pair<const MDNode *, const MDNode *>, 32>
455 ImportedEntityMap ScopesWithImportedEntities;
457 // Map from type MDNodes to a pair used as a union. If the pointer is
458 // non-null, proxy DIEs in CUs meant to reference this type should be stored
459 // in the vector. The hash will be added to these DIEs once it is computed. If
460 // the pointer is null, the hash is immediately available in the uint64_t and
461 // should be directly used for proxy DIEs.
462 DenseMap<const MDNode *, std::pair<uint64_t, SmallVectorImpl<DIE *> *> >
465 // Whether to emit the pubnames/pubtypes sections.
466 bool HasDwarfPubSections;
468 // Version of dwarf we're emitting.
469 unsigned DwarfVersion;
471 // Maps from a type identifier to the actual MDNode.
472 DITypeIdentifierMap TypeIdentifierMap;
474 // DWARF5 Experimental Options
475 bool HasDwarfAccelTables;
478 // Separated Dwarf Variables
479 // In general these will all be for bits that are left in the
480 // original object file, rather than things that are meant
481 // to be in the .dwo sections.
483 // Holder for the skeleton information.
484 DwarfFile SkeletonHolder;
486 void addScopeVariable(LexicalScope *LS, DbgVariable *Var);
488 const SmallVectorImpl<Unit *> &getUnits() { return InfoHolder.getUnits(); }
490 /// \brief Find abstract variable associated with Var.
491 DbgVariable *findAbstractVariable(DIVariable &Var, DebugLoc Loc);
493 /// \brief Find DIE for the given subprogram and attach appropriate
494 /// DW_AT_low_pc and DW_AT_high_pc attributes. If there are global
495 /// variables in this scope then create and insert DIEs for these
497 DIE *updateSubprogramScopeDIE(CompileUnit *SPCU, DISubprogram SP);
499 /// \brief A helper function to check whether the DIE for a given Scope is
500 /// going to be null.
501 bool isLexicalScopeDIENull(LexicalScope *Scope);
503 /// \brief A helper function to construct a RangeSpanList for a given
505 void addScopeRangeList(CompileUnit *TheCU, DIE *ScopeDIE,
506 const SmallVectorImpl<InsnRange> &Range);
508 /// \brief Construct new DW_TAG_lexical_block for this scope and
509 /// attach DW_AT_low_pc/DW_AT_high_pc labels.
510 DIE *constructLexicalScopeDIE(CompileUnit *TheCU, LexicalScope *Scope);
512 /// \brief This scope represents inlined body of a function. Construct
513 /// DIE to represent this concrete inlined copy of the function.
514 DIE *constructInlinedScopeDIE(CompileUnit *TheCU, LexicalScope *Scope);
516 /// \brief Construct a DIE for this scope.
517 DIE *constructScopeDIE(CompileUnit *TheCU, LexicalScope *Scope);
518 /// A helper function to create children of a Scope DIE.
519 DIE *createScopeChildrenDIE(CompileUnit *TheCU, LexicalScope *Scope,
520 SmallVectorImpl<DIE*> &Children);
522 /// \brief Emit initial Dwarf sections with a label at the start of each one.
523 void emitSectionLabels();
525 /// \brief Compute the size and offset of a DIE given an incoming Offset.
526 unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
528 /// \brief Compute the size and offset of all the DIEs.
529 void computeSizeAndOffsets();
531 /// \brief Attach DW_AT_inline attribute with inlined subprogram DIEs.
532 void computeInlinedDIEs();
534 /// \brief Collect info for variables that were optimized out.
535 void collectDeadVariables();
537 /// \brief Finish off debug information after all functions have been
539 void finalizeModuleInfo();
541 /// \brief Emit labels to close any remaining sections that have been left
545 /// \brief Emit the debug info section.
546 void emitDebugInfo();
548 /// \brief Emit the abbreviation section.
549 void emitAbbreviations();
551 /// \brief Emit the last address of the section and the end of
553 void emitEndOfLineMatrix(unsigned SectionEnd);
555 /// \brief Emit visible names into a hashed accelerator table section.
556 void emitAccelNames();
558 /// \brief Emit objective C classes and categories into a hashed
559 /// accelerator table section.
560 void emitAccelObjC();
562 /// \brief Emit namespace dies into a hashed accelerator table.
563 void emitAccelNamespaces();
565 /// \brief Emit type dies into a hashed accelerator table.
566 void emitAccelTypes();
568 /// \brief Emit visible names into a debug pubnames section.
569 /// \param GnuStyle determines whether or not we want to emit
570 /// additional information into the table ala newer gcc for gdb
572 void emitDebugPubNames(bool GnuStyle = false);
574 /// \brief Emit visible types into a debug pubtypes section.
575 /// \param GnuStyle determines whether or not we want to emit
576 /// additional information into the table ala newer gcc for gdb
578 void emitDebugPubTypes(bool GnuStyle = false);
580 /// \brief Emit visible names into a debug str section.
583 /// \brief Emit visible names into a debug loc section.
586 /// \brief Emit visible names into a debug aranges section.
587 void emitDebugARanges();
589 /// \brief Emit visible names into a debug ranges section.
590 void emitDebugRanges();
592 /// \brief Emit visible names into a debug macinfo section.
593 void emitDebugMacInfo();
595 /// \brief Emit inline info using custom format.
596 void emitDebugInlineInfo();
598 /// DWARF 5 Experimental Split Dwarf Emitters
600 /// \brief Construct the split debug info compile unit for the debug info
602 CompileUnit *constructSkeletonCU(const CompileUnit *CU);
604 /// \brief Emit the debug info dwo section.
605 void emitDebugInfoDWO();
607 /// \brief Emit the debug abbrev dwo section.
608 void emitDebugAbbrevDWO();
610 /// \brief Emit the debug str dwo section.
611 void emitDebugStrDWO();
613 /// Flags to let the linker know we have emitted new style pubnames. Only
614 /// emit it here if we don't have a skeleton CU for split dwarf.
615 void addGnuPubAttributes(Unit *U, DIE *D) const;
617 /// \brief Create new CompileUnit for the given metadata node with tag
618 /// DW_TAG_compile_unit.
619 CompileUnit *constructCompileUnit(DICompileUnit DIUnit);
621 /// \brief Construct subprogram DIE.
622 void constructSubprogramDIE(CompileUnit *TheCU, const MDNode *N);
624 /// \brief Construct imported_module or imported_declaration DIE.
625 void constructImportedEntityDIE(CompileUnit *TheCU, const MDNode *N);
627 /// \brief Construct import_module DIE.
628 void constructImportedEntityDIE(CompileUnit *TheCU, const MDNode *N,
631 /// \brief Construct import_module DIE.
632 void constructImportedEntityDIE(CompileUnit *TheCU,
633 const DIImportedEntity &Module,
636 /// \brief Register a source line with debug info. Returns the unique
637 /// label that was emitted and which provides correspondence to the
638 /// source line list.
639 void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
642 /// \brief Indentify instructions that are marking the beginning of or
643 /// ending of a scope.
644 void identifyScopeMarkers();
646 /// \brief If Var is an current function argument that add it in
647 /// CurrentFnArguments list.
648 bool addCurrentFnArgument(DbgVariable *Var, LexicalScope *Scope);
650 /// \brief Populate LexicalScope entries with variables' info.
651 void collectVariableInfo(SmallPtrSet<const MDNode *, 16> &ProcessedVars);
653 /// \brief Collect variable information from the side table maintained
655 void collectVariableInfoFromMMITable(SmallPtrSet<const MDNode *, 16> &P);
657 /// \brief Ensure that a label will be emitted before MI.
658 void requestLabelBeforeInsn(const MachineInstr *MI) {
659 LabelsBeforeInsn.insert(std::make_pair(MI, (MCSymbol*)0));
662 /// \brief Return Label preceding the instruction.
663 MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
665 /// \brief Ensure that a label will be emitted after MI.
666 void requestLabelAfterInsn(const MachineInstr *MI) {
667 LabelsAfterInsn.insert(std::make_pair(MI, (MCSymbol*)0));
670 /// \brief Return Label immediately following the instruction.
671 MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
674 //===--------------------------------------------------------------------===//
675 // Main entry points.
677 DwarfDebug(AsmPrinter *A, Module *M);
679 void insertDIE(const MDNode *TypeMD, DIE *Die) {
680 MDTypeNodeToDieMap.insert(std::make_pair(TypeMD, Die));
682 DIE *getDIE(const MDNode *TypeMD) {
683 return MDTypeNodeToDieMap.lookup(TypeMD);
686 /// \brief Emit all Dwarf sections that should come prior to the
690 /// \brief Emit all Dwarf sections that should come after the content.
693 /// \brief Gather pre-function debug information.
694 void beginFunction(const MachineFunction *MF);
696 /// \brief Gather and emit post-function debug information.
697 void endFunction(const MachineFunction *MF);
699 /// \brief Process beginning of an instruction.
700 void beginInstruction(const MachineInstr *MI);
702 /// \brief Process end of an instruction.
703 void endInstruction();
705 /// \brief Add a DIE to the set of types that we're going to pull into
707 void addTypeUnitType(uint16_t Language, DIE *Die, DICompositeType CTy);
709 /// \brief Add a label so that arange data can be generated for it.
710 void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
712 /// \brief For symbols that have a size designated (e.g. common symbols),
713 /// this tracks that size.
714 void setSymbolSize(const MCSymbol *Sym, uint64_t Size) { SymSize[Sym] = Size;}
716 /// \brief Look up the source id with the given directory and source file
717 /// names. If none currently exists, create a new id and insert it in the
719 unsigned getOrCreateSourceID(StringRef DirName, StringRef FullName,
722 /// \brief Recursively Emits a debug information entry.
723 void emitDIE(DIE *Die);
725 // Experimental DWARF5 features.
727 /// \brief Returns whether or not to emit tables that dwarf consumers can
728 /// use to accelerate lookup.
729 bool useDwarfAccelTables() { return HasDwarfAccelTables; }
731 /// \brief Returns whether or not to change the current debug info for the
732 /// split dwarf proposal support.
733 bool useSplitDwarf() { return HasSplitDwarf; }
735 /// Returns the Dwarf Version.
736 unsigned getDwarfVersion() const { return DwarfVersion; }
738 /// Find the MDNode for the given reference.
739 template <typename T> T resolve(DIRef<T> Ref) const {
740 return Ref.resolve(TypeIdentifierMap);
743 /// isSubprogramContext - Return true if Context is either a subprogram
744 /// or another context nested inside a subprogram.
745 bool isSubprogramContext(const MDNode *Context);
748 } // End of namespace llvm