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