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