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