[InstCombine] Signed saturation patterns
[llvm-complete.git] / lib / CodeGen / AsmPrinter / DwarfDebug.h
blobc8c511f67c2a095d7260b8c5d4f093b7ffa6e601
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 "DebugLocEntry.h"
19 #include "DwarfFile.h"
20 #include "llvm/ADT/ArrayRef.h"
21 #include "llvm/ADT/DenseMap.h"
22 #include "llvm/ADT/DenseSet.h"
23 #include "llvm/ADT/MapVector.h"
24 #include "llvm/ADT/STLExtras.h"
25 #include "llvm/ADT/SetVector.h"
26 #include "llvm/ADT/SmallPtrSet.h"
27 #include "llvm/ADT/SmallVector.h"
28 #include "llvm/ADT/StringMap.h"
29 #include "llvm/ADT/StringRef.h"
30 #include "llvm/BinaryFormat/Dwarf.h"
31 #include "llvm/CodeGen/AccelTable.h"
32 #include "llvm/CodeGen/DbgEntityHistoryCalculator.h"
33 #include "llvm/CodeGen/DebugHandlerBase.h"
34 #include "llvm/CodeGen/MachineInstr.h"
35 #include "llvm/IR/DebugInfoMetadata.h"
36 #include "llvm/IR/DebugLoc.h"
37 #include "llvm/IR/Metadata.h"
38 #include "llvm/MC/MCDwarf.h"
39 #include "llvm/Support/Allocator.h"
40 #include "llvm/Target/TargetOptions.h"
41 #include <cassert>
42 #include <cstdint>
43 #include <limits>
44 #include <memory>
45 #include <utility>
46 #include <vector>
48 namespace llvm {
50 class AsmPrinter;
51 class ByteStreamer;
52 class DebugLocEntry;
53 class DIE;
54 class DwarfCompileUnit;
55 class DwarfExpression;
56 class DwarfTypeUnit;
57 class DwarfUnit;
58 class LexicalScope;
59 class MachineFunction;
60 class MCSection;
61 class MCSymbol;
62 class MDNode;
63 class Module;
65 //===----------------------------------------------------------------------===//
66 /// This class is defined as the common parent of DbgVariable and DbgLabel
67 /// such that it could levarage polymorphism to extract common code for
68 /// DbgVariable and DbgLabel.
69 class DbgEntity {
70 const DINode *Entity;
71 const DILocation *InlinedAt;
72 DIE *TheDIE = nullptr;
73 unsigned SubclassID;
75 public:
76 enum DbgEntityKind {
77 DbgVariableKind,
78 DbgLabelKind
81 DbgEntity(const DINode *N, const DILocation *IA, unsigned ID)
82 : Entity(N), InlinedAt(IA), SubclassID(ID) {}
83 virtual ~DbgEntity() {}
85 /// Accessors.
86 /// @{
87 const DINode *getEntity() const { return Entity; }
88 const DILocation *getInlinedAt() const { return InlinedAt; }
89 DIE *getDIE() const { return TheDIE; }
90 unsigned getDbgEntityID() const { return SubclassID; }
91 /// @}
93 void setDIE(DIE &D) { TheDIE = &D; }
95 static bool classof(const DbgEntity *N) {
96 switch (N->getDbgEntityID()) {
97 default:
98 return false;
99 case DbgVariableKind:
100 case DbgLabelKind:
101 return true;
106 //===----------------------------------------------------------------------===//
107 /// This class is used to track local variable information.
109 /// Variables can be created from allocas, in which case they're generated from
110 /// the MMI table. Such variables can have multiple expressions and frame
111 /// indices.
113 /// Variables can be created from \c DBG_VALUE instructions. Those whose
114 /// location changes over time use \a DebugLocListIndex, while those with a
115 /// single location use \a ValueLoc and (optionally) a single entry of \a Expr.
117 /// Variables that have been optimized out use none of these fields.
118 class DbgVariable : public DbgEntity {
119 /// Offset in DebugLocs.
120 unsigned DebugLocListIndex = ~0u;
121 /// Single value location description.
122 std::unique_ptr<DbgValueLoc> ValueLoc = nullptr;
124 struct FrameIndexExpr {
125 int FI;
126 const DIExpression *Expr;
128 mutable SmallVector<FrameIndexExpr, 1>
129 FrameIndexExprs; /// Frame index + expression.
131 public:
132 /// Construct a DbgVariable.
134 /// Creates a variable without any DW_AT_location. Call \a initializeMMI()
135 /// for MMI entries, or \a initializeDbgValue() for DBG_VALUE instructions.
136 DbgVariable(const DILocalVariable *V, const DILocation *IA)
137 : DbgEntity(V, IA, DbgVariableKind) {}
139 /// Initialize from the MMI table.
140 void initializeMMI(const DIExpression *E, int FI) {
141 assert(FrameIndexExprs.empty() && "Already initialized?");
142 assert(!ValueLoc.get() && "Already initialized?");
144 assert((!E || E->isValid()) && "Expected valid expression");
145 assert(FI != std::numeric_limits<int>::max() && "Expected valid index");
147 FrameIndexExprs.push_back({FI, E});
150 // Initialize variable's location.
151 void initializeDbgValue(DbgValueLoc Value) {
152 assert(FrameIndexExprs.empty() && "Already initialized?");
153 assert(!ValueLoc && "Already initialized?");
154 assert(!Value.getExpression()->isFragment() && "Fragments not supported.");
156 ValueLoc = std::make_unique<DbgValueLoc>(Value);
157 if (auto *E = ValueLoc->getExpression())
158 if (E->getNumElements())
159 FrameIndexExprs.push_back({0, E});
162 /// Initialize from a DBG_VALUE instruction.
163 void initializeDbgValue(const MachineInstr *DbgValue);
165 // Accessors.
166 const DILocalVariable *getVariable() const {
167 return cast<DILocalVariable>(getEntity());
170 const DIExpression *getSingleExpression() const {
171 assert(ValueLoc.get() && FrameIndexExprs.size() <= 1);
172 return FrameIndexExprs.size() ? FrameIndexExprs[0].Expr : nullptr;
175 void setDebugLocListIndex(unsigned O) { DebugLocListIndex = O; }
176 unsigned getDebugLocListIndex() const { return DebugLocListIndex; }
177 StringRef getName() const { return getVariable()->getName(); }
178 const DbgValueLoc *getValueLoc() const { return ValueLoc.get(); }
179 /// Get the FI entries, sorted by fragment offset.
180 ArrayRef<FrameIndexExpr> getFrameIndexExprs() const;
181 bool hasFrameIndexExprs() const { return !FrameIndexExprs.empty(); }
182 void addMMIEntry(const DbgVariable &V);
184 // Translate tag to proper Dwarf tag.
185 dwarf::Tag getTag() const {
186 // FIXME: Why don't we just infer this tag and store it all along?
187 if (getVariable()->isParameter())
188 return dwarf::DW_TAG_formal_parameter;
190 return dwarf::DW_TAG_variable;
193 /// Return true if DbgVariable is artificial.
194 bool isArtificial() const {
195 if (getVariable()->isArtificial())
196 return true;
197 if (getType()->isArtificial())
198 return true;
199 return false;
202 bool isObjectPointer() const {
203 if (getVariable()->isObjectPointer())
204 return true;
205 if (getType()->isObjectPointer())
206 return true;
207 return false;
210 bool hasComplexAddress() const {
211 assert(ValueLoc.get() && "Expected DBG_VALUE, not MMI variable");
212 assert((FrameIndexExprs.empty() ||
213 (FrameIndexExprs.size() == 1 &&
214 FrameIndexExprs[0].Expr->getNumElements())) &&
215 "Invalid Expr for DBG_VALUE");
216 return !FrameIndexExprs.empty();
219 const DIType *getType() const;
221 static bool classof(const DbgEntity *N) {
222 return N->getDbgEntityID() == DbgVariableKind;
226 //===----------------------------------------------------------------------===//
227 /// This class is used to track label information.
229 /// Labels are collected from \c DBG_LABEL instructions.
230 class DbgLabel : public DbgEntity {
231 const MCSymbol *Sym; /// Symbol before DBG_LABEL instruction.
233 public:
234 /// We need MCSymbol information to generate DW_AT_low_pc.
235 DbgLabel(const DILabel *L, const DILocation *IA, const MCSymbol *Sym = nullptr)
236 : DbgEntity(L, IA, DbgLabelKind), Sym(Sym) {}
238 /// Accessors.
239 /// @{
240 const DILabel *getLabel() const { return cast<DILabel>(getEntity()); }
241 const MCSymbol *getSymbol() const { return Sym; }
243 StringRef getName() const { return getLabel()->getName(); }
244 /// @}
246 /// Translate tag to proper Dwarf tag.
247 dwarf::Tag getTag() const {
248 return dwarf::DW_TAG_label;
251 static bool classof(const DbgEntity *N) {
252 return N->getDbgEntityID() == DbgLabelKind;
256 /// Used for tracking debug info about call site parameters.
257 class DbgCallSiteParam {
258 private:
259 unsigned Register; ///< Parameter register at the callee entry point.
260 DbgValueLoc Value; ///< Corresponding location for the parameter value at
261 ///< the call site.
262 public:
263 DbgCallSiteParam(unsigned Reg, DbgValueLoc Val)
264 : Register(Reg), Value(Val) {
265 assert(Reg && "Parameter register cannot be undef");
268 unsigned getRegister() const { return Register; }
269 DbgValueLoc getValue() const { return Value; }
272 /// Collection used for storing debug call site parameters.
273 using ParamSet = SmallVector<DbgCallSiteParam, 4>;
275 /// Helper used to pair up a symbol and its DWARF compile unit.
276 struct SymbolCU {
277 SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
279 const MCSymbol *Sym;
280 DwarfCompileUnit *CU;
283 /// The kind of accelerator tables we should emit.
284 enum class AccelTableKind {
285 Default, ///< Platform default.
286 None, ///< None.
287 Apple, ///< .apple_names, .apple_namespaces, .apple_types, .apple_objc.
288 Dwarf, ///< DWARF v5 .debug_names.
291 /// Collects and handles dwarf debug information.
292 class DwarfDebug : public DebugHandlerBase {
293 /// All DIEValues are allocated through this allocator.
294 BumpPtrAllocator DIEValueAllocator;
296 /// Maps MDNode with its corresponding DwarfCompileUnit.
297 MapVector<const MDNode *, DwarfCompileUnit *> CUMap;
299 /// Maps a CU DIE with its corresponding DwarfCompileUnit.
300 DenseMap<const DIE *, DwarfCompileUnit *> CUDieMap;
302 /// List of all labels used in aranges generation.
303 std::vector<SymbolCU> ArangeLabels;
305 /// Size of each symbol emitted (for those symbols that have a specific size).
306 DenseMap<const MCSymbol *, uint64_t> SymSize;
308 /// Collection of abstract variables/labels.
309 SmallVector<std::unique_ptr<DbgEntity>, 64> ConcreteEntities;
311 /// Collection of DebugLocEntry. Stored in a linked list so that DIELocLists
312 /// can refer to them in spite of insertions into this list.
313 DebugLocStream DebugLocs;
315 /// This is a collection of subprogram MDNodes that are processed to
316 /// create DIEs.
317 SetVector<const DISubprogram *, SmallVector<const DISubprogram *, 16>,
318 SmallPtrSet<const DISubprogram *, 16>>
319 ProcessedSPNodes;
321 /// If nonnull, stores the current machine function we're processing.
322 const MachineFunction *CurFn = nullptr;
324 /// If nonnull, stores the CU in which the previous subprogram was contained.
325 const DwarfCompileUnit *PrevCU;
327 /// As an optimization, there is no need to emit an entry in the directory
328 /// table for the same directory as DW_AT_comp_dir.
329 StringRef CompilationDir;
331 /// Holder for the file specific debug information.
332 DwarfFile InfoHolder;
334 /// Holders for the various debug information flags that we might need to
335 /// have exposed. See accessor functions below for description.
337 /// Map from MDNodes for user-defined types to their type signatures. Also
338 /// used to keep track of which types we have emitted type units for.
339 DenseMap<const MDNode *, uint64_t> TypeSignatures;
341 DenseMap<const MCSection *, const MCSymbol *> SectionLabels;
343 SmallVector<
344 std::pair<std::unique_ptr<DwarfTypeUnit>, const DICompositeType *>, 1>
345 TypeUnitsUnderConstruction;
347 /// Whether to use the GNU TLS opcode (instead of the standard opcode).
348 bool UseGNUTLSOpcode;
350 /// Whether to use DWARF 2 bitfields (instead of the DWARF 4 format).
351 bool UseDWARF2Bitfields;
353 /// Whether to emit all linkage names, or just abstract subprograms.
354 bool UseAllLinkageNames;
356 /// Use inlined strings.
357 bool UseInlineStrings = false;
359 /// Allow emission of .debug_ranges section.
360 bool UseRangesSection = true;
362 /// True if the sections itself must be used as references and don't create
363 /// temp symbols inside DWARF sections.
364 bool UseSectionsAsReferences = false;
366 ///Allow emission of the .debug_loc section.
367 bool UseLocSection = true;
369 /// Generate DWARF v4 type units.
370 bool GenerateTypeUnits;
372 /// DWARF5 Experimental Options
373 /// @{
374 AccelTableKind TheAccelTableKind;
375 bool HasAppleExtensionAttributes;
376 bool HasSplitDwarf;
378 /// Whether to generate the DWARF v5 string offsets table.
379 /// It consists of a series of contributions, each preceded by a header.
380 /// The pre-DWARF v5 string offsets table for split dwarf is, in contrast,
381 /// a monolithic sequence of string offsets.
382 bool UseSegmentedStringOffsetsTable;
384 /// Separated Dwarf Variables
385 /// In general these will all be for bits that are left in the
386 /// original object file, rather than things that are meant
387 /// to be in the .dwo sections.
389 /// Holder for the skeleton information.
390 DwarfFile SkeletonHolder;
392 /// Store file names for type units under fission in a line table
393 /// header that will be emitted into debug_line.dwo.
394 // FIXME: replace this with a map from comp_dir to table so that we
395 // can emit multiple tables during LTO each of which uses directory
396 // 0, referencing the comp_dir of all the type units that use it.
397 MCDwarfDwoLineTable SplitTypeUnitFileTable;
398 /// @}
400 /// True iff there are multiple CUs in this module.
401 bool SingleCU;
402 bool IsDarwin;
404 AddressPool AddrPool;
406 /// Accelerator tables.
407 AccelTable<DWARF5AccelTableData> AccelDebugNames;
408 AccelTable<AppleAccelTableOffsetData> AccelNames;
409 AccelTable<AppleAccelTableOffsetData> AccelObjC;
410 AccelTable<AppleAccelTableOffsetData> AccelNamespace;
411 AccelTable<AppleAccelTableTypeData> AccelTypes;
413 // Identify a debugger for "tuning" the debug info.
414 DebuggerKind DebuggerTuning = DebuggerKind::Default;
416 MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
418 const SmallVectorImpl<std::unique_ptr<DwarfCompileUnit>> &getUnits() {
419 return InfoHolder.getUnits();
422 using InlinedEntity = DbgValueHistoryMap::InlinedEntity;
424 void ensureAbstractEntityIsCreated(DwarfCompileUnit &CU,
425 const DINode *Node,
426 const MDNode *Scope);
427 void ensureAbstractEntityIsCreatedIfScoped(DwarfCompileUnit &CU,
428 const DINode *Node,
429 const MDNode *Scope);
431 DbgEntity *createConcreteEntity(DwarfCompileUnit &TheCU,
432 LexicalScope &Scope,
433 const DINode *Node,
434 const DILocation *Location,
435 const MCSymbol *Sym = nullptr);
437 /// Construct a DIE for this abstract scope.
438 void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU, LexicalScope *Scope);
440 /// Construct DIEs for call site entries describing the calls in \p MF.
441 void constructCallSiteEntryDIEs(const DISubprogram &SP, DwarfCompileUnit &CU,
442 DIE &ScopeDIE, const MachineFunction &MF);
444 template <typename DataT>
445 void addAccelNameImpl(const DICompileUnit &CU, AccelTable<DataT> &AppleAccel,
446 StringRef Name, const DIE &Die);
448 void finishEntityDefinitions();
450 void finishSubprogramDefinitions();
452 /// Finish off debug information after all functions have been
453 /// processed.
454 void finalizeModuleInfo();
456 /// Emit the debug info section.
457 void emitDebugInfo();
459 /// Emit the abbreviation section.
460 void emitAbbreviations();
462 /// Emit the string offsets table header.
463 void emitStringOffsetsTableHeader();
465 /// Emit a specified accelerator table.
466 template <typename AccelTableT>
467 void emitAccel(AccelTableT &Accel, MCSection *Section, StringRef TableName);
469 /// Emit DWARF v5 accelerator table.
470 void emitAccelDebugNames();
472 /// Emit visible names into a hashed accelerator table section.
473 void emitAccelNames();
475 /// Emit objective C classes and categories into a hashed
476 /// accelerator table section.
477 void emitAccelObjC();
479 /// Emit namespace dies into a hashed accelerator table.
480 void emitAccelNamespaces();
482 /// Emit type dies into a hashed accelerator table.
483 void emitAccelTypes();
485 /// Emit visible names and types into debug pubnames and pubtypes sections.
486 void emitDebugPubSections();
488 void emitDebugPubSection(bool GnuStyle, StringRef Name,
489 DwarfCompileUnit *TheU,
490 const StringMap<const DIE *> &Globals);
492 /// Emit null-terminated strings into a debug str section.
493 void emitDebugStr();
495 /// Emit variable locations into a debug loc section.
496 void emitDebugLoc();
498 /// Emit variable locations into a debug loc dwo section.
499 void emitDebugLocDWO();
501 /// Emit address ranges into a debug aranges section.
502 void emitDebugARanges();
504 /// Emit address ranges into a debug ranges section.
505 void emitDebugRanges();
506 void emitDebugRangesDWO();
508 /// Emit macros into a debug macinfo section.
509 void emitDebugMacinfo();
510 void emitMacro(DIMacro &M);
511 void emitMacroFile(DIMacroFile &F, DwarfCompileUnit &U);
512 void handleMacroNodes(DIMacroNodeArray Nodes, DwarfCompileUnit &U);
514 /// DWARF 5 Experimental Split Dwarf Emitters
516 /// Initialize common features of skeleton units.
517 void initSkeletonUnit(const DwarfUnit &U, DIE &Die,
518 std::unique_ptr<DwarfCompileUnit> NewU);
520 /// Construct the split debug info compile unit for the debug info section.
521 /// In DWARF v5, the skeleton unit DIE may have the following attributes:
522 /// DW_AT_addr_base, DW_AT_comp_dir, DW_AT_dwo_name, DW_AT_high_pc,
523 /// DW_AT_low_pc, DW_AT_ranges, DW_AT_stmt_list, and DW_AT_str_offsets_base.
524 /// Prior to DWARF v5 it may also have DW_AT_GNU_dwo_id. DW_AT_GNU_dwo_name
525 /// is used instead of DW_AT_dwo_name, Dw_AT_GNU_addr_base instead of
526 /// DW_AT_addr_base, and DW_AT_GNU_ranges_base instead of DW_AT_rnglists_base.
527 DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU);
529 /// Emit the debug info dwo section.
530 void emitDebugInfoDWO();
532 /// Emit the debug abbrev dwo section.
533 void emitDebugAbbrevDWO();
535 /// Emit the debug line dwo section.
536 void emitDebugLineDWO();
538 /// Emit the dwo stringoffsets table header.
539 void emitStringOffsetsTableHeaderDWO();
541 /// Emit the debug str dwo section.
542 void emitDebugStrDWO();
544 /// Emit DWO addresses.
545 void emitDebugAddr();
547 /// Flags to let the linker know we have emitted new style pubnames. Only
548 /// emit it here if we don't have a skeleton CU for split dwarf.
549 void addGnuPubAttributes(DwarfCompileUnit &U, DIE &D) const;
551 /// Create new DwarfCompileUnit for the given metadata node with tag
552 /// DW_TAG_compile_unit.
553 DwarfCompileUnit &getOrCreateDwarfCompileUnit(const DICompileUnit *DIUnit);
554 void finishUnitAttributes(const DICompileUnit *DIUnit,
555 DwarfCompileUnit &NewCU);
557 /// Construct imported_module or imported_declaration DIE.
558 void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
559 const DIImportedEntity *N);
561 /// Register a source line with debug info. Returns the unique
562 /// label that was emitted and which provides correspondence to the
563 /// source line list.
564 void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
565 unsigned Flags);
567 /// Populate LexicalScope entries with variables' info.
568 void collectEntityInfo(DwarfCompileUnit &TheCU, const DISubprogram *SP,
569 DenseSet<InlinedEntity> &ProcessedVars);
571 /// Build the location list for all DBG_VALUEs in the
572 /// function that describe the same variable. If the resulting
573 /// list has only one entry that is valid for entire variable's
574 /// scope return true.
575 bool buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
576 const DbgValueHistoryMap::Entries &Entries);
578 /// Collect variable information from the side table maintained by MF.
579 void collectVariableInfoFromMFTable(DwarfCompileUnit &TheCU,
580 DenseSet<InlinedEntity> &P);
582 /// Emit the reference to the section.
583 void emitSectionReference(const DwarfCompileUnit &CU);
585 protected:
586 /// Gather pre-function debug information.
587 void beginFunctionImpl(const MachineFunction *MF) override;
589 /// Gather and emit post-function debug information.
590 void endFunctionImpl(const MachineFunction *MF) override;
592 void skippedNonDebugFunction() override;
594 public:
595 //===--------------------------------------------------------------------===//
596 // Main entry points.
598 DwarfDebug(AsmPrinter *A, Module *M);
600 ~DwarfDebug() override;
602 /// Emit all Dwarf sections that should come prior to the
603 /// content.
604 void beginModule();
606 /// Emit all Dwarf sections that should come after the content.
607 void endModule() override;
609 /// Emits inital debug location directive.
610 DebugLoc emitInitialLocDirective(const MachineFunction &MF, unsigned CUID);
612 /// Process beginning of an instruction.
613 void beginInstruction(const MachineInstr *MI) override;
615 /// Perform an MD5 checksum of \p Identifier and return the lower 64 bits.
616 static uint64_t makeTypeSignature(StringRef Identifier);
618 /// Add a DIE to the set of types that we're going to pull into
619 /// type units.
620 void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
621 DIE &Die, const DICompositeType *CTy);
623 friend class NonTypeUnitContext;
624 class NonTypeUnitContext {
625 DwarfDebug *DD;
626 decltype(DwarfDebug::TypeUnitsUnderConstruction) TypeUnitsUnderConstruction;
627 friend class DwarfDebug;
628 NonTypeUnitContext(DwarfDebug *DD);
629 public:
630 NonTypeUnitContext(NonTypeUnitContext&&) = default;
631 ~NonTypeUnitContext();
634 NonTypeUnitContext enterNonTypeUnitContext();
636 /// Add a label so that arange data can be generated for it.
637 void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
639 /// For symbols that have a size designated (e.g. common symbols),
640 /// this tracks that size.
641 void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {
642 SymSize[Sym] = Size;
645 /// Returns whether we should emit all DW_AT_[MIPS_]linkage_name.
646 /// If not, we still might emit certain cases.
647 bool useAllLinkageNames() const { return UseAllLinkageNames; }
649 /// Returns whether to use DW_OP_GNU_push_tls_address, instead of the
650 /// standard DW_OP_form_tls_address opcode
651 bool useGNUTLSOpcode() const { return UseGNUTLSOpcode; }
653 /// Returns whether to use the DWARF2 format for bitfields instyead of the
654 /// DWARF4 format.
655 bool useDWARF2Bitfields() const { return UseDWARF2Bitfields; }
657 /// Returns whether to use inline strings.
658 bool useInlineStrings() const { return UseInlineStrings; }
660 /// Returns whether ranges section should be emitted.
661 bool useRangesSection() const { return UseRangesSection; }
663 /// Returns whether to use sections as labels rather than temp symbols.
664 bool useSectionsAsReferences() const {
665 return UseSectionsAsReferences;
668 /// Returns whether .debug_loc section should be emitted.
669 bool useLocSection() const { return UseLocSection; }
671 /// Returns whether to generate DWARF v4 type units.
672 bool generateTypeUnits() const { return GenerateTypeUnits; }
674 // Experimental DWARF5 features.
676 /// Returns what kind (if any) of accelerator tables to emit.
677 AccelTableKind getAccelTableKind() const { return TheAccelTableKind; }
679 bool useAppleExtensionAttributes() const {
680 return HasAppleExtensionAttributes;
683 /// Returns whether or not to change the current debug info for the
684 /// split dwarf proposal support.
685 bool useSplitDwarf() const { return HasSplitDwarf; }
687 /// Returns whether to generate a string offsets table with (possibly shared)
688 /// contributions from each CU and type unit. This implies the use of
689 /// DW_FORM_strx* indirect references with DWARF v5 and beyond. Note that
690 /// DW_FORM_GNU_str_index is also an indirect reference, but it is used with
691 /// a pre-DWARF v5 implementation of split DWARF sections, which uses a
692 /// monolithic string offsets table.
693 bool useSegmentedStringOffsetsTable() const {
694 return UseSegmentedStringOffsetsTable;
697 bool shareAcrossDWOCUs() const;
699 /// Returns the Dwarf Version.
700 uint16_t getDwarfVersion() const;
702 /// Returns the previous CU that was being updated
703 const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
704 void setPrevCU(const DwarfCompileUnit *PrevCU) { this->PrevCU = PrevCU; }
706 /// Returns the entries for the .debug_loc section.
707 const DebugLocStream &getDebugLocs() const { return DebugLocs; }
709 /// Emit an entry for the debug loc section. This can be used to
710 /// handle an entry that's going to be emitted into the debug loc section.
711 void emitDebugLocEntry(ByteStreamer &Streamer,
712 const DebugLocStream::Entry &Entry,
713 const DwarfCompileUnit *CU);
715 /// Emit the location for a debug loc entry, including the size header.
716 void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry,
717 const DwarfCompileUnit *CU);
719 void addSubprogramNames(const DICompileUnit &CU, const DISubprogram *SP,
720 DIE &Die);
722 AddressPool &getAddressPool() { return AddrPool; }
724 void addAccelName(const DICompileUnit &CU, StringRef Name, const DIE &Die);
726 void addAccelObjC(const DICompileUnit &CU, StringRef Name, const DIE &Die);
728 void addAccelNamespace(const DICompileUnit &CU, StringRef Name,
729 const DIE &Die);
731 void addAccelType(const DICompileUnit &CU, StringRef Name, const DIE &Die,
732 char Flags);
734 const MachineFunction *getCurrentFunction() const { return CurFn; }
736 /// A helper function to check whether the DIE for a given Scope is
737 /// going to be null.
738 bool isLexicalScopeDIENull(LexicalScope *Scope);
740 /// Find the matching DwarfCompileUnit for the given CU DIE.
741 DwarfCompileUnit *lookupCU(const DIE *Die) { return CUDieMap.lookup(Die); }
742 const DwarfCompileUnit *lookupCU(const DIE *Die) const {
743 return CUDieMap.lookup(Die);
746 /// \defgroup DebuggerTuning Predicates to tune DWARF for a given debugger.
748 /// Returns whether we are "tuning" for a given debugger.
749 /// @{
750 bool tuneForGDB() const { return DebuggerTuning == DebuggerKind::GDB; }
751 bool tuneForLLDB() const { return DebuggerTuning == DebuggerKind::LLDB; }
752 bool tuneForSCE() const { return DebuggerTuning == DebuggerKind::SCE; }
753 /// @}
755 void addSectionLabel(const MCSymbol *Sym);
756 const MCSymbol *getSectionLabel(const MCSection *S);
758 static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT,
759 const DbgValueLoc &Value,
760 DwarfExpression &DwarfExpr);
763 } // end namespace llvm
765 #endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H