Revert r354244 "[DAGCombiner] Eliminate dead stores to stack."
[llvm-complete.git] / lib / CodeGen / AsmPrinter / DwarfDebug.h
blobf0d50a4764090a48dda59c192f6f42913ac29f69
1 //===- llvm/CodeGen/DwarfDebug.h - Dwarf Debug Framework --------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains support for writing dwarf debug info into asm files.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
14 #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
16 #include "AddressPool.h"
17 #include "DebugLocStream.h"
18 #include "DwarfFile.h"
19 #include "llvm/ADT/ArrayRef.h"
20 #include "llvm/ADT/DenseMap.h"
21 #include "llvm/ADT/DenseSet.h"
22 #include "llvm/ADT/MapVector.h"
23 #include "llvm/ADT/STLExtras.h"
24 #include "llvm/ADT/SetVector.h"
25 #include "llvm/ADT/SmallPtrSet.h"
26 #include "llvm/ADT/SmallVector.h"
27 #include "llvm/ADT/StringMap.h"
28 #include "llvm/ADT/StringRef.h"
29 #include "llvm/BinaryFormat/Dwarf.h"
30 #include "llvm/CodeGen/AccelTable.h"
31 #include "llvm/CodeGen/DbgEntityHistoryCalculator.h"
32 #include "llvm/CodeGen/DebugHandlerBase.h"
33 #include "llvm/CodeGen/MachineInstr.h"
34 #include "llvm/IR/DebugInfoMetadata.h"
35 #include "llvm/IR/DebugLoc.h"
36 #include "llvm/IR/Metadata.h"
37 #include "llvm/MC/MCDwarf.h"
38 #include "llvm/Support/Allocator.h"
39 #include "llvm/Target/TargetOptions.h"
40 #include <cassert>
41 #include <cstdint>
42 #include <limits>
43 #include <memory>
44 #include <utility>
45 #include <vector>
47 namespace llvm {
49 class AsmPrinter;
50 class ByteStreamer;
51 class DebugLocEntry;
52 class DIE;
53 class DwarfCompileUnit;
54 class DwarfTypeUnit;
55 class DwarfUnit;
56 class LexicalScope;
57 class MachineFunction;
58 class MCSection;
59 class MCSymbol;
60 class MDNode;
61 class Module;
63 //===----------------------------------------------------------------------===//
64 /// This class is defined as the common parent of DbgVariable and DbgLabel
65 /// such that it could levarage polymorphism to extract common code for
66 /// DbgVariable and DbgLabel.
67 class DbgEntity {
68 const DINode *Entity;
69 const DILocation *InlinedAt;
70 DIE *TheDIE = nullptr;
71 unsigned SubclassID;
73 public:
74 enum DbgEntityKind {
75 DbgVariableKind,
76 DbgLabelKind
79 DbgEntity(const DINode *N, const DILocation *IA, unsigned ID)
80 : Entity(N), InlinedAt(IA), SubclassID(ID) {}
81 virtual ~DbgEntity() {}
83 /// Accessors.
84 /// @{
85 const DINode *getEntity() const { return Entity; }
86 const DILocation *getInlinedAt() const { return InlinedAt; }
87 DIE *getDIE() const { return TheDIE; }
88 unsigned getDbgEntityID() const { return SubclassID; }
89 /// @}
91 void setDIE(DIE &D) { TheDIE = &D; }
93 static bool classof(const DbgEntity *N) {
94 switch (N->getDbgEntityID()) {
95 default:
96 return false;
97 case DbgVariableKind:
98 case DbgLabelKind:
99 return true;
104 //===----------------------------------------------------------------------===//
105 /// This class is used to track local variable information.
107 /// Variables can be created from allocas, in which case they're generated from
108 /// the MMI table. Such variables can have multiple expressions and frame
109 /// indices.
111 /// Variables can be created from \c DBG_VALUE instructions. Those whose
112 /// location changes over time use \a DebugLocListIndex, while those with a
113 /// single instruction use \a MInsn and (optionally) a single entry of \a Expr.
115 /// Variables that have been optimized out use none of these fields.
116 class DbgVariable : public DbgEntity {
117 unsigned DebugLocListIndex = ~0u; /// Offset in DebugLocs.
118 const MachineInstr *MInsn = nullptr; /// DBG_VALUE instruction.
120 struct FrameIndexExpr {
121 int FI;
122 const DIExpression *Expr;
124 mutable SmallVector<FrameIndexExpr, 1>
125 FrameIndexExprs; /// Frame index + expression.
127 public:
128 /// Construct a DbgVariable.
130 /// Creates a variable without any DW_AT_location. Call \a initializeMMI()
131 /// for MMI entries, or \a initializeDbgValue() for DBG_VALUE instructions.
132 DbgVariable(const DILocalVariable *V, const DILocation *IA)
133 : DbgEntity(V, IA, DbgVariableKind) {}
135 /// Initialize from the MMI table.
136 void initializeMMI(const DIExpression *E, int FI) {
137 assert(FrameIndexExprs.empty() && "Already initialized?");
138 assert(!MInsn && "Already initialized?");
140 assert((!E || E->isValid()) && "Expected valid expression");
141 assert(FI != std::numeric_limits<int>::max() && "Expected valid index");
143 FrameIndexExprs.push_back({FI, E});
146 /// Initialize from a DBG_VALUE instruction.
147 void initializeDbgValue(const MachineInstr *DbgValue) {
148 assert(FrameIndexExprs.empty() && "Already initialized?");
149 assert(!MInsn && "Already initialized?");
151 assert(getVariable() == DbgValue->getDebugVariable() && "Wrong variable");
152 assert(getInlinedAt() == DbgValue->getDebugLoc()->getInlinedAt() &&
153 "Wrong inlined-at");
155 MInsn = DbgValue;
156 if (auto *E = DbgValue->getDebugExpression())
157 if (E->getNumElements())
158 FrameIndexExprs.push_back({0, E});
161 // Accessors.
162 const DILocalVariable *getVariable() const {
163 return cast<DILocalVariable>(getEntity());
166 const DIExpression *getSingleExpression() const {
167 assert(MInsn && FrameIndexExprs.size() <= 1);
168 return FrameIndexExprs.size() ? FrameIndexExprs[0].Expr : nullptr;
171 void setDebugLocListIndex(unsigned O) { DebugLocListIndex = O; }
172 unsigned getDebugLocListIndex() const { return DebugLocListIndex; }
173 StringRef getName() const { return getVariable()->getName(); }
174 const MachineInstr *getMInsn() const { return MInsn; }
175 /// Get the FI entries, sorted by fragment offset.
176 ArrayRef<FrameIndexExpr> getFrameIndexExprs() const;
177 bool hasFrameIndexExprs() const { return !FrameIndexExprs.empty(); }
178 void addMMIEntry(const DbgVariable &V);
180 // Translate tag to proper Dwarf tag.
181 dwarf::Tag getTag() const {
182 // FIXME: Why don't we just infer this tag and store it all along?
183 if (getVariable()->isParameter())
184 return dwarf::DW_TAG_formal_parameter;
186 return dwarf::DW_TAG_variable;
189 /// Return true if DbgVariable is artificial.
190 bool isArtificial() const {
191 if (getVariable()->isArtificial())
192 return true;
193 if (getType()->isArtificial())
194 return true;
195 return false;
198 bool isObjectPointer() const {
199 if (getVariable()->isObjectPointer())
200 return true;
201 if (getType()->isObjectPointer())
202 return true;
203 return false;
206 bool hasComplexAddress() const {
207 assert(MInsn && "Expected DBG_VALUE, not MMI variable");
208 assert((FrameIndexExprs.empty() ||
209 (FrameIndexExprs.size() == 1 &&
210 FrameIndexExprs[0].Expr->getNumElements())) &&
211 "Invalid Expr for DBG_VALUE");
212 return !FrameIndexExprs.empty();
215 bool isBlockByrefVariable() const;
216 const DIType *getType() const;
218 static bool classof(const DbgEntity *N) {
219 return N->getDbgEntityID() == DbgVariableKind;
222 private:
223 template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
224 return Ref.resolve();
228 //===----------------------------------------------------------------------===//
229 /// This class is used to track label information.
231 /// Labels are collected from \c DBG_LABEL instructions.
232 class DbgLabel : public DbgEntity {
233 const MCSymbol *Sym; /// Symbol before DBG_LABEL instruction.
235 public:
236 /// We need MCSymbol information to generate DW_AT_low_pc.
237 DbgLabel(const DILabel *L, const DILocation *IA, const MCSymbol *Sym = nullptr)
238 : DbgEntity(L, IA, DbgLabelKind), Sym(Sym) {}
240 /// Accessors.
241 /// @{
242 const DILabel *getLabel() const { return cast<DILabel>(getEntity()); }
243 const MCSymbol *getSymbol() const { return Sym; }
245 StringRef getName() const { return getLabel()->getName(); }
246 /// @}
248 /// Translate tag to proper Dwarf tag.
249 dwarf::Tag getTag() const {
250 return dwarf::DW_TAG_label;
253 static bool classof(const DbgEntity *N) {
254 return N->getDbgEntityID() == DbgLabelKind;
257 private:
258 template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
259 return Ref.resolve();
263 /// Helper used to pair up a symbol and its DWARF compile unit.
264 struct SymbolCU {
265 SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
267 const MCSymbol *Sym;
268 DwarfCompileUnit *CU;
271 /// The kind of accelerator tables we should emit.
272 enum class AccelTableKind {
273 Default, ///< Platform default.
274 None, ///< None.
275 Apple, ///< .apple_names, .apple_namespaces, .apple_types, .apple_objc.
276 Dwarf, ///< DWARF v5 .debug_names.
279 /// Collects and handles dwarf debug information.
280 class DwarfDebug : public DebugHandlerBase {
281 /// All DIEValues are allocated through this allocator.
282 BumpPtrAllocator DIEValueAllocator;
284 /// Maps MDNode with its corresponding DwarfCompileUnit.
285 MapVector<const MDNode *, DwarfCompileUnit *> CUMap;
287 /// Maps a CU DIE with its corresponding DwarfCompileUnit.
288 DenseMap<const DIE *, DwarfCompileUnit *> CUDieMap;
290 /// List of all labels used in aranges generation.
291 std::vector<SymbolCU> ArangeLabels;
293 /// Size of each symbol emitted (for those symbols that have a specific size).
294 DenseMap<const MCSymbol *, uint64_t> SymSize;
296 /// Collection of abstract variables/labels.
297 SmallVector<std::unique_ptr<DbgEntity>, 64> ConcreteEntities;
299 /// Collection of DebugLocEntry. Stored in a linked list so that DIELocLists
300 /// can refer to them in spite of insertions into this list.
301 DebugLocStream DebugLocs;
303 /// This is a collection of subprogram MDNodes that are processed to
304 /// create DIEs.
305 SetVector<const DISubprogram *, SmallVector<const DISubprogram *, 16>,
306 SmallPtrSet<const DISubprogram *, 16>>
307 ProcessedSPNodes;
309 /// If nonnull, stores the current machine function we're processing.
310 const MachineFunction *CurFn = nullptr;
312 /// If nonnull, stores the CU in which the previous subprogram was contained.
313 const DwarfCompileUnit *PrevCU;
315 /// As an optimization, there is no need to emit an entry in the directory
316 /// table for the same directory as DW_AT_comp_dir.
317 StringRef CompilationDir;
319 /// Holder for the file specific debug information.
320 DwarfFile InfoHolder;
322 /// Holders for the various debug information flags that we might need to
323 /// have exposed. See accessor functions below for description.
325 /// Map from MDNodes for user-defined types to their type signatures. Also
326 /// used to keep track of which types we have emitted type units for.
327 DenseMap<const MDNode *, uint64_t> TypeSignatures;
329 DenseMap<const MCSection *, const MCSymbol *> SectionLabels;
331 SmallVector<
332 std::pair<std::unique_ptr<DwarfTypeUnit>, const DICompositeType *>, 1>
333 TypeUnitsUnderConstruction;
335 /// Whether to use the GNU TLS opcode (instead of the standard opcode).
336 bool UseGNUTLSOpcode;
338 /// Whether to use DWARF 2 bitfields (instead of the DWARF 4 format).
339 bool UseDWARF2Bitfields;
341 /// Whether to emit all linkage names, or just abstract subprograms.
342 bool UseAllLinkageNames;
344 /// Use inlined strings.
345 bool UseInlineStrings = false;
347 /// Allow emission of .debug_ranges section.
348 bool UseRangesSection = true;
350 /// True if the sections itself must be used as references and don't create
351 /// temp symbols inside DWARF sections.
352 bool UseSectionsAsReferences = false;
354 ///Allow emission of the .debug_loc section.
355 bool UseLocSection = true;
357 /// Generate DWARF v4 type units.
358 bool GenerateTypeUnits;
360 /// DWARF5 Experimental Options
361 /// @{
362 AccelTableKind TheAccelTableKind;
363 bool HasAppleExtensionAttributes;
364 bool HasSplitDwarf;
366 /// Whether to generate the DWARF v5 string offsets table.
367 /// It consists of a series of contributions, each preceded by a header.
368 /// The pre-DWARF v5 string offsets table for split dwarf is, in contrast,
369 /// a monolithic sequence of string offsets.
370 bool UseSegmentedStringOffsetsTable;
372 /// Separated Dwarf Variables
373 /// In general these will all be for bits that are left in the
374 /// original object file, rather than things that are meant
375 /// to be in the .dwo sections.
377 /// Holder for the skeleton information.
378 DwarfFile SkeletonHolder;
380 /// Store file names for type units under fission in a line table
381 /// header that will be emitted into debug_line.dwo.
382 // FIXME: replace this with a map from comp_dir to table so that we
383 // can emit multiple tables during LTO each of which uses directory
384 // 0, referencing the comp_dir of all the type units that use it.
385 MCDwarfDwoLineTable SplitTypeUnitFileTable;
386 /// @}
388 /// True iff there are multiple CUs in this module.
389 bool SingleCU;
390 bool IsDarwin;
392 AddressPool AddrPool;
394 /// Accelerator tables.
395 AccelTable<DWARF5AccelTableData> AccelDebugNames;
396 AccelTable<AppleAccelTableOffsetData> AccelNames;
397 AccelTable<AppleAccelTableOffsetData> AccelObjC;
398 AccelTable<AppleAccelTableOffsetData> AccelNamespace;
399 AccelTable<AppleAccelTableTypeData> AccelTypes;
401 // Identify a debugger for "tuning" the debug info.
402 DebuggerKind DebuggerTuning = DebuggerKind::Default;
404 MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
406 const SmallVectorImpl<std::unique_ptr<DwarfCompileUnit>> &getUnits() {
407 return InfoHolder.getUnits();
410 using InlinedEntity = DbgValueHistoryMap::InlinedEntity;
412 void ensureAbstractEntityIsCreated(DwarfCompileUnit &CU,
413 const DINode *Node,
414 const MDNode *Scope);
415 void ensureAbstractEntityIsCreatedIfScoped(DwarfCompileUnit &CU,
416 const DINode *Node,
417 const MDNode *Scope);
419 DbgEntity *createConcreteEntity(DwarfCompileUnit &TheCU,
420 LexicalScope &Scope,
421 const DINode *Node,
422 const DILocation *Location,
423 const MCSymbol *Sym = nullptr);
425 /// Construct a DIE for this abstract scope.
426 void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU, LexicalScope *Scope);
428 /// Construct DIEs for call site entries describing the calls in \p MF.
429 void constructCallSiteEntryDIEs(const DISubprogram &SP, DwarfCompileUnit &CU,
430 DIE &ScopeDIE, const MachineFunction &MF);
432 template <typename DataT>
433 void addAccelNameImpl(const DICompileUnit &CU, AccelTable<DataT> &AppleAccel,
434 StringRef Name, const DIE &Die);
436 void finishEntityDefinitions();
438 void finishSubprogramDefinitions();
440 /// Finish off debug information after all functions have been
441 /// processed.
442 void finalizeModuleInfo();
444 /// Emit the debug info section.
445 void emitDebugInfo();
447 /// Emit the abbreviation section.
448 void emitAbbreviations();
450 /// Emit the string offsets table header.
451 void emitStringOffsetsTableHeader();
453 /// Emit a specified accelerator table.
454 template <typename AccelTableT>
455 void emitAccel(AccelTableT &Accel, MCSection *Section, StringRef TableName);
457 /// Emit DWARF v5 accelerator table.
458 void emitAccelDebugNames();
460 /// Emit visible names into a hashed accelerator table section.
461 void emitAccelNames();
463 /// Emit objective C classes and categories into a hashed
464 /// accelerator table section.
465 void emitAccelObjC();
467 /// Emit namespace dies into a hashed accelerator table.
468 void emitAccelNamespaces();
470 /// Emit type dies into a hashed accelerator table.
471 void emitAccelTypes();
473 /// Emit visible names and types into debug pubnames and pubtypes sections.
474 void emitDebugPubSections();
476 void emitDebugPubSection(bool GnuStyle, StringRef Name,
477 DwarfCompileUnit *TheU,
478 const StringMap<const DIE *> &Globals);
480 /// Emit null-terminated strings into a debug str section.
481 void emitDebugStr();
483 /// Emit variable locations into a debug loc section.
484 void emitDebugLoc();
486 /// Emit variable locations into a debug loc dwo section.
487 void emitDebugLocDWO();
489 /// Emit address ranges into a debug aranges section.
490 void emitDebugARanges();
492 /// Emit address ranges into a debug ranges section.
493 void emitDebugRanges();
494 void emitDebugRangesDWO();
496 /// Emit macros into a debug macinfo section.
497 void emitDebugMacinfo();
498 void emitMacro(DIMacro &M);
499 void emitMacroFile(DIMacroFile &F, DwarfCompileUnit &U);
500 void handleMacroNodes(DIMacroNodeArray Nodes, DwarfCompileUnit &U);
502 /// DWARF 5 Experimental Split Dwarf Emitters
504 /// Initialize common features of skeleton units.
505 void initSkeletonUnit(const DwarfUnit &U, DIE &Die,
506 std::unique_ptr<DwarfCompileUnit> NewU);
508 /// Construct the split debug info compile unit for the debug info section.
509 /// In DWARF v5, the skeleton unit DIE may have the following attributes:
510 /// DW_AT_addr_base, DW_AT_comp_dir, DW_AT_dwo_name, DW_AT_high_pc,
511 /// DW_AT_low_pc, DW_AT_ranges, DW_AT_stmt_list, and DW_AT_str_offsets_base.
512 /// Prior to DWARF v5 it may also have DW_AT_GNU_dwo_id. DW_AT_GNU_dwo_name
513 /// is used instead of DW_AT_dwo_name, Dw_AT_GNU_addr_base instead of
514 /// DW_AT_addr_base, and DW_AT_GNU_ranges_base instead of DW_AT_rnglists_base.
515 DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU);
517 /// Emit the debug info dwo section.
518 void emitDebugInfoDWO();
520 /// Emit the debug abbrev dwo section.
521 void emitDebugAbbrevDWO();
523 /// Emit the debug line dwo section.
524 void emitDebugLineDWO();
526 /// Emit the dwo stringoffsets table header.
527 void emitStringOffsetsTableHeaderDWO();
529 /// Emit the debug str dwo section.
530 void emitDebugStrDWO();
532 /// Emit DWO addresses.
533 void emitDebugAddr();
535 /// Flags to let the linker know we have emitted new style pubnames. Only
536 /// emit it here if we don't have a skeleton CU for split dwarf.
537 void addGnuPubAttributes(DwarfCompileUnit &U, DIE &D) const;
539 /// Create new DwarfCompileUnit for the given metadata node with tag
540 /// DW_TAG_compile_unit.
541 DwarfCompileUnit &getOrCreateDwarfCompileUnit(const DICompileUnit *DIUnit);
542 void finishUnitAttributes(const DICompileUnit *DIUnit,
543 DwarfCompileUnit &NewCU);
545 /// Construct imported_module or imported_declaration DIE.
546 void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
547 const DIImportedEntity *N);
549 /// Register a source line with debug info. Returns the unique
550 /// label that was emitted and which provides correspondence to the
551 /// source line list.
552 void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
553 unsigned Flags);
555 /// Populate LexicalScope entries with variables' info.
556 void collectEntityInfo(DwarfCompileUnit &TheCU, const DISubprogram *SP,
557 DenseSet<InlinedEntity> &ProcessedVars);
559 /// Build the location list for all DBG_VALUEs in the
560 /// function that describe the same variable.
561 void buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
562 const DbgValueHistoryMap::InstrRanges &Ranges);
564 /// Collect variable information from the side table maintained by MF.
565 void collectVariableInfoFromMFTable(DwarfCompileUnit &TheCU,
566 DenseSet<InlinedEntity> &P);
568 /// Emit the reference to the section.
569 void emitSectionReference(const DwarfCompileUnit &CU);
571 protected:
572 /// Gather pre-function debug information.
573 void beginFunctionImpl(const MachineFunction *MF) override;
575 /// Gather and emit post-function debug information.
576 void endFunctionImpl(const MachineFunction *MF) override;
578 void skippedNonDebugFunction() override;
580 public:
581 //===--------------------------------------------------------------------===//
582 // Main entry points.
584 DwarfDebug(AsmPrinter *A, Module *M);
586 ~DwarfDebug() override;
588 /// Emit all Dwarf sections that should come prior to the
589 /// content.
590 void beginModule();
592 /// Emit all Dwarf sections that should come after the content.
593 void endModule() override;
595 /// Emits inital debug location directive.
596 DebugLoc emitInitialLocDirective(const MachineFunction &MF, unsigned CUID);
598 /// Process beginning of an instruction.
599 void beginInstruction(const MachineInstr *MI) override;
601 /// Perform an MD5 checksum of \p Identifier and return the lower 64 bits.
602 static uint64_t makeTypeSignature(StringRef Identifier);
604 /// Add a DIE to the set of types that we're going to pull into
605 /// type units.
606 void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
607 DIE &Die, const DICompositeType *CTy);
609 /// Add a label so that arange data can be generated for it.
610 void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
612 /// For symbols that have a size designated (e.g. common symbols),
613 /// this tracks that size.
614 void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {
615 SymSize[Sym] = Size;
618 /// Returns whether we should emit all DW_AT_[MIPS_]linkage_name.
619 /// If not, we still might emit certain cases.
620 bool useAllLinkageNames() const { return UseAllLinkageNames; }
622 /// Returns whether to use DW_OP_GNU_push_tls_address, instead of the
623 /// standard DW_OP_form_tls_address opcode
624 bool useGNUTLSOpcode() const { return UseGNUTLSOpcode; }
626 /// Returns whether to use the DWARF2 format for bitfields instyead of the
627 /// DWARF4 format.
628 bool useDWARF2Bitfields() const { return UseDWARF2Bitfields; }
630 /// Returns whether to use inline strings.
631 bool useInlineStrings() const { return UseInlineStrings; }
633 /// Returns whether ranges section should be emitted.
634 bool useRangesSection() const { return UseRangesSection; }
636 /// Returns whether to use sections as labels rather than temp symbols.
637 bool useSectionsAsReferences() const {
638 return UseSectionsAsReferences;
641 /// Returns whether .debug_loc section should be emitted.
642 bool useLocSection() const { return UseLocSection; }
644 /// Returns whether to generate DWARF v4 type units.
645 bool generateTypeUnits() const { return GenerateTypeUnits; }
647 // Experimental DWARF5 features.
649 /// Returns what kind (if any) of accelerator tables to emit.
650 AccelTableKind getAccelTableKind() const { return TheAccelTableKind; }
652 bool useAppleExtensionAttributes() const {
653 return HasAppleExtensionAttributes;
656 /// Returns whether or not to change the current debug info for the
657 /// split dwarf proposal support.
658 bool useSplitDwarf() const { return HasSplitDwarf; }
660 /// Returns whether to generate a string offsets table with (possibly shared)
661 /// contributions from each CU and type unit. This implies the use of
662 /// DW_FORM_strx* indirect references with DWARF v5 and beyond. Note that
663 /// DW_FORM_GNU_str_index is also an indirect reference, but it is used with
664 /// a pre-DWARF v5 implementation of split DWARF sections, which uses a
665 /// monolithic string offsets table.
666 bool useSegmentedStringOffsetsTable() const {
667 return UseSegmentedStringOffsetsTable;
670 bool shareAcrossDWOCUs() const;
672 /// Returns the Dwarf Version.
673 uint16_t getDwarfVersion() const;
675 /// Returns the previous CU that was being updated
676 const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
677 void setPrevCU(const DwarfCompileUnit *PrevCU) { this->PrevCU = PrevCU; }
679 /// Returns the entries for the .debug_loc section.
680 const DebugLocStream &getDebugLocs() const { return DebugLocs; }
682 /// Emit an entry for the debug loc section. This can be used to
683 /// handle an entry that's going to be emitted into the debug loc section.
684 void emitDebugLocEntry(ByteStreamer &Streamer,
685 const DebugLocStream::Entry &Entry);
687 /// Emit the location for a debug loc entry, including the size header.
688 void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry);
690 /// Find the MDNode for the given reference.
691 template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
692 return Ref.resolve();
695 void addSubprogramNames(const DICompileUnit &CU, const DISubprogram *SP,
696 DIE &Die);
698 AddressPool &getAddressPool() { return AddrPool; }
700 void addAccelName(const DICompileUnit &CU, StringRef Name, const DIE &Die);
702 void addAccelObjC(const DICompileUnit &CU, StringRef Name, const DIE &Die);
704 void addAccelNamespace(const DICompileUnit &CU, StringRef Name,
705 const DIE &Die);
707 void addAccelType(const DICompileUnit &CU, StringRef Name, const DIE &Die,
708 char Flags);
710 const MachineFunction *getCurrentFunction() const { return CurFn; }
712 /// A helper function to check whether the DIE for a given Scope is
713 /// going to be null.
714 bool isLexicalScopeDIENull(LexicalScope *Scope);
716 /// Find the matching DwarfCompileUnit for the given CU DIE.
717 DwarfCompileUnit *lookupCU(const DIE *Die) { return CUDieMap.lookup(Die); }
718 const DwarfCompileUnit *lookupCU(const DIE *Die) const {
719 return CUDieMap.lookup(Die);
722 /// \defgroup DebuggerTuning Predicates to tune DWARF for a given debugger.
724 /// Returns whether we are "tuning" for a given debugger.
725 /// @{
726 bool tuneForGDB() const { return DebuggerTuning == DebuggerKind::GDB; }
727 bool tuneForLLDB() const { return DebuggerTuning == DebuggerKind::LLDB; }
728 bool tuneForSCE() const { return DebuggerTuning == DebuggerKind::SCE; }
729 /// @}
731 void addSectionLabel(const MCSymbol *Sym);
732 const MCSymbol *getSectionLabel(const MCSection *S);
735 } // end namespace llvm
737 #endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H