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 /// Get string containing language specific context for a global name.
117 ///
118 /// Walks the metadata parent chain in a language specific manner (using the
119 /// compile unit language) and returns it as a string. This is done at the
120 /// metadata level because DIEs may not currently have been added to the
121 /// parent context and walking the DIEs looking for names is more expensive
122 /// than walking the metadata.
123 std::string getParentContextString(const DIScope *Context) const;
124
125 /// Add a new global name to the compile unit.
126 virtual void addGlobalName(StringRef Name, const DIE &Die,
127 const DIScope *Context) = 0;
128
129 /// Add a new global type to the compile unit.
130 virtual void addGlobalTypeImpl(const DIType *Ty, const DIE &Die,
131 const DIScope *Context) = 0;
132
133 void addGlobalType(const DIType *Ty, const DIE &Die, const DIScope *Context);
134
135 /// Returns the DIE map slot for the specified debug variable.
136 ///
137 /// We delegate the request to DwarfDebug when the MDNode can be part of the
138 /// type system, since DIEs for the type system can be shared across CUs and
139 /// the mappings are kept in DwarfDebug.
140 DIE *getDIE(const DINode *D) const;
141
142 /// Returns a fresh newly allocated DIELoc.
144
145 /// Insert DIE into the map.
146 ///
147 /// We delegate the request to DwarfDebug when the MDNode can be part of the
148 /// type system, since DIEs for the type system can be shared across CUs and
149 /// the mappings are kept in DwarfDebug.
150 void insertDIE(const DINode *Desc, DIE *D);
151
152 void insertDIE(DIE *D);
153
154 /// Add a flag that is true to the DIE.
156
157 /// Add an unsigned integer attribute data and value.
159 std::optional<dwarf::Form> Form, uint64_t Integer);
160
162
163 /// Add an signed integer attribute data and value.
165 std::optional<dwarf::Form> Form, int64_t Integer);
166
167 void addSInt(DIEValueList &Die, std::optional<dwarf::Form> Form,
168 int64_t Integer);
169
170 /// Add an integer attribute data and value; value may be any width.
172 bool Unsigned);
173
174 /// Add a string attribute data and value.
175 ///
176 /// We always emit a reference to the string pool instead of immediate
177 /// strings so that DIEs have more predictable sizes. In the case of split
178 /// dwarf we emit an index into another table which gets us the static offset
179 /// into the string table.
181
182 /// Add a Dwarf label attribute data and value.
184 const MCSymbol *Label);
185
186 void addLabel(DIELoc &Die, dwarf::Form Form, const MCSymbol *Label);
187
188 /// Add an offset into a section attribute data and value.
190
191 /// Add a dwarf op address data and value using the form given and an
192 /// op of either DW_FORM_addr or DW_FORM_GNU_addr_index.
193 void addOpAddress(DIELoc &Die, const MCSymbol *Sym);
194 void addPoolOpAddress(DIEValueList &Die, const MCSymbol *Label);
195
196 /// Add a label delta attribute data and value.
198 const MCSymbol *Hi, const MCSymbol *Lo);
199
200 /// Add a DIE attribute data and value.
201 void addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIE &Entry);
202
203 /// Add a DIE attribute data and value.
205
206 /// Add a type's DW_AT_signature and set the declaration flag.
207 void addDIETypeSignature(DIE &Die, uint64_t Signature);
208
209 /// Add block data.
211
212 /// Add block data.
215 DIEBlock *Block);
216
217 /// Add an expression as block data.
218 void addBlock(DIE &Die, dwarf::Attribute Attribute, const DIExpression *Expr);
219
220 /// Add location information to specified debug information entry.
221 void addSourceLine(DIE &Die, unsigned Line, unsigned Column,
222 const DIFile *File);
223 void addSourceLine(DIE &Die, const DILocalVariable *V);
224 void addSourceLine(DIE &Die, const DIGlobalVariable *G);
225 void addSourceLine(DIE &Die, const DISubprogram *SP);
226 void addSourceLine(DIE &Die, const DILabel *L);
227 void addSourceLine(DIE &Die, const DIType *Ty);
228 void addSourceLine(DIE &Die, const DIObjCProperty *Ty);
229 void addSourceLine(DIE &Die, const DIProperty *P);
230
231 /// Add constant value entry in variable DIE.
232 void addConstantValue(DIE &Die, const ConstantInt *CI, const DIType *Ty);
233 void addConstantValue(DIE &Die, const APInt &Val, const DIType *Ty);
234 void addConstantValue(DIE &Die, const APInt &Val, bool Unsigned);
235 void addConstantValue(DIE &Die, uint64_t Val, const DIType *Ty);
236 void addConstantValue(DIE &Die, bool Unsigned, uint64_t Val);
237
238 /// Add constant value entry in variable DIE.
239 void addConstantFPValue(DIE &Die, const ConstantFP *CFP);
240
241 /// Add a linkage name, if it isn't empty.
243
244 /// Add template parameters in buffer.
245 void addTemplateParams(DIE &Buffer, DINodeArray TParams);
246
247 /// Add thrown types.
248 void addThrownTypes(DIE &Die, DINodeArray ThrownTypes);
249
250 /// Add the accessibility attribute.
251 void addAccess(DIE &Die, DINode::DIFlags Flags);
252
253 /// Add a new type attribute to the specified entity.
254 ///
255 /// This takes and attribute parameter because DW_AT_friend attributes are
256 /// also type references.
257 void addType(DIE &Entity, const DIType *Ty,
258 dwarf::Attribute Attribute = dwarf::DW_AT_type);
259
261 DIE *getOrCreateModule(const DIModule *M);
262 virtual DIE *getOrCreateSubprogramDIE(const DISubprogram *SP,
263 const Function *FnHint,
264 bool Minimal = false);
265
266 void applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie,
267 bool SkipSPAttributes = false);
268
269 /// Creates type DIE with specific context.
270 DIE *createTypeDIE(const DIScope *Context, DIE &ContextDIE, const DIType *Ty);
271
272 /// Find existing DIE or create new DIE for the given type.
273 virtual DIE *getOrCreateTypeDIE(const MDNode *TyNode);
274
275 /// Get context owner's DIE.
276 virtual DIE *getOrCreateContextDIE(const DIScope *Context);
277
278 /// Construct DIEs for types that contain vtables.
280
282
283 /// Construct function argument DIEs.
284 ///
285 /// \returns The index of the object parameter in \c Args if one exists.
286 /// Returns std::nullopt otherwise.
287 std::optional<unsigned> constructSubprogramArguments(DIE &Buffer,
288 DITypeArray Args);
289
290 /// Create a DIE with the given Tag, add the DIE to its parent, and
291 /// call insertDIE if MD is not null.
292 DIE &createAndAddDIE(dwarf::Tag Tag, DIE &Parent, const DINode *N = nullptr);
293
295 return DD->useSegmentedStringOffsetsTable();
296 }
297
298 /// Compute the size of a header for this unit, not including the initial
299 /// length field.
300 virtual unsigned getHeaderSize() const {
301 return sizeof(int16_t) + // DWARF version number
302 Asm->getDwarfOffsetByteSize() + // Offset Into Abbrev. Section
303 sizeof(int8_t) + // Pointer Size (in bytes)
304 (DD->getDwarfVersion() >= 5 ? sizeof(int8_t)
305 : 0); // DWARF v5 unit type
306 }
307
308 /// Emit the header for this unit, not including the initial length field.
309 virtual void emitHeader(bool UseOffsets) = 0;
310
311 /// Add the DW_AT_str_offsets_base attribute to the unit DIE.
313
314 /// Add the DW_AT_rnglists_base attribute to the unit DIE.
315 void addRnglistsBase();
316
317 virtual DwarfCompileUnit &getCU() = 0;
318
319 void constructTypeDIE(DIE &Buffer, const DICompositeType *CTy);
320
321 /// Add a Dwarf section label attribute data and value. If the current unit
322 /// is a DWO, this function will instead emit a section delta.
324 const MCSymbol *Label, const MCSymbol *Sec);
325
326 /// Add DW_TAG_LLVM_annotation.
327 void addAnnotation(DIE &Buffer, DINodeArray Annotations);
328
329 /// Get context owner's DIE.
331
332 /// If this is a named finished type then include it in the list of types for
333 /// the accelerator tables.
334 void updateAcceleratorTables(const DIScope *Context, const DIType *Ty,
335 const DIE &TyDIE);
336
337protected:
338 ~DwarfUnit() override;
339
340 /// Create new static data member DIE.
342
343 /// Look up the source ID for the given file. If none currently exists,
344 /// create a new ID and insert it in the line table.
345 virtual unsigned getOrCreateSourceID(const DIFile *File) = 0;
346
347 /// Emit the common part of the header for this unit.
348 void emitCommonHeader(bool UseOffsets, dwarf::UnitType UT);
349
350 bool shouldPlaceInUnitDIE(const DISubprogram *SP, bool Minimal) {
351 // Add subprogram definitions to the CU die directly.
352 return Minimal || SP->getDeclaration();
353 }
354
356 bool IgnoreScope) {
357 if (IgnoreScope)
358 return &getUnitDie();
359 return getOrCreateContextDIE(SP->getScope());
360 }
361
362private:
363 DISourceLanguageName getLanguage() const {
364 return CUNode->getSourceLanguage();
365 }
366
367 /// Emit the bytes of an APInt value into an existing DIEBlock,
368 /// respecting target endianness.
369 void addIntToBlock(DIEBlock &Block, const APInt &Val);
370
371 /// A helper to add a wide integer constant to a DIE using a block
372 /// form.
373 void addIntAsBlock(DIE &Die, dwarf::Attribute Attribute, const APInt &Val);
374
375 // Add discriminant constants to a DW_TAG_variant DIE.
376 void addDiscriminant(DIE &Variant, Constant *Discriminant, bool IsUnsigned);
377
378 void constructTypeDIE(DIE &Buffer, const DIBasicType *BTy);
379 void constructTypeDIE(DIE &Buffer, const DIFixedPointType *BTy);
380 void constructTypeDIE(DIE &Buffer, const DIStringType *BTy);
381 void constructTypeDIE(DIE &Buffer, const DIDerivedType *DTy);
382 void constructTypeDIE(DIE &Buffer, const DISubroutineType *CTy);
383 void constructSubrangeDIE(DIE &Buffer, const DISubrangeType *SR,
384 bool ForArray = false);
385 void constructSubrangeDIE(DIE &Buffer, const DISubrange *SR);
386 void constructGenericSubrangeDIE(DIE &Buffer, const DIGenericSubrange *SR);
387 void constructArrayTypeDIE(DIE &Buffer, const DICompositeType *CTy);
388 void constructEnumTypeDIE(DIE &Buffer, const DICompositeType *CTy);
389 DIE &constructMemberDIE(DIE &Buffer, const DIDerivedType *DT);
390 void constructPropertyDIE(DIE &Buffer, const DIProperty *P);
391 void constructTemplateTypeParameterDIE(DIE &Buffer,
392 const DITemplateTypeParameter *TP);
393 void constructTemplateValueParameterDIE(DIE &Buffer,
394 const DITemplateValueParameter *TVP);
395
396 /// Return the default lower bound for an array.
397 ///
398 /// If the DWARF version doesn't handle the language, return -1.
399 int64_t getDefaultLowerBound() const;
400
401 /// Get an anonymous type for index type.
402 DIE *getIndexTyDie();
403
404 virtual void finishNonUnitTypeDIE(DIE& D, const DICompositeType *CTy) = 0;
405
406 virtual bool isDwoUnit() const = 0;
407 const MCSymbol *getCrossSectionRelativeBaseAddress() const override;
408
409 /// Returns 'true' if the current DwarfVersion is compatible
410 /// with the specified \p Version.
411 bool isCompatibleWithVersion(uint16_t Version) const;
412
413 /// addSectionDelta - Add a label delta attribute data and value.
414 void addSectionDelta(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Hi,
415 const MCSymbol *Lo);
416};
417
418class DwarfTypeUnit final : public DwarfUnit {
419 uint64_t TypeSignature;
420 const DIE *Ty;
422 MCDwarfDwoLineTable *SplitLineTable;
423 bool UsedLineTable = false;
424
425 unsigned getOrCreateSourceID(const DIFile *File) override;
426 void finishNonUnitTypeDIE(DIE& D, const DICompositeType *CTy) override;
427 bool isDwoUnit() const override;
428
429public:
431 DwarfFile *DWU, unsigned UniqueID,
432 MCDwarfDwoLineTable *SplitLineTable = nullptr);
433
434 void setTypeSignature(uint64_t Signature) { TypeSignature = Signature; }
435 /// Returns Type Signature.
436 uint64_t getTypeSignature() const { return TypeSignature; }
437 void setType(const DIE *Ty) { this->Ty = Ty; }
438
439 /// Emit the header for this unit, not including the initial length field.
440 void emitHeader(bool UseOffsets) override;
441 unsigned getHeaderSize() const override {
442 return DwarfUnit::getHeaderSize() + sizeof(uint64_t) + // Type Signature
443 Asm->getDwarfOffsetByteSize(); // Type DIE Offset
444 }
445 void addGlobalName(StringRef Name, const DIE &Die,
446 const DIScope *Context) override;
447 void addGlobalTypeImpl(const DIType *Ty, const DIE &Die,
448 const DIScope *Context) override;
449 DwarfCompileUnit &getCU() override { return CU; }
450};
451} // end llvm namespace
452#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:106
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:1063
A pointer to another debug information entry.
Definition DIE.h:318
DIELoc - Represents an expression location.
Definition DIE.h:1027
virtual const MCSymbol * getCrossSectionRelativeBaseAddress() const
Definition DIE.h:1006
LLVM_ABI DIEUnit(dwarf::Tag UnitTag)
Definition DIE.cpp:305
DIE & getUnitDie()
Definition DIE.h:1016
A list of DIE values.
Definition DIE.h:705
A structured debug information entry.
Definition DIE.h:835
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:441
DwarfCompileUnit & getCU() override
Definition DwarfUnit.h:449
uint64_t getTypeSignature() const
Returns Type Signature.
Definition DwarfUnit.h:436
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:434
void setType(const DIE *Ty)
Definition DwarfUnit.h:437
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:294
bool applySubprogramDefinitionAttributes(const DISubprogram *SP, DIE &SPDie, bool Minimal)
DIELoc * getDIELoc()
Returns a fresh newly allocated DIELoc.
Definition DwarfUnit.h:143
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:350
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:355
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:300
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:1081
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:986
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