LLVM  3.7.0
DwarfCompileUnit.cpp
Go to the documentation of this file.
1 #include "DwarfCompileUnit.h"
2 #include "DwarfExpression.h"
4 #include "llvm/IR/Constants.h"
5 #include "llvm/IR/DataLayout.h"
6 #include "llvm/IR/GlobalValue.h"
8 #include "llvm/IR/Instruction.h"
9 #include "llvm/MC/MCAsmInfo.h"
10 #include "llvm/MC/MCStreamer.h"
16 
17 namespace llvm {
18 
20  AsmPrinter *A, DwarfDebug *DW,
21  DwarfFile *DWU)
22  : DwarfUnit(UID, dwarf::DW_TAG_compile_unit, Node, A, DW, DWU),
23  Skeleton(nullptr), BaseAddress(nullptr) {
24  insertDIE(Node, &getUnitDie());
25 }
26 
27 /// addLabelAddress - Add a dwarf label attribute data and value using
28 /// DW_FORM_addr or DW_FORM_GNU_addr_index.
29 ///
31  const MCSymbol *Label) {
32 
33  // Don't use the address pool in non-fission or in the skeleton unit itself.
34  // FIXME: Once GDB supports this, it's probably worthwhile using the address
35  // pool from the skeleton - maybe even in non-fission (possibly fewer
36  // relocations by sharing them in the pool, but we have other ideas about how
37  // to reduce the number of relocations as well/instead).
38  if (!DD->useSplitDwarf() || !Skeleton)
39  return addLocalLabelAddress(Die, Attribute, Label);
40 
41  if (Label)
42  DD->addArangeLabel(SymbolCU(this, Label));
43 
44  unsigned idx = DD->getAddressPool().getIndex(Label);
46  DIEInteger(idx));
47 }
48 
51  const MCSymbol *Label) {
52  if (Label)
53  DD->addArangeLabel(SymbolCU(this, Label));
54 
55  if (Label)
57  DIELabel(Label));
58  else
60  DIEInteger(0));
61 }
62 
64  StringRef DirName) {
65  // If we print assembly, we can't separate .file entries according to
66  // compile units. Thus all files will belong to the default compile unit.
67 
68  // FIXME: add a better feature test than hasRawTextSupport. Even better,
69  // extend .file to support this.
70  return Asm->OutStreamer->EmitDwarfFileDirective(
71  0, DirName, FileName,
72  Asm->OutStreamer->hasRawTextSupport() ? 0 : getUniqueID());
73 }
74 
75 // Return const expression if value is a GEP to access merged global
76 // constant. e.g.
77 // i8* getelementptr ({ i8, i8, i8, i8 }* @_MergedGlobals, i32 0, i32 0)
78 static const ConstantExpr *getMergedGlobalExpr(const Value *V) {
79  const ConstantExpr *CE = dyn_cast_or_null<ConstantExpr>(V);
80  if (!CE || CE->getNumOperands() != 3 ||
81  CE->getOpcode() != Instruction::GetElementPtr)
82  return nullptr;
83 
84  // First operand points to a global struct.
85  Value *Ptr = CE->getOperand(0);
86  if (!isa<GlobalValue>(Ptr) ||
87  !isa<StructType>(cast<PointerType>(Ptr->getType())->getElementType()))
88  return nullptr;
89 
90  // Second operand is zero.
91  const ConstantInt *CI = dyn_cast_or_null<ConstantInt>(CE->getOperand(1));
92  if (!CI || !CI->isZero())
93  return nullptr;
94 
95  // Third operand is offset.
96  if (!isa<ConstantInt>(CE->getOperand(2)))
97  return nullptr;
98 
99  return CE;
100 }
101 
102 /// getOrCreateGlobalVariableDIE - get or create global variable DIE.
104  const DIGlobalVariable *GV) {
105  // Check for pre-existence.
106  if (DIE *Die = getDIE(GV))
107  return Die;
108 
109  assert(GV);
110 
111  auto *GVContext = GV->getScope();
112  auto *GTy = DD->resolve(GV->getType());
113 
114  // Construct the context before querying for the existence of the DIE in
115  // case such construction creates the DIE.
116  DIE *ContextDIE = getOrCreateContextDIE(GVContext);
117 
118  // Add to map.
119  DIE *VariableDIE = &createAndAddDIE(GV->getTag(), *ContextDIE, GV);
120  DIScope *DeclContext;
121  if (auto *SDMDecl = GV->getStaticDataMemberDeclaration()) {
122  DeclContext = resolve(SDMDecl->getScope());
123  assert(SDMDecl->isStaticMember() && "Expected static member decl");
124  assert(GV->isDefinition());
125  // We need the declaration DIE that is in the static member's class.
126  DIE *VariableSpecDIE = getOrCreateStaticMemberDIE(SDMDecl);
127  addDIEEntry(*VariableDIE, dwarf::DW_AT_specification, *VariableSpecDIE);
128  } else {
129  DeclContext = GV->getScope();
130  // Add name and type.
131  addString(*VariableDIE, dwarf::DW_AT_name, GV->getDisplayName());
132  addType(*VariableDIE, GTy);
133 
134  // Add scoping info.
135  if (!GV->isLocalToUnit())
136  addFlag(*VariableDIE, dwarf::DW_AT_external);
137 
138  // Add line number info.
139  addSourceLine(*VariableDIE, GV);
140  }
141 
142  if (!GV->isDefinition())
143  addFlag(*VariableDIE, dwarf::DW_AT_declaration);
144  else
145  addGlobalName(GV->getName(), *VariableDIE, DeclContext);
146 
147  // Add location.
148  bool addToAccelTable = false;
149  if (auto *Global = dyn_cast_or_null<GlobalVariable>(GV->getVariable())) {
150  addToAccelTable = true;
151  DIELoc *Loc = new (DIEValueAllocator) DIELoc;
152  const MCSymbol *Sym = Asm->getSymbol(Global);
153  if (Global->isThreadLocal()) {
154  // FIXME: Make this work with -gsplit-dwarf.
155  unsigned PointerSize = Asm->getDataLayout().getPointerSize();
156  assert((PointerSize == 4 || PointerSize == 8) &&
157  "Add support for other sizes if necessary");
158  // Based on GCC's support for TLS:
159  if (!DD->useSplitDwarf()) {
160  // 1) Start with a constNu of the appropriate pointer size
162  PointerSize == 4 ? dwarf::DW_OP_const4u : dwarf::DW_OP_const8u);
163  // 2) containing the (relocated) offset of the TLS variable
164  // within the module's TLS block.
167  } else {
168  addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_const_index);
170  DD->getAddressPool().getIndex(Sym, /* TLS */ true));
171  }
172  // 3) followed by an OP to make the debugger do a TLS lookup.
174  DD->useGNUTLSOpcode() ? dwarf::DW_OP_GNU_push_tls_address
175  : dwarf::DW_OP_form_tls_address);
176  } else {
177  DD->addArangeLabel(SymbolCU(this, Sym));
178  addOpAddress(*Loc, Sym);
179  }
180 
181  addBlock(*VariableDIE, dwarf::DW_AT_location, Loc);
182  addLinkageName(*VariableDIE, GV->getLinkageName());
183  } else if (const ConstantInt *CI =
184  dyn_cast_or_null<ConstantInt>(GV->getVariable())) {
185  addConstantValue(*VariableDIE, CI, GTy);
186  } else if (const ConstantExpr *CE = getMergedGlobalExpr(GV->getVariable())) {
187  addToAccelTable = true;
188  // GV is a merged global.
189  DIELoc *Loc = new (DIEValueAllocator) DIELoc;
190  Value *Ptr = CE->getOperand(0);
191  MCSymbol *Sym = Asm->getSymbol(cast<GlobalValue>(Ptr));
192  DD->addArangeLabel(SymbolCU(this, Sym));
193  addOpAddress(*Loc, Sym);
194  addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
195  SmallVector<Value *, 3> Idx(CE->op_begin() + 1, CE->op_end());
197  Asm->getDataLayout().getIndexedOffset(Ptr->getType(), Idx));
198  addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
199  addBlock(*VariableDIE, dwarf::DW_AT_location, Loc);
200  }
201 
202  if (addToAccelTable) {
203  DD->addAccelName(GV->getName(), *VariableDIE);
204 
205  // If the linkage name is different than the name, go ahead and output
206  // that as well into the name table.
207  if (GV->getLinkageName() != "" && GV->getName() != GV->getLinkageName())
208  DD->addAccelName(GV->getLinkageName(), *VariableDIE);
209  }
210 
211  return VariableDIE;
212 }
213 
215  bool SameAsPrevCU = this == DD->getPrevCU();
216  DD->setPrevCU(this);
217  // If we have no current ranges just add the range and return, otherwise,
218  // check the current section and CU against the previous section and CU we
219  // emitted into and the subprogram was contained within. If these are the
220  // same then extend our current range, otherwise add this as a new range.
221  if (CURanges.empty() || !SameAsPrevCU ||
222  (&CURanges.back().getEnd()->getSection() !=
223  &Range.getEnd()->getSection())) {
224  CURanges.push_back(Range);
225  return;
226  }
227 
228  CURanges.back().setEnd(Range.getEnd());
229 }
230 
233  const MCSymbol *Label, const MCSymbol *Sec) {
235  return addLabel(Die, Attribute,
238  Label);
239  return addSectionDelta(Die, Attribute, Label, Sec);
240 }
241 
243  // Define start line table label for each Compile Unit.
244  MCSymbol *LineTableStartSym =
245  Asm->OutStreamer->getDwarfLineTableSymbol(getUniqueID());
246 
247  // DW_AT_stmt_list is a offset of line number information for this
248  // compile unit in debug_line section. For split dwarf this is
249  // left in the skeleton CU and so not included.
250  // The line table entries are not always emitted in assembly, so it
251  // is not okay to use line_table_start here.
253  StmtListValue =
254  addSectionLabel(UnitDie, dwarf::DW_AT_stmt_list, LineTableStartSym,
256 }
257 
259  D.addValue(DIEValueAllocator, *StmtListValue);
260 }
261 
263  const MCSymbol *End) {
264  assert(Begin && "Begin label should not be null!");
265  assert(End && "End label should not be null!");
266  assert(Begin->isDefined() && "Invalid starting label");
267  assert(End->isDefined() && "Invalid end label");
268 
270  if (DD->getDwarfVersion() < 4)
272  else
273  addLabelDelta(D, dwarf::DW_AT_high_pc, End, Begin);
274 }
275 
276 // Find DIE for the given subprogram and attach appropriate DW_AT_low_pc
277 // and DW_AT_high_pc attributes. If there are global variables in this
278 // scope then create and insert DIEs for these variables.
280  DIE *SPDie = getOrCreateSubprogramDIE(SP, includeMinimalInlineScopes());
281 
284  *DD->getCurrentFunction()))
286 
287  // Only include DW_AT_frame_base in full debug info
288  if (!includeMinimalInlineScopes()) {
290  MachineLocation Location(RI->getFrameRegister(*Asm->MF));
291  if (RI->isPhysicalRegister(Location.getReg()))
292  addAddress(*SPDie, dwarf::DW_AT_frame_base, Location);
293  }
294 
295  // Add name to the name table, we do this here because we're guaranteed
296  // to have concrete versions of our DW_TAG_subprogram nodes.
297  DD->addSubprogramNames(SP, *SPDie);
298 
299  return *SPDie;
300 }
301 
302 // Construct a DIE for this scope.
304  LexicalScope *Scope, SmallVectorImpl<DIE *> &FinalChildren) {
305  if (!Scope || !Scope->getScopeNode())
306  return;
307 
308  auto *DS = Scope->getScopeNode();
309 
310  assert((Scope->getInlinedAt() || !isa<DISubprogram>(DS)) &&
311  "Only handle inlined subprograms here, use "
312  "constructSubprogramScopeDIE for non-inlined "
313  "subprograms");
314 
315  SmallVector<DIE *, 8> Children;
316 
317  // We try to create the scope DIE first, then the children DIEs. This will
318  // avoid creating un-used children then removing them later when we find out
319  // the scope DIE is null.
320  DIE *ScopeDIE;
321  if (Scope->getParent() && isa<DISubprogram>(DS)) {
322  ScopeDIE = constructInlinedScopeDIE(Scope);
323  if (!ScopeDIE)
324  return;
325  // We create children when the scope DIE is not null.
326  createScopeChildrenDIE(Scope, Children);
327  } else {
328  // Early exit when we know the scope DIE is going to be null.
329  if (DD->isLexicalScopeDIENull(Scope))
330  return;
331 
332  unsigned ChildScopeCount;
333 
334  // We create children here when we know the scope DIE is not going to be
335  // null and the children will be added to the scope DIE.
336  createScopeChildrenDIE(Scope, Children, &ChildScopeCount);
337 
338  // Skip imported directives in gmlt-like data.
339  if (!includeMinimalInlineScopes()) {
340  // There is no need to emit empty lexical block DIE.
341  for (const auto &E : DD->findImportedEntitiesForScope(DS))
342  Children.push_back(
343  constructImportedEntityDIE(cast<DIImportedEntity>(E.second)));
344  }
345 
346  // If there are only other scopes as children, put them directly in the
347  // parent instead, as this scope would serve no purpose.
348  if (Children.size() == ChildScopeCount) {
349  FinalChildren.insert(FinalChildren.end(),
350  std::make_move_iterator(Children.begin()),
351  std::make_move_iterator(Children.end()));
352  return;
353  }
354  ScopeDIE = constructLexicalScopeDIE(Scope);
355  assert(ScopeDIE && "Scope DIE should not be null.");
356  }
357 
358  // Add children
359  for (auto &I : Children)
360  ScopeDIE->addChild(std::move(I));
361 
362  FinalChildren.push_back(std::move(ScopeDIE));
363 }
364 
367  const MCSymbol *Hi, const MCSymbol *Lo) {
368  return Die.addValue(DIEValueAllocator, Attribute,
371  new (DIEValueAllocator) DIEDelta(Hi, Lo));
372 }
373 
377 
378  // Emit offset in .debug_range as a relocatable label. emitDIE will handle
379  // emitting it appropriately.
380  const MCSymbol *RangeSectionSym =
382 
383  RangeSpanList List(Asm->createTempSymbol("debug_ranges"), std::move(Range));
384 
385  // Under fission, ranges are specified by constant offsets relative to the
386  // CU's DW_AT_GNU_ranges_base.
387  if (isDwoUnit())
388  addSectionDelta(ScopeDIE, dwarf::DW_AT_ranges, List.getSym(),
389  RangeSectionSym);
390  else
391  addSectionLabel(ScopeDIE, dwarf::DW_AT_ranges, List.getSym(),
392  RangeSectionSym);
393 
394  // Add the range list to the set of ranges to be emitted.
395  (Skeleton ? Skeleton : this)->CURangeLists.push_back(std::move(List));
396 }
397 
400  if (Ranges.size() == 1) {
401  const auto &single = Ranges.front();
402  attachLowHighPC(Die, single.getStart(), single.getEnd());
403  } else
404  addScopeRangeList(Die, std::move(Ranges));
405 }
406 
408  DIE &Die, const SmallVectorImpl<InsnRange> &Ranges) {
410  List.reserve(Ranges.size());
411  for (const InsnRange &R : Ranges)
412  List.push_back(RangeSpan(DD->getLabelBeforeInsn(R.first),
413  DD->getLabelAfterInsn(R.second)));
414  attachRangesOrLowHighPC(Die, std::move(List));
415 }
416 
417 // This scope represents inlined body of a function. Construct DIE to
418 // represent this concrete inlined copy of the function.
420  assert(Scope->getScopeNode());
421  auto *DS = Scope->getScopeNode();
422  auto *InlinedSP = getDISubprogram(DS);
423  // Find the subprogram's DwarfCompileUnit in the SPMap in case the subprogram
424  // was inlined from another compile unit.
425  DIE *OriginDIE = DU->getAbstractSPDies()[InlinedSP];
426  assert(OriginDIE && "Unable to find original DIE for an inlined subprogram.");
427 
428  auto ScopeDIE = DIE::get(DIEValueAllocator, dwarf::DW_TAG_inlined_subroutine);
429  addDIEEntry(*ScopeDIE, dwarf::DW_AT_abstract_origin, *OriginDIE);
430 
431  attachRangesOrLowHighPC(*ScopeDIE, Scope->getRanges());
432 
433  // Add the call site information to the DIE.
434  const DILocation *IA = Scope->getInlinedAt();
435  addUInt(*ScopeDIE, dwarf::DW_AT_call_file, None,
436  getOrCreateSourceID(IA->getFilename(), IA->getDirectory()));
437  addUInt(*ScopeDIE, dwarf::DW_AT_call_line, None, IA->getLine());
438 
439  // Add name to the name table, we do this here because we're guaranteed
440  // to have concrete versions of our DW_TAG_inlined_subprogram nodes.
441  DD->addSubprogramNames(InlinedSP, *ScopeDIE);
442 
443  return ScopeDIE;
444 }
445 
446 // Construct new DW_TAG_lexical_block for this scope and attach
447 // DW_AT_low_pc/DW_AT_high_pc labels.
449  if (DD->isLexicalScopeDIENull(Scope))
450  return nullptr;
451 
452  auto ScopeDIE = DIE::get(DIEValueAllocator, dwarf::DW_TAG_lexical_block);
453  if (Scope->isAbstractScope())
454  return ScopeDIE;
455 
456  attachRangesOrLowHighPC(*ScopeDIE, Scope->getRanges());
457 
458  return ScopeDIE;
459 }
460 
461 /// constructVariableDIE - Construct a DIE for the given DbgVariable.
463  auto D = constructVariableDIEImpl(DV, Abstract);
464  DV.setDIE(*D);
465  return D;
466 }
467 
468 DIE *DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV,
469  bool Abstract) {
470  // Define variable debug information entry.
471  auto VariableDie = DIE::get(DIEValueAllocator, DV.getTag());
472 
473  if (Abstract) {
474  applyVariableAttributes(DV, *VariableDie);
475  return VariableDie;
476  }
477 
478  // Add variable address.
479 
480  unsigned Offset = DV.getDebugLocListIndex();
481  if (Offset != ~0U) {
482  addLocationList(*VariableDie, dwarf::DW_AT_location, Offset);
483  return VariableDie;
484  }
485 
486  // Check if variable is described by a DBG_VALUE instruction.
487  if (const MachineInstr *DVInsn = DV.getMInsn()) {
488  assert(DVInsn->getNumOperands() == 4);
489  if (DVInsn->getOperand(0).isReg()) {
490  const MachineOperand RegOp = DVInsn->getOperand(0);
491  // If the second operand is an immediate, this is an indirect value.
492  if (DVInsn->getOperand(1).isImm()) {
493  MachineLocation Location(RegOp.getReg(),
494  DVInsn->getOperand(1).getImm());
495  addVariableAddress(DV, *VariableDie, Location);
496  } else if (RegOp.getReg())
497  addVariableAddress(DV, *VariableDie, MachineLocation(RegOp.getReg()));
498  } else if (DVInsn->getOperand(0).isImm())
499  addConstantValue(*VariableDie, DVInsn->getOperand(0), DV.getType());
500  else if (DVInsn->getOperand(0).isFPImm())
501  addConstantFPValue(*VariableDie, DVInsn->getOperand(0));
502  else if (DVInsn->getOperand(0).isCImm())
503  addConstantValue(*VariableDie, DVInsn->getOperand(0).getCImm(),
504  DV.getType());
505 
506  return VariableDie;
507  }
508 
509  // .. else use frame index.
510  if (DV.getFrameIndex().empty())
511  return VariableDie;
512 
513  auto Expr = DV.getExpression().begin();
514  DIELoc *Loc = new (DIEValueAllocator) DIELoc;
515  DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
516  for (auto FI : DV.getFrameIndex()) {
517  unsigned FrameReg = 0;
518  const TargetFrameLowering *TFI = Asm->MF->getSubtarget().getFrameLowering();
519  int Offset = TFI->getFrameIndexReference(*Asm->MF, FI, FrameReg);
520  assert(Expr != DV.getExpression().end() &&
521  "Wrong number of expressions");
522  DwarfExpr.AddMachineRegIndirect(FrameReg, Offset);
523  DwarfExpr.AddExpression((*Expr)->expr_op_begin(), (*Expr)->expr_op_end());
524  ++Expr;
525  }
526  addBlock(*VariableDie, dwarf::DW_AT_location, Loc);
527 
528  return VariableDie;
529 }
530 
532  const LexicalScope &Scope,
533  DIE *&ObjectPointer) {
534  auto Var = constructVariableDIE(DV, Scope.isAbstractScope());
535  if (DV.isObjectPointer())
536  ObjectPointer = Var;
537  return Var;
538 }
539 
541  SmallVectorImpl<DIE *> &Children,
542  unsigned *ChildScopeCount) {
543  DIE *ObjectPointer = nullptr;
544 
545  for (DbgVariable *DV : DU->getScopeVariables().lookup(Scope))
546  Children.push_back(constructVariableDIE(*DV, *Scope, ObjectPointer));
547 
548  unsigned ChildCountWithoutScopes = Children.size();
549 
550  for (LexicalScope *LS : Scope->getChildren())
551  constructScopeDIE(LS, Children);
552 
553  if (ChildScopeCount)
554  *ChildScopeCount = Children.size() - ChildCountWithoutScopes;
555 
556  return ObjectPointer;
557 }
558 
560  assert(Scope && Scope->getScopeNode());
561  assert(!Scope->getInlinedAt());
562  assert(!Scope->isAbstractScope());
563  auto *Sub = cast<DISubprogram>(Scope->getScopeNode());
564 
565  DD->getProcessedSPNodes().insert(Sub);
566 
567  DIE &ScopeDIE = updateSubprogramScopeDIE(Sub);
568 
569  // If this is a variadic function, add an unspecified parameter.
570  DITypeRefArray FnArgs = Sub->getType()->getTypeArray();
571 
572  // Collect lexical scope children first.
573  // ObjectPointer might be a local (non-argument) local variable if it's a
574  // block's synthetic this pointer.
575  if (DIE *ObjectPointer = createAndAddScopeChildren(Scope, ScopeDIE))
576  addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, *ObjectPointer);
577 
578  // If we have a single element of null, it is a function that returns void.
579  // If we have more than one elements and the last one is null, it is a
580  // variadic function.
581  if (FnArgs.size() > 1 && !FnArgs[FnArgs.size() - 1] &&
582  !includeMinimalInlineScopes())
583  ScopeDIE.addChild(
584  DIE::get(DIEValueAllocator, dwarf::DW_TAG_unspecified_parameters));
585 }
586 
588  DIE &ScopeDIE) {
589  // We create children when the scope DIE is not null.
590  SmallVector<DIE *, 8> Children;
591  DIE *ObjectPointer = createScopeChildrenDIE(Scope, Children);
592 
593  // Add children
594  for (auto &I : Children)
595  ScopeDIE.addChild(std::move(I));
596 
597  return ObjectPointer;
598 }
599 
600 void
602  DIE *&AbsDef = DU->getAbstractSPDies()[Scope->getScopeNode()];
603  if (AbsDef)
604  return;
605 
606  auto *SP = cast<DISubprogram>(Scope->getScopeNode());
607 
608  DIE *ContextDIE;
609 
610  if (includeMinimalInlineScopes())
611  ContextDIE = &getUnitDie();
612  // Some of this is duplicated from DwarfUnit::getOrCreateSubprogramDIE, with
613  // the important distinction that the debug node is not associated with the
614  // DIE (since the debug node will be associated with the concrete DIE, if
615  // any). It could be refactored to some common utility function.
616  else if (auto *SPDecl = SP->getDeclaration()) {
617  ContextDIE = &getUnitDie();
618  getOrCreateSubprogramDIE(SPDecl);
619  } else
620  ContextDIE = getOrCreateContextDIE(resolve(SP->getScope()));
621 
622  // Passing null as the associated node because the abstract definition
623  // shouldn't be found by lookup.
624  AbsDef = &createAndAddDIE(dwarf::DW_TAG_subprogram, *ContextDIE, nullptr);
626 
627  if (!includeMinimalInlineScopes())
629  if (DIE *ObjectPointer = createAndAddScopeChildren(Scope, *AbsDef))
630  addDIEEntry(*AbsDef, dwarf::DW_AT_object_pointer, *ObjectPointer);
631 }
632 
634  const DIImportedEntity *Module) {
635  DIE *IMDie = DIE::get(DIEValueAllocator, (dwarf::Tag)Module->getTag());
636  insertDIE(Module, IMDie);
637  DIE *EntityDie;
638  auto *Entity = resolve(Module->getEntity());
639  if (auto *NS = dyn_cast<DINamespace>(Entity))
640  EntityDie = getOrCreateNameSpace(NS);
641  else if (auto *M = dyn_cast<DIModule>(Entity))
642  EntityDie = getOrCreateModule(M);
643  else if (auto *SP = dyn_cast<DISubprogram>(Entity))
644  EntityDie = getOrCreateSubprogramDIE(SP);
645  else if (auto *T = dyn_cast<DIType>(Entity))
646  EntityDie = getOrCreateTypeDIE(T);
647  else if (auto *GV = dyn_cast<DIGlobalVariable>(Entity))
648  EntityDie = getOrCreateGlobalVariableDIE(GV);
649  else
650  EntityDie = getDIE(Entity);
651  assert(EntityDie);
652  addSourceLine(*IMDie, Module->getLine(), Module->getScope()->getFilename(),
653  Module->getScope()->getDirectory());
654  addDIEEntry(*IMDie, dwarf::DW_AT_import, *EntityDie);
655  StringRef Name = Module->getName();
656  if (!Name.empty())
657  addString(*IMDie, dwarf::DW_AT_name, Name);
658 
659  return IMDie;
660 }
661 
663  DIE *D = getDIE(SP);
664  if (DIE *AbsSPDIE = DU->getAbstractSPDies().lookup(SP)) {
665  if (D)
666  // If this subprogram has an abstract definition, reference that
668  } else {
669  if (!D && !includeMinimalInlineScopes())
670  // Lazily construct the subprogram if we didn't see either concrete or
671  // inlined versions during codegen. (except in -gmlt ^ where we want
672  // to omit these entirely)
673  D = getOrCreateSubprogramDIE(SP);
674  if (D)
675  // And attach the attributes
677  }
678 }
680  assert(SP && "CU's subprogram list contains a non-subprogram");
681  assert(SP->isDefinition() &&
682  "CU's subprogram list contains a subprogram declaration");
683  auto Variables = SP->getVariables();
684  if (Variables.size() == 0)
685  return;
686 
687  DIE *SPDIE = DU->getAbstractSPDies().lookup(SP);
688  if (!SPDIE)
689  SPDIE = getDIE(SP);
690  assert(SPDIE);
691  for (const DILocalVariable *DV : Variables) {
692  DbgVariable NewVar(DV, /* IA */ nullptr, DD);
693  auto VariableDie = constructVariableDIE(NewVar);
694  applyVariableAttributes(NewVar, *VariableDie);
695  SPDIE->addChild(std::move(VariableDie));
696  }
697 }
698 
699 void DwarfCompileUnit::emitHeader(bool UseOffsets) {
700  // Don't bother labeling the .dwo unit, as its offset isn't used.
701  if (!Skeleton) {
702  LabelBegin = Asm->createTempSymbol("cu_begin");
703  Asm->OutStreamer->EmitLabel(LabelBegin);
704  }
705 
706  DwarfUnit::emitHeader(UseOffsets);
707 }
708 
709 /// addGlobalName - Add a new global name to the compile unit.
711  const DIScope *Context) {
712  if (includeMinimalInlineScopes())
713  return;
714  std::string FullName = getParentContextString(Context) + Name.str();
715  GlobalNames[FullName] = &Die;
716 }
717 
718 /// Add a new global type to the unit.
719 void DwarfCompileUnit::addGlobalType(const DIType *Ty, const DIE &Die,
720  const DIScope *Context) {
721  if (includeMinimalInlineScopes())
722  return;
723  std::string FullName = getParentContextString(Context) + Ty->getName().str();
724  GlobalTypes[FullName] = &Die;
725 }
726 
727 /// addVariableAddress - Add DW_AT_location attribute for a
728 /// DbgVariable based on provided MachineLocation.
730  MachineLocation Location) {
731  if (DV.hasComplexAddress())
732  addComplexAddress(DV, Die, dwarf::DW_AT_location, Location);
733  else if (DV.isBlockByrefVariable())
734  addBlockByrefAddress(DV, Die, dwarf::DW_AT_location, Location);
735  else
736  addAddress(Die, dwarf::DW_AT_location, Location);
737 }
738 
739 /// Add an address attribute to a die based on the location provided.
741  const MachineLocation &Location) {
742  DIELoc *Loc = new (DIEValueAllocator) DIELoc;
743 
744  bool validReg;
745  if (Location.isReg())
746  validReg = addRegisterOpPiece(*Loc, Location.getReg());
747  else
748  validReg = addRegisterOffset(*Loc, Location.getReg(), Location.getOffset());
749 
750  if (!validReg)
751  return;
752 
753  // Now attach the location information to the DIE.
754  addBlock(Die, Attribute, Loc);
755 }
756 
757 /// Start with the address based on the location provided, and generate the
758 /// DWARF information necessary to find the actual variable given the extra
759 /// address information encoded in the DbgVariable, starting from the starting
760 /// location. Add the DWARF information to the die.
763  const MachineLocation &Location) {
764  DIELoc *Loc = new (DIEValueAllocator) DIELoc;
765  DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
766  assert(DV.getExpression().size() == 1);
767  const DIExpression *Expr = DV.getExpression().back();
768  bool ValidReg;
769  if (Location.getOffset()) {
770  ValidReg = DwarfExpr.AddMachineRegIndirect(Location.getReg(),
771  Location.getOffset());
772  if (ValidReg)
773  DwarfExpr.AddExpression(Expr->expr_op_begin(), Expr->expr_op_end());
774  } else
775  ValidReg = DwarfExpr.AddMachineRegExpression(Expr, Location.getReg());
776 
777  // Now attach the location information to the DIE.
778  if (ValidReg)
779  addBlock(Die, Attribute, Loc);
780 }
781 
782 /// Add a Dwarf loclistptr attribute data and value.
784  unsigned Index) {
787  Die.addValue(DIEValueAllocator, Attribute, Form, DIELocList(Index));
788 }
789 
791  DIE &VariableDie) {
792  StringRef Name = Var.getName();
793  if (!Name.empty())
794  addString(VariableDie, dwarf::DW_AT_name, Name);
795  addSourceLine(VariableDie, Var.getVariable());
796  addType(VariableDie, Var.getType());
797  if (Var.isArtificial())
798  addFlag(VariableDie, dwarf::DW_AT_artificial);
799 }
800 
801 /// Add a Dwarf expression attribute data and value.
803  const MCExpr *Expr) {
804  Die.addValue(DIEValueAllocator, (dwarf::Attribute)0, Form, DIEExpr(Expr));
805 }
806 
808  const DISubprogram *SP, DIE &SPDie) {
809  auto *SPDecl = SP->getDeclaration();
810  auto *Context = resolve(SPDecl ? SPDecl->getScope() : SP->getScope());
811  applySubprogramAttributes(SP, SPDie, includeMinimalInlineScopes());
812  addGlobalName(SP->getName(), SPDie, Context);
813 }
814 
815 bool DwarfCompileUnit::isDwoUnit() const {
816  return DD->useSplitDwarf() && Skeleton;
817 }
818 
819 bool DwarfCompileUnit::includeMinimalInlineScopes() const {
821  (DD->useSplitDwarf() && !Skeleton);
822 }
823 } // end llvm namespace
StringRef getName() const
void addFlag(DIE &Die, dwarf::Attribute Attribute)
Add a flag that is true to the DIE.
Definition: DwarfUnit.cpp:186
const DILocalScope * getScopeNode() const
Definition: LexicalScopes.h:62
unsigned getUniqueID() const
Definition: DwarfUnit.h:137
const MachineInstr * getMInsn() const
Definition: DwarfDebug.h:136
void addLabelDelta(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Hi, const MCSymbol *Lo)
Add a label delta attribute data and value.
Definition: DwarfUnit.cpp:259
const DICompileUnit * getCUNode() const
Definition: DwarfUnit.h:139
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition: AsmPrinter.h:83
MCSymbol * getSymbol(const GlobalValue *GV) const
Definition: AsmPrinter.cpp:339
DIELoc - Represents an expression location.
Definition: DIE.h:748
unsigned getDebugLocListIndex() const
Definition: DwarfDebug.h:134
DIE * getOrCreateStaticMemberDIE(const DIDerivedType *DT)
Create new static data member DIE.
Definition: DwarfUnit.cpp:1445
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:39
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:114
const DataLayout & getDataLayout() const
Return information about data layout.
Definition: AsmPrinter.cpp:139
const MachineFunction * getCurrentFunction() const
Definition: DwarfDebug.h:623
void attachLowHighPC(DIE &D, const MCSymbol *Begin, const MCSymbol *End)
unsigned getNumOperands() const
Definition: User.h:138
void insertDIE(const DINode *Desc, DIE *D)
Insert DIE into the map.
Definition: DwarfUnit.cpp:178
Collects and handles dwarf debug information.
Definition: DwarfDebug.h:207
const MachineFunction * MF
The current machine function.
Definition: AsmPrinter.h:86
DIE & getUnitDie()
Definition: DwarfUnit.h:140
SmallVectorImpl< InsnRange > & getRanges()
Definition: LexicalScopes.h:65
void collectDeadVariables(const DISubprogram *SP)
unsigned getEmissionKind() const
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:188
DenseMap< LexicalScope *, SmallVector< DbgVariable *, 8 > > & getScopeVariables()
Definition: DwarfFile.h:102
StringRef getName() const
Definition: DwarfDebug.h:135
DIScope * getScope() const
bool hasComplexAddress() const
Definition: DwarfDebug.h:181
bool AddMachineRegExpression(const DIExpression *Expr, unsigned MachineReg, unsigned PieceOffsetInBits=0)
Emit an entire expression on top of a machine register location.
void reserve(size_type N)
Definition: SmallVector.h:401
DIELocList - Represents a pointer to a location list in the debug_loc section.
Definition: DIE.h:285
LexicalScope - This class is used to track scope information.
Definition: LexicalScopes.h:45
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:770
bool useGNUTLSOpcode() const
Returns whether to use DW_OP_GNU_push_tls_address, instead of the standard DW_OP_form_tls_address opc...
Definition: DwarfDebug.h:563
unsigned getOpcode() const
getOpcode - Return the opcode at the root of this constant expression
Definition: Constants.h:1144
const DILocation * getInlinedAt() const
Definition: LexicalScopes.h:61
DIE & updateSubprogramScopeDIE(const DISubprogram *SP)
Find DIE for the given subprogram and attach appropriate DW_AT_low_pc and DW_AT_high_pc attributes...
AsmPrinter * Asm
Target of Dwarf emission.
Definition: DwarfUnit.h:86
DIE * constructLexicalScopeDIE(LexicalScope *Scope)
Construct new DW_TAG_lexical_block for this scope and attach DW_AT_low_pc/DW_AT_high_pc labels...
DIE * getOrCreateTypeDIE(const MDNode *N)
Find existing DIE or create new DIE for the given type.
Definition: DwarfUnit.cpp:707
void addBlock(DIE &Die, dwarf::Attribute Attribute, DIELoc *Block)
Add block data.
Definition: DwarfUnit.cpp:303
virtual void emitHeader(bool UseOffsets)
Emit the header for this unit, not including the initial length field.
Definition: DwarfUnit.cpp:1488
void addArangeLabel(SymbolCU SCU)
Add a label so that arange data can be generated for it.
Definition: DwarfDebug.h:553
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
SmallVectorImpl< LexicalScope * > & getChildren()
Definition: LexicalScopes.h:64
void applyVariableAttributes(const DbgVariable &Var, DIE &VariableDie)
DIE * createAndAddScopeChildren(LexicalScope *Scope, DIE &ScopeDIE)
bool isArtificial() const
Return true if DbgVariable is artificial.
Definition: DwarfDebug.h:165
bool DisableFramePointerElim(const MachineFunction &MF) const
DisableFramePointerElim - This returns true if frame pointer elimination optimization should be disab...
T * resolve(TypedDINodeRef< T > Ref) const
Look in the DwarfDebug map for the MDNode that corresponds to the reference.
Definition: DwarfUnit.h:344
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APInt.h:33
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:33
void addConstantFPValue(DIE &Die, const MachineOperand &MO)
Add constant value entry in variable DIE.
Definition: DwarfUnit.cpp:582
void attachRangesOrLowHighPC(DIE &D, SmallVector< RangeSpan, 2 > Ranges)
value_iterator addValue(BumpPtrAllocator &Alloc, DIEValue Value)
addValue - Add a value and attributes to a DIE.
Definition: DIE.h:716
const ArrayRef< int > getFrameIndex() const
Definition: DwarfDebug.h:137
bool addRegisterOffset(DIELoc &TheDie, unsigned Reg, int64_t Offset)
Add register offset.
Definition: DwarfUnit.cpp:370
bool isLexicalScopeDIENull(LexicalScope *Scope)
A helper function to check whether the DIE for a given Scope is going to be null. ...
Definition: DwarfDebug.cpp:317
uint64_t getIndexedOffset(Type *Ty, ArrayRef< Value * > Indices) const
Returns the offset from the beginning of the type for the specified indices.
Definition: DataLayout.cpp:721
StringRef getFilename() const
virtual unsigned getFrameRegister(const MachineFunction &MF) const =0
Debug information queries.
DISubprogram * getDISubprogram(const MDNode *Scope)
Find subprogram that is enclosing this scope.
Definition: DebugInfo.cpp:36
StringRef getName() const
MCSymbol * getLabelAfterInsn(const MachineInstr *MI)
Return Label immediately following the instruction.
Definition: DwarfDebug.cpp:952
void addScopeRangeList(DIE &ScopeDIE, SmallVector< RangeSpan, 2 > Range)
A helper function to construct a RangeSpanList for a given lexical scope.
void addString(DIE &Die, dwarf::Attribute Attribute, StringRef Str)
Add a string attribute data and value.
Definition: DwarfUnit.cpp:218
AddressPool & getAddressPool()
Definition: DwarfDebug.h:613
unsigned size() const
Subprogram description.
LexicalScope * getParent() const
Definition: LexicalScopes.h:59
void constructScopeDIE(LexicalScope *Scope, SmallVectorImpl< DIE * > &FinalChildren)
ConstantExpr - a constant value that is initialized with an expression using other constant values...
Definition: Constants.h:852
void addComplexAddress(const DbgVariable &DV, DIE &Die, dwarf::Attribute Attribute, const MachineLocation &Location)
Start with the address based on the location provided, and generate the DWARF information necessary t...
iterator_range< ImportedEntityMap::const_iterator > findImportedEntitiesForScope(const MDNode *Scope) const
Definition: DwarfDebug.h:626
void addExpr(DIELoc &Die, dwarf::Form Form, const MCExpr *Expr)
Add a Dwarf expression attribute data and value.
DenseMap< const MDNode *, DIE * > & getAbstractSPDies()
Definition: DwarfFile.h:106
This class is used to track local variable information.
Definition: DwarfDebug.h:81
const ArrayRef< const DIExpression * > getExpression() const
Definition: DwarfDebug.h:130
void applySubprogramAttributesToDefinition(const DISubprogram *SP, DIE &SPDie)
virtual const MCExpr * getDebugThreadLocalSymbol(const MCSymbol *Sym) const
Create a symbol reference to describe the given TLS variable when emitting the address in debug info...
DwarfCompileUnit(unsigned UID, const DICompileUnit *Node, AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU)
DIScopeRef getScope() const
void addAddress(DIE &Die, dwarf::Attribute Attribute, const MachineLocation &Location)
Add an address attribute to a die based on the location provided.
DIE * getOrCreateGlobalVariableDIE(const DIGlobalVariable *GV)
getOrCreateGlobalVariableDIE - get or create global variable DIE.
DIE * getOrCreateNameSpace(const DINamespace *NS)
Definition: DwarfUnit.cpp:1052
bool addRegisterOpPiece(DIELoc &TheDie, unsigned Reg, unsigned SizeInBits=0, unsigned OffsetInBits=0)
Add register operand.
Definition: DwarfUnit.cpp:363
Debug location.
DIE & addChild(DIE *Child)
Add a child to the DIE.
Definition: DIE.h:726
DIScope * getScope() const
void addConstantValue(DIE &Die, const MachineOperand &MO, const DIType *Ty)
Add constant value entry in variable DIE.
Definition: DwarfUnit.cpp:614
unsigned getLine() const
static DIE * get(BumpPtrAllocator &Alloc, dwarf::Tag Tag)
Definition: DIE.h:657
MCSection * getDwarfLineSection() const
bool useSplitDwarf() const
Returns whether or not to change the current debug info for the split dwarf proposal support...
Definition: DwarfDebug.h:573
This dwarf writer support class manages information associated with a source file.
Definition: DwarfUnit.h:68
const DIType * getType() const
Definition: DwarfDebug.cpp:144
void applyStmtList(DIE &D)
Apply the DW_AT_stmt_list from this compile unit to the specified DIE.
StringRef getName() const
const MCAsmInfo * MAI
Target Asm Printer information.
Definition: AsmPrinter.h:74
void addSourceLine(DIE &Die, unsigned Line, StringRef File, StringRef Directory)
Add location information to specified debug information entry.
Definition: DwarfUnit.cpp:317
void setDIE(DIE &D)
Definition: DwarfDebug.h:131
This file contains the declarations for the subclasses of Constant, which represent the different fla...
DIE - A structured debug information entry.
Definition: DIE.h:623
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:66
DIEExpr - An expression DIE.
Definition: DIE.h:154
T * resolve(TypedDINodeRef< T > Ref) const
Find the MDNode for the given reference.
Definition: DwarfDebug.h:594
MCSymbol * getLabelBeforeInsn(const MachineInstr *MI)
Return Label preceding the instruction.
Definition: DwarfDebug.cpp:945
DIELabel - A label DIE.
Definition: DIE.h:175
DIE * getOrCreateSubprogramDIE(const DISubprogram *SP, bool Minimal=false)
Definition: DwarfUnit.cpp:1096
Value * getOperand(unsigned i) const
Definition: User.h:118
void addLocalLabelAddress(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Label)
addLocalLabelAddress - Add a dwarf label attribute data and value using DW_FORM_addr only...
void constructAbstractSubprogramScopeDIE(LexicalScope *Scope)
bool isAbstractScope() const
Definition: LexicalScopes.h:63
DIE::value_iterator addSectionLabel(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Label, const MCSymbol *Sec)
addSectionLabel - Add a Dwarf section label attribute data and value.
DIE * constructImportedEntityDIE(const DIImportedEntity *Module)
Construct import_module DIE.
DINodeRef getEntity() const
Helper used to pair up a symbol and its DWARF compile unit.
Definition: DwarfDebug.h:200
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
DIE * constructVariableDIE(DbgVariable &DV, bool Abstract=false)
constructVariableDIE - Construct a DIE for the given DbgVariable.
DITypeRef getType() const
An imported module (C++ using directive or similar).
DIE * getDIE(const DINode *D) const
Returns the DIE map slot for the specified debug variable.
Definition: DwarfUnit.cpp:172
Base class for scope-like contexts.
DIEDelta - A simple label difference DIE.
Definition: DIE.h:196
StringRef getDisplayName() const
StringRef getDirectory() const
bool isDefined() const
isDefined - Check if this symbol is defined (i.e., it has an address).
Definition: MCSymbol.h:251
virtual const TargetFrameLowering * getFrameLowering() const
unsigned getOrCreateSourceID(StringRef FileName, StringRef DirName) override
Look up the source ID with the given directory and source file names.
DIE * constructInlinedScopeDIE(LexicalScope *Scope)
This scope represents inlined body of a function.
bool AddMachineRegIndirect(unsigned MachineReg, int Offset=0)
Emit an indirect dwarf register operation for the given machine register.
void setPrevCU(const DwarfCompileUnit *PrevCU)
Definition: DwarfDebug.h:580
unsigned getTag() const
Base class for types.
This is the shared class of boolean and integer constants.
Definition: Constants.h:47
void constructSubprogramScopeDIE(LexicalScope *Scope)
Construct a DIE for this subprogram scope.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:861
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:222
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
Definition: MCSymbol.h:264
void addLinkageName(DIE &Die, StringRef LinkageName)
Add a linkage name, if it isn't empty.
Definition: DwarfUnit.cpp:661
MCSymbol * getBeginSymbol()
Definition: MCSection.h:113
MCSymbol * createTempSymbol(const Twine &Name) const
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
Definition: Constants.h:161
void addAccelName(StringRef Name, const DIE &Die)
DWARF expression.
DwarfDebug * DD
Definition: DwarfUnit.h:89
const DILocalVariable * getVariable() const
Definition: DwarfDebug.h:128
std::string getParentContextString(const DIScope *Context) const
Get string containing language specific context for a global name.
Definition: DwarfUnit.cpp:776
void addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIE &Entry)
Add a DIE attribute data and value.
Definition: DwarfUnit.cpp:265
iterator insert(iterator I, T &&Elt)
Definition: SmallVector.h:481
SmallPtrSet< const MDNode *, 16 > & getProcessedSPNodes()
Definition: DwarfDebug.h:645
void addRange(RangeSpan Range)
addRange - Add an address range to the list of ranges for this unit.
DIE::value_iterator addLabel(DIE &Die, dwarf::Attribute Attribute, dwarf::Form Form, const MCSymbol *Label)
Add a Dwarf label attribute data and value.
Definition: DwarfUnit.cpp:225
SI Fix SGPR Live Ranges
DIE * getOrCreateContextDIE(const DIScope *Context)
Get context owner's DIE.
Definition: DwarfUnit.cpp:679
DIEInteger - An integer value DIE.
Definition: DIE.h:112
static bool isPhysicalRegister(unsigned Reg)
isPhysicalRegister - Return true if the specified register number is in the physical register namespa...
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:294
MCSymbol * getFunctionBegin() const
Definition: AsmPrinter.h:158
void addVariableAddress(const DbgVariable &DV, DIE &Die, MachineLocation Location)
Add DW_AT_location attribute for a DbgVariable based on provided MachineLocation. ...
#define I(x, y, z)
Definition: MD5.cpp:54
MCSymbol * getFunctionEnd() const
Definition: AsmPrinter.h:159
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
DIE * getOrCreateModule(const DIModule *M)
Definition: DwarfUnit.cpp:1072
void addBlockByrefAddress(const DbgVariable &DV, DIE &Die, dwarf::Attribute Attribute, const MachineLocation &Location)
Start with the address based on the location provided, and generate the DWARF information necessary t...
Definition: DwarfUnit.cpp:430
std::pair< const MachineInstr *, const MachineInstr * > InsnRange
InsnRange - This is used to track range of instructions with identical lexical scope.
Definition: LexicalScopes.h:34
DIE::value_iterator addSectionDelta(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Hi, const MCSymbol *Lo)
addSectionDelta - Add a label delta attribute data and value.
dwarf::Tag getTag() const
Definition: DwarfDebug.h:158
DwarfExpression implementation for singular DW_AT_location.
void addSubprogramNames(const DISubprogram *SP, DIE &Die)
Definition: DwarfDebug.cpp:280
static const ConstantExpr * getMergedGlobalExpr(const Value *V)
const DwarfCompileUnit * getPrevCU() const
Returns the previous CU that was being updated.
Definition: DwarfDebug.h:579
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
Definition: AsmPrinter.cpp:134
BumpPtrAllocator DIEValueAllocator
Definition: DwarfUnit.h:77
bool isBlockByrefVariable() const
Definition: DwarfDebug.cpp:137
bool isObjectPointer() const
Definition: DwarfDebug.h:173
StringRef getName() const
LLVM Value Representation.
Definition: Value.h:69
DIDerivedType * getStaticDataMemberDeclaration() const
void addGlobalName(StringRef Name, DIE &Die, const DIScope *Context) override
Add a new global name to the compile unit.
void addGlobalType(const DIType *Ty, const DIE &Die, const DIScope *Context) override
Add a new global type to the compile unit.
DIE & UnitDie
Unit debug information entry.
Definition: DwarfUnit.h:80
MCSection * getDwarfRangesSection() const
Constant * getVariable() const
void addOpAddress(DIELoc &Die, const MCSymbol *Label)
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:248
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40
void addLocationList(DIE &Die, dwarf::Attribute Attribute, unsigned Index)
Add a Dwarf loclistptr attribute data and value.
DwarfFile * DU
Definition: DwarfUnit.h:90
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size FIXME: The defaults need to be removed once all of the backends/clients are updat...
Definition: DataLayout.cpp:593
void applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie, bool Minimal=false)
Definition: DwarfUnit.cpp:1159
unsigned getReg() const
void finishSubprogramDefinition(const DISubprogram *SP)
unsigned getDwarfVersion() const
Returns the Dwarf Version.
Definition: DwarfDebug.h:576
void addUInt(DIE &Die, dwarf::Attribute Attribute, Optional< dwarf::Form > Form, uint64_t Integer)
Add an unsigned integer attribute data and value.
Definition: DwarfUnit.cpp:195
void emitHeader(bool UseOffsets) override
Emit the header for this unit, not including the initial length field.
StringRef getLinkageName() const
bool doesDwarfUseRelocationsAcrossSections() const
Definition: MCAsmInfo.h:527
void AddExpression(DIExpression::expr_op_iterator I, DIExpression::expr_op_iterator E, unsigned PieceOffsetInBits=0)
Emit a the operations remaining the DIExpressionIterator I.
const MCSymbol * getEnd() const
Definition: DwarfUnit.h:43
void addLabelAddress(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Label)
addLabelAddress - Add a dwarf label attribute data and value using either DW_FORM_addr or DW_FORM_GNU...
bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:110
unsigned getIndex(const MCSymbol *Sym, bool TLS=false)
Returns the index into the address pool with the given label/symbol.
Definition: AddressPool.cpp:19
DIE * createScopeChildrenDIE(LexicalScope *Scope, SmallVectorImpl< DIE * > &Children, unsigned *ChildScopeCount=nullptr)
A helper function to create children of a Scope DIE.