LLVM 24.0.0git
DwarfDebug.h
Go to the documentation of this file.
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.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
14#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
15
16#include "AddressPool.h"
17#include "DebugLocEntry.h"
18#include "DebugLocStream.h"
19#include "DwarfFile.h"
20#include "llvm/ADT/DenseMap.h"
21#include "llvm/ADT/DenseSet.h"
22#include "llvm/ADT/MapVector.h"
23#include "llvm/ADT/SetVector.h"
26#include "llvm/ADT/StringMap.h"
27#include "llvm/ADT/StringRef.h"
33#include "llvm/IR/DebugLoc.h"
34#include "llvm/IR/Metadata.h"
35#include "llvm/MC/MCDwarf.h"
38#include <cassert>
39#include <cstdint>
40#include <limits>
41#include <memory>
42#include <utility>
43#include <variant>
44#include <vector>
45
46namespace llvm {
47
48class AsmPrinter;
49class ByteStreamer;
50class DIE;
52class DwarfExpression;
53class DwarfTypeUnit;
54class DwarfUnit;
55class GlobalVariable;
56class LexicalScope;
57class MachineFunction;
58class MCSection;
59class MCSymbol;
60class Module;
61
62//===----------------------------------------------------------------------===//
63/// This class is defined as the common parent of DbgVariable and DbgLabel
64/// such that it could levarage polymorphism to extract common code for
65/// DbgVariable and DbgLabel.
66class DbgEntity {
67public:
72
73private:
74 const DINode *Entity;
75 const DILocation *InlinedAt;
76 DIE *TheDIE = nullptr;
77 const DbgEntityKind SubclassID;
78
79public:
80 DbgEntity(const DINode *N, const DILocation *IA, DbgEntityKind ID)
81 : Entity(N), InlinedAt(IA), SubclassID(ID) {}
82 virtual ~DbgEntity() = default;
83
84 /// Accessors.
85 /// @{
86 const DINode *getEntity() const { return Entity; }
87 const DILocation *getInlinedAt() const { return InlinedAt; }
88 DIE *getDIE() const { return TheDIE; }
89 DbgEntityKind getDbgEntityID() const { return SubclassID; }
90 /// @}
91
92 void setDIE(DIE &D) { TheDIE = &D; }
93
94 static bool classof(const DbgEntity *N) {
95 switch (N->getDbgEntityID()) {
96 case DbgVariableKind:
97 case DbgLabelKind:
98 return true;
99 }
100 llvm_unreachable("Invalid DbgEntityKind");
101 }
102};
103
104class DbgVariable;
105
106bool operator<(const struct FrameIndexExpr &LHS,
107 const struct FrameIndexExpr &RHS);
108bool operator<(const struct EntryValueInfo &LHS,
109 const struct EntryValueInfo &RHS);
110
111/// Proxy for one MMI entry.
113 int FI;
115
116 /// Operator enabling sorting based on fragment offset.
117 friend bool operator<(const FrameIndexExpr &LHS, const FrameIndexExpr &RHS);
118};
119
120/// Represents an entry-value location, or a fragment of one.
124
125 /// Operator enabling sorting based on fragment offset.
126 friend bool operator<(const EntryValueInfo &LHS, const EntryValueInfo &RHS);
127};
128
129// Namespace for alternatives of a DbgVariable.
130namespace Loc {
131/// Single value location description.
132class Single {
133 std::unique_ptr<DbgValueLoc> ValueLoc;
134 const DIExpression *Expr;
135
136public:
137 explicit Single(DbgValueLoc ValueLoc);
138 explicit Single(const MachineInstr *DbgValue);
139 const DbgValueLoc &getValueLoc() const { return *ValueLoc; }
140 const DIExpression *getExpr() const { return Expr; }
141};
142/// Multi-value location description.
143class Multi {
144 /// Index of the entry list in DebugLocs.
145 unsigned DebugLocListIndex;
146 /// DW_OP_LLVM_tag_offset value from DebugLocs.
147 std::optional<uint8_t> DebugLocListTagOffset;
148
149public:
150 explicit Multi(unsigned DebugLocListIndex,
151 std::optional<uint8_t> DebugLocListTagOffset)
152 : DebugLocListIndex(DebugLocListIndex),
153 DebugLocListTagOffset(DebugLocListTagOffset) {}
154 unsigned getDebugLocListIndex() const { return DebugLocListIndex; }
155 std::optional<uint8_t> getDebugLocListTagOffset() const {
156 return DebugLocListTagOffset;
157 }
158};
159/// Single location defined by (potentially multiple) MMI entries.
160struct MMI {
161 std::set<FrameIndexExpr> FrameIndexExprs;
162
163public:
164 explicit MMI(const DIExpression *E, int FI) : FrameIndexExprs({{FI, E}}) {
165 assert((!E || E->isValid()) && "Expected valid expression");
166 assert(FI != std::numeric_limits<int>::max() && "Expected valid index");
167 }
168 void addFrameIndexExpr(const DIExpression *Expr, int FI);
169 /// Get the FI entries, sorted by fragment offset.
170 const std::set<FrameIndexExpr> &getFrameIndexExprs() const;
171};
172/// Single location defined by (potentially multiple) EntryValueInfo.
174 std::set<EntryValueInfo> EntryValues;
175 explicit EntryValue(MCRegister Reg, const DIExpression &Expr) {
176 addExpr(Reg, Expr);
177 };
178 // Add the pair Reg, Expr to the list of entry values describing the variable.
179 // If multiple expressions are added, it is the callers responsibility to
180 // ensure they are all non-overlapping fragments.
181 void addExpr(MCRegister Reg, const DIExpression &Expr) {
182 std::optional<const DIExpression *> NonVariadicExpr =
184 assert(NonVariadicExpr && *NonVariadicExpr);
185
186 EntryValues.insert({Reg, **NonVariadicExpr});
187 }
188};
189/// Alias for the std::variant specialization base class of DbgVariable.
190using Variant = std::variant<std::monostate, Loc::Single, Loc::Multi, Loc::MMI,
192} // namespace Loc
193
194//===----------------------------------------------------------------------===//
195/// This class is used to track local variable information.
196///
197/// Variables that have been optimized out hold the \c monostate alternative.
198/// This is not distinguished from the case of a constructed \c DbgVariable
199/// which has not be initialized yet.
200///
201/// Variables can be created from allocas, in which case they're generated from
202/// the MMI table. Such variables hold the \c Loc::MMI alternative which can
203/// have multiple expressions and frame indices.
204///
205/// Variables can be created from the entry value of registers, in which case
206/// they're generated from the MMI table. Such variables hold the \c
207/// EntryValueLoc alternative which can either have a single expression or
208/// multiple *fragment* expressions.
209///
210/// Variables can be created from \c DBG_VALUE instructions. Those whose
211/// location changes over time hold a \c Loc::Multi alternative which uses \c
212/// DebugLocListIndex and (optionally) \c DebugLocListTagOffset, while those
213/// with a single location hold a \c Loc::Single alternative which use \c
214/// ValueLoc and (optionally) a single \c Expr.
215class DbgVariable : public DbgEntity, public Loc::Variant {
216
217public:
218 /// To workaround P2162R0 https://github.com/cplusplus/papers/issues/873 the
219 /// base class subobject needs to be passed directly to std::visit, so expose
220 /// it directly here.
221 Loc::Variant &asVariant() { return *static_cast<Loc::Variant *>(this); }
222 const Loc::Variant &asVariant() const {
223 return *static_cast<const Loc::Variant *>(this);
224 }
225 /// Member shorthand for std::holds_alternative
226 template <typename T> bool holds() const {
227 return std::holds_alternative<T>(*this);
228 }
229 /// Asserting, noexcept member alternative to std::get
230 template <typename T> auto &get() noexcept {
231 assert(holds<T>());
232 return *std::get_if<T>(this);
233 }
234 /// Asserting, noexcept member alternative to std::get
235 template <typename T> const auto &get() const noexcept {
236 assert(holds<T>());
237 return *std::get_if<T>(this);
238 }
239
240 /// Construct a DbgVariable.
241 ///
242 /// Creates a variable without any DW_AT_location.
245
246 // Accessors.
249 }
250
251 StringRef getName() const { return getVariable()->getName(); }
252
253 // Translate tag to proper Dwarf tag.
255 // FIXME: Why don't we just infer this tag and store it all along?
256 if (getVariable()->isParameter())
257 return dwarf::DW_TAG_formal_parameter;
258
259 return dwarf::DW_TAG_variable;
260 }
261
262 /// Return true if DbgVariable is artificial.
263 bool isArtificial() const {
264 if (getVariable()->isArtificial())
265 return true;
266 if (getType()->isArtificial())
267 return true;
268 return false;
269 }
270
271 bool isObjectPointer() const {
273 return true;
274 if (getType()->isObjectPointer())
275 return true;
276 return false;
277 }
278
279 const DIType *getType() const;
280
281 static bool classof(const DbgEntity *N) {
282 return N->getDbgEntityID() == DbgVariableKind;
283 }
284};
285
286//===----------------------------------------------------------------------===//
287/// This class is used to track label information.
288///
289/// Labels are collected from \c DBG_LABEL instructions.
290class DbgLabel : public DbgEntity {
291 const MCSymbol *Sym; /// Symbol before DBG_LABEL instruction.
292
293public:
294 /// We need MCSymbol information to generate DW_AT_low_pc.
295 DbgLabel(const DILabel *L, const DILocation *IA, const MCSymbol *Sym = nullptr)
296 : DbgEntity(L, IA, DbgLabelKind), Sym(Sym) {}
297
298 /// Accessors.
299 /// @{
300 const DILabel *getLabel() const { return cast<DILabel>(getEntity()); }
301 const MCSymbol *getSymbol() const { return Sym; }
302
303 StringRef getName() const { return getLabel()->getName(); }
304 /// @}
305
306 /// Translate tag to proper Dwarf tag.
308 return dwarf::DW_TAG_label;
309 }
310
311 static bool classof(const DbgEntity *N) {
312 return N->getDbgEntityID() == DbgLabelKind;
313 }
314};
315
316/// Used for tracking debug info about call site parameters.
318private:
319 unsigned Register; ///< Parameter register at the callee entry point.
320 DbgValueLoc Value; ///< Corresponding location for the parameter value at
321 ///< the call site.
322public:
324 : Register(Reg), Value(Val) {
325 assert(Reg && "Parameter register cannot be undef");
326 }
327
328 unsigned getRegister() const { return Register; }
329 DbgValueLoc getValue() const { return Value; }
330};
331
332/// Collection used for storing debug call site parameters.
334
335/// Helper used to pair up a symbol and its DWARF compile unit.
342
343/// The kind of accelerator tables we should emit.
344enum class AccelTableKind {
345 Default, ///< Platform default.
346 None, ///< None.
347 Apple, ///< .apple_names, .apple_namespaces, .apple_types, .apple_objc.
348 Dwarf, ///< DWARF v5 .debug_names.
349};
350
351/// Collects and handles dwarf debug information.
353 /// All DIEValues are allocated through this allocator.
354 BumpPtrAllocator DIEValueAllocator;
355
356 /// Maps MDNode with its corresponding DwarfCompileUnit.
358
359 /// Maps a CU DIE with its corresponding DwarfCompileUnit.
361
362 /// List of all labels used in aranges generation.
363 std::vector<SymbolCU> ArangeLabels;
364
365 /// Size of each symbol emitted (for those symbols that have a specific size).
367
368 /// Collection of abstract variables/labels.
369 SmallVector<std::unique_ptr<DbgEntity>, 64> ConcreteEntities;
370
371 /// Collection of DebugLocEntry. Stored in a linked list so that DIELocLists
372 /// can refer to them in spite of insertions into this list.
373 DebugLocStream DebugLocs;
374
375 /// This is a collection of subprogram MDNodes that are processed to
376 /// create DIEs.
378
379 /// Whether all functions of the module have been processed, so that it is
380 /// known which subprograms have abstract DIEs.
381 bool AllFunctionsProcessed = false;
382
383 /// Map function-local imported entities to their parent local scope
384 /// (either DILexicalBlock or DISubprogram) for a processed function
385 /// (including inlined subprograms).
389
390 SmallDenseSet<const MachineInstr *> ForceIsStmtInstrs;
391
392 /// If nonnull, stores the current machine function we're processing.
393 const MachineFunction *CurFn = nullptr;
394
395 /// If nonnull, stores the CU in which the previous subprogram was contained.
396 const DwarfCompileUnit *PrevCU = nullptr;
397
398 /// As an optimization, there is no need to emit an entry in the directory
399 /// table for the same directory as DW_AT_comp_dir.
400 StringRef CompilationDir;
401
402 /// Holders for the various debug information flags that we might need to
403 /// have exposed. See accessor functions below for description.
404
405 /// Map from MDNodes for user-defined types to their type signatures. Also
406 /// used to keep track of which types we have emitted type units for.
408
410
412 std::pair<std::unique_ptr<DwarfTypeUnit>, const DICompositeType *>, 1>
413 TypeUnitsUnderConstruction;
414
415 /// Symbol pointing to the current function's DWARF line table entries.
416 MCSymbol *FunctionLineTableLabel;
417
418 /// Used to set a uniqe ID for a Type Unit.
419 /// This counter represents number of DwarfTypeUnits created, not necessarily
420 /// number of type units that will be emitted.
421 unsigned NumTypeUnitsCreated = 0;
422
423 /// Whether to use the GNU TLS opcode (instead of the standard opcode).
424 bool UseGNUTLSOpcode;
425
426 /// Whether to use DWARF 2 bitfields (instead of the DWARF 4 format).
427 bool UseDWARF2Bitfields;
428
429 /// Whether to emit all linkage names, or just abstract subprograms.
430 bool UseAllLinkageNames;
431
432 /// Use inlined strings.
433 bool UseInlineStrings = false;
434
435 /// Allow emission of .debug_ranges section.
436 bool UseRangesSection = true;
437
438 /// True if the sections itself must be used as references and don't create
439 /// temp symbols inside DWARF sections.
440 bool UseSectionsAsReferences = false;
441
442 /// Allow emission of .debug_aranges section
443 bool UseARangesSection = false;
444
445 /// Generate DWARF v4 type units.
446 bool GenerateTypeUnits;
447
448 /// Emit a .debug_macro section instead of .debug_macinfo.
449 bool UseDebugMacroSection;
450
451 /// Avoid using DW_OP_convert due to consumer incompatibilities.
452 bool EnableOpConvert;
453
454public:
462
464 CU = 0,
465 TU = 1,
466 };
467
468private:
469 /// Instructions which should get is_stmt applied because they implement key
470 /// functionality for a source atom.
472
473 /// Force the use of DW_AT_ranges even for single-entry range lists.
474 MinimizeAddrInV5 MinimizeAddr = MinimizeAddrInV5::Disabled;
475
476 /// DWARF5 Experimental Options
477 /// @{
478 AccelTableKind TheAccelTableKind;
479 bool HasAppleExtensionAttributes;
480 bool HasSplitDwarf;
481
482 /// Whether to generate the DWARF v5 string offsets table.
483 /// It consists of a series of contributions, each preceded by a header.
484 /// The pre-DWARF v5 string offsets table for split dwarf is, in contrast,
485 /// a monolithic sequence of string offsets.
486 bool UseSegmentedStringOffsetsTable;
487
488 /// Enable production of call site parameters needed to print the debug entry
489 /// values. Useful for testing purposes when a debugger does not support the
490 /// feature yet.
491 bool EmitDebugEntryValues;
492
493 /// Separated Dwarf Variables
494 /// In general these will all be for bits that are left in the
495 /// original object file, rather than things that are meant
496 /// to be in the .dwo sections.
497
498 /// Holder for the skeleton information.
499 DwarfFile SkeletonHolder;
500
501 /// Store file names for type units under fission in a line table
502 /// header that will be emitted into debug_line.dwo.
503 // FIXME: replace this with a map from comp_dir to table so that we
504 // can emit multiple tables during LTO each of which uses directory
505 // 0, referencing the comp_dir of all the type units that use it.
506 MCDwarfDwoLineTable SplitTypeUnitFileTable;
507 /// @}
508
509 /// True iff there are multiple CUs in this module.
510 bool SingleCU;
511 bool IsDarwin;
512
513 AddressPool AddrPool;
514
515 /// Accelerator tables.
516 DWARF5AccelTable AccelDebugNames;
517 DWARF5AccelTable AccelTypeUnitsDebugNames;
518 /// Used to hide which DWARF5AccelTable we are using now.
519 DWARF5AccelTable *CurrentDebugNames = &AccelDebugNames;
524
525 /// Identify a debugger for "tuning" the debug info.
526 ///
527 /// The "tuning" should be used to set defaults for individual feature flags
528 /// in DwarfDebug; if a given feature has a more specific command-line option,
529 /// that option should take precedence over the tuning.
530 DebuggerKind DebuggerTuning = DebuggerKind::Default;
531
532 MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
533
534 using InlinedEntity = DbgValueHistoryMap::InlinedEntity;
535
536 void ensureAbstractEntityIsCreatedIfScoped(DwarfCompileUnit &CU,
537 const DINode *Node,
538 const MDNode *Scope);
539
540 DbgEntity *createConcreteEntity(DwarfCompileUnit &TheCU,
541 LexicalScope &Scope,
542 const DINode *Node,
543 const DILocation *Location,
544 const MCSymbol *Sym = nullptr);
545
546 /// Construct a DIE for this abstract scope.
547 void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU, LexicalScope *Scope);
548
549 /// Construct DIEs for call site entries describing the calls in \p MF.
550 void constructCallSiteEntryDIEs(const DISubprogram &SP, DwarfCompileUnit &CU,
551 DIE &ScopeDIE, const MachineFunction &MF);
552
553 template <typename DataT>
554 void addAccelNameImpl(const DwarfUnit &Unit,
555 const DICompileUnit::DebugNameTableKind NameTableKind,
556 AccelTable<DataT> &AppleAccel, StringRef Name,
557 const DIE &Die);
558
559 void finishEntityDefinitions();
560
561 void finishSubprogramDefinitions();
562
563 /// Finish off debug information after all functions have been
564 /// processed.
565 void finalizeModuleInfo();
566
567 /// Emit the debug info section.
568 void emitDebugInfo();
569
570 /// Emit the abbreviation section.
571 void emitAbbreviations();
572
573 /// Emit the string offsets table header.
574 void emitStringOffsetsTableHeader();
575
576 /// Emit a specified accelerator table.
577 template <typename AccelTableT>
578 void emitAccel(AccelTableT &Accel, MCSection *Section, StringRef TableName);
579
580 /// Emit DWARF v5 accelerator table.
581 void emitAccelDebugNames();
582
583 /// Emit visible names into a hashed accelerator table section.
584 void emitAccelNames();
585
586 /// Emit objective C classes and categories into a hashed
587 /// accelerator table section.
588 void emitAccelObjC();
589
590 /// Emit namespace dies into a hashed accelerator table.
591 void emitAccelNamespaces();
592
593 /// Emit type dies into a hashed accelerator table.
594 void emitAccelTypes();
595
596 /// Emit visible names and types into debug pubnames and pubtypes sections.
597 void emitDebugPubSections();
598
599 void emitDebugPubSection(bool GnuStyle, StringRef Name,
600 DwarfCompileUnit *TheU,
601 const StringMap<const DIE *> &Globals);
602
603 /// Emit null-terminated strings into a debug str section.
604 void emitDebugStr();
605
606 /// Emit variable locations into a debug loc section.
607 void emitDebugLoc();
608
609 /// Emit variable locations into a debug loc dwo section.
610 void emitDebugLocDWO();
611
612 void emitDebugLocImpl(MCSection *Sec);
613
614 /// Emit address ranges into a debug aranges section.
615 void emitDebugARanges();
616
617 /// Emit address ranges into a debug ranges section.
618 void emitDebugRanges();
619 void emitDebugRangesDWO();
620 void emitDebugRangesImpl(const DwarfFile &Holder, MCSection *Section);
621
622 /// Emit macros into a debug macinfo section.
623 void emitDebugMacinfo();
624 /// Emit macros into a debug macinfo.dwo section.
625 void emitDebugMacinfoDWO();
626 void emitDebugMacinfoImpl(MCSection *Section);
627 void emitMacro(DIMacro &M);
628 void emitMacroFile(DIMacroFile &F, DwarfCompileUnit &U);
629 void emitMacroFileImpl(DIMacroFile &F, DwarfCompileUnit &U,
630 unsigned StartFile, unsigned EndFile,
631 StringRef (*MacroFormToString)(unsigned Form));
632 void handleMacroNodes(DIMacroNodeArray Nodes, DwarfCompileUnit &U);
633
634 /// DWARF 5 Experimental Split Dwarf Emitters
635
636 /// Initialize common features of skeleton units.
637 void initSkeletonUnit(const DwarfUnit &U, DIE &Die,
638 std::unique_ptr<DwarfCompileUnit> NewU);
639
640 /// Construct the split debug info compile unit for the debug info section.
641 /// In DWARF v5, the skeleton unit DIE may have the following attributes:
642 /// DW_AT_addr_base, DW_AT_comp_dir, DW_AT_dwo_name, DW_AT_high_pc,
643 /// DW_AT_low_pc, DW_AT_ranges, DW_AT_stmt_list, and DW_AT_str_offsets_base.
644 /// Prior to DWARF v5 it may also have DW_AT_GNU_dwo_id. DW_AT_GNU_dwo_name
645 /// is used instead of DW_AT_dwo_name, Dw_AT_GNU_addr_base instead of
646 /// DW_AT_addr_base, and DW_AT_GNU_ranges_base instead of DW_AT_rnglists_base.
647 DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU);
648
649 /// Emit the debug info dwo section.
650 void emitDebugInfoDWO();
651
652 /// Emit the debug abbrev dwo section.
653 void emitDebugAbbrevDWO();
654
655 /// Emit the debug line dwo section.
656 void emitDebugLineDWO();
657
658 /// Emit the dwo stringoffsets table header.
659 void emitStringOffsetsTableHeaderDWO();
660
661 /// Emit the debug str dwo section.
662 void emitDebugStrDWO();
663
664 /// Emit DWO addresses.
665 void emitDebugAddr();
666
667 /// Flags to let the linker know we have emitted new style pubnames. Only
668 /// emit it here if we don't have a skeleton CU for split dwarf.
669 void addGnuPubAttributes(DwarfCompileUnit &U, DIE &D) const;
670
671 DwarfCompileUnit *getDwarfCompileUnit(const DICompileUnit *DIUnit);
672 /// Create new DwarfCompileUnit for the given metadata node with tag
673 /// DW_TAG_compile_unit.
674 DwarfCompileUnit &getOrCreateDwarfCompileUnit(const DICompileUnit *DIUnit);
675 void finishUnitAttributes(const DICompileUnit *DIUnit,
676 DwarfCompileUnit &NewCU);
677
678 /// Register a source line with debug info. Returns the unique
679 /// label that was emitted and which provides correspondence to the
680 /// source line list.
681 void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
682 unsigned Flags, StringRef Location = {});
683
684 /// Populate LexicalScope entries with variables' info.
685 void collectEntityInfo(DwarfCompileUnit &TheCU, const DISubprogram *SP,
686 DenseSet<InlinedEntity> &ProcessedVars);
687
688 /// Build the location list for all DBG_VALUEs in the
689 /// function that describe the same variable. If the resulting
690 /// list has only one entry that is valid for entire variable's
691 /// scope return true.
692 bool buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
693 const DbgValueHistoryMap::Entries &Entries);
694
695 /// Collect variable information from the side table maintained by MF.
696 void collectVariableInfoFromMFTable(DwarfCompileUnit &TheCU,
697 DenseSet<InlinedEntity> &P);
698
699 /// Emit the reference to the section.
700 void emitSectionReference(const DwarfCompileUnit &CU);
701
702 void findForceIsStmtInstrs(const MachineFunction *MF);
703
704 /// Compute instructions which should get is_stmt applied because they
705 /// implement key functionality for a source location atom, store results in
706 /// DwarfDebug::KeyInstructions.
707 void computeKeyInstructions(const MachineFunction *MF);
708
709protected:
710 /// Holder for the file specific debug information.
712 /// Gather pre-function debug information.
713 void beginFunctionImpl(const MachineFunction *MF) override;
714
715 /// Gather and emit post-function debug information.
716 void endFunctionImpl(const MachineFunction *MF) override;
717
718 /// Get Dwarf compile unit ID for line table.
720
721 void skippedNonDebugFunction() override;
722
723 /// Target-specific debug info initialization at function start.
725
726 /// Setters for target-specific DWARF configuration overrides.
727 /// Called from target DwarfDebug subclass constructors.
728 void setUseInlineStrings(bool V) { UseInlineStrings = V; }
729 void setUseRangesSection(bool V) { UseRangesSection = V; }
730 void setUseSectionsAsReferences(bool V) { UseSectionsAsReferences = V; }
731
732 /// Whether to attach ranges/low_pc to the compile unit DIE in endModule.
733 virtual bool shouldAttachCompileUnitRanges() const { return true; }
734
735 /// Target-specific source line recording.
736 virtual void recordTargetSourceLine(const DebugLoc &DL, unsigned Flags);
737
738 /// Target-specific compile unit attribute finalization.
739 virtual void finishTargetUnitAttributes(const DICompileUnit &DIUnit,
740 DwarfCompileUnit &NewCU) {}
741
745
746public:
747 //===--------------------------------------------------------------------===//
748 // Target hooks for debug info customization.
749 //
750
751 /// Whether the target requires resetting the base address in range/loc lists.
752 virtual bool shouldResetBaseAddress(const MCSection &Section) const {
753 return false;
754 }
755
756 /// Describes the storage kind of a debug variable for target hooks.
758
759 /// Extract target-specific address space information from a DIExpression.
760 /// Targets may strip address-space-encoding ops from the expression and
761 /// return the address space via \p TargetAddrSpace.
762 virtual const DIExpression *
764 std::optional<unsigned> &TargetAddrSpace) const {
765 return Expr;
766 }
767
768 /// Add target-specific attributes to a variable DIE (e.g.
769 /// DW_AT_address_class).
770 virtual void
772 std::optional<unsigned> TargetAddrSpace,
773 VariableLocationKind VarLocKind,
774 const GlobalVariable *GV = nullptr) const {}
775
776 //===--------------------------------------------------------------------===//
777 // Main entry points.
778 //
780
781 ~DwarfDebug() override;
782
783 /// Emit all Dwarf sections that should come prior to the
784 /// content.
785 void beginModule(Module *M) override;
786
787 /// Emit all Dwarf sections that should come after the content.
788 void endModule() override;
789
790 /// Emits inital debug location directive. Returns instruction at which
791 /// the function prologue ends.
793 unsigned CUID);
794
795 /// Process beginning of an instruction.
796 void beginInstruction(const MachineInstr *MI) override;
797
798 /// Process beginning of code alignment.
799 void beginCodeAlignment(const MachineBasicBlock &MBB) override;
800
801 /// Perform an MD5 checksum of \p Identifier and return the lower 64 bits.
802 static uint64_t makeTypeSignature(StringRef Identifier);
803
804 /// Add a DIE to the set of types that we're going to pull into
805 /// type units.
807 DIE &Die, const DICompositeType *CTy);
808
809 /// Add a label so that arange data can be generated for it.
810 void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
811
812 /// For symbols that have a size designated (e.g. common symbols),
813 /// this tracks that size.
814 void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {
815 SymSize[Sym] = Size;
816 }
817
818 /// Whether to emit .debug_pubnames / .debug_pubtypes. Default true;
819 virtual bool shouldEmitDwarfPubSections() const { return true; }
820
821 /// Returns whether we should emit all DW_AT_[MIPS_]linkage_name.
822 /// If not, we still might emit certain cases.
823 bool useAllLinkageNames() const { return UseAllLinkageNames; }
824
825 /// Returns whether to use DW_OP_GNU_push_tls_address, instead of the
826 /// standard DW_OP_form_tls_address opcode
827 bool useGNUTLSOpcode() const { return UseGNUTLSOpcode; }
828
829 /// Returns whether to use the DWARF2 format for bitfields instyead of the
830 /// DWARF4 format.
831 bool useDWARF2Bitfields() const { return UseDWARF2Bitfields; }
832
833 /// Returns whether to use inline strings.
834 bool useInlineStrings() const { return UseInlineStrings; }
835
836 /// Returns whether ranges section should be emitted.
837 bool useRangesSection() const { return UseRangesSection; }
838
839 /// Returns whether range encodings should be used for single entry range
840 /// lists.
841 bool alwaysUseRanges(const DwarfCompileUnit &) const;
842
843 // Returns whether novel exprloc addrx+offset encodings should be used to
844 // reduce debug_addr size.
846 return MinimizeAddr == MinimizeAddrInV5::Expressions;
847 }
848
849 // Returns whether addrx+offset LLVM extension form should be used to reduce
850 // debug_addr size.
851 bool useAddrOffsetForm() const {
852 return MinimizeAddr == MinimizeAddrInV5::Form;
853 }
854
855 /// Returns whether to use sections as labels rather than temp symbols.
857 return UseSectionsAsReferences;
858 }
859
860 /// Returns whether to generate DWARF v4 type units.
861 bool generateTypeUnits() const { return GenerateTypeUnits; }
862
863 // Experimental DWARF5 features.
864
865 /// Returns what kind (if any) of accelerator tables to emit.
866 AccelTableKind getAccelTableKind() const { return TheAccelTableKind; }
867
868 /// Seet TheAccelTableKind
869 void setTheAccelTableKind(AccelTableKind K) { TheAccelTableKind = K; };
870
872 return HasAppleExtensionAttributes;
873 }
874
875 /// Returns whether or not to change the current debug info for split DWARF.
876 bool useSplitDwarf() const { return HasSplitDwarf; }
877
878 /// Returns whether to generate a string offsets table with (possibly shared)
879 /// contributions from each CU and type unit. This implies the use of
880 /// DW_FORM_strx* indirect references with DWARF v5 and beyond. Note that
881 /// DW_FORM_GNU_str_index is also an indirect reference, but it is used with
882 /// a pre-DWARF v5 implementation of split DWARF sections, which uses a
883 /// monolithic string offsets table.
885 return UseSegmentedStringOffsetsTable;
886 }
887
888 bool emitDebugEntryValues() const {
889 return EmitDebugEntryValues;
890 }
891
892 bool useOpConvert() const {
893 return EnableOpConvert;
894 }
895
896 bool shareAcrossDWOCUs() const;
897
898 /// Returns the Dwarf Version.
900
901 /// Returns a suitable DWARF form to represent a section offset, i.e.
902 /// * DW_FORM_sec_offset for DWARF version >= 4;
903 /// * DW_FORM_data8 for 64-bit DWARFv3;
904 /// * DW_FORM_data4 for 32-bit DWARFv3 and DWARFv2.
906
907 /// Returns the previous CU that was being updated
908 const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
909 void setPrevCU(const DwarfCompileUnit *PrevCU) { this->PrevCU = PrevCU; }
910
911 /// Terminate the line table by adding the last range label.
913
914 /// Returns the entries for the .debug_loc section.
915 const DebugLocStream &getDebugLocs() const { return DebugLocs; }
916
917 /// Emit an entry for the debug loc section. This can be used to
918 /// handle an entry that's going to be emitted into the debug loc section.
920 const DebugLocStream::Entry &Entry,
921 const DwarfCompileUnit *CU);
922
923 /// Emit the location for a debug loc entry, including the size header.
925 const DwarfCompileUnit *CU);
926
927 void addSubprogramNames(const DwarfUnit &Unit,
928 const DICompileUnit::DebugNameTableKind NameTableKind,
929 const DISubprogram *SP, DIE &Die);
930
931 AddressPool &getAddressPool() { return AddrPool; }
932
933 void addAccelName(const DwarfUnit &Unit,
934 const DICompileUnit::DebugNameTableKind NameTableKind,
935 StringRef Name, const DIE &Die);
936
937 void addAccelObjC(const DwarfUnit &Unit,
938 const DICompileUnit::DebugNameTableKind NameTableKind,
939 StringRef Name, const DIE &Die);
940
941 void addAccelNamespace(const DwarfUnit &Unit,
942 const DICompileUnit::DebugNameTableKind NameTableKind,
943 StringRef Name, const DIE &Die);
944
945 void addAccelType(const DwarfUnit &Unit,
946 const DICompileUnit::DebugNameTableKind NameTableKind,
947 StringRef Name, const DIE &Die, char Flags);
948
949 const MachineFunction *getCurrentFunction() const { return CurFn; }
950
951 /// A helper function to check whether the DIE for a given Scope is
952 /// going to be null.
954
955 /// Find the matching DwarfCompileUnit for the given CU DIE.
956 DwarfCompileUnit *lookupCU(const DIE *Die) { return CUDieMap.lookup(Die); }
957 const DwarfCompileUnit *lookupCU(const DIE *Die) const {
958 return CUDieMap.lookup(Die);
959 }
960
961 /// Find the matching DwarfCompileUnit for the given SP referenced from SrcCU.
963 DwarfCompileUnit &SrcCU);
964
965 /// Returns whether all functions of the module have been processed, so that
966 /// abstract subprogram DIEs are not created for inlined subprograms anymore.
967 bool allFunctionsProcessed() const { return AllFunctionsProcessed; }
968
969 /// Returns whether a DIE for the function of \p SP has been constructed.
970 bool isProcessedSubprogram(const DISubprogram *SP) const {
971 return ProcessedSPNodes.contains(SP);
972 }
973
974 /// \defgroup DebuggerTuning Predicates to tune DWARF for a given debugger.
975 ///
976 /// Returns whether we are "tuning" for a given debugger.
977 /// @{
978 bool tuneForGDB() const { return DebuggerTuning == DebuggerKind::GDB; }
979 bool tuneForLLDB() const { return DebuggerTuning == DebuggerKind::LLDB; }
980 bool tuneForSCE() const { return DebuggerTuning == DebuggerKind::SCE; }
981 bool tuneForDBX() const { return DebuggerTuning == DebuggerKind::DBX; }
982 /// @}
983
984 const MCSymbol *getSectionLabel(const MCSection *S);
985 void insertSectionLabel(const MCSymbol *S);
986
987 static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT,
988 const DbgValueLoc &Value,
989 DwarfExpression &DwarfExpr);
990
991 /// If the \p File has an MD5 checksum, return it as an MD5Result
992 /// allocated in the MCContext.
993 std::optional<MD5::MD5Result> getMD5AsBytes(const DIFile *File) const;
994
995 MDNodeSet &getLocalDeclsForScope(const DILocalScope *S) {
996 return LocalDeclsPerLS[S];
997 }
998
999 /// Sets the current DWARF5AccelTable to use.
1001 switch (Kind) {
1003 CurrentDebugNames = &AccelDebugNames;
1004 break;
1006 CurrentDebugNames = &AccelTypeUnitsDebugNames;
1007 }
1008 }
1009 /// Returns either CU or TU DWARF5AccelTable.
1010 DWARF5AccelTable &getCurrentDWARF5AccelTable() { return *CurrentDebugNames; }
1011};
1012
1013} // end namespace llvm
1014
1015#endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
aarch64 promote const
This file defines the StringMap class.
uint64_t uint64_t
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains support for writing accelerator tables.
This file defines the BumpPtrAllocator interface.
BitTracker BT
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
static void recordSourceLine(AsmPrinter &Asm, unsigned Line, unsigned Col, const MDNode *S, unsigned Flags, unsigned CUID, uint16_t DwarfVersion, ArrayRef< std::unique_ptr< DwarfCompileUnit > > DCUs, StringRef Comment={})
Register a source line with debug info.
This file contains constants used for implementing Dwarf debug support.
IRTranslator LLVM IR MI
#define F(x, y, z)
Definition MD5.cpp:54
Register Reg
This file implements a map that provides insertion order iteration.
This file contains the declarations for metadata subclasses.
#define P(N)
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
std::unique_ptr< MCStreamer > && Streamer
Value * RHS
Value * LHS
Class recording the (high level) value of a variable.
This class holds an abstract representation of an Accelerator Table, consisting of a sequence of buck...
Definition AccelTable.h:203
This class is intended to be used as a driving class for all asm writers.
Definition AsmPrinter.h:95
Basic type, like 'int' or 'float'.
A structured debug information entry.
Definition DIE.h:835
DWARF expression.
static LLVM_ABI std::optional< const DIExpression * > convertToNonVariadicExpression(const DIExpression *Expr)
If Expr is a valid single-location expression, i.e.
StringRef getName() const
A scope for locals.
Tagged DWARF-like metadata node.
Subprogram description. Uses SubclassData1.
Base class for types.
StringRef getName() const
unsigned getRegister() const
Definition DwarfDebug.h:328
DbgCallSiteParam(unsigned Reg, DbgValueLoc Val)
Definition DwarfDebug.h:323
DbgValueLoc getValue() const
Definition DwarfDebug.h:329
This class is defined as the common parent of DbgVariable and DbgLabel such that it could levarage po...
Definition DwarfDebug.h:66
virtual ~DbgEntity()=default
static bool classof(const DbgEntity *N)
Definition DwarfDebug.h:94
const DINode * getEntity() const
Accessors.
Definition DwarfDebug.h:86
DbgEntityKind getDbgEntityID() const
Definition DwarfDebug.h:89
void setDIE(DIE &D)
Definition DwarfDebug.h:92
DIE * getDIE() const
Definition DwarfDebug.h:88
DbgEntity(const DINode *N, const DILocation *IA, DbgEntityKind ID)
Definition DwarfDebug.h:80
const DILocation * getInlinedAt() const
Definition DwarfDebug.h:87
dwarf::Tag getTag() const
Translate tag to proper Dwarf tag.
Definition DwarfDebug.h:307
static bool classof(const DbgEntity *N)
Definition DwarfDebug.h:311
DbgLabel(const DILabel *L, const DILocation *IA, const MCSymbol *Sym=nullptr)
Symbol before DBG_LABEL instruction.
Definition DwarfDebug.h:295
StringRef getName() const
Definition DwarfDebug.h:303
const MCSymbol * getSymbol() const
Definition DwarfDebug.h:301
const DILabel * getLabel() const
Accessors.
Definition DwarfDebug.h:300
std::pair< const DINode *, const DILocation * > InlinedEntity
The location of a single variable, composed of an expression and 0 or more DbgValueLocEntries.
const Loc::Variant & asVariant() const
Definition DwarfDebug.h:222
bool isArtificial() const
Return true if DbgVariable is artificial.
Definition DwarfDebug.h:263
dwarf::Tag getTag() const
Definition DwarfDebug.h:254
bool isObjectPointer() const
Definition DwarfDebug.h:271
const DILocalVariable * getVariable() const
Definition DwarfDebug.h:247
DbgVariable(const DILocalVariable *V, const DILocation *IA)
Construct a DbgVariable.
Definition DwarfDebug.h:243
auto & get() noexcept
Asserting, noexcept member alternative to std::get.
Definition DwarfDebug.h:230
StringRef getName() const
Definition DwarfDebug.h:251
const DIType * getType() const
const auto & get() const noexcept
Asserting, noexcept member alternative to std::get.
Definition DwarfDebug.h:235
Loc::Variant & asVariant()
To workaround P2162R0 https://github.com/cplusplus/papers/issues/873 the base class subobject needs t...
Definition DwarfDebug.h:221
static bool classof(const DbgEntity *N)
Definition DwarfDebug.h:281
bool holds() const
Member shorthand for std::holds_alternative.
Definition DwarfDebug.h:226
Byte stream of .debug_loc entries.
A debug info location.
Definition DebugLoc.h:126
virtual const DIExpression * adjustExpressionForTarget(const DIExpression *Expr, std::optional< unsigned > &TargetAddrSpace) const
Extract target-specific address space information from a DIExpression.
Definition DwarfDebug.h:763
bool useSegmentedStringOffsetsTable() const
Returns whether to generate a string offsets table with (possibly shared) contributions from each CU ...
Definition DwarfDebug.h:884
virtual bool shouldResetBaseAddress(const MCSection &Section) const
Whether the target requires resetting the base address in range/loc lists.
Definition DwarfDebug.h:752
MDNodeSet & getLocalDeclsForScope(const DILocalScope *S)
Definition DwarfDebug.h:995
std::optional< MD5::MD5Result > getMD5AsBytes(const DIFile *File) const
If the File has an MD5 checksum, return it as an MD5Result allocated in the MCContext.
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:827
bool isProcessedSubprogram(const DISubprogram *SP) const
Returns whether a DIE for the function of SP has been constructed.
Definition DwarfDebug.h:970
bool useAddrOffsetForm() const
Definition DwarfDebug.h:851
const DwarfCompileUnit * getPrevCU() const
Returns the previous CU that was being updated.
Definition DwarfDebug.h:908
bool allFunctionsProcessed() const
Returns whether all functions of the module have been processed, so that abstract subprogram DIEs are...
Definition DwarfDebug.h:967
void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override
For symbols that have a size designated (e.g.
Definition DwarfDebug.h:814
virtual bool shouldAttachCompileUnitRanges() const
Whether to attach ranges/low_pc to the compile unit DIE in endModule.
Definition DwarfDebug.h:733
bool emitDebugEntryValues() const
Definition DwarfDebug.h:888
const DwarfCompileUnit * lookupCU(const DIE *Die) const
Definition DwarfDebug.h:957
uint16_t getDwarfVersion() const
Returns the Dwarf Version.
void emitDebugLocEntry(ByteStreamer &Streamer, const DebugLocStream::Entry &Entry, const DwarfCompileUnit *CU)
Emit an entry for the debug loc section.
void addAccelNamespace(const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const DIE &Die)
void setCurrentDWARF5AccelTable(const DWARF5AccelTableKind Kind)
Sets the current DWARF5AccelTable to use.
bool alwaysUseRanges(const DwarfCompileUnit &) const
Returns whether range encodings should be used for single entry range lists.
void beginModule(Module *M) override
Emit all Dwarf sections that should come prior to the content.
void addSubprogramNames(const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, const DISubprogram *SP, DIE &Die)
bool useAllLinkageNames() const
Returns whether we should emit all DW_AT_[MIPS_]linkage_name.
Definition DwarfDebug.h:823
void insertSectionLabel(const MCSymbol *S)
void addAccelObjC(const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const DIE &Die)
VariableLocationKind
Describes the storage kind of a debug variable for target hooks.
Definition DwarfDebug.h:757
dwarf::Form getDwarfSectionOffsetForm() const
Returns a suitable DWARF form to represent a section offset, i.e.
bool useAppleExtensionAttributes() const
Definition DwarfDebug.h:871
void setPrevCU(const DwarfCompileUnit *PrevCU)
Definition DwarfDebug.h:909
const MachineFunction * getCurrentFunction() const
Definition DwarfDebug.h:949
void skippedNonDebugFunction() override
bool useInlineStrings() const
Returns whether to use inline strings.
Definition DwarfDebug.h:834
void addArangeLabel(SymbolCU SCU)
Add a label so that arange data can be generated for it.
Definition DwarfDebug.h:810
bool generateTypeUnits() const
Returns whether to generate DWARF v4 type units.
Definition DwarfDebug.h:861
virtual void finishTargetUnitAttributes(const DICompileUnit &DIUnit, DwarfCompileUnit &NewCU)
Target-specific compile unit attribute finalization.
Definition DwarfDebug.h:739
void beginInstruction(const MachineInstr *MI) override
Process beginning of an instruction.
AddressPool & getAddressPool()
Definition DwarfDebug.h:931
DWARF5AccelTable & getCurrentDWARF5AccelTable()
Returns either CU or TU DWARF5AccelTable.
void setUseSectionsAsReferences(bool V)
Definition DwarfDebug.h:730
bool useSectionsAsReferences() const
Returns whether to use sections as labels rather than temp symbols.
Definition DwarfDebug.h:856
const DebugLocStream & getDebugLocs() const
Returns the entries for the .debug_loc section.
Definition DwarfDebug.h:915
void setUseRangesSection(bool V)
Definition DwarfDebug.h:729
bool shareAcrossDWOCUs() const
bool useOpConvert() const
Definition DwarfDebug.h:892
void terminateLineTable(const DwarfCompileUnit *CU)
Terminate the line table by adding the last range label.
~DwarfDebug() override
void endFunctionImpl(const MachineFunction *MF) override
Gather and emit post-function debug information.
DwarfCompileUnit & getOrCreateAbstractSubprogramCU(const DISubprogram *SP, DwarfCompileUnit &SrcCU)
Find the matching DwarfCompileUnit for the given SP referenced from SrcCU.
void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry, const DwarfCompileUnit *CU)
Emit the location for a debug loc entry, including the size header.
const SmallVectorImpl< std::unique_ptr< DwarfCompileUnit > > & getUnits()
Definition DwarfDebug.h:742
DwarfCompileUnit * lookupCU(const DIE *Die)
Find the matching DwarfCompileUnit for the given CU DIE.
Definition DwarfDebug.h:956
const MCSymbol * getSectionLabel(const MCSection *S)
static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT, const DbgValueLoc &Value, DwarfExpression &DwarfExpr)
bool useSplitDwarf() const
Returns whether or not to change the current debug info for split DWARF.
Definition DwarfDebug.h:876
virtual void addTargetVariableAttributes(DwarfCompileUnit &CU, DIE &Die, std::optional< unsigned > TargetAddrSpace, VariableLocationKind VarLocKind, const GlobalVariable *GV=nullptr) const
Add target-specific attributes to a variable DIE (e.g.
Definition DwarfDebug.h:771
virtual void initializeTargetDebugInfo(const MachineFunction &MF)
Target-specific debug info initialization at function start.
Definition DwarfDebug.h:724
unsigned getDwarfCompileUnitIDForLineTable(const DwarfCompileUnit &CU)
Get Dwarf compile unit ID for line table.
virtual bool shouldEmitDwarfPubSections() const
Whether to emit .debug_pubnames / .debug_pubtypes. Default true;.
Definition DwarfDebug.h:819
const MachineInstr * emitInitialLocDirective(const MachineFunction &MF, unsigned CUID)
Emits inital debug location directive.
void setTheAccelTableKind(AccelTableKind K)
Seet TheAccelTableKind.
Definition DwarfDebug.h:869
bool useDWARF2Bitfields() const
Returns whether to use the DWARF2 format for bitfields instyead of the DWARF4 format.
Definition DwarfDebug.h:831
bool useAddrOffsetExpressions() const
Definition DwarfDebug.h:845
bool useRangesSection() const
Returns whether ranges section should be emitted.
Definition DwarfDebug.h:837
void addAccelName(const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const DIE &Die)
virtual void recordTargetSourceLine(const DebugLoc &DL, unsigned Flags)
Target-specific source line recording.
bool isLexicalScopeDIENull(LexicalScope *Scope)
A helper function to check whether the DIE for a given Scope is going to be null.
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.
DwarfFile InfoHolder
Holder for the file specific debug information.
Definition DwarfDebug.h:711
void endModule() override
Emit all Dwarf sections that should come after the content.
void setUseInlineStrings(bool V)
Setters for target-specific DWARF configuration overrides.
Definition DwarfDebug.h:728
void addAccelType(const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const DIE &Die, char Flags)
void beginCodeAlignment(const MachineBasicBlock &MBB) override
Process beginning of code alignment.
DwarfDebug(AsmPrinter *A)
void beginFunctionImpl(const MachineFunction *MF) override
Gather pre-function debug information.
AccelTableKind getAccelTableKind() const
Returns what kind (if any) of accelerator tables to emit.
Definition DwarfDebug.h:866
static uint64_t makeTypeSignature(StringRef Identifier)
Perform an MD5 checksum of Identifier and return the lower 64 bits.
Base class containing the logic for constructing DWARF expressions independently of whether they are ...
This dwarf writer support class manages information associated with a source file.
Definition DwarfUnit.h:36
This class is used to track scope information.
Multi-value location description.
Definition DwarfDebug.h:143
Multi(unsigned DebugLocListIndex, std::optional< uint8_t > DebugLocListTagOffset)
Definition DwarfDebug.h:150
unsigned getDebugLocListIndex() const
Definition DwarfDebug.h:154
std::optional< uint8_t > getDebugLocListTagOffset() const
Definition DwarfDebug.h:155
Single value location description.
Definition DwarfDebug.h:132
Single(DbgValueLoc ValueLoc)
const DbgValueLoc & getValueLoc() const
Definition DwarfDebug.h:139
const DIExpression * getExpr() const
Definition DwarfDebug.h:140
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition MCSection.h:580
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
Metadata node.
Definition Metadata.h:1081
Representation of each machine instruction.
This class implements a map that also provides access to all stored values in a deterministic order.
Definition MapVector.h:39
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
A vector that has set insertion semantics.
Definition SetVector.h:57
Implements a dense probed hash-table based set with some number of buckets stored inline.
Definition DenseSet.h:295
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
A SetVector that performs no allocations if smaller than a certain size.
Definition SetVector.h:346
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition StringMap.h:129
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
LLVM Value Representation.
Definition Value.h:75
bool tuneForSCE() const
Definition DwarfDebug.h:980
bool tuneForDBX() const
Definition DwarfDebug.h:981
bool tuneForGDB() const
Definition DwarfDebug.h:978
bool tuneForLLDB() const
Definition DwarfDebug.h:979
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
std::variant< std::monostate, Loc::Single, Loc::Multi, Loc::MMI, Loc::EntryValue > Variant
Alias for the std::variant specialization base class of DbgVariable.
Definition DwarfDebug.h:190
This is an optimization pass for GlobalISel generic memory operations.
bool operator<(int64_t V1, const APSInt &V2)
Definition APSInt.h:360
SmallVector< DbgCallSiteParam, 4 > ParamSet
Collection used for storing debug call site parameters.
Definition DwarfDebug.h:333
AccelTableKind
The kind of accelerator tables we should emit.
Definition DwarfDebug.h:344
@ Apple
.apple_names, .apple_namespaces, .apple_types, .apple_objc.
Definition DwarfDebug.h:347
@ Dwarf
DWARF v5 .debug_names.
Definition DwarfDebug.h:348
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
DebuggerKind
Identify a debugger for "tuning" the debug info.
Definition CodeGen.h:231
@ SCE
Tune debug info for SCE targets (e.g. PS4).
Definition CodeGen.h:235
@ DBX
Tune debug info for dbx.
Definition CodeGen.h:236
@ Default
No specific tuning requested.
Definition CodeGen.h:232
@ GDB
Tune debug info for gdb.
Definition CodeGen.h:233
@ LLDB
Tune debug info for lldb.
Definition CodeGen.h:234
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:391
#define N
Represents an entry-value location, or a fragment of one.
Definition DwarfDebug.h:121
friend bool operator<(const EntryValueInfo &LHS, const EntryValueInfo &RHS)
Operator enabling sorting based on fragment offset.
const DIExpression & Expr
Definition DwarfDebug.h:123
Proxy for one MMI entry.
Definition DwarfDebug.h:112
const DIExpression * Expr
Definition DwarfDebug.h:114
friend bool operator<(const FrameIndexExpr &LHS, const FrameIndexExpr &RHS)
Operator enabling sorting based on fragment offset.
Single location defined by (potentially multiple) EntryValueInfo.
Definition DwarfDebug.h:173
void addExpr(MCRegister Reg, const DIExpression &Expr)
Definition DwarfDebug.h:181
std::set< EntryValueInfo > EntryValues
Definition DwarfDebug.h:174
EntryValue(MCRegister Reg, const DIExpression &Expr)
Definition DwarfDebug.h:175
Single location defined by (potentially multiple) MMI entries.
Definition DwarfDebug.h:160
void addFrameIndexExpr(const DIExpression *Expr, int FI)
std::set< FrameIndexExpr > FrameIndexExprs
Definition DwarfDebug.h:161
const std::set< FrameIndexExpr > & getFrameIndexExprs() const
Get the FI entries, sorted by fragment offset.
MMI(const DIExpression *E, int FI)
Definition DwarfDebug.h:164
Helper used to pair up a symbol and its DWARF compile unit.
Definition DwarfDebug.h:336
const MCSymbol * Sym
Definition DwarfDebug.h:339
SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym)
Definition DwarfDebug.h:337