LLVM  3.7.0
DwarfDebug.h
Go to the documentation of this file.
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 LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
15 #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
16 
17 #include "AsmPrinterHandler.h"
19 #include "DebugLocStream.h"
20 #include "DwarfAccelTable.h"
21 #include "DwarfFile.h"
22 #include "llvm/ADT/DenseMap.h"
23 #include "llvm/ADT/DenseSet.h"
24 #include "llvm/ADT/FoldingSet.h"
25 #include "llvm/ADT/MapVector.h"
26 #include "llvm/ADT/SmallPtrSet.h"
27 #include "llvm/ADT/StringMap.h"
28 #include "llvm/CodeGen/DIE.h"
31 #include "llvm/IR/DebugInfo.h"
32 #include "llvm/IR/DebugLoc.h"
33 #include "llvm/MC/MCDwarf.h"
35 #include "llvm/Support/Allocator.h"
36 #include <memory>
37 
38 namespace llvm {
39 
40 class AsmPrinter;
41 class ByteStreamer;
42 class ConstantInt;
43 class ConstantFP;
44 class DebugLocEntry;
45 class DwarfCompileUnit;
46 class DwarfDebug;
47 class DwarfTypeUnit;
48 class DwarfUnit;
49 class MachineModuleInfo;
50 
51 //===----------------------------------------------------------------------===//
52 /// This class is used to record source line correspondence.
53 class SrcLineInfo {
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.
58 public:
59  SrcLineInfo(unsigned L, unsigned C, unsigned S, MCSymbol *label)
60  : Line(L), Column(C), SourceID(S), Label(label) {}
61 
62  // Accessors
63  unsigned getLine() const { return Line; }
64  unsigned getColumn() const { return Column; }
65  unsigned getSourceID() const { return SourceID; }
66  MCSymbol *getLabel() const { return Label; }
67 };
68 
69 //===----------------------------------------------------------------------===//
70 /// This class is used to track local variable information.
71 ///
72 /// Variables can be created from allocas, in which case they're generated from
73 /// the MMI table. Such variables can have multiple expressions and frame
74 /// indices. The \a Expr and \a FrameIndices array must match.
75 ///
76 /// Variables can be created from \c DBG_VALUE instructions. Those whose
77 /// location changes over time use \a DebugLocListIndex, while those with a
78 /// single instruction use \a MInsn and (optionally) a single entry of \a Expr.
79 ///
80 /// Variables that have been optimized out use none of these fields.
81 class DbgVariable {
82  const DILocalVariable *Var; /// Variable Descriptor.
83  const DILocation *IA; /// Inlined at location.
84  SmallVector<const DIExpression *, 1> Expr; /// Complex address.
85  DIE *TheDIE = nullptr; /// Variable DIE.
86  unsigned DebugLocListIndex = ~0u; /// Offset in DebugLocs.
87  const MachineInstr *MInsn = nullptr; /// DBG_VALUE instruction.
88  SmallVector<int, 1> FrameIndex; /// Frame index.
89  DwarfDebug *DD;
90 
91 public:
92  /// Construct a DbgVariable.
93  ///
94  /// Creates a variable without any DW_AT_location. Call \a initializeMMI()
95  /// for MMI entries, or \a initializeDbgValue() for DBG_VALUE instructions.
97  : Var(V), IA(IA), DD(DD) {}
98 
99  /// Initialize from the MMI table.
100  void initializeMMI(const DIExpression *E, int FI) {
101  assert(Expr.empty() && "Already initialized?");
102  assert(FrameIndex.empty() && "Already initialized?");
103  assert(!MInsn && "Already initialized?");
104 
105  assert((!E || E->isValid()) && "Expected valid expression");
106  assert(~FI && "Expected valid index");
107 
108  Expr.push_back(E);
109  FrameIndex.push_back(FI);
110  }
111 
112  /// Initialize from a DBG_VALUE instruction.
113  void initializeDbgValue(const MachineInstr *DbgValue) {
114  assert(Expr.empty() && "Already initialized?");
115  assert(FrameIndex.empty() && "Already initialized?");
116  assert(!MInsn && "Already initialized?");
117 
118  assert(Var == DbgValue->getDebugVariable() && "Wrong variable");
119  assert(IA == DbgValue->getDebugLoc()->getInlinedAt() && "Wrong inlined-at");
120 
121  MInsn = DbgValue;
122  if (auto *E = DbgValue->getDebugExpression())
123  if (E->getNumElements())
124  Expr.push_back(E);
125  }
126 
127  // Accessors.
128  const DILocalVariable *getVariable() const { return Var; }
129  const DILocation *getInlinedAt() const { return IA; }
130  const ArrayRef<const DIExpression *> getExpression() const { return Expr; }
131  void setDIE(DIE &D) { TheDIE = &D; }
132  DIE *getDIE() const { return TheDIE; }
133  void setDebugLocListIndex(unsigned O) { DebugLocListIndex = O; }
134  unsigned getDebugLocListIndex() const { return DebugLocListIndex; }
135  StringRef getName() const { return Var->getName(); }
136  const MachineInstr *getMInsn() const { return MInsn; }
137  const ArrayRef<int> getFrameIndex() const { return FrameIndex; }
138 
139  void addMMIEntry(const DbgVariable &V) {
140  assert(DebugLocListIndex == ~0U && !MInsn && "not an MMI entry");
141  assert(V.DebugLocListIndex == ~0U && !V.MInsn && "not an MMI entry");
142  assert(V.Var == Var && "conflicting variable");
143  assert(V.IA == IA && "conflicting inlined-at location");
144 
145  assert(!FrameIndex.empty() && "Expected an MMI entry");
146  assert(!V.FrameIndex.empty() && "Expected an MMI entry");
147  assert(Expr.size() == FrameIndex.size() && "Mismatched expressions");
148  assert(V.Expr.size() == V.FrameIndex.size() && "Mismatched expressions");
149 
150  Expr.append(V.Expr.begin(), V.Expr.end());
151  FrameIndex.append(V.FrameIndex.begin(), V.FrameIndex.end());
152  assert(std::all_of(Expr.begin(), Expr.end(), [](const DIExpression *E) {
153  return E && E->isBitPiece();
154  }) && "conflicting locations for variable");
155  }
156 
157  // Translate tag to proper Dwarf tag.
158  dwarf::Tag getTag() const {
159  if (Var->getTag() == dwarf::DW_TAG_arg_variable)
160  return dwarf::DW_TAG_formal_parameter;
161 
162  return dwarf::DW_TAG_variable;
163  }
164  /// Return true if DbgVariable is artificial.
165  bool isArtificial() const {
166  if (Var->isArtificial())
167  return true;
168  if (getType()->isArtificial())
169  return true;
170  return false;
171  }
172 
173  bool isObjectPointer() const {
174  if (Var->isObjectPointer())
175  return true;
176  if (getType()->isObjectPointer())
177  return true;
178  return false;
179  }
180 
181  bool hasComplexAddress() const {
182  assert(MInsn && "Expected DBG_VALUE, not MMI variable");
183  assert(FrameIndex.empty() && "Expected DBG_VALUE, not MMI variable");
184  assert(
185  (Expr.empty() || (Expr.size() == 1 && Expr.back()->getNumElements())) &&
186  "Invalid Expr for DBG_VALUE");
187  return !Expr.empty();
188  }
189  bool isBlockByrefVariable() const;
190  const DIType *getType() const;
191 
192 private:
193  /// Look in the DwarfDebug map for the MDNode that
194  /// corresponds to the reference.
195  template <typename T> T *resolve(TypedDINodeRef<T> Ref) const;
196 };
197 
198 
199 /// Helper used to pair up a symbol and its DWARF compile unit.
200 struct SymbolCU {
201  SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
202  const MCSymbol *Sym;
204 };
205 
206 /// Collects and handles dwarf debug information.
208  /// Target of Dwarf emission.
209  AsmPrinter *Asm;
210 
211  /// Collected machine module information.
212  MachineModuleInfo *MMI;
213 
214  /// All DIEValues are allocated through this allocator.
215  BumpPtrAllocator DIEValueAllocator;
216 
217  /// Maps MDNode with its corresponding DwarfCompileUnit.
219 
220  /// Maps subprogram MDNode with its corresponding DwarfCompileUnit.
222 
223  /// Maps a CU DIE with its corresponding DwarfCompileUnit.
225 
226  /// List of all labels used in aranges generation.
227  std::vector<SymbolCU> ArangeLabels;
228 
229  /// Size of each symbol emitted (for those symbols that have a specific size).
231 
232  LexicalScopes LScopes;
233 
234  /// Collection of abstract variables.
236  SmallVector<std::unique_ptr<DbgVariable>, 64> ConcreteVariables;
237 
238  /// Collection of DebugLocEntry. Stored in a linked list so that DIELocLists
239  /// can refer to them in spite of insertions into this list.
240  DebugLocStream DebugLocs;
241 
242  /// This is a collection of subprogram MDNodes that are processed to
243  /// create DIEs.
244  SmallPtrSet<const MDNode *, 16> ProcessedSPNodes;
245 
246  /// Maps instruction with label emitted before instruction.
248 
249  /// Maps instruction with label emitted after instruction.
251 
252  /// History of DBG_VALUE and clobber instructions for each user
253  /// variable. Variables are listed in order of appearance.
254  DbgValueHistoryMap DbgValues;
255 
256  /// Previous instruction's location information. This is used to
257  /// determine label location to indicate scope boundries in dwarf
258  /// debug info.
259  DebugLoc PrevInstLoc;
260  MCSymbol *PrevLabel;
261 
262  /// This location indicates end of function prologue and beginning of
263  /// function body.
264  DebugLoc PrologEndLoc;
265 
266  /// If nonnull, stores the current machine function we're processing.
267  const MachineFunction *CurFn;
268 
269  /// If nonnull, stores the current machine instruction we're processing.
270  const MachineInstr *CurMI;
271 
272  /// If nonnull, stores the CU in which the previous subprogram was contained.
273  const DwarfCompileUnit *PrevCU;
274 
275  /// As an optimization, there is no need to emit an entry in the directory
276  /// table for the same directory as DW_AT_comp_dir.
277  StringRef CompilationDir;
278 
279  /// Holder for the file specific debug information.
280  DwarfFile InfoHolder;
281 
282  /// Holders for the various debug information flags that we might need to
283  /// have exposed. See accessor functions below for description.
284 
285  /// Holder for imported entities.
288  ImportedEntityMap ScopesWithImportedEntities;
289 
290  /// Map from MDNodes for user-defined types to the type units that
291  /// describe them.
293 
294  SmallVector<
295  std::pair<std::unique_ptr<DwarfTypeUnit>, const DICompositeType *>, 1>
296  TypeUnitsUnderConstruction;
297 
298  /// Whether to emit the pubnames/pubtypes sections.
299  bool HasDwarfPubSections;
300 
301  /// Whether or not to use AT_ranges for compilation units.
302  bool HasCURanges;
303 
304  /// Whether we emitted a function into a section other than the
305  /// default text.
306  bool UsedNonDefaultText;
307 
308  /// Whether to use the GNU TLS opcode (instead of the standard opcode).
309  bool UseGNUTLSOpcode;
310 
311  /// Version of dwarf we're emitting.
312  unsigned DwarfVersion;
313 
314  /// Maps from a type identifier to the actual MDNode.
315  DITypeIdentifierMap TypeIdentifierMap;
316 
317  /// DWARF5 Experimental Options
318  /// @{
319  bool HasDwarfAccelTables;
320  bool HasSplitDwarf;
321 
322  /// Separated Dwarf Variables
323  /// In general these will all be for bits that are left in the
324  /// original object file, rather than things that are meant
325  /// to be in the .dwo sections.
326 
327  /// Holder for the skeleton information.
328  DwarfFile SkeletonHolder;
329 
330  /// Store file names for type units under fission in a line table
331  /// header that will be emitted into debug_line.dwo.
332  // FIXME: replace this with a map from comp_dir to table so that we
333  // can emit multiple tables during LTO each of which uses directory
334  // 0, referencing the comp_dir of all the type units that use it.
335  MCDwarfDwoLineTable SplitTypeUnitFileTable;
336  /// @}
337 
338  /// True iff there are multiple CUs in this module.
339  bool SingleCU;
340  bool IsDarwin;
341  bool IsPS4;
342 
343  AddressPool AddrPool;
344 
345  DwarfAccelTable AccelNames;
346  DwarfAccelTable AccelObjC;
347  DwarfAccelTable AccelNamespace;
348  DwarfAccelTable AccelTypes;
349 
351 
352  MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
353 
354  const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() {
355  return InfoHolder.getUnits();
356  }
357 
358  typedef DbgValueHistoryMap::InlinedVariable InlinedVariable;
359 
360  /// Find abstract variable associated with Var.
361  DbgVariable *getExistingAbstractVariable(InlinedVariable IV,
362  const DILocalVariable *&Cleansed);
363  DbgVariable *getExistingAbstractVariable(InlinedVariable IV);
364  void createAbstractVariable(const DILocalVariable *DV, LexicalScope *Scope);
365  void ensureAbstractVariableIsCreated(InlinedVariable Var,
366  const MDNode *Scope);
367  void ensureAbstractVariableIsCreatedIfScoped(InlinedVariable Var,
368  const MDNode *Scope);
369 
370  DbgVariable *createConcreteVariable(LexicalScope &Scope, InlinedVariable IV);
371 
372  /// Construct a DIE for this abstract scope.
373  void constructAbstractSubprogramScopeDIE(LexicalScope *Scope);
374 
375  /// Compute the size and offset of a DIE given an incoming Offset.
376  unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
377 
378  /// Compute the size and offset of all the DIEs.
379  void computeSizeAndOffsets();
380 
381  /// Collect info for variables that were optimized out.
382  void collectDeadVariables();
383 
384  void finishVariableDefinitions();
385 
386  void finishSubprogramDefinitions();
387 
388  /// Finish off debug information after all functions have been
389  /// processed.
390  void finalizeModuleInfo();
391 
392  /// Emit the debug info section.
393  void emitDebugInfo();
394 
395  /// Emit the abbreviation section.
396  void emitAbbreviations();
397 
398  /// Emit a specified accelerator table.
399  void emitAccel(DwarfAccelTable &Accel, MCSection *Section,
400  StringRef TableName);
401 
402  /// Emit visible names into a hashed accelerator table section.
403  void emitAccelNames();
404 
405  /// Emit objective C classes and categories into a hashed
406  /// accelerator table section.
407  void emitAccelObjC();
408 
409  /// Emit namespace dies into a hashed accelerator table.
410  void emitAccelNamespaces();
411 
412  /// Emit type dies into a hashed accelerator table.
413  void emitAccelTypes();
414 
415  /// Emit visible names into a debug pubnames section.
416  /// \param GnuStyle determines whether or not we want to emit
417  /// additional information into the table ala newer gcc for gdb
418  /// index.
419  void emitDebugPubNames(bool GnuStyle = false);
420 
421  /// Emit visible types into a debug pubtypes section.
422  /// \param GnuStyle determines whether or not we want to emit
423  /// additional information into the table ala newer gcc for gdb
424  /// index.
425  void emitDebugPubTypes(bool GnuStyle = false);
426 
427  void emitDebugPubSection(
428  bool GnuStyle, MCSection *PSec, StringRef Name,
429  const StringMap<const DIE *> &(DwarfCompileUnit::*Accessor)() const);
430 
431  /// Emit visible names into a debug str section.
432  void emitDebugStr();
433 
434  /// Emit visible names into a debug loc section.
435  void emitDebugLoc();
436 
437  /// Emit visible names into a debug loc dwo section.
438  void emitDebugLocDWO();
439 
440  /// Emit visible names into a debug aranges section.
441  void emitDebugARanges();
442 
443  /// Emit visible names into a debug ranges section.
444  void emitDebugRanges();
445 
446  /// Emit inline info using custom format.
447  void emitDebugInlineInfo();
448 
449  /// DWARF 5 Experimental Split Dwarf Emitters
450 
451  /// Initialize common features of skeleton units.
452  void initSkeletonUnit(const DwarfUnit &U, DIE &Die,
453  std::unique_ptr<DwarfUnit> NewU);
454 
455  /// Construct the split debug info compile unit for the debug info
456  /// section.
457  DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU);
458 
459  /// Construct the split debug info compile unit for the debug info
460  /// section.
461  DwarfTypeUnit &constructSkeletonTU(DwarfTypeUnit &TU);
462 
463  /// Emit the debug info dwo section.
464  void emitDebugInfoDWO();
465 
466  /// Emit the debug abbrev dwo section.
467  void emitDebugAbbrevDWO();
468 
469  /// Emit the debug line dwo section.
470  void emitDebugLineDWO();
471 
472  /// Emit the debug str dwo section.
473  void emitDebugStrDWO();
474 
475  /// Flags to let the linker know we have emitted new style pubnames. Only
476  /// emit it here if we don't have a skeleton CU for split dwarf.
477  void addGnuPubAttributes(DwarfUnit &U, DIE &D) const;
478 
479  /// Create new DwarfCompileUnit for the given metadata node with tag
480  /// DW_TAG_compile_unit.
481  DwarfCompileUnit &constructDwarfCompileUnit(const DICompileUnit *DIUnit);
482 
483  /// Construct imported_module or imported_declaration DIE.
484  void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
485  const DIImportedEntity *N);
486 
487  /// Register a source line with debug info. Returns the unique
488  /// label that was emitted and which provides correspondence to the
489  /// source line list.
490  void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
491  unsigned Flags);
492 
493  /// Indentify instructions that are marking the beginning of or
494  /// ending of a scope.
495  void identifyScopeMarkers();
496 
497  /// Populate LexicalScope entries with variables' info.
498  void collectVariableInfo(DwarfCompileUnit &TheCU, const DISubprogram *SP,
499  DenseSet<InlinedVariable> &ProcessedVars);
500 
501  /// Build the location list for all DBG_VALUEs in the
502  /// function that describe the same variable.
503  void buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
505 
506  /// Collect variable information from the side table maintained
507  /// by MMI.
508  void collectVariableInfoFromMMITable(DenseSet<InlinedVariable> &P);
509 
510  /// Ensure that a label will be emitted before MI.
511  void requestLabelBeforeInsn(const MachineInstr *MI) {
512  LabelsBeforeInsn.insert(std::make_pair(MI, nullptr));
513  }
514 
515  /// Ensure that a label will be emitted after MI.
516  void requestLabelAfterInsn(const MachineInstr *MI) {
517  LabelsAfterInsn.insert(std::make_pair(MI, nullptr));
518  }
519 
520 public:
521  //===--------------------------------------------------------------------===//
522  // Main entry points.
523  //
525 
526  ~DwarfDebug() override;
527 
528  /// Emit all Dwarf sections that should come prior to the
529  /// content.
530  void beginModule();
531 
532  /// Emit all Dwarf sections that should come after the content.
533  void endModule() override;
534 
535  /// Gather pre-function debug information.
536  void beginFunction(const MachineFunction *MF) override;
537 
538  /// Gather and emit post-function debug information.
539  void endFunction(const MachineFunction *MF) override;
540 
541  /// Process beginning of an instruction.
542  void beginInstruction(const MachineInstr *MI) override;
543 
544  /// Process end of an instruction.
545  void endInstruction() override;
546 
547  /// Add a DIE to the set of types that we're going to pull into
548  /// type units.
549  void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
550  DIE &Die, const DICompositeType *CTy);
551 
552  /// Add a label so that arange data can be generated for it.
553  void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
554 
555  /// For symbols that have a size designated (e.g. common symbols),
556  /// this tracks that size.
557  void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {
558  SymSize[Sym] = Size;
559  }
560 
561  /// Returns whether to use DW_OP_GNU_push_tls_address, instead of the
562  /// standard DW_OP_form_tls_address opcode
563  bool useGNUTLSOpcode() const { return UseGNUTLSOpcode; }
564 
565  // Experimental DWARF5 features.
566 
567  /// Returns whether or not to emit tables that dwarf consumers can
568  /// use to accelerate lookup.
569  bool useDwarfAccelTables() const { return HasDwarfAccelTables; }
570 
571  /// Returns whether or not to change the current debug info for the
572  /// split dwarf proposal support.
573  bool useSplitDwarf() const { return HasSplitDwarf; }
574 
575  /// Returns the Dwarf Version.
576  unsigned getDwarfVersion() const { return DwarfVersion; }
577 
578  /// Returns the previous CU that was being updated
579  const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
580  void setPrevCU(const DwarfCompileUnit *PrevCU) { this->PrevCU = PrevCU; }
581 
582  /// Returns the entries for the .debug_loc section.
583  const DebugLocStream &getDebugLocs() const { return DebugLocs; }
584 
585  /// Emit an entry for the debug loc section. This can be used to
586  /// handle an entry that's going to be emitted into the debug loc section.
587  void emitDebugLocEntry(ByteStreamer &Streamer,
588  const DebugLocStream::Entry &Entry);
589 
590  /// Emit the location for a debug loc entry, including the size header.
592 
593  /// Find the MDNode for the given reference.
594  template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
595  return Ref.resolve(TypeIdentifierMap);
596  }
597 
598  /// Return the TypeIdentifierMap.
600  return TypeIdentifierMap;
601  }
602 
603  /// Find the DwarfCompileUnit for the given CU Die.
604  DwarfCompileUnit *lookupUnit(const DIE *CU) const {
605  return CUDieMap.lookup(CU);
606  }
607  /// isSubprogramContext - Return true if Context is either a subprogram
608  /// or another context nested inside a subprogram.
609  bool isSubprogramContext(const MDNode *Context);
610 
611  void addSubprogramNames(const DISubprogram *SP, DIE &Die);
612 
613  AddressPool &getAddressPool() { return AddrPool; }
614 
615  void addAccelName(StringRef Name, const DIE &Die);
616 
617  void addAccelObjC(StringRef Name, const DIE &Die);
618 
619  void addAccelNamespace(StringRef Name, const DIE &Die);
620 
621  void addAccelType(StringRef Name, const DIE &Die, char Flags);
622 
623  const MachineFunction *getCurrentFunction() const { return CurFn; }
624 
626  findImportedEntitiesForScope(const MDNode *Scope) const {
627  return make_range(std::equal_range(
628  ScopesWithImportedEntities.begin(), ScopesWithImportedEntities.end(),
629  std::pair<const MDNode *, const MDNode *>(Scope, nullptr),
630  less_first()));
631  }
632 
633  /// A helper function to check whether the DIE for a given Scope is
634  /// going to be null.
635  bool isLexicalScopeDIENull(LexicalScope *Scope);
636 
637  /// Return Label preceding the instruction.
639 
640  /// Return Label immediately following the instruction.
642 
643  // FIXME: Sink these functions down into DwarfFile/Dwarf*Unit.
644 
646  return ProcessedSPNodes;
647  }
648 };
649 } // End of namespace llvm
650 
651 #endif
void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry)
Emit the location for a debug loc entry, including the size header.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:48
void push_back(const T &Elt)
Definition: SmallVector.h:222
void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override
For symbols that have a size designated (e.g.
Definition: DwarfDebug.h:557
const MachineInstr * getMInsn() const
Definition: DwarfDebug.h:136
bool isArtificial() const
unsigned getDebugLocListIndex() const
Definition: DwarfDebug.h:134
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:39
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:114
const MachineFunction * getCurrentFunction() const
Definition: DwarfDebug.h:623
const DIExpression * getDebugExpression() const
Return the complex address expression referenced by this DBG_VALUE instruction.
Definition: MachineInstr.h:249
DenseSet - This implements a dense probed hash-table based set.
Definition: DenseSet.h:39
SrcLineInfo(unsigned L, unsigned C, unsigned S, MCSymbol *label)
Definition: DwarfDebug.h:59
Collects and handles AsmPrinter objects required to build debug or EH information.
Collects and handles dwarf debug information.
Definition: DwarfDebug.h:207
bool useDwarfAccelTables() const
Returns whether or not to emit tables that dwarf consumers can use to accelerate lookup.
Definition: DwarfDebug.h:569
This class implements a map that also provides access to all stored values in a deterministic order...
Definition: MapVector.h:32
A debug info location.
Definition: DebugLoc.h:34
Metadata node.
Definition: Metadata.h:740
StringRef getName() const
Definition: DwarfDebug.h:135
bool hasComplexAddress() const
Definition: DwarfDebug.h:181
LexicalScope - This class is used to track scope information.
Definition: LexicalScopes.h:45
bool useGNUTLSOpcode() const
Returns whether to use DW_OP_GNU_push_tls_address, instead of the standard DW_OP_form_tls_address opc...
Definition: DwarfDebug.h:563
const DILocation * getInlinedAt() const
Definition: DwarfDebug.h:129
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
void addAccelNamespace(StringRef Name, const DIE &Die)
void initializeDbgValue(const MachineInstr *DbgValue)
Initialize from a DBG_VALUE instruction.
Definition: DwarfDebug.h:113
void addArangeLabel(SymbolCU SCU)
Add a label so that arange data can be generated for it.
Definition: DwarfDebug.h:553
bool isArtificial() const
Return true if DbgVariable is artificial.
Definition: DwarfDebug.h:165
This class is used to record source line correspondence.
Definition: DwarfDebug.h:53
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APInt.h:33
const ArrayRef< int > getFrameIndex() const
Definition: DwarfDebug.h:137
bool isLexicalScopeDIENull(LexicalScope *Scope)
A helper function to check whether the DIE for a given Scope is going to be null. ...
Definition: DwarfDebug.cpp:317
Pointer union between a subclass of DINode and MDString.
StringRef getName() const
T * resolve(const MapTy &Map) const
MCSymbol * getLabelAfterInsn(const MachineInstr *MI)
Return Label immediately following the instruction.
Definition: DwarfDebug.cpp:952
AddressPool & getAddressPool()
Definition: DwarfDebug.h:613
Subprogram description.
~DwarfDebug() override
Definition: DwarfDebug.cpp:246
iterator_range< ImportedEntityMap::const_iterator > findImportedEntitiesForScope(const MDNode *Scope) const
Definition: DwarfDebug.h:626
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
Definition: SmallVector.h:57
This class is used to track local variable information.
Definition: DwarfDebug.h:81
const ArrayRef< const DIExpression * > getExpression() const
Definition: DwarfDebug.h:130
unsigned getLine() const
Definition: DwarfDebug.h:63
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: ArrayRef.h:31
DIE * getDIE() const
Definition: DwarfDebug.h:132
Debug location.
unsigned getSourceID() const
Definition: DwarfDebug.h:65
bool useSplitDwarf() const
Returns whether or not to change the current debug info for the split dwarf proposal support...
Definition: DwarfDebug.h:573
This dwarf writer support class manages information associated with a source file.
Definition: DwarfUnit.h:68
#define P(N)
void endModule() override
Emit all Dwarf sections that should come after the content.
Definition: DwarfDebug.cpp:600
const DIType * getType() const
Definition: DwarfDebug.cpp:144
DwarfCompileUnit * CU
Definition: DwarfDebug.h:203
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:135
void addMMIEntry(const DbgVariable &V)
Definition: DwarfDebug.h:139
MCSymbol * getLabel() const
Definition: DwarfDebug.h:66
void setDIE(DIE &D)
Definition: DwarfDebug.h:131
DIE - A structured debug information entry.
Definition: DIE.h:623
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:66
void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier, DIE &Die, const DICompositeType *CTy)
Add a DIE to the set of types that we're going to pull into type units.
T * resolve(TypedDINodeRef< T > Ref) const
Find the MDNode for the given reference.
Definition: DwarfDebug.h:594
MCSymbol * getLabelBeforeInsn(const MachineInstr *MI)
Return Label preceding the instruction.
Definition: DwarfDebug.cpp:945
void addAccelType(StringRef Name, const DIE &Die, char Flags)
DwarfDebug(AsmPrinter *A, Module *M)
Definition: DwarfDebug.cpp:194
void endFunction(const MachineFunction *MF) override
Gather and emit post-function debug information.
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
Definition: SmallVector.h:416
Helper used to pair up a symbol and its DWARF compile unit.
Definition: DwarfDebug.h:200
bool isObjectPointer() const
void initializeMMI(const DIExpression *E, int FI)
Initialize from the MMI table.
Definition: DwarfDebug.h:100
SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym)
Definition: DwarfDebug.h:201
DbgVariable(const DILocalVariable *V, const DILocation *IA, DwarfDebug *DD)
Construct a DbgVariable.
Definition: DwarfDebug.h:96
An imported module (C++ using directive or similar).
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
const DILocalVariable * getDebugVariable() const
Return the debug variable referenced by this DBG_VALUE instruction.
Definition: MachineInstr.h:242
void setPrevCU(const DwarfCompileUnit *PrevCU)
Definition: DwarfDebug.h:580
unsigned getTag() const
void beginInstruction(const MachineInstr *MI) override
Process beginning of an instruction.
Definition: DwarfDebug.cpp:957
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
Definition: SmallPtrSet.h:299
Base class for types.
void beginFunction(const MachineFunction *MF) override
Gather pre-function debug information.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:861
unsigned getColumn() const
Definition: DwarfDebug.h:64
void beginModule()
Emit all Dwarf sections that should come prior to the content.
Definition: DwarfDebug.cpp:433
const DebugLocStream & getDebugLocs() const
Returns the entries for the .debug_loc section.
Definition: DwarfDebug.h:583
bool isSubprogramContext(const MDNode *Context)
isSubprogramContext - Return true if Context is either a subprogram or another context nested inside ...
Definition: DwarfDebug.cpp:305
DwarfCompileUnit * lookupUnit(const DIE *CU) const
Find the DwarfCompileUnit for the given CU Die.
Definition: DwarfDebug.h:604
void addAccelName(StringRef Name, const DIE &Die)
void emitDebugLocEntry(ByteStreamer &Streamer, const DebugLocStream::Entry &Entry)
Emit an entry for the debug loc section.
DWARF expression.
A range adaptor for a pair of iterators.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition: StringMap.h:214
const DILocalVariable * getVariable() const
Definition: DwarfDebug.h:128
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
Definition: MachineInstr.h:238
void endInstruction() override
Process end of an instruction.
SmallPtrSet< const MDNode *, 16 > & getProcessedSPNodes()
Definition: DwarfDebug.h:645
SI Fix SGPR Live Ranges
Representation of each machine instruction.
Definition: MachineInstr.h:51
LexicalScopes - This class provides interface to collect and use lexical scoping information from mac...
#define N
const SmallVectorImpl< std::unique_ptr< DwarfUnit > > & getUnits()
Definition: DwarfFile.h:69
dwarf::Tag getTag() const
Definition: DwarfDebug.h:158
bool all_of(R &&Range, UnaryPredicate &&P)
Provide wrappers to std::all_of which take ranges instead of having to pass being/end explicitly...
Definition: STLExtras.h:334
const DITypeIdentifierMap & getTypeIdentifierMap() const
Return the TypeIdentifierMap.
Definition: DwarfDebug.h:599
void addSubprogramNames(const DISubprogram *SP, DIE &Die)
Definition: DwarfDebug.cpp:280
void setDebugLocListIndex(unsigned O)
Definition: DwarfDebug.h:133
const DwarfCompileUnit * getPrevCU() const
Returns the previous CU that was being updated.
Definition: DwarfDebug.h:579
bool isBlockByrefVariable() const
Definition: DwarfDebug.cpp:137
bool isObjectPointer() const
Definition: DwarfDebug.h:173
std::pair< const DILocalVariable *, const DILocation * > InlinedVariable
void addAccelObjC(StringRef Name, const DIE &Die)
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40
Byte stream of .debug_loc entries.
unsigned getDwarfVersion() const
Returns the Dwarf Version.
Definition: DwarfDebug.h:576
Function object to check whether the first component of a std::pair compares less than the first comp...
Definition: STLExtras.h:205
MachineModuleInfo - This class contains meta information specific to a module.
const MCSymbol * Sym
Definition: DwarfDebug.h:202