LLVM 24.0.0git
DwarfUnit.h
Go to the documentation of this file.
1//===-- llvm/CodeGen/DwarfUnit.h - Dwarf Compile Unit ---*- 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 compile unit.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFUNIT_H
14#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFUNIT_H
15
16#include "DwarfDebug.h"
17#include "llvm/ADT/DenseMap.h"
19#include "llvm/CodeGen/DIE.h"
22#include <optional>
23#include <string>
24
25namespace llvm {
26
27class ConstantFP;
28class ConstantInt;
31class MCSymbol;
32
33//===----------------------------------------------------------------------===//
34/// This dwarf writer support class manages information associated with a
35/// source file.
36class DwarfUnit : public DIEUnit {
37protected:
38 /// A numeric ID unique among all CUs in the module
39 unsigned UniqueID;
40 /// MDNode for the compile unit.
42
43 // All DIEValues are allocated through this allocator.
45
46 /// Target of Dwarf emission.
48
49 /// The start of the unit within its section.
50 MCSymbol *LabelBegin = nullptr;
51
52 /// Emitted at the end of the CU and used to compute the CU Length field.
53 MCSymbol *EndLabel = nullptr;
54
55 // Holders for some common dwarf information.
58
59 /// An anonymous type for index type. Owned by DIEUnit.
60 DIE *IndexTyDie = nullptr;
61
62 /// Tracks the mapping of unit level debug information variables to debug
63 /// information entries.
65
66 /// A list of all the DIEBlocks in use.
67 std::vector<DIEBlock *> DIEBlocks;
68
69 /// A list of all the DIELocs in use.
70 std::vector<DIELoc *> DIELocs;
71
72 /// This map is used to keep track of subprogram DIEs that need
73 /// DW_AT_containing_type attribute. This attribute points to a DIE that
74 /// corresponds to the MDNode mapped with the subprogram DIE.
77
79 DwarfDebug *DW, DwarfFile *DWU, unsigned UniqueID = 0);
80
81 bool applySubprogramDefinitionAttributes(const DISubprogram *SP, DIE &SPDie, bool Minimal);
82
83 bool isShareableAcrossCUs(const DINode *D) const;
84
85 template <typename T>
87 dwarf::Form Form, T &&Value) {
88 // For strict DWARF mode, only generate attributes available to current
89 // DWARF version.
90 // Attribute 0 is used when emitting form-encoded values in blocks, which
91 // don't have attributes (only forms) so we cannot detect their DWARF
92 // version compatibility here and assume they are compatible.
93 if (Attribute != 0 && Asm->TM.Options.DebugStrictDwarf &&
94 DD->getDwarfVersion() < dwarf::AttributeVersion(Attribute))
95 return;
96
97 Die.addValue(DIEValueAllocator,
98 DIEValue(Attribute, Form, std::forward<T>(Value)));
99 }
100
101public:
102 /// Gets Unique ID for this unit.
103 unsigned getUniqueID() const { return UniqueID; }
104 // Accessors.
105 AsmPrinter* getAsmPrinter() const { return Asm; }
106 /// Get the the symbol for start of the section for this unit.
108 assert(LabelBegin && "LabelBegin is not initialized");
109 return LabelBegin;
110 }
111 MCSymbol *getEndLabel() const { return EndLabel; }
113 const DICompileUnit *getCUNode() const { return CUNode; }
114 DwarfDebug &getDwarfDebug() const { return *DD; }
115
116 /// Return true if this compile unit has something to write out.
117 bool hasContent() const { return getUnitDie().hasChildren(); }
118
119 /// Get string containing language specific context for a global name.
120 ///
121 /// Walks the metadata parent chain in a language specific manner (using the
122 /// compile unit language) and returns it as a string. This is done at the
123 /// metadata level because DIEs may not currently have been added to the
124 /// parent context and walking the DIEs looking for names is more expensive
125 /// than walking the metadata.
126 std::string getParentContextString(const DIScope *Context) const;
127
128 /// Add a new global name to the compile unit.
129 virtual void addGlobalName(StringRef Name, const DIE &Die,
130 const DIScope *Context) = 0;
131
132 /// Add a new global type to the compile unit.
133 virtual void addGlobalTypeImpl(const DIType *Ty, const DIE &Die,
134 const DIScope *Context) = 0;
135
136 void addGlobalType(const DIType *Ty, const DIE &Die, const DIScope *Context);
137
138 /// Returns the DIE map slot for the specified debug variable.
139 ///
140 /// We delegate the request to DwarfDebug when the MDNode can be part of the
141 /// type system, since DIEs for the type system can be shared across CUs and
142 /// the mappings are kept in DwarfDebug.
143 DIE *getDIE(const DINode *D) const;
144
145 /// Returns a fresh newly allocated DIELoc.
147
148 /// Insert DIE into the map.
149 ///
150 /// We delegate the request to DwarfDebug when the MDNode can be part of the
151 /// type system, since DIEs for the type system can be shared across CUs and
152 /// the mappings are kept in DwarfDebug.
153 void insertDIE(const DINode *Desc, DIE *D);
154
155 void insertDIE(DIE *D);
156
157 /// Add a flag that is true to the DIE.
159
160 /// Add an unsigned integer attribute data and value.
162 std::optional<dwarf::Form> Form, uint64_t Integer);
163
165
166 /// Add an signed integer attribute data and value.
168 std::optional<dwarf::Form> Form, int64_t Integer);
169
170 void addSInt(DIEValueList &Die, std::optional<dwarf::Form> Form,
171 int64_t Integer);
172
173 /// Add an integer attribute data and value; value may be any width.
175 bool Unsigned);
176
177 /// Add a string attribute data and value.
178 ///
179 /// We always emit a reference to the string pool instead of immediate
180 /// strings so that DIEs have more predictable sizes. In the case of split
181 /// dwarf we emit an index into another table which gets us the static offset
182 /// into the string table.
184
185 /// Add a Dwarf label attribute data and value.
187 const MCSymbol *Label);
188
189 void addLabel(DIELoc &Die, dwarf::Form Form, const MCSymbol *Label);
190
191 /// Add an offset into a section attribute data and value.
193
194 /// Add a dwarf op address data and value using the form given and an
195 /// op of either DW_FORM_addr or DW_FORM_GNU_addr_index.
196 void addOpAddress(DIELoc &Die, const MCSymbol *Sym);
197 void addPoolOpAddress(DIEValueList &Die, const MCSymbol *Label);
198
199 /// Add a label delta attribute data and value.
201 const MCSymbol *Hi, const MCSymbol *Lo);
202
203 /// Add a DIE attribute data and value.
204 void addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIE &Entry);
205
206 /// Add a DIE attribute data and value.
208
209 /// Add a type's DW_AT_signature and set the declaration flag.
210 void addDIETypeSignature(DIE &Die, uint64_t Signature);
211
212 /// Add block data.
214
215 /// Add block data.
218 DIEBlock *Block);
219
220 /// Add an expression as block data.
221 void addBlock(DIE &Die, dwarf::Attribute Attribute, const DIExpression *Expr);
222
223 /// Add location information to specified debug information entry.
224 void addSourceLine(DIE &Die, unsigned Line, unsigned Column,
225 const DIFile *File);
226 void addSourceLine(DIE &Die, const DILocalVariable *V);
227 void addSourceLine(DIE &Die, const DIGlobalVariable *G);
228 void addSourceLine(DIE &Die, const DISubprogram *SP);
229 void addSourceLine(DIE &Die, const DILabel *L);
230 void addSourceLine(DIE &Die, const DIType *Ty);
231 void addSourceLine(DIE &Die, const DIObjCProperty *Ty);
232 void addSourceLine(DIE &Die, const DIProperty *P);
233
234 /// Add constant value entry in variable DIE.
235 void addConstantValue(DIE &Die, const ConstantInt *CI, const DIType *Ty);
236 void addConstantValue(DIE &Die, const APInt &Val, const DIType *Ty);
237 void addConstantValue(DIE &Die, const APInt &Val, bool Unsigned);
238 void addConstantValue(DIE &Die, uint64_t Val, const DIType *Ty);
239 void addConstantValue(DIE &Die, bool Unsigned, uint64_t Val);
240
241 /// Add constant value entry in variable DIE.
242 void addConstantFPValue(DIE &Die, const ConstantFP *CFP);
243
244 /// Add a linkage name, if it isn't empty.
246
247 /// Add template parameters in buffer.
248 void addTemplateParams(DIE &Buffer, DINodeArray TParams);
249
250 /// Add thrown types.
251 void addThrownTypes(DIE &Die, DINodeArray ThrownTypes);
252
253 /// Add the accessibility attribute.
254 void addAccess(DIE &Die, DINode::DIFlags Flags);
255
256 /// Add a new type attribute to the specified entity.
257 ///
258 /// This takes and attribute parameter because DW_AT_friend attributes are
259 /// also type references.
260 void addType(DIE &Entity, const DIType *Ty,
261 dwarf::Attribute Attribute = dwarf::DW_AT_type);
262
264 DIE *getOrCreateModule(const DIModule *M);
265 virtual DIE *getOrCreateSubprogramDIE(const DISubprogram *SP,
266 const Function *FnHint,
267 bool Minimal = false);
268
269 void applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie,
270 bool SkipSPAttributes = false);
271
272 /// Creates type DIE with specific context.
273 DIE *createTypeDIE(const DIScope *Context, DIE &ContextDIE, const DIType *Ty);
274
275 /// Find existing DIE or create new DIE for the given type.
276 virtual DIE *getOrCreateTypeDIE(const MDNode *TyNode);
277
278 /// Get context owner's DIE.
279 virtual DIE *getOrCreateContextDIE(const DIScope *Context);
280
281 /// Construct DIEs for types that contain vtables.
283
285
286 /// Construct function argument DIEs.
287 ///
288 /// \returns The index of the object parameter in \c Args if one exists.
289 /// Returns std::nullopt otherwise.
290 std::optional<unsigned> constructSubprogramArguments(DIE &Buffer,
291 DITypeArray Args);
292
293 /// Create a DIE with the given Tag, add the DIE to its parent, and
294 /// call insertDIE if MD is not null.
295 DIE &createAndAddDIE(dwarf::Tag Tag, DIE &Parent, const DINode *N = nullptr);
296
298 return DD->useSegmentedStringOffsetsTable();
299 }
300
301 /// Compute the size of a header for this unit, not including the initial
302 /// length field.
303 virtual unsigned getHeaderSize() const {
304 return sizeof(int16_t) + // DWARF version number
305 Asm->getDwarfOffsetByteSize() + // Offset Into Abbrev. Section
306 sizeof(int8_t) + // Pointer Size (in bytes)
307 (DD->getDwarfVersion() >= 5 ? sizeof(int8_t)
308 : 0); // DWARF v5 unit type
309 }
310
311 /// Emit the header for this unit, not including the initial length field.
312 virtual void emitHeader(bool UseOffsets) = 0;
313
314 /// Add the DW_AT_str_offsets_base attribute to the unit DIE.
316
317 /// Add the DW_AT_rnglists_base attribute to the unit DIE.
318 void addRnglistsBase();
319
320 virtual DwarfCompileUnit &getCU() = 0;
321
322 void constructTypeDIE(DIE &Buffer, const DICompositeType *CTy);
323
324 /// Add a Dwarf section label attribute data and value. If the current unit
325 /// is a DWO, this function will instead emit a section delta.
327 const MCSymbol *Label, const MCSymbol *Sec);
328
329 /// Add DW_TAG_LLVM_annotation.
330 void addAnnotation(DIE &Buffer, DINodeArray Annotations);
331
332 /// Get context owner's DIE.
334
335 /// If this is a named finished type then include it in the list of types for
336 /// the accelerator tables.
337 void updateAcceleratorTables(const DIScope *Context, const DIType *Ty,
338 const DIE &TyDIE);
339
340protected:
341 ~DwarfUnit() override;
342
343 /// Create new static data member DIE.
345
346 /// Look up the source ID for the given file. If none currently exists,
347 /// create a new ID and insert it in the line table.
348 virtual unsigned getOrCreateSourceID(const DIFile *File) = 0;
349
350 /// Emit the common part of the header for this unit.
351 void emitCommonHeader(bool UseOffsets, dwarf::UnitType UT);
352
353 bool shouldPlaceInUnitDIE(const DISubprogram *SP, bool Minimal) {
354 // Add subprogram definitions to the CU die directly.
355 return Minimal || SP->getDeclaration();
356 }
357
359 bool IgnoreScope) {
360 if (IgnoreScope)
361 return &getUnitDie();
362 return getOrCreateContextDIE(SP->getScope());
363 }
364
365private:
366 DISourceLanguageName getLanguage() const {
367 return CUNode->getSourceLanguage();
368 }
369
370 /// Emit the bytes of an APInt value into an existing DIEBlock,
371 /// respecting target endianness.
372 void addIntToBlock(DIEBlock &Block, const APInt &Val);
373
374 /// A helper to add a wide integer constant to a DIE using a block
375 /// form.
376 void addIntAsBlock(DIE &Die, dwarf::Attribute Attribute, const APInt &Val);
377
378 // Add discriminant constants to a DW_TAG_variant DIE.
379 void addDiscriminant(DIE &Variant, Constant *Discriminant, bool IsUnsigned);
380
381 void constructTypeDIE(DIE &Buffer, const DIBasicType *BTy);
382 void constructTypeDIE(DIE &Buffer, const DIFixedPointType *BTy);
383 void constructTypeDIE(DIE &Buffer, const DIStringType *BTy);
384 void constructTypeDIE(DIE &Buffer, const DIDerivedType *DTy);
385 void constructTypeDIE(DIE &Buffer, const DISubroutineType *CTy);
386 void constructSubrangeDIE(DIE &Buffer, const DISubrangeType *SR,
387 bool ForArray = false);
388 void constructSubrangeDIE(DIE &Buffer, const DISubrange *SR);
389 void constructGenericSubrangeDIE(DIE &Buffer, const DIGenericSubrange *SR);
390 void constructArrayTypeDIE(DIE &Buffer, const DICompositeType *CTy);
391 void constructEnumTypeDIE(DIE &Buffer, const DICompositeType *CTy);
392 DIE &constructMemberDIE(DIE &Buffer, const DIDerivedType *DT);
393 void constructPropertyDIE(DIE &Buffer, const DIProperty *P);
394 void constructTemplateTypeParameterDIE(DIE &Buffer,
395 const DITemplateTypeParameter *TP);
396 void constructTemplateValueParameterDIE(DIE &Buffer,
397 const DITemplateValueParameter *TVP);
398
399 /// Return the default lower bound for an array.
400 ///
401 /// If the DWARF version doesn't handle the language, return -1.
402 int64_t getDefaultLowerBound() const;
403
404 /// Get an anonymous type for index type.
405 DIE *getIndexTyDie();
406
407 /// Set D as anonymous type for index which can be reused later.
408 void setIndexTyDie(DIE *D) { IndexTyDie = D; }
409
410 virtual void finishNonUnitTypeDIE(DIE& D, const DICompositeType *CTy) = 0;
411
412 virtual bool isDwoUnit() const = 0;
413 const MCSymbol *getCrossSectionRelativeBaseAddress() const override;
414
415 /// Returns 'true' if the current DwarfVersion is compatible
416 /// with the specified \p Version.
417 bool isCompatibleWithVersion(uint16_t Version) const;
418
419 /// addSectionDelta - Add a label delta attribute data and value.
420 void addSectionDelta(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Hi,
421 const MCSymbol *Lo);
422};
423
424class DwarfTypeUnit final : public DwarfUnit {
425 uint64_t TypeSignature;
426 const DIE *Ty;
428 MCDwarfDwoLineTable *SplitLineTable;
429 bool UsedLineTable = false;
430
431 unsigned getOrCreateSourceID(const DIFile *File) override;
432 void finishNonUnitTypeDIE(DIE& D, const DICompositeType *CTy) override;
433 bool isDwoUnit() const override;
434
435public:
437 DwarfFile *DWU, unsigned UniqueID,
438 MCDwarfDwoLineTable *SplitLineTable = nullptr);
439
440 void setTypeSignature(uint64_t Signature) { TypeSignature = Signature; }
441 /// Returns Type Signature.
442 uint64_t getTypeSignature() const { return TypeSignature; }
443 void setType(const DIE *Ty) { this->Ty = Ty; }
444
445 /// Emit the header for this unit, not including the initial length field.
446 void emitHeader(bool UseOffsets) override;
447 unsigned getHeaderSize() const override {
448 return DwarfUnit::getHeaderSize() + sizeof(uint64_t) + // Type Signature
449 Asm->getDwarfOffsetByteSize(); // Type DIE Offset
450 }
451 void addGlobalName(StringRef Name, const DIE &Die,
452 const DIScope *Context) override;
453 void addGlobalTypeImpl(const DIType *Ty, const DIE &Die,
454 const DIScope *Context) override;
455 DwarfCompileUnit &getCU() override { return CU; }
456};
457} // end llvm namespace
458#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
unsigned uint64_t
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
This file defines the DenseMap class.
#define G(x, y, z)
Definition MD5.cpp:55
#define T
#define P(N)
Class for arbitrary precision integers.
Definition APInt.h:78
Annotations lets you mark points and ranges inside source code, for tests:
Definition Annotations.h:67
This class is intended to be used as a driving class for all asm writers.
Definition AsmPrinter.h:91
Functions, function parameters, and return types can have attributes to indicate how they should be t...
Definition Attributes.h:105
ConstantFP - Floating Point Values [float, double].
Definition Constants.h:420
This is the shared class of boolean and integer constants.
Definition Constants.h:87
DISourceLanguageName getSourceLanguage() const
DIEBlock - Represents a block of values.
Definition DIE.h:1070
A pointer to another debug information entry.
Definition DIE.h:325
DIELoc - Represents an expression location.
Definition DIE.h:1034
virtual const MCSymbol * getCrossSectionRelativeBaseAddress() const
Definition DIE.h:1013
LLVM_ABI DIEUnit(dwarf::Tag UnitTag)
Definition DIE.cpp:305
DIE & getUnitDie()
Definition DIE.h:1023
A list of DIE values.
Definition DIE.h:712
A structured debug information entry.
Definition DIE.h:842
bool hasChildren() const
Definition DIE.h:890
DWARF expression.
Represents a module in the programming language, for example, a Clang module, or a Fortran module.
Debug lexical block.
Tagged DWARF-like metadata node.
DIFlags
Debug info flags.
A property of a class or structure.
Base class for scope-like contexts.
Wrapper structure that holds source language identity metadata that includes language name,...
Subprogram description. Uses SubclassData1.
Base class for types.
Collects and handles dwarf debug information.
Definition DwarfDebug.h:352
DwarfTypeUnit(DwarfCompileUnit &CU, AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU, unsigned UniqueID, MCDwarfDwoLineTable *SplitLineTable=nullptr)
Definition DwarfUnit.cpp:88
void addGlobalTypeImpl(const DIType *Ty, const DIE &Die, const DIScope *Context) override
Add a new global type to the compile unit.
unsigned getHeaderSize() const override
Compute the size of a header for this unit, not including the initial length field.
Definition DwarfUnit.h:447
DwarfCompileUnit & getCU() override
Definition DwarfUnit.h:455
uint64_t getTypeSignature() const
Returns Type Signature.
Definition DwarfUnit.h:442
void emitHeader(bool UseOffsets) override
Emit the header for this unit, not including the initial length field.
void addGlobalName(StringRef Name, const DIE &Die, const DIScope *Context) override
Add a new global name to the compile unit.
void setTypeSignature(uint64_t Signature)
Definition DwarfUnit.h:440
void setType(const DIE *Ty)
Definition DwarfUnit.h:443
virtual DIE * getOrCreateTypeDIE(const MDNode *TyNode)
Find existing DIE or create new DIE for the given type.
void addInt(DIE &Die, dwarf::Attribute Attribute, const APInt &Integer, bool Unsigned)
Add an integer attribute data and value; value may be any width.
DwarfDebug & getDwarfDebug() const
Definition DwarfUnit.h:114
void addThrownTypes(DIE &Die, DINodeArray ThrownTypes)
Add thrown types.
void addStringOffsetsStart()
Add the DW_AT_str_offsets_base attribute to the unit DIE.
void addAnnotation(DIE &Buffer, DINodeArray Annotations)
Add DW_TAG_LLVM_annotation.
std::vector< DIEBlock * > DIEBlocks
A list of all the DIEBlocks in use.
Definition DwarfUnit.h:67
std::vector< DIELoc * > DIELocs
A list of all the DIELocs in use.
Definition DwarfUnit.h:70
void addBlock(DIE &Die, dwarf::Attribute Attribute, DIELoc *Loc)
Add block data.
void addTemplateParams(DIE &Buffer, DINodeArray TParams)
Add template parameters in buffer.
virtual DIE * getOrCreateContextDIE(const DIScope *Context)
Get context owner's DIE.
bool useSegmentedStringOffsetsTable() const
Definition DwarfUnit.h:297
bool applySubprogramDefinitionAttributes(const DISubprogram *SP, DIE &SPDie, bool Minimal)
DIELoc * getDIELoc()
Returns a fresh newly allocated DIELoc.
Definition DwarfUnit.h:146
void updateAcceleratorTables(const DIScope *Context, const DIType *Ty, const DIE &TyDIE)
If this is a named finished type then include it in the list of types for the accelerator tables.
virtual void emitHeader(bool UseOffsets)=0
Emit the header for this unit, not including the initial length field.
void addAttribute(DIEValueList &Die, dwarf::Attribute Attribute, dwarf::Form Form, T &&Value)
Definition DwarfUnit.h:86
void addOpAddress(DIELoc &Die, const MCSymbol *Sym)
Add a dwarf op address data and value using the form given and an op of either DW_FORM_addr or DW_FOR...
void addUInt(DIEValueList &Die, dwarf::Attribute Attribute, std::optional< dwarf::Form > Form, uint64_t Integer)
Add an unsigned integer attribute data and value.
void addString(DIE &Die, dwarf::Attribute Attribute, StringRef Str)
Add a string attribute data and value.
void addConstantValue(DIE &Die, const ConstantInt *CI, const DIType *Ty)
Add constant value entry in variable DIE.
DIE * getOrCreateNameSpace(const DINamespace *NS)
void insertDIE(const DINode *Desc, DIE *D)
Insert DIE into the map.
void addAccess(DIE &Die, DINode::DIFlags Flags)
Add the accessibility attribute.
void addGlobalType(const DIType *Ty, const DIE &Die, const DIScope *Context)
DIE * createTypeDIE(const DIScope *Context, DIE &ContextDIE, const DIType *Ty)
Creates type DIE with specific context.
bool shouldPlaceInUnitDIE(const DISubprogram *SP, bool Minimal)
Definition DwarfUnit.h:353
DwarfDebug * DD
Definition DwarfUnit.h:56
DenseMap< DIE *, const DINode * > ContainingTypeMap
This map is used to keep track of subprogram DIEs that need DW_AT_containing_type attribute.
Definition DwarfUnit.h:75
const DICompileUnit * CUNode
MDNode for the compile unit.
Definition DwarfUnit.h:41
virtual unsigned getOrCreateSourceID(const DIFile *File)=0
Look up the source ID for the given file.
virtual DIE * getOrCreateSubprogramDIE(const DISubprogram *SP, const Function *FnHint, bool Minimal=false)
DIE * getOrCreateSubprogramContextDIE(const DISubprogram *SP, bool IgnoreScope)
Definition DwarfUnit.h:358
virtual void addGlobalTypeImpl(const DIType *Ty, const DIE &Die, const DIScope *Context)=0
Add a new global type to the compile unit.
void addDIETypeSignature(DIE &Die, uint64_t Signature)
Add a type's DW_AT_signature and set the declaration flag.
virtual DwarfCompileUnit & getCU()=0
DIE * getDIE(const DINode *D) const
Returns the DIE map slot for the specified debug variable.
AsmPrinter * getAsmPrinter() const
Definition DwarfUnit.h:105
void constructPropertyForwardDIEs()
virtual unsigned getHeaderSize() const
Compute the size of a header for this unit, not including the initial length field.
Definition DwarfUnit.h:303
bool hasContent() const
Return true if this compile unit has something to write out.
Definition DwarfUnit.h:117
MCSymbol * LabelBegin
The start of the unit within its section.
Definition DwarfUnit.h:50
void addSInt(DIEValueList &Die, dwarf::Attribute Attribute, std::optional< dwarf::Form > Form, int64_t Integer)
Add an signed integer attribute data and value.
DwarfUnit(dwarf::Tag, const DICompileUnit *Node, AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU, unsigned UniqueID=0)
Definition DwarfUnit.cpp:82
void addLabelDelta(DIEValueList &Die, dwarf::Attribute Attribute, const MCSymbol *Hi, const MCSymbol *Lo)
Add a label delta attribute data and value.
void addLinkageName(DIE &Die, StringRef LinkageName)
Add a linkage name, if it isn't empty.
MCSymbol * getEndLabel() const
Definition DwarfUnit.h:111
std::string getParentContextString(const DIScope *Context) const
Get string containing language specific context for a global name.
void addSourceLine(DIE &Die, unsigned Line, unsigned Column, const DIFile *File)
Add location information to specified debug information entry.
void emitCommonHeader(bool UseOffsets, dwarf::UnitType UT)
Emit the common part of the header for this unit.
BumpPtrAllocator DIEValueAllocator
Definition DwarfUnit.h:44
DIE * IndexTyDie
An anonymous type for index type. Owned by DIEUnit.
Definition DwarfUnit.h:60
void addRnglistsBase()
Add the DW_AT_rnglists_base attribute to the unit DIE.
DIE * getOrCreateModule(const DIModule *M)
const DICompileUnit * getCUNode() const
Definition DwarfUnit.h:113
DIE & createAndAddDIE(dwarf::Tag Tag, DIE &Parent, const DINode *N=nullptr)
Create a DIE with the given Tag, add the DIE to its parent, and call insertDIE if MD is not null.
DwarfFile * DU
Definition DwarfUnit.h:57
std::optional< unsigned > constructSubprogramArguments(DIE &Buffer, DITypeArray Args)
Construct function argument DIEs.
void addSectionOffset(DIE &Die, dwarf::Attribute Attribute, uint64_t Integer)
Add an offset into a section attribute data and value.
DIE * getOrCreateStaticMemberDIE(const DIDerivedType *DT)
Create new static data member DIE.
void addLabel(DIEValueList &Die, dwarf::Attribute Attribute, dwarf::Form Form, const MCSymbol *Label)
Add a Dwarf label attribute data and value.
void addConstantFPValue(DIE &Die, const ConstantFP *CFP)
Add constant value entry in variable DIE.
void constructContainingTypeDIEs()
Construct DIEs for types that contain vtables.
unsigned UniqueID
A numeric ID unique among all CUs in the module.
Definition DwarfUnit.h:39
void addSectionLabel(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Label, const MCSymbol *Sec)
Add a Dwarf section label attribute data and value.
bool isShareableAcrossCUs(const DINode *D) const
Check whether the DIE for this MDNode can be shared across CUs.
DenseMap< DIE *, const DINode * > PropertyForwardMap
Definition DwarfUnit.h:76
llvm::dwarf::SourceLanguage getSourceLanguage() const
void addPoolOpAddress(DIEValueList &Die, const MCSymbol *Label)
~DwarfUnit() override
Definition DwarfUnit.cpp:94
MCSymbol * getLabelBegin() const
Get the the symbol for start of the section for this unit.
Definition DwarfUnit.h:107
DenseMap< const MDNode *, DIE * > MDNodeToDieMap
Tracks the mapping of unit level debug information variables to debug information entries.
Definition DwarfUnit.h:64
void constructTypeDIE(DIE &Buffer, const DICompositeType *CTy)
virtual void addGlobalName(StringRef Name, const DIE &Die, const DIScope *Context)=0
Add a new global name to the compile unit.
MCSymbol * EndLabel
Emitted at the end of the CU and used to compute the CU Length field.
Definition DwarfUnit.h:53
void addFlag(DIE &Die, dwarf::Attribute Attribute)
Add a flag that is true to the DIE.
AsmPrinter * Asm
Target of Dwarf emission.
Definition DwarfUnit.h:47
unsigned getUniqueID() const
Gets Unique ID for this unit.
Definition DwarfUnit.h:103
void addType(DIE &Entity, const DIType *Ty, dwarf::Attribute Attribute=dwarf::DW_AT_type)
Add a new type attribute to the specified entity.
void applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie, bool SkipSPAttributes=false)
void addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIE &Entry)
Add a DIE attribute data and value.
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:1069
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
LLVM Value Representation.
Definition Value.h:75
LLVM_ABI unsigned AttributeVersion(Attribute A)
Definition Dwarf.cpp:83
Attribute
Attributes.
Definition Dwarf.h:125
UnitType
Constants for unit types in DWARF v5.
Definition Dwarf.h:979
This is an optimization pass for GlobalISel generic memory operations.
Op::Description Desc
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:390
#define N