Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
DwarfUnit.cpp
Go to the documentation of this file.
1//===-- llvm/CodeGen/DwarfUnit.cpp - Dwarf Type and Compile Units ---------===//
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 constructing a dwarf compile unit.
10//
11//===----------------------------------------------------------------------===//
12
13#include "DwarfUnit.h"
14#include "AddressPool.h"
15#include "DwarfCompileUnit.h"
16#include "DwarfExpression.h"
17#include "llvm/ADT/APFloat.h"
18#include "llvm/ADT/APInt.h"
19#include "llvm/CodeGen/TargetRegisterInfo.h"
20#include "llvm/IR/Constants.h"
21#include "llvm/IR/DataLayout.h"
22#include "llvm/IR/GlobalValue.h"
23#include "llvm/IR/Metadata.h"
24#include "llvm/MC/MCAsmInfo.h"
25#include "llvm/MC/MCContext.h"
26#include "llvm/MC/MCDwarf.h"
27#include "llvm/MC/MCSection.h"
28#include "llvm/MC/MCStreamer.h"
29#include "llvm/Support/Casting.h"
30#include "llvm/Target/TargetLoweringObjectFile.h"
31#include <cassert>
32#include <cstdint>
33#include <limits>
34#include <string>
35#include <utility>
36
37using namespacellvm;
38
39#define DEBUG_TYPE "dwarfdebug"
40
41DIEDwarfExpression::DIEDwarfExpression(constAsmPrinter &AP,
42DwarfCompileUnit &CU,DIELoc &DIE)
43 :DwarfExpression(AP.getDwarfVersion(),CU), AP(AP), OutDIE(DIE) {}
44
45void DIEDwarfExpression::emitOp(uint8_tOp,constchar* Comment) {
46CU.addUInt(getActiveDIE(), dwarf::DW_FORM_data1,Op);
47}
48
49void DIEDwarfExpression::emitSigned(int64_tValue) {
50CU.addSInt(getActiveDIE(), dwarf::DW_FORM_sdata,Value);
51}
52
53void DIEDwarfExpression::emitUnsigned(uint64_tValue) {
54CU.addUInt(getActiveDIE(), dwarf::DW_FORM_udata,Value);
55}
56
57void DIEDwarfExpression::emitData1(uint8_tValue) {
58CU.addUInt(getActiveDIE(), dwarf::DW_FORM_data1,Value);
59}
60
61void DIEDwarfExpression::emitBaseTypeRef(uint64_tIdx) {
62CU.addBaseTypeRef(getActiveDIE(),Idx);
63}
64
65void DIEDwarfExpression::enableTemporaryBuffer() {
66assert(!IsBuffering &&"Already buffering?");
67 IsBuffering =true;
68}
69
70void DIEDwarfExpression::disableTemporaryBuffer() { IsBuffering =false; }
71
72unsigned DIEDwarfExpression::getTemporaryBufferSize() {
73return TmpDIE.computeSize(AP.getDwarfFormParams());
74}
75
76void DIEDwarfExpression::commitTemporaryBuffer() { OutDIE.takeValues(TmpDIE); }
77
78bool DIEDwarfExpression::isFrameRegister(constTargetRegisterInfo &TRI,
79llvm::Register MachineReg) {
80return MachineReg ==TRI.getFrameRegister(*AP.MF);
81}
82
83DwarfUnit::DwarfUnit(dwarf::Tag UnitTag,constDICompileUnit *Node,
84AsmPrinter *A,DwarfDebug *DW,DwarfFile *DWU,
85unsigned UniqueID)
86 :DIEUnit(UnitTag), UniqueID(UniqueID), CUNode(Node), Asm(A), DD(DW),
87 DU(DWU) {}
88
89DwarfTypeUnit::DwarfTypeUnit(DwarfCompileUnit &CU,AsmPrinter *A,
90DwarfDebug *DW,DwarfFile *DWU,unsigned UniqueID,
91MCDwarfDwoLineTable *SplitLineTable)
92 :DwarfUnit(dwarf::DW_TAG_type_unit,CU.getCUNode(),A, DW, DWU, UniqueID),
93CU(CU), SplitLineTable(SplitLineTable) {}
94
95DwarfUnit::~DwarfUnit() {
96for (DIEBlock *B :DIEBlocks)
97B->~DIEBlock();
98for (DIELoc *L :DIELocs)
99 L->~DIELoc();
100}
101
102int64_t DwarfUnit::getDefaultLowerBound() const{
103switch (getLanguage()) {
104default:
105break;
106
107// The languages below have valid values in all DWARF versions.
108case dwarf::DW_LANG_C:
109case dwarf::DW_LANG_C89:
110case dwarf::DW_LANG_C_plus_plus:
111return 0;
112
113case dwarf::DW_LANG_Fortran77:
114case dwarf::DW_LANG_Fortran90:
115return 1;
116
117// The languages below have valid values only if the DWARF version >= 3.
118case dwarf::DW_LANG_C99:
119case dwarf::DW_LANG_ObjC:
120case dwarf::DW_LANG_ObjC_plus_plus:
121if (DD->getDwarfVersion() >= 3)
122return 0;
123break;
124
125case dwarf::DW_LANG_Fortran95:
126if (DD->getDwarfVersion() >= 3)
127return 1;
128break;
129
130// Starting with DWARF v4, all defined languages have valid values.
131case dwarf::DW_LANG_D:
132case dwarf::DW_LANG_Java:
133case dwarf::DW_LANG_Python:
134case dwarf::DW_LANG_UPC:
135if (DD->getDwarfVersion() >= 4)
136return 0;
137break;
138
139case dwarf::DW_LANG_Ada83:
140case dwarf::DW_LANG_Ada95:
141case dwarf::DW_LANG_Cobol74:
142case dwarf::DW_LANG_Cobol85:
143case dwarf::DW_LANG_Modula2:
144case dwarf::DW_LANG_Pascal83:
145case dwarf::DW_LANG_PLI:
146if (DD->getDwarfVersion() >= 4)
147return 1;
148break;
149
150// The languages below are new in DWARF v5.
151case dwarf::DW_LANG_BLISS:
152case dwarf::DW_LANG_C11:
153case dwarf::DW_LANG_C_plus_plus_03:
154case dwarf::DW_LANG_C_plus_plus_11:
155case dwarf::DW_LANG_C_plus_plus_14:
156case dwarf::DW_LANG_Dylan:
157case dwarf::DW_LANG_Go:
158case dwarf::DW_LANG_Haskell:
159case dwarf::DW_LANG_OCaml:
160case dwarf::DW_LANG_OpenCL:
161case dwarf::DW_LANG_RenderScript:
162case dwarf::DW_LANG_Rust:
163case dwarf::DW_LANG_Swift:
164if (DD->getDwarfVersion() >= 5)
165return 0;
166break;
167
168case dwarf::DW_LANG_Fortran03:
169case dwarf::DW_LANG_Fortran08:
170case dwarf::DW_LANG_Julia:
171case dwarf::DW_LANG_Modula3:
172if (DD->getDwarfVersion() >= 5)
173return 1;
174break;
175 }
176
177return -1;
178}
179
180/// Check whether the DIE for this MDNode can be shared across CUs.
181boolDwarfUnit::isShareableAcrossCUs(constDINode *D) const{
182// When the MDNode can be part of the type system, the DIE can be shared
183// across CUs.
184// Combining type units and cross-CU DIE sharing is lower value (since
185// cross-CU DIE sharing is used in LTO and removes type redundancy at that
186// level already) but may be implementable for some value in projects
187// building multiple independent libraries with LTO and then linking those
188// together.
189if (isDwoUnit() && !DD->shareAcrossDWOCUs())
190returnfalse;
191return (isa<DIType>(D) ||
192 (isa<DISubprogram>(D) && !cast<DISubprogram>(D)->isDefinition())) &&
193 !DD->generateTypeUnits();
194}
195
196DIE *DwarfUnit::getDIE(constDINode *D) const{
197if (isShareableAcrossCUs(D))
198returnDU->getDIE(D);
199returnMDNodeToDieMap.lookup(D);
200}
201
202voidDwarfUnit::insertDIE(constDINode *Desc,DIE *D) {
203if (isShareableAcrossCUs(Desc)) {
204DU->insertDIE(Desc,D);
205return;
206 }
207MDNodeToDieMap.insert(std::make_pair(Desc,D));
208}
209
210voidDwarfUnit::insertDIE(DIE *D) {
211MDNodeToDieMap.insert(std::make_pair(nullptr,D));
212}
213
214voidDwarfUnit::addFlag(DIE &Die,dwarf::AttributeAttribute) {
215if (DD->getDwarfVersion() >= 4)
216addAttribute(Die,Attribute, dwarf::DW_FORM_flag_present,DIEInteger(1));
217else
218addAttribute(Die,Attribute, dwarf::DW_FORM_flag,DIEInteger(1));
219}
220
221voidDwarfUnit::addUInt(DIEValueList &Die,dwarf::AttributeAttribute,
222 std::optional<dwarf::Form> Form,uint64_tInteger) {
223if (!Form)
224 Form =DIEInteger::BestForm(false,Integer);
225assert(Form != dwarf::DW_FORM_implicit_const &&
226"DW_FORM_implicit_const is used only for signed integers");
227addAttribute(Die,Attribute, *Form,DIEInteger(Integer));
228}
229
230voidDwarfUnit::addUInt(DIEValueList &Block,dwarf::Form Form,
231uint64_tInteger) {
232addUInt(Block, (dwarf::Attribute)0, Form,Integer);
233}
234
235voidDwarfUnit::addSInt(DIEValueList &Die,dwarf::AttributeAttribute,
236 std::optional<dwarf::Form> Form, int64_tInteger) {
237if (!Form)
238 Form =DIEInteger::BestForm(true,Integer);
239addAttribute(Die,Attribute, *Form,DIEInteger(Integer));
240}
241
242voidDwarfUnit::addSInt(DIELoc &Die, std::optional<dwarf::Form> Form,
243 int64_tInteger) {
244addSInt(Die, (dwarf::Attribute)0, Form,Integer);
245}
246
247voidDwarfUnit::addString(DIE &Die,dwarf::AttributeAttribute,
248StringRefString) {
249if (CUNode->isDebugDirectivesOnly())
250return;
251
252if (DD->useInlineStrings()) {
253addAttribute(Die,Attribute, dwarf::DW_FORM_string,
254new (DIEValueAllocator)
255DIEInlineString(String,DIEValueAllocator));
256return;
257 }
258dwarf::Form IxForm =
259 isDwoUnit() ? dwarf::DW_FORM_GNU_str_index : dwarf::DW_FORM_strp;
260
261auto StringPoolEntry =
262useSegmentedStringOffsetsTable() || IxForm == dwarf::DW_FORM_GNU_str_index
263 ?DU->getStringPool().getIndexedEntry(*Asm,String)
264 :DU->getStringPool().getEntry(*Asm,String);
265
266// For DWARF v5 and beyond, use the smallest strx? form possible.
267if (useSegmentedStringOffsetsTable()) {
268 IxForm = dwarf::DW_FORM_strx1;
269unsigned Index = StringPoolEntry.getIndex();
270if (Index > 0xffffff)
271 IxForm = dwarf::DW_FORM_strx4;
272elseif (Index > 0xffff)
273 IxForm = dwarf::DW_FORM_strx3;
274elseif (Index > 0xff)
275 IxForm = dwarf::DW_FORM_strx2;
276 }
277addAttribute(Die,Attribute, IxForm,DIEString(StringPoolEntry));
278}
279
280voidDwarfUnit::addLabel(DIEValueList &Die,dwarf::AttributeAttribute,
281dwarf::Form Form,constMCSymbol *Label) {
282addAttribute(Die,Attribute, Form,DIELabel(Label));
283}
284
285voidDwarfUnit::addLabel(DIELoc &Die,dwarf::Form Form,constMCSymbol *Label) {
286addLabel(Die, (dwarf::Attribute)0, Form, Label);
287}
288
289voidDwarfUnit::addSectionOffset(DIE &Die,dwarf::AttributeAttribute,
290uint64_tInteger) {
291addUInt(Die,Attribute,DD->getDwarfSectionOffsetForm(),Integer);
292}
293
294unsigned DwarfTypeUnit::getOrCreateSourceID(constDIFile *File) {
295if (!SplitLineTable)
296returngetCU().getOrCreateSourceID(File);
297if (!UsedLineTable) {
298 UsedLineTable =true;
299// This is a split type unit that needs a line table.
300addSectionOffset(getUnitDie(), dwarf::DW_AT_stmt_list, 0);
301 }
302return SplitLineTable->getFile(
303 File->getDirectory(), File->getFilename(),DD->getMD5AsBytes(File),
304Asm->OutContext.getDwarfVersion(), File->getSource());
305}
306
307voidDwarfUnit::addPoolOpAddress(DIEValueList &Die,constMCSymbol *Label) {
308bool UseAddrOffsetFormOrExpressions =
309DD->useAddrOffsetForm() ||DD->useAddrOffsetExpressions();
310
311constMCSymbol *Base =nullptr;
312if (Label->isInSection() && UseAddrOffsetFormOrExpressions)
313Base =DD->getSectionLabel(&Label->getSection());
314
315uint32_t Index =DD->getAddressPool().getIndex(Base ?Base : Label);
316
317if (DD->getDwarfVersion() >= 5) {
318addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_addrx);
319addUInt(Die, dwarf::DW_FORM_addrx, Index);
320 }else {
321addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_addr_index);
322addUInt(Die, dwarf::DW_FORM_GNU_addr_index, Index);
323 }
324
325if (Base &&Base != Label) {
326addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_const4u);
327addLabelDelta(Die, (dwarf::Attribute)0, Label,Base);
328addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
329 }
330}
331
332voidDwarfUnit::addOpAddress(DIELoc &Die,constMCSymbol *Sym) {
333if (DD->getDwarfVersion() >= 5) {
334addPoolOpAddress(Die,Sym);
335return;
336 }
337
338if (DD->useSplitDwarf()) {
339addPoolOpAddress(Die,Sym);
340return;
341 }
342
343addUInt(Die, dwarf::DW_FORM_data1, dwarf::DW_OP_addr);
344addLabel(Die, dwarf::DW_FORM_addr,Sym);
345}
346
347voidDwarfUnit::addLabelDelta(DIEValueList &Die,dwarf::AttributeAttribute,
348constMCSymbol *Hi,constMCSymbol *Lo) {
349addAttribute(Die,Attribute, dwarf::DW_FORM_data4,
350new (DIEValueAllocator)DIEDelta(Hi,Lo));
351}
352
353voidDwarfUnit::addDIEEntry(DIE &Die,dwarf::AttributeAttribute,DIE &Entry) {
354addDIEEntry(Die,Attribute,DIEEntry(Entry));
355}
356
357voidDwarfUnit::addDIETypeSignature(DIE &Die,uint64_t Signature) {
358// Flag the type unit reference as a declaration so that if it contains
359// members (implicit special members, static data member definitions, member
360// declarations for definitions in this CU, etc) consumers don't get confused
361// and think this is a full definition.
362addFlag(Die, dwarf::DW_AT_declaration);
363
364addAttribute(Die, dwarf::DW_AT_signature, dwarf::DW_FORM_ref_sig8,
365DIEInteger(Signature));
366}
367
368voidDwarfUnit::addDIEEntry(DIE &Die,dwarf::AttributeAttribute,
369DIEEntry Entry) {
370constDIEUnit *CU = Die.getUnit();
371constDIEUnit *EntryCU = Entry.getEntry().getUnit();
372if (!CU)
373// We assume that Die belongs to this CU, if it is not linked to any CU yet.
374CU =getUnitDie().getUnit();
375if (!EntryCU)
376 EntryCU =getUnitDie().getUnit();
377assert(EntryCU ==CU || !DD->useSplitDwarf() ||DD->shareAcrossDWOCUs() ||
378 !static_cast<constDwarfUnit*>(CU)->isDwoUnit());
379addAttribute(Die,Attribute,
380 EntryCU ==CU ? dwarf::DW_FORM_ref4 : dwarf::DW_FORM_ref_addr,
381 Entry);
382}
383
384DIE &DwarfUnit::createAndAddDIE(dwarf::TagTag,DIE &Parent,constDINode *N) {
385DIE &Die = Parent.addChild(DIE::get(DIEValueAllocator,Tag));
386if (N)
387insertDIE(N, &Die);
388return Die;
389}
390
391voidDwarfUnit::addBlock(DIE &Die,dwarf::AttributeAttribute,DIELoc *Loc) {
392 Loc->computeSize(Asm->getDwarfFormParams());
393DIELocs.push_back(Loc);// Memoize so we can call the destructor later on.
394addAttribute(Die,Attribute, Loc->BestForm(DD->getDwarfVersion()), Loc);
395}
396
397voidDwarfUnit::addBlock(DIE &Die,dwarf::AttributeAttribute,dwarf::Form Form,
398DIEBlock *Block) {
399Block->computeSize(Asm->getDwarfFormParams());
400DIEBlocks.push_back(Block);// Memoize so we can call the destructor later on.
401addAttribute(Die,Attribute, Form,Block);
402}
403
404voidDwarfUnit::addBlock(DIE &Die,dwarf::AttributeAttribute,
405DIEBlock *Block) {
406addBlock(Die,Attribute,Block->BestForm(),Block);
407}
408
409voidDwarfUnit::addSourceLine(DIE &Die,unsigned Line,constDIFile *File) {
410if (Line == 0)
411return;
412
413unsigned FileID =getOrCreateSourceID(File);
414addUInt(Die, dwarf::DW_AT_decl_file, std::nullopt, FileID);
415addUInt(Die, dwarf::DW_AT_decl_line, std::nullopt, Line);
416}
417
418voidDwarfUnit::addSourceLine(DIE &Die,constDILocalVariable *V) {
419assert(V);
420
421addSourceLine(Die, V->getLine(), V->getFile());
422}
423
424voidDwarfUnit::addSourceLine(DIE &Die,constDIGlobalVariable *G) {
425assert(G);
426
427addSourceLine(Die,G->getLine(),G->getFile());
428}
429
430voidDwarfUnit::addSourceLine(DIE &Die,constDISubprogram *SP) {
431assert(SP);
432
433addSourceLine(Die, SP->getLine(), SP->getFile());
434}
435
436voidDwarfUnit::addSourceLine(DIE &Die,constDILabel *L) {
437assert(L);
438
439addSourceLine(Die, L->getLine(), L->getFile());
440}
441
442voidDwarfUnit::addSourceLine(DIE &Die,constDIType *Ty) {
443assert(Ty);
444
445addSourceLine(Die, Ty->getLine(), Ty->getFile());
446}
447
448voidDwarfUnit::addSourceLine(DIE &Die,constDIObjCProperty *Ty) {
449assert(Ty);
450
451addSourceLine(Die, Ty->getLine(), Ty->getFile());
452}
453
454voidDwarfUnit::addConstantFPValue(DIE &Die,constConstantFP *CFP) {
455// Pass this down to addConstantValue as an unsigned bag of bits.
456addConstantValue(Die, CFP->getValueAPF().bitcastToAPInt(),true);
457}
458
459voidDwarfUnit::addConstantValue(DIE &Die,constConstantInt *CI,
460constDIType *Ty) {
461addConstantValue(Die, CI->getValue(), Ty);
462}
463
464voidDwarfUnit::addConstantValue(DIE &Die,uint64_t Val,constDIType *Ty) {
465addConstantValue(Die,DD->isUnsignedDIType(Ty), Val);
466}
467
468voidDwarfUnit::addConstantValue(DIE &Die,boolUnsigned,uint64_t Val) {
469// FIXME: This is a bit conservative/simple - it emits negative values always
470// sign extended to 64 bits rather than minimizing the number of bytes.
471addUInt(Die, dwarf::DW_AT_const_value,
472Unsigned ? dwarf::DW_FORM_udata : dwarf::DW_FORM_sdata, Val);
473}
474
475voidDwarfUnit::addConstantValue(DIE &Die,constAPInt &Val,constDIType *Ty) {
476addConstantValue(Die, Val,DD->isUnsignedDIType(Ty));
477}
478
479voidDwarfUnit::addConstantValue(DIE &Die,constAPInt &Val,boolUnsigned) {
480unsigned CIBitWidth = Val.getBitWidth();
481if (CIBitWidth <= 64) {
482addConstantValue(Die,Unsigned,
483Unsigned ? Val.getZExtValue() : Val.getSExtValue());
484return;
485 }
486
487DIEBlock *Block =new (DIEValueAllocator)DIEBlock;
488
489// Get the raw data form of the large APInt.
490constuint64_t *Ptr64 = Val.getRawData();
491
492int NumBytes = Val.getBitWidth() / 8;// 8 bits per byte.
493bool LittleEndian =Asm->getDataLayout().isLittleEndian();
494
495// Output the constant to DWARF one byte at a time.
496for (int i = 0; i < NumBytes; i++) {
497uint8_t c;
498if (LittleEndian)
499 c = Ptr64[i / 8] >> (8 * (i & 7));
500else
501 c = Ptr64[(NumBytes - 1 - i) / 8] >> (8 * ((NumBytes - 1 - i) & 7));
502addUInt(*Block, dwarf::DW_FORM_data1, c);
503 }
504
505addBlock(Die, dwarf::DW_AT_const_value,Block);
506}
507
508voidDwarfUnit::addLinkageName(DIE &Die,StringRefLinkageName) {
509if (!LinkageName.empty())
510addString(Die,
511DD->getDwarfVersion() >= 4 ? dwarf::DW_AT_linkage_name
512 : dwarf::DW_AT_MIPS_linkage_name,
513GlobalValue::dropLLVMManglingEscape(LinkageName));
514}
515
516voidDwarfUnit::addTemplateParams(DIE &Buffer, DINodeArray TParams) {
517// Add template parameters.
518for (constauto *Element : TParams) {
519if (auto *TTP = dyn_cast<DITemplateTypeParameter>(Element))
520 constructTemplateTypeParameterDIE(Buffer, TTP);
521elseif (auto *TVP = dyn_cast<DITemplateValueParameter>(Element))
522 constructTemplateValueParameterDIE(Buffer, TVP);
523 }
524}
525
526/// Add thrown types.
527voidDwarfUnit::addThrownTypes(DIE &Die, DINodeArray ThrownTypes) {
528for (constauto *Ty : ThrownTypes) {
529DIE &TT =createAndAddDIE(dwarf::DW_TAG_thrown_type, Die);
530addType(TT, cast<DIType>(Ty));
531 }
532}
533
534voidDwarfUnit::addAccess(DIE &Die,DINode::DIFlags Flags) {
535if ((Flags &DINode::FlagAccessibility) == DINode::FlagProtected)
536addUInt(Die, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
537dwarf::DW_ACCESS_protected);
538elseif ((Flags &DINode::FlagAccessibility) == DINode::FlagPrivate)
539addUInt(Die, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
540dwarf::DW_ACCESS_private);
541elseif ((Flags &DINode::FlagAccessibility) == DINode::FlagPublic)
542addUInt(Die, dwarf::DW_AT_accessibility, dwarf::DW_FORM_data1,
543dwarf::DW_ACCESS_public);
544}
545
546DIE *DwarfUnit::getOrCreateContextDIE(constDIScope *Context) {
547if (!Context || isa<DIFile>(Context) || isa<DICompileUnit>(Context))
548return &getUnitDie();
549if (auto *T = dyn_cast<DIType>(Context))
550returngetOrCreateTypeDIE(T);
551if (auto *NS = dyn_cast<DINamespace>(Context))
552returngetOrCreateNameSpace(NS);
553if (auto *SP = dyn_cast<DISubprogram>(Context))
554returngetOrCreateSubprogramDIE(SP);
555if (auto *M = dyn_cast<DIModule>(Context))
556returngetOrCreateModule(M);
557returngetDIE(Context);
558}
559
560DIE *DwarfUnit::createTypeDIE(constDICompositeType *Ty) {
561auto *Context = Ty->getScope();
562DIE *ContextDIE =getOrCreateContextDIE(Context);
563
564if (DIE *TyDIE =getDIE(Ty))
565return TyDIE;
566
567// Create new type.
568DIE &TyDIE =createAndAddDIE(Ty->getTag(), *ContextDIE, Ty);
569
570constructTypeDIE(TyDIE, cast<DICompositeType>(Ty));
571
572updateAcceleratorTables(Context, Ty, TyDIE);
573return &TyDIE;
574}
575
576DIE *DwarfUnit::createTypeDIE(constDIScope *Context,DIE &ContextDIE,
577constDIType *Ty) {
578// Create new type.
579DIE &TyDIE =createAndAddDIE(Ty->getTag(), ContextDIE, Ty);
580
581auto construct = [&](constauto *Ty) {
582updateAcceleratorTables(Context, Ty, TyDIE);
583constructTypeDIE(TyDIE, Ty);
584 };
585
586if (auto *CTy = dyn_cast<DICompositeType>(Ty)) {
587if (DD->generateTypeUnits() && !Ty->isForwardDecl() &&
588 (Ty->getRawName() || CTy->getRawIdentifier())) {
589// Skip updating the accelerator tables since this is not the full type.
590if (MDString *TypeId = CTy->getRawIdentifier()) {
591addGlobalType(Ty, TyDIE, Context);
592DD->addDwarfTypeUnitType(getCU(), TypeId->getString(), TyDIE, CTy);
593 }else {
594updateAcceleratorTables(Context, Ty, TyDIE);
595 finishNonUnitTypeDIE(TyDIE, CTy);
596 }
597return &TyDIE;
598 }
599 construct(CTy);
600 }elseif (auto *BT = dyn_cast<DIBasicType>(Ty))
601 construct(BT);
602elseif (auto *ST = dyn_cast<DIStringType>(Ty))
603 construct(ST);
604elseif (auto *STy = dyn_cast<DISubroutineType>(Ty))
605 construct(STy);
606else
607 construct(cast<DIDerivedType>(Ty));
608
609return &TyDIE;
610}
611
612DIE *DwarfUnit::getOrCreateTypeDIE(constMDNode *TyNode) {
613if (!TyNode)
614returnnullptr;
615
616auto *Ty = cast<DIType>(TyNode);
617
618// DW_TAG_restrict_type is not supported in DWARF2
619if (Ty->getTag() == dwarf::DW_TAG_restrict_type &&DD->getDwarfVersion() <= 2)
620returngetOrCreateTypeDIE(cast<DIDerivedType>(Ty)->getBaseType());
621
622// DW_TAG_atomic_type is not supported in DWARF < 5
623if (Ty->getTag() == dwarf::DW_TAG_atomic_type &&DD->getDwarfVersion() < 5)
624returngetOrCreateTypeDIE(cast<DIDerivedType>(Ty)->getBaseType());
625
626// Construct the context before querying for the existence of the DIE in case
627// such construction creates the DIE.
628auto *Context = Ty->getScope();
629DIE *ContextDIE =getOrCreateContextDIE(Context);
630assert(ContextDIE);
631
632if (DIE *TyDIE =getDIE(Ty))
633return TyDIE;
634
635returnstatic_cast<DwarfUnit *>(ContextDIE->getUnit())
636 ->createTypeDIE(Context, *ContextDIE, Ty);
637}
638
639voidDwarfUnit::updateAcceleratorTables(constDIScope *Context,
640constDIType *Ty,constDIE &TyDIE) {
641if (Ty->getName().empty())
642return;
643if (Ty->isForwardDecl())
644return;
645
646// add temporary record for this type to be added later
647
648unsigned Flags = 0;
649if (auto *CT = dyn_cast<DICompositeType>(Ty)) {
650// A runtime language of 0 actually means C/C++ and that any
651// non-negative value is some version of Objective-C/C++.
652if (CT->getRuntimeLang() == 0 || CT->isObjcClassComplete())
653 Flags =dwarf::DW_FLAG_type_implementation;
654 }
655
656DD->addAccelType(*this,CUNode->getNameTableKind(), Ty->getName(), TyDIE,
657 Flags);
658
659if (auto *CT = dyn_cast<DICompositeType>(Ty))
660if (Ty->getName() != CT->getIdentifier() &&
661 CT->getRuntimeLang() == dwarf::DW_LANG_Swift)
662DD->addAccelType(*this,CUNode->getNameTableKind(), CT->getIdentifier(),
663 TyDIE, Flags);
664
665addGlobalType(Ty, TyDIE, Context);
666}
667
668voidDwarfUnit::addGlobalType(constDIType *Ty,constDIE &TyDIE,
669constDIScope *Context) {
670if (!Context || isa<DICompileUnit>(Context) || isa<DIFile>(Context) ||
671 isa<DINamespace>(Context) || isa<DICommonBlock>(Context))
672addGlobalTypeImpl(Ty, TyDIE, Context);
673}
674
675voidDwarfUnit::addType(DIE &Entity,constDIType *Ty,
676dwarf::AttributeAttribute) {
677assert(Ty &&"Trying to add a type that doesn't exist?");
678addDIEEntry(Entity,Attribute,DIEEntry(*getOrCreateTypeDIE(Ty)));
679}
680
681std::stringDwarfUnit::getParentContextString(constDIScope *Context) const{
682if (!Context)
683return"";
684
685// FIXME: Decide whether to implement this for non-C++ languages.
686if (!dwarf::isCPlusPlus((dwarf::SourceLanguage)getLanguage()))
687return"";
688
689 std::string CS;
690SmallVector<const DIScope *, 1> Parents;
691while (!isa<DICompileUnit>(Context)) {
692 Parents.push_back(Context);
693if (constDIScope *S = Context->getScope())
694 Context = S;
695else
696// Structure, etc types will have a NULL context if they're at the top
697// level.
698break;
699 }
700
701// Reverse iterate over our list to go from the outermost construct to the
702// innermost.
703for (constDIScope *Ctx :llvm::reverse(Parents)) {
704StringRefName = Ctx->getName();
705if (Name.empty() && isa<DINamespace>(Ctx))
706Name ="(anonymous namespace)";
707if (!Name.empty()) {
708 CS +=Name;
709 CS +="::";
710 }
711 }
712return CS;
713}
714
715voidDwarfUnit::constructTypeDIE(DIE &Buffer,constDIBasicType *BTy) {
716// Get core information.
717StringRefName = BTy->getName();
718// Add name if not anonymous or intermediate type.
719if (!Name.empty())
720addString(Buffer, dwarf::DW_AT_name,Name);
721
722// An unspecified type only has a name attribute.
723if (BTy->getTag() == dwarf::DW_TAG_unspecified_type)
724return;
725
726if (BTy->getTag() != dwarf::DW_TAG_string_type)
727addUInt(Buffer, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
728 BTy->getEncoding());
729
730uint64_tSize = BTy->getSizeInBits() >> 3;
731addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,Size);
732
733if (BTy->isBigEndian())
734addUInt(Buffer, dwarf::DW_AT_endianity, std::nullopt, dwarf::DW_END_big);
735elseif (BTy->isLittleEndian())
736addUInt(Buffer, dwarf::DW_AT_endianity, std::nullopt, dwarf::DW_END_little);
737
738if (uint32_t NumExtraInhabitants = BTy->getNumExtraInhabitants())
739addUInt(Buffer, dwarf::DW_AT_LLVM_num_extra_inhabitants, std::nullopt,
740 NumExtraInhabitants);
741}
742
743voidDwarfUnit::constructTypeDIE(DIE &Buffer,constDIStringType *STy) {
744// Get core information.
745StringRefName = STy->getName();
746// Add name if not anonymous or intermediate type.
747if (!Name.empty())
748addString(Buffer, dwarf::DW_AT_name,Name);
749
750if (DIVariable *Var = STy->getStringLength()) {
751if (auto *VarDIE =getDIE(Var))
752addDIEEntry(Buffer, dwarf::DW_AT_string_length, *VarDIE);
753 }elseif (DIExpression *Expr = STy->getStringLengthExp()) {
754DIELoc *Loc =new (DIEValueAllocator)DIELoc;
755DIEDwarfExpression DwarfExpr(*Asm,getCU(), *Loc);
756// This is to describe the memory location of the
757// length of a Fortran deferred length string, so
758// lock it down as such.
759 DwarfExpr.setMemoryLocationKind();
760 DwarfExpr.addExpression(Expr);
761addBlock(Buffer, dwarf::DW_AT_string_length, DwarfExpr.finalize());
762 }else {
763uint64_tSize = STy->getSizeInBits() >> 3;
764addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,Size);
765 }
766
767if (DIExpression *Expr = STy->getStringLocationExp()) {
768DIELoc *Loc =new (DIEValueAllocator)DIELoc;
769DIEDwarfExpression DwarfExpr(*Asm,getCU(), *Loc);
770// This is to describe the memory location of the
771// string, so lock it down as such.
772 DwarfExpr.setMemoryLocationKind();
773 DwarfExpr.addExpression(Expr);
774addBlock(Buffer, dwarf::DW_AT_data_location, DwarfExpr.finalize());
775 }
776
777if (STy->getEncoding()) {
778// For eventual Unicode support.
779addUInt(Buffer, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
780 STy->getEncoding());
781 }
782}
783
784voidDwarfUnit::constructTypeDIE(DIE &Buffer,constDIDerivedType *DTy) {
785// Get core information.
786StringRefName = DTy->getName();
787uint64_tSize = DTy->getSizeInBits() >> 3;
788uint16_tTag = Buffer.getTag();
789
790// Map to main type, void will not have a type.
791constDIType *FromTy = DTy->getBaseType();
792if (FromTy)
793addType(Buffer, FromTy);
794
795// Add name if not anonymous or intermediate type.
796if (!Name.empty())
797addString(Buffer, dwarf::DW_AT_name,Name);
798
799addAnnotation(Buffer, DTy->getAnnotations());
800
801// If alignment is specified for a typedef , create and insert DW_AT_alignment
802// attribute in DW_TAG_typedef DIE.
803if (Tag == dwarf::DW_TAG_typedef &&DD->getDwarfVersion() >= 5) {
804uint32_t AlignInBytes = DTy->getAlignInBytes();
805if (AlignInBytes > 0)
806addUInt(Buffer, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
807 AlignInBytes);
808 }
809
810// Add size if non-zero (derived types might be zero-sized.)
811if (Size &&Tag != dwarf::DW_TAG_pointer_type
812 &&Tag != dwarf::DW_TAG_ptr_to_member_type
813 &&Tag != dwarf::DW_TAG_reference_type
814 &&Tag != dwarf::DW_TAG_rvalue_reference_type)
815addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,Size);
816
817if (Tag == dwarf::DW_TAG_ptr_to_member_type)
818addDIEEntry(Buffer, dwarf::DW_AT_containing_type,
819 *getOrCreateTypeDIE(cast<DIDerivedType>(DTy)->getClassType()));
820
821addAccess(Buffer, DTy->getFlags());
822
823// Add source line info if available and TyDesc is not a forward declaration.
824if (!DTy->isForwardDecl())
825addSourceLine(Buffer, DTy);
826
827// If DWARF address space value is other than None, add it. The IR
828// verifier checks that DWARF address space only exists for pointer
829// or reference types.
830if (DTy->getDWARFAddressSpace())
831addUInt(Buffer, dwarf::DW_AT_address_class, dwarf::DW_FORM_data4,
832 *DTy->getDWARFAddressSpace());
833
834// Add template alias template parameters.
835if (Tag == dwarf::DW_TAG_template_alias)
836addTemplateParams(Buffer, DTy->getTemplateParams());
837
838if (auto PtrAuthData = DTy->getPtrAuthData()) {
839addUInt(Buffer, dwarf::DW_AT_LLVM_ptrauth_key, dwarf::DW_FORM_data1,
840 PtrAuthData->key());
841if (PtrAuthData->isAddressDiscriminated())
842addFlag(Buffer, dwarf::DW_AT_LLVM_ptrauth_address_discriminated);
843addUInt(Buffer, dwarf::DW_AT_LLVM_ptrauth_extra_discriminator,
844 dwarf::DW_FORM_data2, PtrAuthData->extraDiscriminator());
845if (PtrAuthData->isaPointer())
846addFlag(Buffer, dwarf::DW_AT_LLVM_ptrauth_isa_pointer);
847if (PtrAuthData->authenticatesNullValues())
848addFlag(Buffer, dwarf::DW_AT_LLVM_ptrauth_authenticates_null_values);
849 }
850}
851
852DIE *DwarfUnit::constructSubprogramArguments(DIE &Buffer,DITypeRefArray Args) {
853// Args[0] is the return type.
854DIE *ObjectPointer =nullptr;
855for (unsigned i = 1,N = Args.size(); i <N; ++i) {
856constDIType *Ty = Args[i];
857if (!Ty) {
858assert(i ==N-1 &&"Unspecified parameter must be the last argument");
859createAndAddDIE(dwarf::DW_TAG_unspecified_parameters, Buffer);
860 }else {
861DIE &Arg =createAndAddDIE(dwarf::DW_TAG_formal_parameter, Buffer);
862addType(Arg, Ty);
863if (Ty->isArtificial())
864addFlag(Arg, dwarf::DW_AT_artificial);
865if (Ty->isObjectPointer()) {
866assert(!ObjectPointer &&"Can't have more than one object pointer");
867 ObjectPointer = &Arg;
868 }
869 }
870 }
871
872return ObjectPointer;
873}
874
875voidDwarfUnit::constructTypeDIE(DIE &Buffer,constDISubroutineType *CTy) {
876// Add return type. A void return won't have a type.
877auto Elements = cast<DISubroutineType>(CTy)->getTypeArray();
878if (Elements.size())
879if (auto RTy = Elements[0])
880addType(Buffer, RTy);
881
882bool isPrototyped =true;
883if (Elements.size() == 2 && !Elements[1])
884 isPrototyped =false;
885
886constructSubprogramArguments(Buffer, Elements);
887
888// Add prototype flag if we're dealing with a C language and the function has
889// been prototyped.
890if (isPrototyped &&dwarf::isC((dwarf::SourceLanguage)getLanguage()))
891addFlag(Buffer, dwarf::DW_AT_prototyped);
892
893// Add a DW_AT_calling_convention if this has an explicit convention.
894if (CTy->getCC() && CTy->getCC() != dwarf::DW_CC_normal)
895addUInt(Buffer, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1,
896 CTy->getCC());
897
898if (CTy->isLValueReference())
899addFlag(Buffer, dwarf::DW_AT_reference);
900
901if (CTy->isRValueReference())
902addFlag(Buffer, dwarf::DW_AT_rvalue_reference);
903}
904
905voidDwarfUnit::addAnnotation(DIE &Buffer, DINodeArrayAnnotations) {
906if (!Annotations)
907return;
908
909for (constMetadata *Annotation :Annotations->operands()) {
910constMDNode *MD = cast<MDNode>(Annotation);
911constMDString *Name = cast<MDString>(MD->getOperand(0));
912constauto &Value = MD->getOperand(1);
913
914DIE &AnnotationDie =createAndAddDIE(dwarf::DW_TAG_LLVM_annotation, Buffer);
915addString(AnnotationDie, dwarf::DW_AT_name,Name->getString());
916if (constauto *Data = dyn_cast<MDString>(Value))
917addString(AnnotationDie, dwarf::DW_AT_const_value,Data->getString());
918elseif (constauto *Data = dyn_cast<ConstantAsMetadata>(Value))
919addConstantValue(AnnotationDie,Data->getValue()->getUniqueInteger(),
920/*Unsigned=*/true);
921else
922assert(false &&"Unsupported annotation value type");
923 }
924}
925
926voidDwarfUnit::constructTypeDIE(DIE &Buffer,constDICompositeType *CTy) {
927// Add name if not anonymous or intermediate type.
928StringRefName = CTy->getName();
929
930uint64_tSize = CTy->getSizeInBits() >> 3;
931uint16_tTag = Buffer.getTag();
932
933switch (Tag) {
934case dwarf::DW_TAG_array_type:
935 constructArrayTypeDIE(Buffer, CTy);
936break;
937case dwarf::DW_TAG_enumeration_type:
938 constructEnumTypeDIE(Buffer, CTy);
939break;
940case dwarf::DW_TAG_variant_part:
941case dwarf::DW_TAG_structure_type:
942case dwarf::DW_TAG_union_type:
943case dwarf::DW_TAG_class_type:
944case dwarf::DW_TAG_namelist: {
945// Emit the discriminator for a variant part.
946DIDerivedType *Discriminator =nullptr;
947if (Tag == dwarf::DW_TAG_variant_part) {
948 Discriminator = CTy->getDiscriminator();
949if (Discriminator) {
950// DWARF says:
951// If the variant part has a discriminant, the discriminant is
952// represented by a separate debugging information entry which is
953// a child of the variant part entry.
954DIE &DiscMember = constructMemberDIE(Buffer, Discriminator);
955addDIEEntry(Buffer, dwarf::DW_AT_discr, DiscMember);
956 }
957 }
958
959// Add template parameters to a class, structure or union types.
960if (Tag == dwarf::DW_TAG_class_type ||
961Tag == dwarf::DW_TAG_structure_type ||Tag == dwarf::DW_TAG_union_type)
962addTemplateParams(Buffer, CTy->getTemplateParams());
963
964// Add elements to structure type.
965 DINodeArray Elements = CTy->getElements();
966for (constauto *Element : Elements) {
967if (!Element)
968continue;
969if (auto *SP = dyn_cast<DISubprogram>(Element))
970getOrCreateSubprogramDIE(SP);
971elseif (auto *DDTy = dyn_cast<DIDerivedType>(Element)) {
972if (DDTy->getTag() == dwarf::DW_TAG_friend) {
973DIE &ElemDie =createAndAddDIE(dwarf::DW_TAG_friend, Buffer);
974addType(ElemDie, DDTy->getBaseType(), dwarf::DW_AT_friend);
975 }elseif (DDTy->isStaticMember()) {
976getOrCreateStaticMemberDIE(DDTy);
977 }elseif (Tag == dwarf::DW_TAG_variant_part) {
978// When emitting a variant part, wrap each member in
979// DW_TAG_variant.
980DIE &Variant =createAndAddDIE(dwarf::DW_TAG_variant, Buffer);
981if (constConstantInt *CI =
982 dyn_cast_or_null<ConstantInt>(DDTy->getDiscriminantValue())) {
983if (DD->isUnsignedDIType(Discriminator->getBaseType()))
984addUInt(Variant, dwarf::DW_AT_discr_value, std::nullopt,
985 CI->getZExtValue());
986else
987addSInt(Variant, dwarf::DW_AT_discr_value, std::nullopt,
988 CI->getSExtValue());
989 }
990 constructMemberDIE(Variant, DDTy);
991 }else {
992 constructMemberDIE(Buffer, DDTy);
993 }
994 }elseif (auto *Property = dyn_cast<DIObjCProperty>(Element)) {
995DIE &ElemDie =createAndAddDIE(Property->getTag(), Buffer);
996StringRef PropertyName = Property->getName();
997addString(ElemDie, dwarf::DW_AT_APPLE_property_name, PropertyName);
998if (Property->getType())
999addType(ElemDie, Property->getType());
1000addSourceLine(ElemDie, Property);
1001StringRef GetterName = Property->getGetterName();
1002if (!GetterName.empty())
1003addString(ElemDie, dwarf::DW_AT_APPLE_property_getter, GetterName);
1004StringRef SetterName = Property->getSetterName();
1005if (!SetterName.empty())
1006addString(ElemDie, dwarf::DW_AT_APPLE_property_setter, SetterName);
1007if (unsigned PropertyAttributes = Property->getAttributes())
1008addUInt(ElemDie, dwarf::DW_AT_APPLE_property_attribute, std::nullopt,
1009 PropertyAttributes);
1010 }elseif (auto *Composite = dyn_cast<DICompositeType>(Element)) {
1011if (Composite->getTag() == dwarf::DW_TAG_variant_part) {
1012DIE &VariantPart =createAndAddDIE(Composite->getTag(), Buffer);
1013constructTypeDIE(VariantPart, Composite);
1014 }
1015 }elseif (Tag == dwarf::DW_TAG_namelist) {
1016auto *Var = dyn_cast<DINode>(Element);
1017auto *VarDIE =getDIE(Var);
1018if (VarDIE) {
1019DIE &ItemDie =createAndAddDIE(dwarf::DW_TAG_namelist_item, Buffer);
1020addDIEEntry(ItemDie, dwarf::DW_AT_namelist_item, *VarDIE);
1021 }
1022 }
1023 }
1024
1025if (CTy->isAppleBlockExtension())
1026addFlag(Buffer, dwarf::DW_AT_APPLE_block);
1027
1028if (CTy->getExportSymbols())
1029addFlag(Buffer, dwarf::DW_AT_export_symbols);
1030
1031// This is outside the DWARF spec, but GDB expects a DW_AT_containing_type
1032// inside C++ composite types to point to the base class with the vtable.
1033// Rust uses DW_AT_containing_type to link a vtable to the type
1034// for which it was created.
1035if (auto *ContainingType = CTy->getVTableHolder())
1036addDIEEntry(Buffer, dwarf::DW_AT_containing_type,
1037 *getOrCreateTypeDIE(ContainingType));
1038
1039if (CTy->isObjcClassComplete())
1040addFlag(Buffer, dwarf::DW_AT_APPLE_objc_complete_type);
1041
1042// Add the type's non-standard calling convention.
1043// DW_CC_pass_by_value/DW_CC_pass_by_reference are introduced in DWARF 5.
1044if (!Asm->TM.Options.DebugStrictDwarf ||DD->getDwarfVersion() >= 5) {
1045uint8_tCC = 0;
1046if (CTy->isTypePassByValue())
1047CC = dwarf::DW_CC_pass_by_value;
1048elseif (CTy->isTypePassByReference())
1049CC = dwarf::DW_CC_pass_by_reference;
1050if (CC)
1051addUInt(Buffer, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1,
1052CC);
1053 }
1054
1055if (auto *SpecifiedFrom = CTy->getSpecification())
1056addDIEEntry(Buffer, dwarf::DW_AT_specification,
1057 *getOrCreateContextDIE(SpecifiedFrom));
1058
1059break;
1060 }
1061default:
1062break;
1063 }
1064
1065// Add name if not anonymous or intermediate type.
1066if (!Name.empty())
1067addString(Buffer, dwarf::DW_AT_name,Name);
1068
1069// For Swift, mangled names are put into DW_AT_linkage_name.
1070if (CTy->getRuntimeLang() == dwarf::DW_LANG_Swift && CTy->getRawIdentifier())
1071addString(Buffer, dwarf::DW_AT_linkage_name, CTy->getIdentifier());
1072
1073addAnnotation(Buffer, CTy->getAnnotations());
1074
1075if (Tag == dwarf::DW_TAG_enumeration_type ||
1076Tag == dwarf::DW_TAG_class_type ||Tag == dwarf::DW_TAG_structure_type ||
1077Tag == dwarf::DW_TAG_union_type) {
1078// Add size if non-zero (derived types might be zero-sized.)
1079// Ignore the size if it's a non-enum forward decl.
1080// TODO: Do we care about size for enum forward declarations?
1081if (Size &&
1082 (!CTy->isForwardDecl() ||Tag == dwarf::DW_TAG_enumeration_type))
1083addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,Size);
1084elseif (!CTy->isForwardDecl())
1085// Add zero size if it is not a forward declaration.
1086addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt, 0);
1087
1088// If we're a forward decl, say so.
1089if (CTy->isForwardDecl())
1090addFlag(Buffer, dwarf::DW_AT_declaration);
1091
1092// Add accessibility info if available.
1093addAccess(Buffer, CTy->getFlags());
1094
1095// Add source line info if available.
1096if (!CTy->isForwardDecl())
1097addSourceLine(Buffer, CTy);
1098
1099// No harm in adding the runtime language to the declaration.
1100unsigned RLang = CTy->getRuntimeLang();
1101if (RLang)
1102addUInt(Buffer, dwarf::DW_AT_APPLE_runtime_class, dwarf::DW_FORM_data1,
1103 RLang);
1104
1105// Add align info if available.
1106if (uint32_t AlignInBytes = CTy->getAlignInBytes())
1107addUInt(Buffer, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1108 AlignInBytes);
1109
1110if (uint32_t NumExtraInhabitants = CTy->getNumExtraInhabitants())
1111addUInt(Buffer, dwarf::DW_AT_LLVM_num_extra_inhabitants, std::nullopt,
1112 NumExtraInhabitants);
1113 }
1114}
1115
1116void DwarfUnit::constructTemplateTypeParameterDIE(
1117DIE &Buffer,constDITemplateTypeParameter *TP) {
1118DIE &ParamDIE =
1119createAndAddDIE(dwarf::DW_TAG_template_type_parameter, Buffer);
1120// Add the type if it exists, it could be void and therefore no type.
1121if (TP->getType())
1122addType(ParamDIE, TP->getType());
1123if (!TP->getName().empty())
1124addString(ParamDIE, dwarf::DW_AT_name, TP->getName());
1125if (TP->isDefault() && isCompatibleWithVersion(5))
1126addFlag(ParamDIE, dwarf::DW_AT_default_value);
1127}
1128
1129void DwarfUnit::constructTemplateValueParameterDIE(
1130DIE &Buffer,constDITemplateValueParameter *VP) {
1131DIE &ParamDIE =createAndAddDIE(VP->getTag(), Buffer);
1132
1133// Add the type if there is one, template template and template parameter
1134// packs will not have a type.
1135if (VP->getTag() == dwarf::DW_TAG_template_value_parameter)
1136addType(ParamDIE, VP->getType());
1137if (!VP->getName().empty())
1138addString(ParamDIE, dwarf::DW_AT_name, VP->getName());
1139if (VP->isDefault() && isCompatibleWithVersion(5))
1140addFlag(ParamDIE, dwarf::DW_AT_default_value);
1141if (Metadata *Val = VP->getValue()) {
1142if (ConstantInt *CI = mdconst::dyn_extract<ConstantInt>(Val))
1143addConstantValue(ParamDIE, CI, VP->getType());
1144elseif (GlobalValue *GV = mdconst::dyn_extract<GlobalValue>(Val)) {
1145// We cannot describe the location of dllimport'd entities: the
1146// computation of their address requires loads from the IAT.
1147if (!GV->hasDLLImportStorageClass()) {
1148// For declaration non-type template parameters (such as global values
1149// and functions)
1150DIELoc *Loc =new (DIEValueAllocator)DIELoc;
1151addOpAddress(*Loc,Asm->getSymbol(GV));
1152// Emit DW_OP_stack_value to use the address as the immediate value of
1153// the parameter, rather than a pointer to it.
1154addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_stack_value);
1155addBlock(ParamDIE, dwarf::DW_AT_location, Loc);
1156 }
1157 }elseif (VP->getTag() == dwarf::DW_TAG_GNU_template_template_param) {
1158assert(isa<MDString>(Val));
1159addString(ParamDIE, dwarf::DW_AT_GNU_template_name,
1160 cast<MDString>(Val)->getString());
1161 }elseif (VP->getTag() == dwarf::DW_TAG_GNU_template_parameter_pack) {
1162addTemplateParams(ParamDIE, cast<MDTuple>(Val));
1163 }
1164 }
1165}
1166
1167DIE *DwarfUnit::getOrCreateNameSpace(constDINamespace *NS) {
1168// Construct the context before querying for the existence of the DIE in case
1169// such construction creates the DIE.
1170DIE *ContextDIE =getOrCreateContextDIE(NS->getScope());
1171
1172if (DIE *NDie =getDIE(NS))
1173return NDie;
1174DIE &NDie =createAndAddDIE(dwarf::DW_TAG_namespace, *ContextDIE, NS);
1175
1176StringRefName = NS->getName();
1177if (!Name.empty())
1178addString(NDie, dwarf::DW_AT_name, NS->getName());
1179else
1180Name ="(anonymous namespace)";
1181DD->addAccelNamespace(*this,CUNode->getNameTableKind(),Name, NDie);
1182addGlobalName(Name, NDie, NS->getScope());
1183if (NS->getExportSymbols())
1184addFlag(NDie, dwarf::DW_AT_export_symbols);
1185return &NDie;
1186}
1187
1188DIE *DwarfUnit::getOrCreateModule(constDIModule *M) {
1189// Construct the context before querying for the existence of the DIE in case
1190// such construction creates the DIE.
1191DIE *ContextDIE =getOrCreateContextDIE(M->getScope());
1192
1193if (DIE *MDie =getDIE(M))
1194return MDie;
1195DIE &MDie =createAndAddDIE(dwarf::DW_TAG_module, *ContextDIE, M);
1196
1197if (!M->getName().empty()) {
1198addString(MDie, dwarf::DW_AT_name, M->getName());
1199addGlobalName(M->getName(), MDie, M->getScope());
1200 }
1201if (!M->getConfigurationMacros().empty())
1202addString(MDie, dwarf::DW_AT_LLVM_config_macros,
1203 M->getConfigurationMacros());
1204if (!M->getIncludePath().empty())
1205addString(MDie, dwarf::DW_AT_LLVM_include_path, M->getIncludePath());
1206if (!M->getAPINotesFile().empty())
1207addString(MDie, dwarf::DW_AT_LLVM_apinotes, M->getAPINotesFile());
1208if (M->getFile())
1209addUInt(MDie, dwarf::DW_AT_decl_file, std::nullopt,
1210getOrCreateSourceID(M->getFile()));
1211if (M->getLineNo())
1212addUInt(MDie, dwarf::DW_AT_decl_line, std::nullopt, M->getLineNo());
1213if (M->getIsDecl())
1214addFlag(MDie, dwarf::DW_AT_declaration);
1215
1216return &MDie;
1217}
1218
1219DIE *DwarfUnit::getOrCreateSubprogramDIE(constDISubprogram *SP,bool Minimal) {
1220// Construct the context before querying for the existence of the DIE in case
1221// such construction creates the DIE (as is the case for member function
1222// declarations).
1223DIE *ContextDIE =
1224 Minimal ? &getUnitDie() :getOrCreateContextDIE(SP->getScope());
1225
1226if (DIE *SPDie =getDIE(SP))
1227return SPDie;
1228
1229if (auto *SPDecl = SP->getDeclaration()) {
1230if (!Minimal) {
1231// Add subprogram definitions to the CU die directly.
1232 ContextDIE = &getUnitDie();
1233// Build the decl now to ensure it precedes the definition.
1234getOrCreateSubprogramDIE(SPDecl);
1235 }
1236 }
1237
1238// DW_TAG_inlined_subroutine may refer to this DIE.
1239DIE &SPDie =createAndAddDIE(dwarf::DW_TAG_subprogram, *ContextDIE, SP);
1240
1241// Stop here and fill this in later, depending on whether or not this
1242// subprogram turns out to have inlined instances or not.
1243if (SP->isDefinition())
1244return &SPDie;
1245
1246static_cast<DwarfUnit *>(SPDie.getUnit())
1247 ->applySubprogramAttributes(SP, SPDie);
1248return &SPDie;
1249}
1250
1251boolDwarfUnit::applySubprogramDefinitionAttributes(constDISubprogram *SP,
1252DIE &SPDie,bool Minimal) {
1253DIE *DeclDie =nullptr;
1254StringRef DeclLinkageName;
1255if (auto *SPDecl = SP->getDeclaration()) {
1256if (!Minimal) {
1257DITypeRefArray DeclArgs, DefinitionArgs;
1258 DeclArgs = SPDecl->getType()->getTypeArray();
1259 DefinitionArgs = SP->getType()->getTypeArray();
1260
1261if (DeclArgs.size() && DefinitionArgs.size())
1262if (DefinitionArgs[0] !=nullptr && DeclArgs[0] != DefinitionArgs[0])
1263addType(SPDie, DefinitionArgs[0]);
1264
1265 DeclDie =getDIE(SPDecl);
1266assert(DeclDie &&"This DIE should've already been constructed when the "
1267"definition DIE was created in "
1268"getOrCreateSubprogramDIE");
1269// Look at the Decl's linkage name only if we emitted it.
1270if (DD->useAllLinkageNames())
1271 DeclLinkageName = SPDecl->getLinkageName();
1272unsigned DeclID =getOrCreateSourceID(SPDecl->getFile());
1273unsigned DefID =getOrCreateSourceID(SP->getFile());
1274if (DeclID != DefID)
1275addUInt(SPDie, dwarf::DW_AT_decl_file, std::nullopt, DefID);
1276
1277if (SP->getLine() != SPDecl->getLine())
1278addUInt(SPDie, dwarf::DW_AT_decl_line, std::nullopt, SP->getLine());
1279 }
1280 }
1281
1282// Add function template parameters.
1283addTemplateParams(SPDie, SP->getTemplateParams());
1284
1285// Add the linkage name if we have one and it isn't in the Decl.
1286StringRefLinkageName = SP->getLinkageName();
1287assert(((LinkageName.empty() || DeclLinkageName.empty()) ||
1288LinkageName == DeclLinkageName) &&
1289"decl has a linkage name and it is different");
1290if (DeclLinkageName.empty() &&
1291// Always emit it for abstract subprograms.
1292 (DD->useAllLinkageNames() ||DU->getAbstractScopeDIEs().lookup(SP)))
1293addLinkageName(SPDie,LinkageName);
1294
1295if (!DeclDie)
1296returnfalse;
1297
1298// Refer to the function declaration where all the other attributes will be
1299// found.
1300addDIEEntry(SPDie, dwarf::DW_AT_specification, *DeclDie);
1301returntrue;
1302}
1303
1304voidDwarfUnit::applySubprogramAttributes(constDISubprogram *SP,DIE &SPDie,
1305bool SkipSPAttributes) {
1306// If -fdebug-info-for-profiling is enabled, need to emit the subprogram
1307// and its source location.
1308bool SkipSPSourceLocation = SkipSPAttributes &&
1309 !CUNode->getDebugInfoForProfiling();
1310if (!SkipSPSourceLocation)
1311if (applySubprogramDefinitionAttributes(SP, SPDie, SkipSPAttributes))
1312return;
1313
1314// Constructors and operators for anonymous aggregates do not have names.
1315if (!SP->getName().empty())
1316addString(SPDie, dwarf::DW_AT_name, SP->getName());
1317
1318addAnnotation(SPDie, SP->getAnnotations());
1319
1320if (!SkipSPSourceLocation)
1321addSourceLine(SPDie, SP);
1322
1323// Skip the rest of the attributes under -gmlt to save space.
1324if (SkipSPAttributes)
1325return;
1326
1327// Add the prototype if we have a prototype and we have a C like
1328// language.
1329if (SP->isPrototyped() &&dwarf::isC((dwarf::SourceLanguage)getLanguage()))
1330addFlag(SPDie, dwarf::DW_AT_prototyped);
1331
1332if (SP->isObjCDirect())
1333addFlag(SPDie, dwarf::DW_AT_APPLE_objc_direct);
1334
1335unsignedCC = 0;
1336DITypeRefArray Args;
1337if (constDISubroutineType *SPTy = SP->getType()) {
1338 Args = SPTy->getTypeArray();
1339CC = SPTy->getCC();
1340 }
1341
1342// Add a DW_AT_calling_convention if this has an explicit convention.
1343if (CC &&CC != dwarf::DW_CC_normal)
1344addUInt(SPDie, dwarf::DW_AT_calling_convention, dwarf::DW_FORM_data1,CC);
1345
1346// Add a return type. If this is a type like a C/C++ void type we don't add a
1347// return type.
1348if (Args.size())
1349if (auto Ty = Args[0])
1350addType(SPDie, Ty);
1351
1352unsigned VK = SP->getVirtuality();
1353if (VK) {
1354addUInt(SPDie, dwarf::DW_AT_virtuality, dwarf::DW_FORM_data1, VK);
1355if (SP->getVirtualIndex() != -1u) {
1356DIELoc *Block =getDIELoc();
1357addUInt(*Block, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
1358addUInt(*Block, dwarf::DW_FORM_udata, SP->getVirtualIndex());
1359addBlock(SPDie, dwarf::DW_AT_vtable_elem_location,Block);
1360 }
1361ContainingTypeMap.insert(std::make_pair(&SPDie, SP->getContainingType()));
1362 }
1363
1364if (!SP->isDefinition()) {
1365addFlag(SPDie, dwarf::DW_AT_declaration);
1366
1367// Add arguments. Do not add arguments for subprogram definition. They will
1368// be handled while processing variables.
1369if (auto *ObjectPointer =constructSubprogramArguments(SPDie, Args))
1370addDIEEntry(SPDie, dwarf::DW_AT_object_pointer, *ObjectPointer);
1371 }
1372
1373addThrownTypes(SPDie, SP->getThrownTypes());
1374
1375if (SP->isArtificial())
1376addFlag(SPDie, dwarf::DW_AT_artificial);
1377
1378if (!SP->isLocalToUnit())
1379addFlag(SPDie, dwarf::DW_AT_external);
1380
1381if (DD->useAppleExtensionAttributes()) {
1382if (SP->isOptimized())
1383addFlag(SPDie, dwarf::DW_AT_APPLE_optimized);
1384
1385if (unsignedisa =Asm->getISAEncoding())
1386addUInt(SPDie, dwarf::DW_AT_APPLE_isa, dwarf::DW_FORM_flag,isa);
1387 }
1388
1389if (SP->isLValueReference())
1390addFlag(SPDie, dwarf::DW_AT_reference);
1391
1392if (SP->isRValueReference())
1393addFlag(SPDie, dwarf::DW_AT_rvalue_reference);
1394
1395if (SP->isNoReturn())
1396addFlag(SPDie, dwarf::DW_AT_noreturn);
1397
1398addAccess(SPDie, SP->getFlags());
1399
1400if (SP->isExplicit())
1401addFlag(SPDie, dwarf::DW_AT_explicit);
1402
1403if (SP->isMainSubprogram())
1404addFlag(SPDie, dwarf::DW_AT_main_subprogram);
1405if (SP->isPure())
1406addFlag(SPDie, dwarf::DW_AT_pure);
1407if (SP->isElemental())
1408addFlag(SPDie, dwarf::DW_AT_elemental);
1409if (SP->isRecursive())
1410addFlag(SPDie, dwarf::DW_AT_recursive);
1411
1412if (!SP->getTargetFuncName().empty())
1413addString(SPDie, dwarf::DW_AT_trampoline, SP->getTargetFuncName());
1414
1415if (DD->getDwarfVersion() >= 5 && SP->isDeleted())
1416addFlag(SPDie, dwarf::DW_AT_deleted);
1417}
1418
1419void DwarfUnit::constructSubrangeDIE(DIE &Buffer,constDISubrange *SR,
1420DIE *IndexTy) {
1421DIE &DW_Subrange =createAndAddDIE(dwarf::DW_TAG_subrange_type, Buffer);
1422addDIEEntry(DW_Subrange, dwarf::DW_AT_type, *IndexTy);
1423
1424// The LowerBound value defines the lower bounds which is typically zero for
1425// C/C++. The Count value is the number of elements. Values are 64 bit. If
1426// Count == -1 then the array is unbounded and we do not emit
1427// DW_AT_lower_bound and DW_AT_count attributes.
1428 int64_t DefaultLowerBound = getDefaultLowerBound();
1429
1430auto AddBoundTypeEntry = [&](dwarf::Attribute Attr,
1431 DISubrange::BoundType Bound) ->void {
1432if (auto *BV = dyn_cast_if_present<DIVariable *>(Bound)) {
1433if (auto *VarDIE =getDIE(BV))
1434addDIEEntry(DW_Subrange, Attr, *VarDIE);
1435 }elseif (auto *BE = dyn_cast_if_present<DIExpression *>(Bound)) {
1436DIELoc *Loc =new (DIEValueAllocator)DIELoc;
1437DIEDwarfExpression DwarfExpr(*Asm,getCU(), *Loc);
1438 DwarfExpr.setMemoryLocationKind();
1439 DwarfExpr.addExpression(BE);
1440addBlock(DW_Subrange, Attr, DwarfExpr.finalize());
1441 }elseif (auto *BI = dyn_cast_if_present<ConstantInt *>(Bound)) {
1442if (Attr == dwarf::DW_AT_count) {
1443if (BI->getSExtValue() != -1)
1444addUInt(DW_Subrange, Attr, std::nullopt, BI->getSExtValue());
1445 }elseif (Attr != dwarf::DW_AT_lower_bound || DefaultLowerBound == -1 ||
1446 BI->getSExtValue() != DefaultLowerBound)
1447addSInt(DW_Subrange, Attr, dwarf::DW_FORM_sdata, BI->getSExtValue());
1448 }
1449 };
1450
1451 AddBoundTypeEntry(dwarf::DW_AT_lower_bound, SR->getLowerBound());
1452
1453 AddBoundTypeEntry(dwarf::DW_AT_count, SR->getCount());
1454
1455 AddBoundTypeEntry(dwarf::DW_AT_upper_bound, SR->getUpperBound());
1456
1457 AddBoundTypeEntry(dwarf::DW_AT_byte_stride, SR->getStride());
1458}
1459
1460void DwarfUnit::constructGenericSubrangeDIE(DIE &Buffer,
1461constDIGenericSubrange *GSR,
1462DIE *IndexTy) {
1463DIE &DwGenericSubrange =
1464createAndAddDIE(dwarf::DW_TAG_generic_subrange, Buffer);
1465addDIEEntry(DwGenericSubrange, dwarf::DW_AT_type, *IndexTy);
1466
1467 int64_t DefaultLowerBound = getDefaultLowerBound();
1468
1469auto AddBoundTypeEntry = [&](dwarf::Attribute Attr,
1470DIGenericSubrange::BoundType Bound) ->void {
1471if (auto *BV = dyn_cast_if_present<DIVariable *>(Bound)) {
1472if (auto *VarDIE =getDIE(BV))
1473addDIEEntry(DwGenericSubrange, Attr, *VarDIE);
1474 }elseif (auto *BE = dyn_cast_if_present<DIExpression *>(Bound)) {
1475if (BE->isConstant() &&
1476DIExpression::SignedOrUnsignedConstant::SignedConstant ==
1477 *BE->isConstant()) {
1478if (Attr != dwarf::DW_AT_lower_bound || DefaultLowerBound == -1 ||
1479static_cast<int64_t>(BE->getElement(1)) != DefaultLowerBound)
1480addSInt(DwGenericSubrange, Attr, dwarf::DW_FORM_sdata,
1481 BE->getElement(1));
1482 }else {
1483DIELoc *Loc =new (DIEValueAllocator)DIELoc;
1484DIEDwarfExpression DwarfExpr(*Asm,getCU(), *Loc);
1485 DwarfExpr.setMemoryLocationKind();
1486 DwarfExpr.addExpression(BE);
1487addBlock(DwGenericSubrange, Attr, DwarfExpr.finalize());
1488 }
1489 }
1490 };
1491
1492 AddBoundTypeEntry(dwarf::DW_AT_lower_bound, GSR->getLowerBound());
1493 AddBoundTypeEntry(dwarf::DW_AT_count, GSR->getCount());
1494 AddBoundTypeEntry(dwarf::DW_AT_upper_bound, GSR->getUpperBound());
1495 AddBoundTypeEntry(dwarf::DW_AT_byte_stride, GSR->getStride());
1496}
1497
1498DIE *DwarfUnit::getIndexTyDie() {
1499if (IndexTyDie)
1500returnIndexTyDie;
1501// Construct an integer type to use for indexes.
1502IndexTyDie = &createAndAddDIE(dwarf::DW_TAG_base_type,getUnitDie());
1503StringRefName ="__ARRAY_SIZE_TYPE__";
1504addString(*IndexTyDie, dwarf::DW_AT_name,Name);
1505addUInt(*IndexTyDie, dwarf::DW_AT_byte_size, std::nullopt,sizeof(int64_t));
1506addUInt(*IndexTyDie, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
1507dwarf::getArrayIndexTypeEncoding(
1508 (dwarf::SourceLanguage)getLanguage()));
1509DD->addAccelType(*this,CUNode->getNameTableKind(),Name, *IndexTyDie,
1510/*Flags*/ 0);
1511returnIndexTyDie;
1512}
1513
1514/// Returns true if the vector's size differs from the sum of sizes of elements
1515/// the user specified. This can occur if the vector has been rounded up to
1516/// fit memory alignment constraints.
1517staticboolhasVectorBeenPadded(constDICompositeType *CTy) {
1518assert(CTy && CTy->isVector() &&"Composite type is not a vector");
1519constuint64_t ActualSize = CTy->getSizeInBits();
1520
1521// Obtain the size of each element in the vector.
1522DIType *BaseTy = CTy->getBaseType();
1523assert(BaseTy &&"Unknown vector element type.");
1524constuint64_t ElementSize =BaseTy->getSizeInBits();
1525
1526// Locate the number of elements in the vector.
1527const DINodeArray Elements = CTy->getElements();
1528assert(Elements.size() == 1 &&
1529 Elements[0]->getTag() == dwarf::DW_TAG_subrange_type &&
1530"Invalid vector element array, expected one element of type subrange");
1531constauto Subrange = cast<DISubrange>(Elements[0]);
1532constauto NumVecElements =
1533 Subrange->getCount()
1534 ? cast<ConstantInt *>(Subrange->getCount())->getSExtValue()
1535 : 0;
1536
1537// Ensure we found the element count and that the actual size is wide
1538// enough to contain the requested size.
1539assert(ActualSize >= (NumVecElements * ElementSize) &&"Invalid vector size");
1540return ActualSize != (NumVecElements * ElementSize);
1541}
1542
1543void DwarfUnit::constructArrayTypeDIE(DIE &Buffer,constDICompositeType *CTy) {
1544if (CTy->isVector()) {
1545addFlag(Buffer, dwarf::DW_AT_GNU_vector);
1546if (hasVectorBeenPadded(CTy))
1547addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt,
1548 CTy->getSizeInBits() / CHAR_BIT);
1549 }
1550
1551if (DIVariable *Var = CTy->getDataLocation()) {
1552if (auto *VarDIE =getDIE(Var))
1553addDIEEntry(Buffer, dwarf::DW_AT_data_location, *VarDIE);
1554 }elseif (DIExpression *Expr = CTy->getDataLocationExp()) {
1555DIELoc *Loc =new (DIEValueAllocator)DIELoc;
1556DIEDwarfExpression DwarfExpr(*Asm,getCU(), *Loc);
1557 DwarfExpr.setMemoryLocationKind();
1558 DwarfExpr.addExpression(Expr);
1559addBlock(Buffer, dwarf::DW_AT_data_location, DwarfExpr.finalize());
1560 }
1561
1562if (DIVariable *Var = CTy->getAssociated()) {
1563if (auto *VarDIE =getDIE(Var))
1564addDIEEntry(Buffer, dwarf::DW_AT_associated, *VarDIE);
1565 }elseif (DIExpression *Expr = CTy->getAssociatedExp()) {
1566DIELoc *Loc =new (DIEValueAllocator)DIELoc;
1567DIEDwarfExpression DwarfExpr(*Asm,getCU(), *Loc);
1568 DwarfExpr.setMemoryLocationKind();
1569 DwarfExpr.addExpression(Expr);
1570addBlock(Buffer, dwarf::DW_AT_associated, DwarfExpr.finalize());
1571 }
1572
1573if (DIVariable *Var = CTy->getAllocated()) {
1574if (auto *VarDIE =getDIE(Var))
1575addDIEEntry(Buffer, dwarf::DW_AT_allocated, *VarDIE);
1576 }elseif (DIExpression *Expr = CTy->getAllocatedExp()) {
1577DIELoc *Loc =new (DIEValueAllocator)DIELoc;
1578DIEDwarfExpression DwarfExpr(*Asm,getCU(), *Loc);
1579 DwarfExpr.setMemoryLocationKind();
1580 DwarfExpr.addExpression(Expr);
1581addBlock(Buffer, dwarf::DW_AT_allocated, DwarfExpr.finalize());
1582 }
1583
1584if (auto *RankConst = CTy->getRankConst()) {
1585addSInt(Buffer, dwarf::DW_AT_rank, dwarf::DW_FORM_sdata,
1586 RankConst->getSExtValue());
1587 }elseif (auto *RankExpr = CTy->getRankExp()) {
1588DIELoc *Loc =new (DIEValueAllocator)DIELoc;
1589DIEDwarfExpression DwarfExpr(*Asm,getCU(), *Loc);
1590 DwarfExpr.setMemoryLocationKind();
1591 DwarfExpr.addExpression(RankExpr);
1592addBlock(Buffer, dwarf::DW_AT_rank, DwarfExpr.finalize());
1593 }
1594
1595// Emit the element type.
1596addType(Buffer, CTy->getBaseType());
1597
1598// Get an anonymous type for index type.
1599// FIXME: This type should be passed down from the front end
1600// as different languages may have different sizes for indexes.
1601DIE *IdxTy = getIndexTyDie();
1602
1603// Add subranges to array type.
1604 DINodeArrayElements = CTy->getElements();
1605for (DINode *E : Elements) {
1606// FIXME: Should this really be such a loose cast?
1607if (auto *Element = dyn_cast_or_null<DINode>(E)) {
1608if (Element->getTag() == dwarf::DW_TAG_subrange_type)
1609 constructSubrangeDIE(Buffer, cast<DISubrange>(Element), IdxTy);
1610elseif (Element->getTag() == dwarf::DW_TAG_generic_subrange)
1611 constructGenericSubrangeDIE(Buffer, cast<DIGenericSubrange>(Element),
1612 IdxTy);
1613 }
1614 }
1615}
1616
1617void DwarfUnit::constructEnumTypeDIE(DIE &Buffer,constDICompositeType *CTy) {
1618constDIType *DTy = CTy->getBaseType();
1619bool IsUnsigned = DTy &&DD->isUnsignedDIType(DTy);
1620if (DTy) {
1621if (!Asm->TM.Options.DebugStrictDwarf ||DD->getDwarfVersion() >= 3)
1622addType(Buffer, DTy);
1623if (DD->getDwarfVersion() >= 4 && (CTy->getFlags() & DINode::FlagEnumClass))
1624addFlag(Buffer, dwarf::DW_AT_enum_class);
1625 }
1626
1627auto *Context = CTy->getScope();
1628bool IndexEnumerators = !Context || isa<DICompileUnit>(Context) || isa<DIFile>(Context) ||
1629 isa<DINamespace>(Context) || isa<DICommonBlock>(Context);
1630 DINodeArrayElements = CTy->getElements();
1631
1632// Add enumerators to enumeration type.
1633for (constDINode *E : Elements) {
1634auto *Enum = dyn_cast_or_null<DIEnumerator>(E);
1635if (Enum) {
1636DIE &Enumerator =createAndAddDIE(dwarf::DW_TAG_enumerator, Buffer);
1637StringRefName =Enum->getName();
1638addString(Enumerator, dwarf::DW_AT_name,Name);
1639addConstantValue(Enumerator,Enum->getValue(), IsUnsigned);
1640if (IndexEnumerators)
1641addGlobalName(Name,Enumerator, Context);
1642 }
1643 }
1644}
1645
1646voidDwarfUnit::constructContainingTypeDIEs() {
1647for (auto &P :ContainingTypeMap) {
1648DIE &SPDie = *P.first;
1649constDINode *D =P.second;
1650if (!D)
1651continue;
1652DIE *NDie =getDIE(D);
1653if (!NDie)
1654continue;
1655addDIEEntry(SPDie, dwarf::DW_AT_containing_type, *NDie);
1656 }
1657}
1658
1659DIE &DwarfUnit::constructMemberDIE(DIE &Buffer,constDIDerivedType *DT) {
1660DIE &MemberDie =createAndAddDIE(DT->getTag(), Buffer);
1661StringRefName = DT->getName();
1662if (!Name.empty())
1663addString(MemberDie, dwarf::DW_AT_name,Name);
1664
1665addAnnotation(MemberDie, DT->getAnnotations());
1666
1667if (DIType *Resolved = DT->getBaseType())
1668addType(MemberDie, Resolved);
1669
1670addSourceLine(MemberDie, DT);
1671
1672if (DT->getTag() == dwarf::DW_TAG_inheritance && DT->isVirtual()) {
1673
1674// For C++, virtual base classes are not at fixed offset. Use following
1675// expression to extract appropriate offset from vtable.
1676// BaseAddr = ObAddr + *((*ObAddr) - Offset)
1677
1678DIELoc *VBaseLocationDie =new (DIEValueAllocator)DIELoc;
1679addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_dup);
1680addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
1681addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
1682addUInt(*VBaseLocationDie, dwarf::DW_FORM_udata, DT->getOffsetInBits());
1683addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_minus);
1684addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
1685addUInt(*VBaseLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
1686
1687addBlock(MemberDie, dwarf::DW_AT_data_member_location, VBaseLocationDie);
1688 }else {
1689uint64_tSize = DT->getSizeInBits();
1690uint64_t FieldSize =DD->getBaseTypeSize(DT);
1691uint32_t AlignInBytes = DT->getAlignInBytes();
1692uint64_t OffsetInBytes;
1693
1694bool IsBitfield = DT->isBitField();
1695if (IsBitfield) {
1696// Handle bitfield, assume bytes are 8 bits.
1697if (DD->useDWARF2Bitfields())
1698addUInt(MemberDie, dwarf::DW_AT_byte_size, std::nullopt, FieldSize / 8);
1699addUInt(MemberDie, dwarf::DW_AT_bit_size, std::nullopt,Size);
1700
1701assert(DT->getOffsetInBits() <=
1702 (uint64_t)std::numeric_limits<int64_t>::max());
1703 int64_t Offset = DT->getOffsetInBits();
1704// We can't use DT->getAlignInBits() here: AlignInBits for member type
1705// is non-zero if and only if alignment was forced (e.g. _Alignas()),
1706// which can't be done with bitfields. Thus we use FieldSize here.
1707uint32_t AlignInBits = FieldSize;
1708uint32_t AlignMask = ~(AlignInBits - 1);
1709// The bits from the start of the storage unit to the start of the field.
1710uint64_t StartBitOffset = Offset - (Offset & AlignMask);
1711// The byte offset of the field's aligned storage unit inside the struct.
1712 OffsetInBytes = (Offset - StartBitOffset) / 8;
1713
1714if (DD->useDWARF2Bitfields()) {
1715uint64_t HiMark = (Offset + FieldSize) & AlignMask;
1716uint64_t FieldOffset = (HiMark - FieldSize);
1717 Offset -= FieldOffset;
1718
1719// Maybe we need to work from the other end.
1720if (Asm->getDataLayout().isLittleEndian())
1721 Offset = FieldSize - (Offset +Size);
1722
1723if (Offset < 0)
1724addSInt(MemberDie, dwarf::DW_AT_bit_offset, dwarf::DW_FORM_sdata,
1725 Offset);
1726else
1727addUInt(MemberDie, dwarf::DW_AT_bit_offset, std::nullopt,
1728 (uint64_t)Offset);
1729 OffsetInBytes = FieldOffset >> 3;
1730 }else {
1731addUInt(MemberDie, dwarf::DW_AT_data_bit_offset, std::nullopt, Offset);
1732 }
1733 }else {
1734// This is not a bitfield.
1735 OffsetInBytes = DT->getOffsetInBits() / 8;
1736if (AlignInBytes)
1737addUInt(MemberDie, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1738 AlignInBytes);
1739 }
1740
1741if (DD->getDwarfVersion() <= 2) {
1742DIELoc *MemLocationDie =new (DIEValueAllocator)DIELoc;
1743addUInt(*MemLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
1744addUInt(*MemLocationDie, dwarf::DW_FORM_udata, OffsetInBytes);
1745addBlock(MemberDie, dwarf::DW_AT_data_member_location, MemLocationDie);
1746 }elseif (!IsBitfield ||DD->useDWARF2Bitfields()) {
1747// In DWARF v3, DW_FORM_data4/8 in DW_AT_data_member_location are
1748// interpreted as location-list pointers. Interpreting constants as
1749// pointers is not expected, so we use DW_FORM_udata to encode the
1750// constants here.
1751if (DD->getDwarfVersion() == 3)
1752addUInt(MemberDie, dwarf::DW_AT_data_member_location,
1753 dwarf::DW_FORM_udata, OffsetInBytes);
1754else
1755addUInt(MemberDie, dwarf::DW_AT_data_member_location, std::nullopt,
1756 OffsetInBytes);
1757 }
1758 }
1759
1760addAccess(MemberDie, DT->getFlags());
1761
1762if (DT->isVirtual())
1763addUInt(MemberDie, dwarf::DW_AT_virtuality, dwarf::DW_FORM_data1,
1764 dwarf::DW_VIRTUALITY_virtual);
1765
1766// Objective-C properties.
1767if (DINode *PNode = DT->getObjCProperty())
1768if (DIE *PDie =getDIE(PNode))
1769addAttribute(MemberDie, dwarf::DW_AT_APPLE_property,
1770 dwarf::DW_FORM_ref4,DIEEntry(*PDie));
1771
1772if (DT->isArtificial())
1773addFlag(MemberDie, dwarf::DW_AT_artificial);
1774
1775return MemberDie;
1776}
1777
1778DIE *DwarfUnit::getOrCreateStaticMemberDIE(constDIDerivedType *DT) {
1779if (!DT)
1780returnnullptr;
1781
1782// Construct the context before querying for the existence of the DIE in case
1783// such construction creates the DIE.
1784DIE *ContextDIE =getOrCreateContextDIE(DT->getScope());
1785assert(dwarf::isType(ContextDIE->getTag()) &&
1786"Static member should belong to a type.");
1787
1788if (DIE *StaticMemberDIE =getDIE(DT))
1789return StaticMemberDIE;
1790
1791DIE &StaticMemberDIE =createAndAddDIE(DT->getTag(), *ContextDIE, DT);
1792
1793constDIType *Ty = DT->getBaseType();
1794
1795addString(StaticMemberDIE, dwarf::DW_AT_name, DT->getName());
1796addType(StaticMemberDIE, Ty);
1797addSourceLine(StaticMemberDIE, DT);
1798addFlag(StaticMemberDIE, dwarf::DW_AT_external);
1799addFlag(StaticMemberDIE, dwarf::DW_AT_declaration);
1800
1801// Consider the case when the static member was created by the compiler.
1802if (DT->isArtificial())
1803addFlag(StaticMemberDIE, dwarf::DW_AT_artificial);
1804
1805// FIXME: We could omit private if the parent is a class_type, and
1806// public if the parent is something else.
1807addAccess(StaticMemberDIE, DT->getFlags());
1808
1809if (constConstantInt *CI = dyn_cast_or_null<ConstantInt>(DT->getConstant()))
1810addConstantValue(StaticMemberDIE, CI, Ty);
1811if (constConstantFP *CFP = dyn_cast_or_null<ConstantFP>(DT->getConstant()))
1812addConstantFPValue(StaticMemberDIE, CFP);
1813
1814if (uint32_t AlignInBytes = DT->getAlignInBytes())
1815addUInt(StaticMemberDIE, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1816 AlignInBytes);
1817
1818return &StaticMemberDIE;
1819}
1820
1821voidDwarfUnit::emitCommonHeader(bool UseOffsets,dwarf::UnitType UT) {
1822// Emit size of content not including length itself
1823if (!DD->useSectionsAsReferences())
1824EndLabel =Asm->emitDwarfUnitLength(
1825 isDwoUnit() ?"debug_info_dwo" :"debug_info","Length of Unit");
1826else
1827Asm->emitDwarfUnitLength(getHeaderSize() +getUnitDie().getSize(),
1828"Length of Unit");
1829
1830Asm->OutStreamer->AddComment("DWARF version number");
1831unsignedVersion =DD->getDwarfVersion();
1832Asm->emitInt16(Version);
1833
1834// DWARF v5 reorders the address size and adds a unit type.
1835if (Version >= 5) {
1836Asm->OutStreamer->AddComment("DWARF Unit Type");
1837Asm->emitInt8(UT);
1838Asm->OutStreamer->AddComment("Address Size (in bytes)");
1839Asm->emitInt8(Asm->MAI->getCodePointerSize());
1840 }
1841
1842// We share one abbreviations table across all units so it's always at the
1843// start of the section. Use a relocatable offset where needed to ensure
1844// linking doesn't invalidate that offset.
1845Asm->OutStreamer->AddComment("Offset Into Abbrev. Section");
1846constTargetLoweringObjectFile &TLOF =Asm->getObjFileLowering();
1847if (UseOffsets)
1848Asm->emitDwarfLengthOrOffset(0);
1849else
1850Asm->emitDwarfSymbolReference(
1851 TLOF.getDwarfAbbrevSection()->getBeginSymbol(),false);
1852
1853if (Version <= 4) {
1854Asm->OutStreamer->AddComment("Address Size (in bytes)");
1855Asm->emitInt8(Asm->MAI->getCodePointerSize());
1856 }
1857}
1858
1859voidDwarfTypeUnit::emitHeader(bool UseOffsets) {
1860if (!DD->useSplitDwarf()) {
1861LabelBegin =Asm->createTempSymbol("tu_begin");
1862Asm->OutStreamer->emitLabel(LabelBegin);
1863 }
1864DwarfUnit::emitCommonHeader(UseOffsets,
1865DD->useSplitDwarf() ? dwarf::DW_UT_split_type
1866 : dwarf::DW_UT_type);
1867Asm->OutStreamer->AddComment("Type Signature");
1868Asm->OutStreamer->emitIntValue(TypeSignature,sizeof(TypeSignature));
1869Asm->OutStreamer->AddComment("Type DIE Offset");
1870// In a skeleton type unit there is no type DIE so emit a zero offset.
1871Asm->emitDwarfLengthOrOffset(Ty ? Ty->getOffset() : 0);
1872}
1873
1874voidDwarfUnit::addSectionDelta(DIE &Die,dwarf::AttributeAttribute,
1875constMCSymbol *Hi,constMCSymbol *Lo) {
1876addAttribute(Die,Attribute,DD->getDwarfSectionOffsetForm(),
1877 new (DIEValueAllocator)DIEDelta(Hi,Lo));
1878}
1879
1880voidDwarfUnit::addSectionLabel(DIE &Die,dwarf::AttributeAttribute,
1881constMCSymbol *Label,constMCSymbol *Sec) {
1882if (Asm->doesDwarfUseRelocationsAcrossSections())
1883addLabel(Die,Attribute,DD->getDwarfSectionOffsetForm(), Label);
1884else
1885addSectionDelta(Die,Attribute, Label, Sec);
1886}
1887
1888bool DwarfTypeUnit::isDwoUnit() const{
1889// Since there are no skeleton type units, all type units are dwo type units
1890// when split DWARF is being used.
1891returnDD->useSplitDwarf();
1892}
1893
1894voidDwarfTypeUnit::addGlobalName(StringRefName,constDIE &Die,
1895constDIScope *Context) {
1896getCU().addGlobalNameForTypeUnit(Name, Context);
1897}
1898
1899voidDwarfTypeUnit::addGlobalTypeImpl(constDIType *Ty,constDIE &Die,
1900constDIScope *Context) {
1901getCU().addGlobalTypeUnitType(Ty, Context);
1902}
1903
1904constMCSymbol *DwarfUnit::getCrossSectionRelativeBaseAddress() const{
1905if (!Asm->doesDwarfUseRelocationsAcrossSections())
1906returnnullptr;
1907if (isDwoUnit())
1908returnnullptr;
1909returngetSection()->getBeginSymbol();
1910}
1911
1912voidDwarfUnit::addStringOffsetsStart() {
1913constTargetLoweringObjectFile &TLOF =Asm->getObjFileLowering();
1914addSectionLabel(getUnitDie(), dwarf::DW_AT_str_offsets_base,
1915DU->getStringOffsetsStartSym(),
1916 TLOF.getDwarfStrOffSection()->getBeginSymbol());
1917}
1918
1919voidDwarfUnit::addRnglistsBase() {
1920assert(DD->getDwarfVersion() >= 5 &&
1921"DW_AT_rnglists_base requires DWARF version 5 or later");
1922constTargetLoweringObjectFile &TLOF =Asm->getObjFileLowering();
1923addSectionLabel(getUnitDie(), dwarf::DW_AT_rnglists_base,
1924DU->getRnglistsTableBaseSym(),
1925 TLOF.getDwarfRnglistsSection()->getBeginSymbol());
1926}
1927
1928void DwarfTypeUnit::finishNonUnitTypeDIE(DIE&D,constDICompositeType *CTy) {
1929DD->getAddressPool().resetUsedFlag(true);
1930}
1931
1932bool DwarfUnit::isCompatibleWithVersion(uint16_tVersion) const{
1933return !Asm->TM.Options.DebugStrictDwarf ||DD->getDwarfVersion() >=Version;
1934}
APFloat.h
This file declares a class to represent arbitrary precision floating point values and provide a varie...
APInt.h
This file implements a class to represent arbitrary precision integral constant values and operations...
AddressPool.h
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
A
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Casting.h
Constants.h
This file contains the declarations for the subclasses of Constant, which represent the different fla...
DataLayout.h
Idx
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
Definition:DeadArgumentElimination.cpp:353
DwarfCompileUnit.h
DwarfExpression.h
hasVectorBeenPadded
static bool hasVectorBeenPadded(const DICompositeType *CTy)
Returns true if the vector's size differs from the sum of sizes of elements the user specified.
Definition:DwarfUnit.cpp:1517
DwarfUnit.h
Name
std::string Name
Definition:ELFObjHandler.cpp:77
Size
uint64_t Size
Definition:ELFObjHandler.cpp:81
Sym
Symbol * Sym
Definition:ELF_riscv.cpp:479
GlobalValue.h
MCAsmInfo.h
MCContext.h
MCDwarf.h
MCSection.h
MCStreamer.h
G
#define G(x, y, z)
Definition:MD5.cpp:56
TRI
unsigned const TargetRegisterInfo * TRI
Definition:MachineSink.cpp:2029
Metadata.h
This file contains the declarations for metadata subclasses.
Unsigned
@ Unsigned
Definition:NVPTXISelLowering.cpp:4790
P
#define P(N)
CC
auto CC
Definition:RISCVRedundantCopyElimination.cpp:79
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
getBaseType
static enum BaseType getBaseType(const Value *Val)
Return the baseType for Val which states whether Val is exclusively derived from constant/null,...
Definition:SafepointIRVerifier.cpp:328
TargetLoweringObjectFile.h
TargetRegisterInfo.h
getSize
static unsigned getSize(unsigned Kind)
Definition:XtensaAsmBackend.cpp:134
BaseTy
T
llvm::APFloat::bitcastToAPInt
APInt bitcastToAPInt() const
Definition:APFloat.h:1351
llvm::APInt
Class for arbitrary precision integers.
Definition:APInt.h:78
llvm::APInt::getZExtValue
uint64_t getZExtValue() const
Get zero extended value.
Definition:APInt.h:1520
llvm::APInt::getBitWidth
unsigned getBitWidth() const
Return the number of bits in the APInt.
Definition:APInt.h:1468
llvm::APInt::getRawData
const uint64_t * getRawData() const
This function returns a pointer to the internal storage of the APInt.
Definition:APInt.h:569
llvm::APInt::getSExtValue
int64_t getSExtValue() const
Get sign extended value.
Definition:APInt.h:1542
llvm::AddressPool::getIndex
unsigned getIndex(const MCSymbol *Sym, bool TLS=false)
Returns the index into the address pool with the given label/symbol.
Definition:AddressPool.cpp:19
llvm::AddressPool::resetUsedFlag
void resetUsedFlag(bool HasBeenUsed=false)
Definition:AddressPool.h:51
llvm::Annotations
Annotations lets you mark points and ranges inside source code, for tests:
Definition:Annotations.h:53
llvm::AsmPrinter
This class is intended to be used as a driving class for all asm writers.
Definition:AsmPrinter.h:87
llvm::AsmPrinter::getObjFileLowering
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
Definition:AsmPrinter.cpp:408
llvm::AsmPrinter::getSymbol
MCSymbol * getSymbol(const GlobalValue *GV) const
Definition:AsmPrinter.cpp:697
llvm::AsmPrinter::emitDwarfSymbolReference
void emitDwarfSymbolReference(const MCSymbol *Label, bool ForceOffset=false) const
Emit a reference to a symbol for use in dwarf.
Definition:AsmPrinterDwarf.cpp:131
llvm::AsmPrinter::emitDwarfLengthOrOffset
void emitDwarfLengthOrOffset(uint64_t Value) const
Emit 32- or 64-bit value depending on the DWARF format.
Definition:AsmPrinterDwarf.cpp:169
llvm::AsmPrinter::TM
TargetMachine & TM
Target machine description.
Definition:AsmPrinter.h:90
llvm::AsmPrinter::MAI
const MCAsmInfo * MAI
Target Asm Printer information.
Definition:AsmPrinter.h:93
llvm::AsmPrinter::MF
MachineFunction * MF
The current machine function.
Definition:AsmPrinter.h:105
llvm::AsmPrinter::emitInt8
void emitInt8(int Value) const
Emit a byte directive and value.
Definition:AsmPrinter.cpp:3267
llvm::AsmPrinter::emitDwarfUnitLength
void emitDwarfUnitLength(uint64_t Length, const Twine &Comment) const
Emit a unit length field.
Definition:AsmPrinterDwarf.cpp:174
llvm::AsmPrinter::OutContext
MCContext & OutContext
This is the context for the output file that we are streaming.
Definition:AsmPrinter.h:97
llvm::AsmPrinter::createTempSymbol
MCSymbol * createTempSymbol(const Twine &Name) const
Definition:AsmPrinter.cpp:4075
llvm::AsmPrinter::OutStreamer
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition:AsmPrinter.h:102
llvm::AsmPrinter::getISAEncoding
virtual unsigned getISAEncoding()
Get the value for DW_AT_APPLE_isa. Zero if no isa encoding specified.
Definition:AsmPrinter.h:757
llvm::AsmPrinter::emitInt16
void emitInt16(int Value) const
Emit a short directive and value.
Definition:AsmPrinter.cpp:3270
llvm::AsmPrinter::getDataLayout
const DataLayout & getDataLayout() const
Return information about data layout.
Definition:AsmPrinter.cpp:412
llvm::AsmPrinter::getDwarfFormParams
dwarf::FormParams getDwarfFormParams() const
Returns information about the byte size of DW_FORM values.
Definition:AsmPrinter.cpp:4618
llvm::AsmPrinter::doesDwarfUseRelocationsAcrossSections
bool doesDwarfUseRelocationsAcrossSections() const
Definition:AsmPrinter.h:325
llvm::Attribute
Definition:Attributes.h:67
llvm::ConstantFP
ConstantFP - Floating Point Values [float, double].
Definition:Constants.h:271
llvm::ConstantFP::getValueAPF
const APFloat & getValueAPF() const
Definition:Constants.h:314
llvm::ConstantInt
This is the shared class of boolean and integer constants.
Definition:Constants.h:83
llvm::ConstantInt::getValue
const APInt & getValue() const
Return the constant as an APInt value reference.
Definition:Constants.h:148
llvm::DIBasicType
Basic type, like 'int' or 'float'.
Definition:DebugInfoMetadata.h:823
llvm::DIBasicType::getEncoding
unsigned getEncoding() const
Definition:DebugInfoMetadata.h:891
llvm::DICompileUnit
Compile unit.
Definition:DebugInfoMetadata.h:1469
llvm::DICompileUnit::getDebugInfoForProfiling
bool getDebugInfoForProfiling() const
Definition:DebugInfoMetadata.h:1601
llvm::DICompileUnit::isDebugDirectivesOnly
bool isDebugDirectivesOnly() const
Definition:DebugInfoMetadata.h:1598
llvm::DICompileUnit::getNameTableKind
static std::optional< DebugNameTableKind > getNameTableKind(StringRef Str)
Definition:DebugInfoMetadata.cpp:990
llvm::DICompositeType
Composite types.
Definition:DebugInfoMetadata.h:1174
llvm::DICompositeType::getRankExp
DIExpression * getRankExp() const
Definition:DebugInfoMetadata.h:1367
llvm::DICompositeType::getAssociatedExp
DIExpression * getAssociatedExp() const
Definition:DebugInfoMetadata.h:1351
llvm::DICompositeType::getAllocated
DIVariable * getAllocated() const
Definition:DebugInfoMetadata.h:1355
llvm::DICompositeType::getDataLocationExp
DIExpression * getDataLocationExp() const
Definition:DebugInfoMetadata.h:1344
llvm::DICompositeType::getAssociated
DIVariable * getAssociated() const
Definition:DebugInfoMetadata.h:1348
llvm::DICompositeType::getDiscriminator
DIDerivedType * getDiscriminator() const
Definition:DebugInfoMetadata.h:1337
llvm::DICompositeType::getDataLocation
DIVariable * getDataLocation() const
Definition:DebugInfoMetadata.h:1341
llvm::DICompositeType::getRuntimeLang
unsigned getRuntimeLang() const
Definition:DebugInfoMetadata.h:1329
llvm::DICompositeType::getSpecification
DIType * getSpecification() const
Definition:DebugInfoMetadata.h:1377
llvm::DICompositeType::getIdentifier
StringRef getIdentifier() const
Definition:DebugInfoMetadata.h:1328
llvm::DICompositeType::getElements
DINodeArray getElements() const
Definition:DebugInfoMetadata.h:1319
llvm::DICompositeType::getTemplateParams
DITemplateParameterArray getTemplateParams() const
Definition:DebugInfoMetadata.h:1325
llvm::DICompositeType::getAllocatedExp
DIExpression * getAllocatedExp() const
Definition:DebugInfoMetadata.h:1358
llvm::DICompositeType::getVTableHolder
DIType * getVTableHolder() const
Definition:DebugInfoMetadata.h:1322
llvm::DICompositeType::getAnnotations
DINodeArray getAnnotations() const
Definition:DebugInfoMetadata.h:1372
llvm::DICompositeType::getRankConst
ConstantInt * getRankConst() const
Definition:DebugInfoMetadata.h:1362
llvm::DICompositeType::getRawIdentifier
MDString * getRawIdentifier() const
Definition:DebugInfoMetadata.h:1335
llvm::DICompositeType::getBaseType
DIType * getBaseType() const
Definition:DebugInfoMetadata.h:1318
llvm::DIDerivedType
Derived types.
Definition:DebugInfoMetadata.h:997
llvm::DIDerivedType::getAnnotations
DINodeArray getAnnotations() const
Get annotations associated with this derived type.
Definition:DebugInfoMetadata.h:1133
llvm::DIDerivedType::getTemplateParams
DITemplateParameterArray getTemplateParams() const
Get the template parameters from a template alias.
Definition:DebugInfoMetadata.h:1128
llvm::DIEBlock
DIEBlock - Represents a block of values.
Definition:DIE.h:1046
llvm::DIEDelta
A simple label difference DIE.
Definition:DIE.h:261
llvm::DIEDwarfExpression
DwarfExpression implementation for singular DW_AT_location.
Definition:DwarfExpression.h:344
llvm::DIEDwarfExpression::DIEDwarfExpression
DIEDwarfExpression(const AsmPrinter &AP, DwarfCompileUnit &CU, DIELoc &DIE)
Definition:DwarfUnit.cpp:41
llvm::DIEEntry
A pointer to another debug information entry.
Definition:DIE.h:319
llvm::DIEInlineString
A container for inline string values.
Definition:DIE.h:297
llvm::DIEInteger
An integer value DIE.
Definition:DIE.h:168
llvm::DIEInteger::BestForm
static dwarf::Form BestForm(bool IsSigned, uint64_t Int)
Choose the best form for integer.
Definition:DIE.h:175
llvm::DIELabel
A label DIE.
Definition:DIE.h:223
llvm::DIELoc
DIELoc - Represents an expression location.
Definition:DIE.h:1010
llvm::DIELoc::computeSize
unsigned computeSize(const dwarf::FormParams &FormParams) const
Calculate the size of the location expression.
Definition:DIE.cpp:706
llvm::DIELoc::BestForm
dwarf::Form BestForm(unsigned DwarfVersion) const
BestForm - Choose the best form for data.
Definition:DIE.h:1024
llvm::DIEString
A container for string pool string values.
Definition:DIE.h:278
llvm::DIEUnit
Represents a compile or type unit.
Definition:DIE.h:960
llvm::DIEUnit::getSection
MCSection * getSection() const
Return the section that this DIEUnit will be emitted into.
Definition:DIE.h:996
llvm::DIEUnit::getUnitDie
DIE & getUnitDie()
Definition:DIE.h:999
llvm::DIEValueList
A list of DIE values.
Definition:DIE.h:689
llvm::DIEValueList::takeValues
void takeValues(DIEValueList &Other)
Take ownership of the nodes in Other, and append them to the back of the list.
Definition:DIE.h:805
llvm::DIE
A structured debug information entry.
Definition:DIE.h:819
llvm::DIE::addChild
DIE & addChild(DIE *Child)
Add a child to the DIE.
Definition:DIE.h:934
llvm::DIE::get
static DIE * get(BumpPtrAllocator &Alloc, dwarf::Tag Tag)
Definition:DIE.h:849
llvm::DIE::getUnit
DIEUnit * getUnit() const
Climb up the parent chain to get the compile unit or type unit that this DIE belongs to.
Definition:DIE.cpp:203
llvm::DIE::getOffset
unsigned getOffset() const
Get the compile/type unit relative offset of this DIE.
Definition:DIE.h:857
llvm::DIE::getTag
dwarf::Tag getTag() const
Definition:DIE.h:855
llvm::DIExpression
DWARF expression.
Definition:DebugInfoMetadata.h:2763
llvm::DIExpression::SignedConstant
@ SignedConstant
Definition:DebugInfoMetadata.h:2796
llvm::DIFile
File.
Definition:DebugInfoMetadata.h:573
llvm::DIGenericSubrange
Definition:DebugInfoMetadata.h:411
llvm::DIGenericSubrange::getLowerBound
BoundType getLowerBound() const
Definition:DebugInfoMetadata.cpp:596
llvm::DIGenericSubrange::getCount
BoundType getCount() const
Definition:DebugInfoMetadata.cpp:579
llvm::DIGenericSubrange::getUpperBound
BoundType getUpperBound() const
Definition:DebugInfoMetadata.cpp:613
llvm::DIGenericSubrange::getStride
BoundType getStride() const
Definition:DebugInfoMetadata.cpp:630
llvm::DIGlobalVariable
Global variables.
Definition:DebugInfoMetadata.h:3315
llvm::DILabel
Label.
Definition:DebugInfoMetadata.h:3551
llvm::DILocalVariable
Local variable.
Definition:DebugInfoMetadata.h:3460
llvm::DIModule
Represents a module in the programming language, for example, a Clang module, or a Fortran module.
Definition:DebugInfoMetadata.h:2511
llvm::DINamespace
Debug lexical block.
Definition:DebugInfoMetadata.h:2462
llvm::DINamespace::getScope
DIScope * getScope() const
Definition:DebugInfoMetadata.h:2496
llvm::DINamespace::getName
StringRef getName() const
Definition:DebugInfoMetadata.h:2497
llvm::DINamespace::getExportSymbols
bool getExportSymbols() const
Definition:DebugInfoMetadata.h:2495
llvm::DINode
Tagged DWARF-like metadata node.
Definition:DebugInfoMetadata.h:135
llvm::DINode::getTag
dwarf::Tag getTag() const
Definition:DebugInfoMetadata.cpp:288
llvm::DINode::DIFlags
DIFlags
Debug info flags.
Definition:DebugInfoMetadata.h:174
llvm::DINode::FlagAccessibility
@ FlagAccessibility
Definition:DebugInfoMetadata.h:178
llvm::DIObjCProperty
Definition:DebugInfoMetadata.h:3614
llvm::DIObjCProperty::getLine
unsigned getLine() const
Definition:DebugInfoMetadata.h:3662
llvm::DIObjCProperty::getFile
DIFile * getFile() const
Definition:DebugInfoMetadata.h:3665
llvm::DIScope
Base class for scope-like contexts.
Definition:DebugInfoMetadata.h:519
llvm::DIScope::getName
StringRef getName() const
Definition:DebugInfoMetadata.cpp:368
llvm::DIScope::getFile
DIFile * getFile() const
Definition:DebugInfoMetadata.h:527
llvm::DIScope::getScope
DIScope * getScope() const
Definition:DebugInfoMetadata.cpp:344
llvm::DIStringType
String type, Fortran CHARACTER(n)
Definition:DebugInfoMetadata.h:905
llvm::DIStringType::getEncoding
unsigned getEncoding() const
Definition:DebugInfoMetadata.h:982
llvm::DIStringType::getStringLengthExp
DIExpression * getStringLengthExp() const
Definition:DebugInfoMetadata.h:974
llvm::DIStringType::getStringLength
DIVariable * getStringLength() const
Definition:DebugInfoMetadata.h:970
llvm::DIStringType::getStringLocationExp
DIExpression * getStringLocationExp() const
Definition:DebugInfoMetadata.h:978
llvm::DISubprogram
Subprogram description.
Definition:DebugInfoMetadata.h:1710
llvm::DISubrange
Array subrange.
Definition:DebugInfoMetadata.h:348
llvm::DISubrange::getUpperBound
BoundType getUpperBound() const
Definition:DebugInfoMetadata.cpp:523
llvm::DISubrange::getStride
BoundType getStride() const
Definition:DebugInfoMetadata.cpp:544
llvm::DISubrange::getLowerBound
BoundType getLowerBound() const
Definition:DebugInfoMetadata.cpp:502
llvm::DISubrange::getCount
BoundType getCount() const
Definition:DebugInfoMetadata.cpp:481
llvm::DISubroutineType
Type array for a subprogram.
Definition:DebugInfoMetadata.h:1412
llvm::DISubroutineType::getCC
uint8_t getCC() const
Definition:DebugInfoMetadata.h:1455
llvm::DITemplateParameter::isDefault
bool isDefault() const
Definition:DebugInfoMetadata.h:2599
llvm::DITemplateParameter::getType
DIType * getType() const
Definition:DebugInfoMetadata.h:2595
llvm::DITemplateParameter::getName
StringRef getName() const
Definition:DebugInfoMetadata.h:2594
llvm::DITemplateTypeParameter
Definition:DebugInfoMetadata.h:2607
llvm::DITemplateValueParameter
Definition:DebugInfoMetadata.h:2646
llvm::DITemplateValueParameter::getValue
Metadata * getValue() const
Definition:DebugInfoMetadata.h:2688
llvm::DITypeRefArray
Definition:DebugInfoMetadata.h:73
llvm::DITypeRefArray::size
unsigned size() const
Definition:DebugInfoMetadata.h:88
llvm::DIType
Base class for types.
Definition:DebugInfoMetadata.h:710
llvm::DIType::isLittleEndian
bool isLittleEndian() const
Definition:DebugInfoMetadata.h:802
llvm::DIType::getNumExtraInhabitants
uint32_t getNumExtraInhabitants() const
Definition:DebugInfoMetadata.h:759
llvm::DIType::isBigEndian
bool isBigEndian() const
Definition:DebugInfoMetadata.h:801
llvm::DIType::isLValueReference
bool isLValueReference() const
Definition:DebugInfoMetadata.h:795
llvm::DIType::isObjcClassComplete
bool isObjcClassComplete() const
Definition:DebugInfoMetadata.h:789
llvm::DIType::getRawName
MDString * getRawName() const
Definition:DebugInfoMetadata.h:766
llvm::DIType::isAppleBlockExtension
bool isAppleBlockExtension() const
Definition:DebugInfoMetadata.h:785
llvm::DIType::isVector
bool isVector() const
Definition:DebugInfoMetadata.h:792
llvm::DIType::isObjectPointer
bool isObjectPointer() const
Definition:DebugInfoMetadata.h:788
llvm::DIType::getFlags
DIFlags getFlags() const
Definition:DebugInfoMetadata.h:760
llvm::DIType::getName
StringRef getName() const
Definition:DebugInfoMetadata.h:763
llvm::DIType::isForwardDecl
bool isForwardDecl() const
Definition:DebugInfoMetadata.h:784
llvm::DIType::isTypePassByValue
bool isTypePassByValue() const
Definition:DebugInfoMetadata.h:797
llvm::DIType::getSizeInBits
uint64_t getSizeInBits() const
Definition:DebugInfoMetadata.h:755
llvm::DIType::getAlignInBytes
uint32_t getAlignInBytes() const
Definition:DebugInfoMetadata.h:757
llvm::DIType::getLine
unsigned getLine() const
Definition:DebugInfoMetadata.h:754
llvm::DIType::isRValueReference
bool isRValueReference() const
Definition:DebugInfoMetadata.h:796
llvm::DIType::isArtificial
bool isArtificial() const
Definition:DebugInfoMetadata.h:787
llvm::DIType::getExportSymbols
bool getExportSymbols() const
Definition:DebugInfoMetadata.h:803
llvm::DIType::getScope
DIScope * getScope() const
Definition:DebugInfoMetadata.h:762
llvm::DIType::isTypePassByReference
bool isTypePassByReference() const
Definition:DebugInfoMetadata.h:798
llvm::DIVariable
Base class for variables.
Definition:DebugInfoMetadata.h:2698
llvm::DWARFExpression::Operation
This class represents an Operation in the Expression.
Definition:DWARFExpression.h:32
llvm::DataLayout::isLittleEndian
bool isLittleEndian() const
Layout endianness...
Definition:DataLayout.h:197
llvm::DebugHandlerBase::isUnsignedDIType
static bool isUnsignedDIType(const DIType *Ty)
Return true if type encoding is unsigned.
Definition:DebugHandlerBase.cpp:179
llvm::DebugHandlerBase::getBaseTypeSize
static uint64_t getBaseTypeSize(const DIType *Ty)
If this type is derived from a base type then return base type size.
Definition:DebugHandlerBase.cpp:149
llvm::DwarfCompileUnit
Definition:DwarfCompileUnit.h:45
llvm::DwarfCompileUnit::addGlobalNameForTypeUnit
void addGlobalNameForTypeUnit(StringRef Name, const DIScope *Context)
Add a new global name present in a type unit to this compile unit.
Definition:DwarfCompileUnit.cpp:1550
llvm::DwarfCompileUnit::getOrCreateSourceID
unsigned getOrCreateSourceID(const DIFile *File) override
Look up the source ID for the given file.
Definition:DwarfCompileUnit.cpp:137
llvm::DwarfCompileUnit::addGlobalTypeUnitType
void addGlobalTypeUnitType(const DIType *Ty, const DIScope *Context)
Add a new global type present in a type unit to this compile unit.
Definition:DwarfCompileUnit.cpp:1571
llvm::DwarfDebug
Collects and handles dwarf debug information.
Definition:DwarfDebug.h:351
llvm::DwarfDebug::getMD5AsBytes
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.
Definition:DwarfDebug.cpp:3919
llvm::DwarfDebug::useAddrOffsetForm
bool useAddrOffsetForm() const
Definition:DwarfDebug.h:789
llvm::DwarfDebug::getDwarfVersion
uint16_t getDwarfVersion() const
Returns the Dwarf Version.
Definition:DwarfDebug.cpp:3895
llvm::DwarfDebug::addAccelNamespace
void addAccelNamespace(const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const DIE &Die)
Definition:DwarfDebug.cpp:3881
llvm::DwarfDebug::useAllLinkageNames
bool useAllLinkageNames() const
Returns whether we should emit all DW_AT_[MIPS_]linkage_name.
Definition:DwarfDebug.h:761
llvm::DwarfDebug::getDwarfSectionOffsetForm
dwarf::Form getDwarfSectionOffsetForm() const
Returns a suitable DWARF form to represent a section offset, i.e.
Definition:DwarfDebug.cpp:3899
llvm::DwarfDebug::useAppleExtensionAttributes
bool useAppleExtensionAttributes() const
Definition:DwarfDebug.h:809
llvm::DwarfDebug::useInlineStrings
bool useInlineStrings() const
Returns whether to use inline strings.
Definition:DwarfDebug.h:772
llvm::DwarfDebug::generateTypeUnits
bool generateTypeUnits() const
Returns whether to generate DWARF v4 type units.
Definition:DwarfDebug.h:799
llvm::DwarfDebug::getAddressPool
AddressPool & getAddressPool()
Definition:DwarfDebug.h:870
llvm::DwarfDebug::useSectionsAsReferences
bool useSectionsAsReferences() const
Returns whether to use sections as labels rather than temp symbols.
Definition:DwarfDebug.h:794
llvm::DwarfDebug::shareAcrossDWOCUs
bool shareAcrossDWOCUs() const
Definition:DwarfDebug.cpp:538
llvm::DwarfDebug::getSectionLabel
const MCSymbol * getSectionLabel(const MCSection *S)
Definition:DwarfDebug.cpp:3908
llvm::DwarfDebug::useSplitDwarf
bool useSplitDwarf() const
Returns whether or not to change the current debug info for the split dwarf proposal support.
Definition:DwarfDebug.h:815
llvm::DwarfDebug::useDWARF2Bitfields
bool useDWARF2Bitfields() const
Returns whether to use the DWARF2 format for bitfields instyead of the DWARF4 format.
Definition:DwarfDebug.h:769
llvm::DwarfDebug::useAddrOffsetExpressions
bool useAddrOffsetExpressions() const
Definition:DwarfDebug.h:783
llvm::DwarfDebug::addDwarfTypeUnitType
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.
Definition:DwarfDebug.cpp:3707
llvm::DwarfDebug::addAccelType
void addAccelType(const DwarfUnit &Unit, const DICompileUnit::DebugNameTableKind NameTableKind, StringRef Name, const DIE &Die, char Flags)
Definition:DwarfDebug.cpp:3888
llvm::DwarfExpression
Base class containing the logic for constructing DWARF expressions independently of whether they are ...
Definition:DwarfExpression.h:44
llvm::DwarfFile
Definition:DwarfFile.h:54
llvm::DwarfFile::getStringOffsetsStartSym
MCSymbol * getStringOffsetsStartSym() const
Definition:DwarfFile.h:151
llvm::DwarfFile::getRnglistsTableBaseSym
MCSymbol * getRnglistsTableBaseSym() const
Definition:DwarfFile.h:154
llvm::DwarfFile::getStringPool
DwarfStringPool & getStringPool()
Returns the string pool.
Definition:DwarfFile.h:149
llvm::DwarfFile::getAbstractScopeDIEs
DenseMap< const DILocalScope *, DIE * > & getAbstractScopeDIEs()
Definition:DwarfFile.h:169
llvm::DwarfFile::insertDIE
void insertDIE(const MDNode *TypeMD, DIE *Die)
Definition:DwarfFile.h:177
llvm::DwarfFile::getDIE
DIE * getDIE(const MDNode *TypeMD)
Definition:DwarfFile.h:181
llvm::DwarfStringPool::getEntry
EntryRef getEntry(AsmPrinter &Asm, StringRef Str)
Get a reference to an entry in the string pool.
Definition:DwarfStringPool.cpp:39
llvm::DwarfStringPool::getIndexedEntry
EntryRef getIndexedEntry(AsmPrinter &Asm, StringRef Str)
Same as getEntry, except that you can use EntryRef::getIndex to obtain a unique ID of this entry (e....
Definition:DwarfStringPool.cpp:45
llvm::DwarfTypeUnit::DwarfTypeUnit
DwarfTypeUnit(DwarfCompileUnit &CU, AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU, unsigned UniqueID, MCDwarfDwoLineTable *SplitLineTable=nullptr)
Definition:DwarfUnit.cpp:89
llvm::DwarfTypeUnit::addGlobalTypeImpl
void addGlobalTypeImpl(const DIType *Ty, const DIE &Die, const DIScope *Context) override
Add a new global type to the compile unit.
Definition:DwarfUnit.cpp:1899
llvm::DwarfTypeUnit::getCU
DwarfCompileUnit & getCU() override
Definition:DwarfUnit.h:406
llvm::DwarfTypeUnit::emitHeader
void emitHeader(bool UseOffsets) override
Emit the header for this unit, not including the initial length field.
Definition:DwarfUnit.cpp:1859
llvm::DwarfTypeUnit::addGlobalName
void addGlobalName(StringRef Name, const DIE &Die, const DIScope *Context) override
Add a new global name to the compile unit.
Definition:DwarfUnit.cpp:1894
llvm::DwarfUnit
This dwarf writer support class manages information associated with a source file.
Definition:DwarfUnit.h:35
llvm::DwarfUnit::getOrCreateTypeDIE
virtual DIE * getOrCreateTypeDIE(const MDNode *TyNode)
Find existing DIE or create new DIE for the given type.
Definition:DwarfUnit.cpp:612
llvm::DwarfUnit::addThrownTypes
void addThrownTypes(DIE &Die, DINodeArray ThrownTypes)
Add thrown types.
Definition:DwarfUnit.cpp:527
llvm::DwarfUnit::addStringOffsetsStart
void addStringOffsetsStart()
Add the DW_AT_str_offsets_base attribute to the unit DIE.
Definition:DwarfUnit.cpp:1912
llvm::DwarfUnit::addAnnotation
void addAnnotation(DIE &Buffer, DINodeArray Annotations)
Add DW_TAG_LLVM_annotation.
Definition:DwarfUnit.cpp:905
llvm::DwarfUnit::DIEBlocks
std::vector< DIEBlock * > DIEBlocks
A list of all the DIEBlocks in use.
Definition:DwarfUnit.h:66
llvm::DwarfUnit::DIELocs
std::vector< DIELoc * > DIELocs
A list of all the DIELocs in use.
Definition:DwarfUnit.h:69
llvm::DwarfUnit::getLanguage
uint16_t getLanguage() const
Definition:DwarfUnit.h:110
llvm::DwarfUnit::addBlock
void addBlock(DIE &Die, dwarf::Attribute Attribute, DIELoc *Loc)
Add block data.
Definition:DwarfUnit.cpp:391
llvm::DwarfUnit::addTemplateParams
void addTemplateParams(DIE &Buffer, DINodeArray TParams)
Add template parameters in buffer.
Definition:DwarfUnit.cpp:516
llvm::DwarfUnit::getOrCreateContextDIE
virtual DIE * getOrCreateContextDIE(const DIScope *Context)
Get context owner's DIE.
Definition:DwarfUnit.cpp:546
llvm::DwarfUnit::useSegmentedStringOffsetsTable
bool useSegmentedStringOffsetsTable() const
Definition:DwarfUnit.h:279
llvm::DwarfUnit::applySubprogramDefinitionAttributes
bool applySubprogramDefinitionAttributes(const DISubprogram *SP, DIE &SPDie, bool Minimal)
Definition:DwarfUnit.cpp:1251
llvm::DwarfUnit::getDIELoc
DIELoc * getDIELoc()
Returns a fresh newly allocated DIELoc.
Definition:DwarfUnit.h:144
llvm::DwarfUnit::updateAcceleratorTables
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.
Definition:DwarfUnit.cpp:639
llvm::DwarfUnit::addAttribute
void addAttribute(DIEValueList &Die, dwarf::Attribute Attribute, dwarf::Form Form, T &&Value)
Definition:DwarfUnit.h:84
llvm::DwarfUnit::addOpAddress
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...
Definition:DwarfUnit.cpp:332
llvm::DwarfUnit::addUInt
void addUInt(DIEValueList &Die, dwarf::Attribute Attribute, std::optional< dwarf::Form > Form, uint64_t Integer)
Add an unsigned integer attribute data and value.
Definition:DwarfUnit.cpp:221
llvm::DwarfUnit::addString
void addString(DIE &Die, dwarf::Attribute Attribute, StringRef Str)
Add a string attribute data and value.
Definition:DwarfUnit.cpp:247
llvm::DwarfUnit::addConstantValue
void addConstantValue(DIE &Die, const ConstantInt *CI, const DIType *Ty)
Add constant value entry in variable DIE.
Definition:DwarfUnit.cpp:459
llvm::DwarfUnit::getOrCreateNameSpace
DIE * getOrCreateNameSpace(const DINamespace *NS)
Definition:DwarfUnit.cpp:1167
llvm::DwarfUnit::insertDIE
void insertDIE(const DINode *Desc, DIE *D)
Insert DIE into the map.
Definition:DwarfUnit.cpp:202
llvm::DwarfUnit::addAccess
void addAccess(DIE &Die, DINode::DIFlags Flags)
Add the accessibility attribute.
Definition:DwarfUnit.cpp:534
llvm::DwarfUnit::addSectionDelta
void addSectionDelta(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Hi, const MCSymbol *Lo)
addSectionDelta - Add a label delta attribute data and value.
Definition:DwarfUnit.cpp:1874
llvm::DwarfUnit::addGlobalType
void addGlobalType(const DIType *Ty, const DIE &Die, const DIScope *Context)
Definition:DwarfUnit.cpp:668
llvm::DwarfUnit::createTypeDIE
DIE * createTypeDIE(const DIScope *Context, DIE &ContextDIE, const DIType *Ty)
Creates type DIE with specific context.
Definition:DwarfUnit.cpp:576
llvm::DwarfUnit::DD
DwarfDebug * DD
Definition:DwarfUnit.h:55
llvm::DwarfUnit::ContainingTypeMap
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:74
llvm::DwarfUnit::CUNode
const DICompileUnit * CUNode
MDNode for the compile unit.
Definition:DwarfUnit.h:40
llvm::DwarfUnit::getOrCreateSourceID
virtual unsigned getOrCreateSourceID(const DIFile *File)=0
Look up the source ID for the given file.
llvm::DwarfUnit::addGlobalTypeImpl
virtual void addGlobalTypeImpl(const DIType *Ty, const DIE &Die, const DIScope *Context)=0
Add a new global type to the compile unit.
llvm::DwarfUnit::addDIETypeSignature
void addDIETypeSignature(DIE &Die, uint64_t Signature)
Add a type's DW_AT_signature and set the declaration flag.
Definition:DwarfUnit.cpp:357
llvm::DwarfUnit::getCU
virtual DwarfCompileUnit & getCU()=0
llvm::DwarfUnit::getDIE
DIE * getDIE(const DINode *D) const
Returns the DIE map slot for the specified debug variable.
Definition:DwarfUnit.cpp:196
llvm::DwarfUnit::getHeaderSize
virtual unsigned getHeaderSize() const
Compute the size of a header for this unit, not including the initial length field.
Definition:DwarfUnit.h:285
llvm::DwarfUnit::LabelBegin
MCSymbol * LabelBegin
The start of the unit within its section.
Definition:DwarfUnit.h:49
llvm::DwarfUnit::~DwarfUnit
~DwarfUnit()
Definition:DwarfUnit.cpp:95
llvm::DwarfUnit::addSInt
void addSInt(DIEValueList &Die, dwarf::Attribute Attribute, std::optional< dwarf::Form > Form, int64_t Integer)
Add an signed integer attribute data and value.
Definition:DwarfUnit.cpp:235
llvm::DwarfUnit::DwarfUnit
DwarfUnit(dwarf::Tag, const DICompileUnit *Node, AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU, unsigned UniqueID=0)
Definition:DwarfUnit.cpp:83
llvm::DwarfUnit::addLabelDelta
void addLabelDelta(DIEValueList &Die, dwarf::Attribute Attribute, const MCSymbol *Hi, const MCSymbol *Lo)
Add a label delta attribute data and value.
Definition:DwarfUnit.cpp:347
llvm::DwarfUnit::addLinkageName
void addLinkageName(DIE &Die, StringRef LinkageName)
Add a linkage name, if it isn't empty.
Definition:DwarfUnit.cpp:508
llvm::DwarfUnit::getParentContextString
std::string getParentContextString(const DIScope *Context) const
Get string containing language specific context for a global name.
Definition:DwarfUnit.cpp:681
llvm::DwarfUnit::addSourceLine
void addSourceLine(DIE &Die, unsigned Line, const DIFile *File)
Add location information to specified debug information entry.
Definition:DwarfUnit.cpp:409
llvm::DwarfUnit::emitCommonHeader
void emitCommonHeader(bool UseOffsets, dwarf::UnitType UT)
Emit the common part of the header for this unit.
Definition:DwarfUnit.cpp:1821
llvm::DwarfUnit::DIEValueAllocator
BumpPtrAllocator DIEValueAllocator
Definition:DwarfUnit.h:43
llvm::DwarfUnit::IndexTyDie
DIE * IndexTyDie
An anonymous type for index type. Owned by DIEUnit.
Definition:DwarfUnit.h:59
llvm::DwarfUnit::addRnglistsBase
void addRnglistsBase()
Add the DW_AT_rnglists_base attribute to the unit DIE.
Definition:DwarfUnit.cpp:1919
llvm::DwarfUnit::constructSubprogramArguments
DIE * constructSubprogramArguments(DIE &Buffer, DITypeRefArray Args)
Construct function argument DIEs.
Definition:DwarfUnit.cpp:852
llvm::DwarfUnit::getOrCreateModule
DIE * getOrCreateModule(const DIModule *M)
Definition:DwarfUnit.cpp:1188
llvm::DwarfUnit::createAndAddDIE
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.
Definition:DwarfUnit.cpp:384
llvm::DwarfUnit::DU
DwarfFile * DU
Definition:DwarfUnit.h:56
llvm::DwarfUnit::addSectionOffset
void addSectionOffset(DIE &Die, dwarf::Attribute Attribute, uint64_t Integer)
Add an offset into a section attribute data and value.
Definition:DwarfUnit.cpp:289
llvm::DwarfUnit::getOrCreateStaticMemberDIE
DIE * getOrCreateStaticMemberDIE(const DIDerivedType *DT)
Create new static data member DIE.
Definition:DwarfUnit.cpp:1778
llvm::DwarfUnit::addLabel
void addLabel(DIEValueList &Die, dwarf::Attribute Attribute, dwarf::Form Form, const MCSymbol *Label)
Add a Dwarf label attribute data and value.
Definition:DwarfUnit.cpp:280
llvm::DwarfUnit::addConstantFPValue
void addConstantFPValue(DIE &Die, const ConstantFP *CFP)
Add constant value entry in variable DIE.
Definition:DwarfUnit.cpp:454
llvm::DwarfUnit::constructContainingTypeDIEs
void constructContainingTypeDIEs()
Construct DIEs for types that contain vtables.
Definition:DwarfUnit.cpp:1646
llvm::DwarfUnit::getOrCreateSubprogramDIE
DIE * getOrCreateSubprogramDIE(const DISubprogram *SP, bool Minimal=false)
Definition:DwarfUnit.cpp:1219
llvm::DwarfUnit::addSectionLabel
void addSectionLabel(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Label, const MCSymbol *Sec)
Add a Dwarf section label attribute data and value.
Definition:DwarfUnit.cpp:1880
llvm::DwarfUnit::isShareableAcrossCUs
bool isShareableAcrossCUs(const DINode *D) const
Check whether the DIE for this MDNode can be shared across CUs.
Definition:DwarfUnit.cpp:181
llvm::DwarfUnit::addPoolOpAddress
void addPoolOpAddress(DIEValueList &Die, const MCSymbol *Label)
Definition:DwarfUnit.cpp:307
llvm::DwarfUnit::MDNodeToDieMap
DenseMap< const MDNode *, DIE * > MDNodeToDieMap
Tracks the mapping of unit level debug information variables to debug information entries.
Definition:DwarfUnit.h:63
llvm::DwarfUnit::constructTypeDIE
void constructTypeDIE(DIE &Buffer, const DICompositeType *CTy)
Definition:DwarfUnit.cpp:926
llvm::DwarfUnit::addGlobalName
virtual void addGlobalName(StringRef Name, const DIE &Die, const DIScope *Context)=0
Add a new global name to the compile unit.
llvm::DwarfUnit::EndLabel
MCSymbol * EndLabel
Emitted at the end of the CU and used to compute the CU Length field.
Definition:DwarfUnit.h:52
llvm::DwarfUnit::addFlag
void addFlag(DIE &Die, dwarf::Attribute Attribute)
Add a flag that is true to the DIE.
Definition:DwarfUnit.cpp:214
llvm::DwarfUnit::Asm
AsmPrinter * Asm
Target of Dwarf emission.
Definition:DwarfUnit.h:46
llvm::DwarfUnit::addType
void addType(DIE &Entity, const DIType *Ty, dwarf::Attribute Attribute=dwarf::DW_AT_type)
Add a new type attribute to the specified entity.
Definition:DwarfUnit.cpp:675
llvm::DwarfUnit::applySubprogramAttributes
void applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie, bool SkipSPAttributes=false)
Definition:DwarfUnit.cpp:1304
llvm::DwarfUnit::addDIEEntry
void addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIE &Entry)
Add a DIE attribute data and value.
Definition:DwarfUnit.cpp:353
llvm::GlobalValue
Definition:GlobalValue.h:48
llvm::GlobalValue::dropLLVMManglingEscape
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1',...
Definition:GlobalValue.h:568
llvm::MCAsmInfo::getCodePointerSize
unsigned getCodePointerSize() const
Get the code pointer size in bytes.
Definition:MCAsmInfo.h:449
llvm::MCContext::getDwarfVersion
uint16_t getDwarfVersion() const
Definition:MCContext.h:802
llvm::MCDwarfDwoLineTable
Definition:MCDwarf.h:338
llvm::MCDwarfDwoLineTable::getFile
unsigned getFile(StringRef Directory, StringRef FileName, std::optional< MD5::MD5Result > Checksum, uint16_t DwarfVersion, std::optional< StringRef > Source)
Definition:MCDwarf.h:351
llvm::MCObjectFileInfo::getDwarfStrOffSection
MCSection * getDwarfStrOffSection() const
Definition:MCObjectFileInfo.h:329
llvm::MCObjectFileInfo::getDwarfRnglistsSection
MCSection * getDwarfRnglistsSection() const
Definition:MCObjectFileInfo.h:301
llvm::MCObjectFileInfo::getDwarfAbbrevSection
MCSection * getDwarfAbbrevSection() const
Definition:MCObjectFileInfo.h:278
llvm::MCSection::getBeginSymbol
MCSymbol * getBeginSymbol()
Definition:MCSection.h:135
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition:MCSymbol.h:41
llvm::MDNode
Metadata node.
Definition:Metadata.h:1073
llvm::MDNode::getOperand
const MDOperand & getOperand(unsigned I) const
Definition:Metadata.h:1434
llvm::MDString
A single uniqued string.
Definition:Metadata.h:724
llvm::Metadata
Root of the metadata hierarchy.
Definition:Metadata.h:62
llvm::PointerUnion
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
Definition:PointerUnion.h:118
llvm::Register
Wrapper class representing virtual and physical registers.
Definition:Register.h:19
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition:SmallVector.h:1196
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:StringRef.h:51
llvm::StringRef::empty
constexpr bool empty() const
empty - Check if the string is empty.
Definition:StringRef.h:147
llvm::TargetLoweringObjectFile
Definition:TargetLoweringObjectFile.h:45
llvm::TargetMachine::Options
TargetOptions Options
Definition:TargetMachine.h:118
llvm::TargetOptions::DebugStrictDwarf
unsigned DebugStrictDwarf
When set to true, don't use DWARF extensions in later DWARF versions.
Definition:TargetOptions.h:360
llvm::TargetRegisterInfo
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Definition:TargetRegisterInfo.h:235
llvm::Value
LLVM Value Representation.
Definition:Value.h:74
uint16_t
uint32_t
uint64_t
uint8_t
CU
Definition:AArch64AsmBackend.cpp:549
llvm::dwarf::DW_ACCESS_private
@ DW_ACCESS_private
Definition:Dwarf.h:185
llvm::dwarf::DW_ACCESS_protected
@ DW_ACCESS_protected
Definition:Dwarf.h:184
llvm::dwarf::DW_ACCESS_public
@ DW_ACCESS_public
Definition:Dwarf.h:183
llvm::dwarf::Attribute
Attribute
Attributes.
Definition:Dwarf.h:123
llvm::dwarf::UnitType
UnitType
Constants for unit types in DWARF v5.
Definition:Dwarf.h:875
llvm::dwarf::Form
Form
Definition:Dwarf.h:130
llvm::dwarf::isType
bool isType(Tag T)
Definition:Dwarf.h:111
llvm::dwarf::SourceLanguage
SourceLanguage
Definition:Dwarf.h:207
llvm::dwarf::isCPlusPlus
bool isCPlusPlus(SourceLanguage S)
Definition:Dwarf.h:497
llvm::dwarf::getArrayIndexTypeEncoding
TypeKind getArrayIndexTypeEncoding(SourceLanguage S)
Definition:Dwarf.h:733
llvm::dwarf::Tag
Tag
Definition:Dwarf.h:103
llvm::dwarf::DW_FLAG_type_implementation
@ DW_FLAG_type_implementation
Definition:Dwarf.h:932
llvm::dwarf::isC
bool isC(SourceLanguage S)
Definition:Dwarf.h:657
llvm::logicalview::LVPrintKind::Elements
@ Elements
llvm::pdb::PDB_SymType::Enum
@ Enum
llvm::sampleprof::Base
@ Base
Definition:Discriminator.h:58
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::PseudoProbeType::Block
@ Block
llvm::reverse
auto reverse(ContainerTy &&C)
Definition:STLExtras.h:420
llvm::isa
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition:Casting.h:548
llvm::PackElem::Hi
@ Hi
llvm::PackElem::Lo
@ Lo
llvm::DINameKind::LinkageName
@ LinkageName
llvm::HighlightColor::String
@ String
llvm::HighlightColor::Enumerator
@ Enumerator
llvm::HighlightColor::Tag
@ Tag
llvm::Data
@ Data
Definition:SIMachineScheduler.h:55
llvm::Version
@ Version
Definition:PGOCtxProfWriter.h:22
llvm::IntegerStyle::Integer
@ Integer
N
#define N
llvm::BitTracker
Definition:BitTracker.h:35
llvm::DWARFExpression::Operation::Description
Description of the encoding of one expression Op.
Definition:DWARFExpression.h:66

Generated on Sun Jul 20 2025 08:27:12 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp