LLVM  3.7.0
DIBuilder.cpp
Go to the documentation of this file.
1 //===--- DIBuilder.cpp - Debug Information Builder ------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the DIBuilder.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "llvm/IR/DIBuilder.h"
15 #include "llvm/ADT/STLExtras.h"
16 #include "llvm/IR/Constants.h"
17 #include "llvm/IR/DebugInfo.h"
18 #include "llvm/IR/IntrinsicInst.h"
19 #include "llvm/IR/Module.h"
20 #include "llvm/Support/Debug.h"
21 #include "llvm/Support/Dwarf.h"
22 
23 using namespace llvm;
24 using namespace llvm::dwarf;
25 
26 namespace {
27 class HeaderBuilder {
28  /// \brief Whether there are any fields yet.
29  ///
30  /// Note that this is not equivalent to \c Chars.empty(), since \a concat()
31  /// may have been called already with an empty string.
32  bool IsEmpty;
34 
35 public:
36  HeaderBuilder() : IsEmpty(true) {}
37  HeaderBuilder(const HeaderBuilder &X) : IsEmpty(X.IsEmpty), Chars(X.Chars) {}
38  HeaderBuilder(HeaderBuilder &&X)
39  : IsEmpty(X.IsEmpty), Chars(std::move(X.Chars)) {}
40 
41  template <class Twineable> HeaderBuilder &concat(Twineable &&X) {
42  if (IsEmpty)
43  IsEmpty = false;
44  else
45  Chars.push_back(0);
46  Twine(X).toVector(Chars);
47  return *this;
48  }
49 
50  MDString *get(LLVMContext &Context) const {
51  return MDString::get(Context, StringRef(Chars.begin(), Chars.size()));
52  }
53 
54  static HeaderBuilder get(unsigned Tag) {
55  return HeaderBuilder().concat("0x" + Twine::utohexstr(Tag));
56  }
57 };
58 }
59 
60 DIBuilder::DIBuilder(Module &m, bool AllowUnresolvedNodes)
61  : M(m), VMContext(M.getContext()), CUNode(nullptr),
62  DeclareFn(nullptr), ValueFn(nullptr),
63  AllowUnresolvedNodes(AllowUnresolvedNodes) {}
64 
65 void DIBuilder::trackIfUnresolved(MDNode *N) {
66  if (!N)
67  return;
68  if (N->isResolved())
69  return;
70 
71  assert(AllowUnresolvedNodes && "Cannot handle unresolved nodes");
72  UnresolvedNodes.emplace_back(N);
73 }
74 
76  if (!CUNode) {
77  assert(!AllowUnresolvedNodes &&
78  "creating type nodes without a CU is not supported");
79  return;
80  }
81 
82  CUNode->replaceEnumTypes(MDTuple::get(VMContext, AllEnumTypes));
83 
84  SmallVector<Metadata *, 16> RetainValues;
85  // Declarations and definitions of the same type may be retained. Some
86  // clients RAUW these pairs, leaving duplicates in the retained types
87  // list. Use a set to remove the duplicates while we transform the
88  // TrackingVHs back into Values.
90  for (unsigned I = 0, E = AllRetainTypes.size(); I < E; I++)
91  if (RetainSet.insert(AllRetainTypes[I]).second)
92  RetainValues.push_back(AllRetainTypes[I]);
93 
94  if (!RetainValues.empty())
95  CUNode->replaceRetainedTypes(MDTuple::get(VMContext, RetainValues));
96 
97  DISubprogramArray SPs = MDTuple::get(VMContext, AllSubprograms);
98  if (!AllSubprograms.empty())
99  CUNode->replaceSubprograms(SPs.get());
100 
101  for (auto *SP : SPs) {
102  if (MDTuple *Temp = SP->getVariables().get()) {
103  const auto &PV = PreservedVariables.lookup(SP);
104  SmallVector<Metadata *, 4> Variables(PV.begin(), PV.end());
105  DINodeArray AV = getOrCreateArray(Variables);
106  TempMDTuple(Temp)->replaceAllUsesWith(AV.get());
107  }
108  }
109 
110  if (!AllGVs.empty())
111  CUNode->replaceGlobalVariables(MDTuple::get(VMContext, AllGVs));
112 
113  if (!AllImportedModules.empty())
115  VMContext, SmallVector<Metadata *, 16>(AllImportedModules.begin(),
116  AllImportedModules.end())));
117 
118  // Now that all temp nodes have been replaced or deleted, resolve remaining
119  // cycles.
120  for (const auto &N : UnresolvedNodes)
121  if (N && !N->isResolved())
122  N->resolveCycles();
123  UnresolvedNodes.clear();
124 
125  // Can't handle unresolved nodes anymore.
126  AllowUnresolvedNodes = false;
127 }
128 
129 /// If N is compile unit return NULL otherwise return N.
131  if (!N || isa<DICompileUnit>(N))
132  return nullptr;
133  return cast<DIScope>(N);
134 }
135 
137  unsigned Lang, StringRef Filename, StringRef Directory, StringRef Producer,
138  bool isOptimized, StringRef Flags, unsigned RunTimeVer, StringRef SplitName,
139  DebugEmissionKind Kind, uint64_t DWOId, bool EmitDebugInfo) {
140 
141  assert(((Lang <= dwarf::DW_LANG_Fortran08 && Lang >= dwarf::DW_LANG_C89) ||
142  (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) &&
143  "Invalid Language tag");
144  assert(!Filename.empty() &&
145  "Unable to create compile unit without filename");
146 
147  assert(!CUNode && "Can only make one compile unit per DIBuilder instance");
149  VMContext, Lang, DIFile::get(VMContext, Filename, Directory), Producer,
150  isOptimized, Flags, RunTimeVer, SplitName, Kind, nullptr,
151  nullptr, nullptr, nullptr, nullptr, DWOId);
152 
153  // Create a named metadata so that it is easier to find cu in a module.
154  // Note that we only generate this when the caller wants to actually
155  // emit debug information. When we are only interested in tracking
156  // source line locations throughout the backend, we prevent codegen from
157  // emitting debug info in the final output by not generating llvm.dbg.cu.
158  if (EmitDebugInfo) {
159  NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
160  NMD->addOperand(CUNode);
161  }
162 
163  trackIfUnresolved(CUNode);
164  return CUNode;
165 }
166 
167 static DIImportedEntity *
169  Metadata *NS, unsigned Line, StringRef Name,
170  SmallVectorImpl<TrackingMDNodeRef> &AllImportedModules) {
171  auto *M = DIImportedEntity::get(C, Tag, Context, DINodeRef(NS), Line, Name);
172  AllImportedModules.emplace_back(M);
173  return M;
174 }
175 
177  DINamespace *NS,
178  unsigned Line) {
179  return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
180  Context, NS, Line, StringRef(), AllImportedModules);
181 }
182 
184  DIImportedEntity *NS,
185  unsigned Line) {
186  return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
187  Context, NS, Line, StringRef(), AllImportedModules);
188 }
189 
191  unsigned Line) {
192  return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
193  Context, M, Line, StringRef(), AllImportedModules);
194 }
195 
197  DINode *Decl,
198  unsigned Line,
199  StringRef Name) {
200  // Make sure to use the unique identifier based metadata reference for
201  // types that have one.
202  return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_declaration,
203  Context, DINodeRef::get(Decl), Line, Name,
204  AllImportedModules);
205 }
206 
208  return DIFile::get(VMContext, Filename, Directory);
209 }
210 
212  assert(!Name.empty() && "Unable to create enumerator without name");
213  return DIEnumerator::get(VMContext, Val, Name);
214 }
215 
217  assert(!Name.empty() && "Unable to create type without name");
218  return DIBasicType::get(VMContext, dwarf::DW_TAG_unspecified_type, Name);
219 }
220 
222  return createUnspecifiedType("decltype(nullptr)");
223 }
224 
226  uint64_t AlignInBits,
227  unsigned Encoding) {
228  assert(!Name.empty() && "Unable to create type without name");
229  return DIBasicType::get(VMContext, dwarf::DW_TAG_base_type, Name, SizeInBits,
230  AlignInBits, Encoding);
231 }
232 
234  return DIDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr,
235  DITypeRef::get(FromTy), 0, 0, 0, 0);
236 }
237 
239  uint64_t SizeInBits,
240  uint64_t AlignInBits,
241  StringRef Name) {
242  // FIXME: Why is there a name here?
243  return DIDerivedType::get(VMContext, dwarf::DW_TAG_pointer_type, Name,
244  nullptr, 0, nullptr, DITypeRef::get(PointeeTy),
245  SizeInBits, AlignInBits, 0, 0);
246 }
247 
249  DIType *Base,
250  uint64_t SizeInBits,
251  uint64_t AlignInBits) {
252  return DIDerivedType::get(VMContext, dwarf::DW_TAG_ptr_to_member_type, "",
253  nullptr, 0, nullptr, DITypeRef::get(PointeeTy),
254  SizeInBits, AlignInBits, 0, 0,
255  DITypeRef::get(Base));
256 }
257 
259  assert(RTy && "Unable to create reference type");
260  return DIDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr,
261  DITypeRef::get(RTy), 0, 0, 0, 0);
262 }
263 
265  DIFile *File, unsigned LineNo,
266  DIScope *Context) {
267  return DIDerivedType::get(VMContext, dwarf::DW_TAG_typedef, Name, File,
268  LineNo,
270  DITypeRef::get(Ty), 0, 0, 0, 0);
271 }
272 
274  assert(Ty && "Invalid type!");
275  assert(FriendTy && "Invalid friend type!");
276  return DIDerivedType::get(VMContext, dwarf::DW_TAG_friend, "", nullptr, 0,
277  DITypeRef::get(Ty), DITypeRef::get(FriendTy), 0, 0,
278  0, 0);
279 }
280 
282  uint64_t BaseOffset,
283  unsigned Flags) {
284  assert(Ty && "Unable to create inheritance");
285  return DIDerivedType::get(VMContext, dwarf::DW_TAG_inheritance, "", nullptr,
286  0, DITypeRef::get(Ty), DITypeRef::get(BaseTy), 0, 0,
287  BaseOffset, Flags);
288 }
289 
291  DIFile *File, unsigned LineNumber,
292  uint64_t SizeInBits,
293  uint64_t AlignInBits,
294  uint64_t OffsetInBits,
295  unsigned Flags, DIType *Ty) {
296  return DIDerivedType::get(
297  VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
299  SizeInBits, AlignInBits, OffsetInBits, Flags);
300 }
301 
303  if (C)
304  return ConstantAsMetadata::get(C);
305  return nullptr;
306 }
307 
309  DIFile *File,
310  unsigned LineNumber,
311  DIType *Ty, unsigned Flags,
312  llvm::Constant *Val) {
313  Flags |= DINode::FlagStaticMember;
314  return DIDerivedType::get(
315  VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
317  0, Flags, getConstantOrNull(Val));
318 }
319 
321  unsigned LineNumber,
322  uint64_t SizeInBits,
323  uint64_t AlignInBits,
324  uint64_t OffsetInBits, unsigned Flags,
325  DIType *Ty, MDNode *PropertyNode) {
326  return DIDerivedType::get(
327  VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
329  SizeInBits, AlignInBits, OffsetInBits, Flags, PropertyNode);
330 }
331 
334  StringRef GetterName, StringRef SetterName,
335  unsigned PropertyAttributes, DIType *Ty) {
336  return DIObjCProperty::get(VMContext, Name, File, LineNumber, GetterName,
337  SetterName, PropertyAttributes,
338  DITypeRef::get(Ty));
339 }
340 
343  DIType *Ty) {
344  assert((!Context || isa<DICompileUnit>(Context)) && "Expected compile unit");
345  return DITemplateTypeParameter::get(VMContext, Name, DITypeRef::get(Ty));
346 }
347 
350  DIScope *Context, StringRef Name, DIType *Ty,
351  Metadata *MD) {
352  assert((!Context || isa<DICompileUnit>(Context)) && "Expected compile unit");
353  return DITemplateValueParameter::get(VMContext, Tag, Name, DITypeRef::get(Ty),
354  MD);
355 }
356 
359  DIType *Ty, Constant *Val) {
361  VMContext, dwarf::DW_TAG_template_value_parameter, Context, Name, Ty,
362  getConstantOrNull(Val));
363 }
364 
367  DIType *Ty, StringRef Val) {
369  VMContext, dwarf::DW_TAG_GNU_template_template_param, Context, Name, Ty,
370  MDString::get(VMContext, Val));
371 }
372 
375  DIType *Ty, DINodeArray Val) {
377  VMContext, dwarf::DW_TAG_GNU_template_parameter_pack, Context, Name, Ty,
378  Val.get());
379 }
380 
382  DIScope *Context, StringRef Name, DIFile *File, unsigned LineNumber,
383  uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits,
384  unsigned Flags, DIType *DerivedFrom, DINodeArray Elements,
385  DIType *VTableHolder, MDNode *TemplateParams, StringRef UniqueIdentifier) {
386  assert((!Context || isa<DIScope>(Context)) &&
387  "createClassType should be called with a valid Context");
388 
389  auto *R = DICompositeType::get(
390  VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber,
392  DITypeRef::get(DerivedFrom), SizeInBits, AlignInBits, OffsetInBits, Flags,
393  Elements, 0, DITypeRef::get(VTableHolder),
394  cast_or_null<MDTuple>(TemplateParams), UniqueIdentifier);
395  if (!UniqueIdentifier.empty())
396  retainType(R);
397  trackIfUnresolved(R);
398  return R;
399 }
400 
402  DIScope *Context, StringRef Name, DIFile *File, unsigned LineNumber,
403  uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags,
404  DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang,
405  DIType *VTableHolder, StringRef UniqueIdentifier) {
406  auto *R = DICompositeType::get(
407  VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber,
409  DITypeRef::get(DerivedFrom), SizeInBits, AlignInBits, 0, Flags, Elements,
410  RunTimeLang, DITypeRef::get(VTableHolder), nullptr, UniqueIdentifier);
411  if (!UniqueIdentifier.empty())
412  retainType(R);
413  trackIfUnresolved(R);
414  return R;
415 }
416 
418  DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
419  uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags,
420  DINodeArray Elements, unsigned RunTimeLang, StringRef UniqueIdentifier) {
421  auto *R = DICompositeType::get(
422  VMContext, dwarf::DW_TAG_union_type, Name, File, LineNumber,
423  DIScopeRef::get(getNonCompileUnitScope(Scope)), nullptr, SizeInBits,
424  AlignInBits, 0, Flags, Elements, RunTimeLang, nullptr, nullptr,
425  UniqueIdentifier);
426  if (!UniqueIdentifier.empty())
427  retainType(R);
428  trackIfUnresolved(R);
429  return R;
430 }
431 
433  DITypeRefArray ParameterTypes,
434  unsigned Flags) {
435  return DISubroutineType::get(VMContext, Flags, ParameterTypes);
436 }
437 
439  DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
440  uint64_t SizeInBits, uint64_t AlignInBits, DINodeArray Elements,
441  DIType *UnderlyingType, StringRef UniqueIdentifier) {
442  auto *CTy = DICompositeType::get(
443  VMContext, dwarf::DW_TAG_enumeration_type, Name, File, LineNumber,
445  DITypeRef::get(UnderlyingType), SizeInBits, AlignInBits, 0, 0, Elements,
446  0, nullptr, nullptr, UniqueIdentifier);
447  AllEnumTypes.push_back(CTy);
448  if (!UniqueIdentifier.empty())
449  retainType(CTy);
450  trackIfUnresolved(CTy);
451  return CTy;
452 }
453 
454 DICompositeType *DIBuilder::createArrayType(uint64_t Size, uint64_t AlignInBits,
455  DIType *Ty,
456  DINodeArray Subscripts) {
457  auto *R = DICompositeType::get(VMContext, dwarf::DW_TAG_array_type, "",
458  nullptr, 0, nullptr, DITypeRef::get(Ty), Size,
459  AlignInBits, 0, 0, Subscripts, 0, nullptr);
460  trackIfUnresolved(R);
461  return R;
462 }
463 
465  uint64_t AlignInBits, DIType *Ty,
466  DINodeArray Subscripts) {
467  auto *R =
468  DICompositeType::get(VMContext, dwarf::DW_TAG_array_type, "", nullptr, 0,
469  nullptr, DITypeRef::get(Ty), Size, AlignInBits, 0,
470  DINode::FlagVector, Subscripts, 0, nullptr);
471  trackIfUnresolved(R);
472  return R;
473 }
474 
476  unsigned FlagsToSet) {
477  auto NewTy = Ty->clone();
478  NewTy->setFlags(NewTy->getFlags() | FlagsToSet);
479  return MDNode::replaceWithUniqued(std::move(NewTy));
480 }
481 
483  // FIXME: Restrict this to the nodes where it's valid.
484  if (Ty->isArtificial())
485  return Ty;
486  return createTypeWithFlags(VMContext, Ty, DINode::FlagArtificial);
487 }
488 
490  // FIXME: Restrict this to the nodes where it's valid.
491  if (Ty->isObjectPointer())
492  return Ty;
493  unsigned Flags = DINode::FlagObjectPointer | DINode::FlagArtificial;
494  return createTypeWithFlags(VMContext, Ty, Flags);
495 }
496 
498  assert(T && "Expected non-null type");
499  AllRetainTypes.emplace_back(T);
500 }
501 
503 
506  DIFile *F, unsigned Line, unsigned RuntimeLang,
507  uint64_t SizeInBits, uint64_t AlignInBits,
508  StringRef UniqueIdentifier) {
509  // FIXME: Define in terms of createReplaceableForwardDecl() by calling
510  // replaceWithUniqued().
511  auto *RetTy = DICompositeType::get(
512  VMContext, Tag, Name, F, Line,
513  DIScopeRef::get(getNonCompileUnitScope(Scope)), nullptr, SizeInBits,
514  AlignInBits, 0, DINode::FlagFwdDecl, nullptr, RuntimeLang, nullptr,
515  nullptr, UniqueIdentifier);
516  if (!UniqueIdentifier.empty())
517  retainType(RetTy);
518  trackIfUnresolved(RetTy);
519  return RetTy;
520 }
521 
523  unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line,
524  unsigned RuntimeLang, uint64_t SizeInBits, uint64_t AlignInBits,
525  unsigned Flags, StringRef UniqueIdentifier) {
526  auto *RetTy = DICompositeType::getTemporary(
527  VMContext, Tag, Name, F, Line,
528  DIScopeRef::get(getNonCompileUnitScope(Scope)), nullptr,
529  SizeInBits, AlignInBits, 0, Flags, nullptr, RuntimeLang,
530  nullptr, nullptr, UniqueIdentifier)
531  .release();
532  if (!UniqueIdentifier.empty())
533  retainType(RetTy);
534  trackIfUnresolved(RetTy);
535  return RetTy;
536 }
537 
539  return MDTuple::get(VMContext, Elements);
540 }
541 
544  for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
545  if (Elements[i] && isa<MDNode>(Elements[i]))
546  Elts.push_back(DITypeRef::get(cast<DIType>(Elements[i])));
547  else
548  Elts.push_back(Elements[i]);
549  }
550  return DITypeRefArray(MDNode::get(VMContext, Elts));
551 }
552 
553 DISubrange *DIBuilder::getOrCreateSubrange(int64_t Lo, int64_t Count) {
554  return DISubrange::get(VMContext, Count, Lo);
555 }
556 
557 static void checkGlobalVariableScope(DIScope *Context) {
558 #ifndef NDEBUG
559  if (auto *CT =
560  dyn_cast_or_null<DICompositeType>(getNonCompileUnitScope(Context)))
561  assert(CT->getIdentifier().empty() &&
562  "Context of a global variable should not be a type with identifier");
563 #endif
564 }
565 
567  DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *F,
568  unsigned LineNumber, DIType *Ty, bool isLocalToUnit, Constant *Val,
569  MDNode *Decl) {
570  checkGlobalVariableScope(Context);
571 
572  auto *N = DIGlobalVariable::get(VMContext, cast_or_null<DIScope>(Context),
573  Name, LinkageName, F, LineNumber,
574  DITypeRef::get(Ty), isLocalToUnit, true, Val,
575  cast_or_null<DIDerivedType>(Decl));
576  AllGVs.push_back(N);
577  return N;
578 }
579 
581  DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *F,
582  unsigned LineNumber, DIType *Ty, bool isLocalToUnit, Constant *Val,
583  MDNode *Decl) {
584  checkGlobalVariableScope(Context);
585 
587  VMContext, cast_or_null<DIScope>(Context), Name, LinkageName, F,
588  LineNumber, DITypeRef::get(Ty), isLocalToUnit, false, Val,
589  cast_or_null<DIDerivedType>(Decl))
590  .release();
591 }
592 
594  unsigned Tag, DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo,
595  DIType *Ty, bool AlwaysPreserve, unsigned Flags, unsigned ArgNo) {
596  // FIXME: Why getNonCompileUnitScope()?
597  // FIXME: Why is "!Context" okay here?
598  // FIXME: Why doesn't this check for a subprogram or lexical block (AFAICT
599  // the only valid scopes)?
600  DIScope *Context = getNonCompileUnitScope(Scope);
601 
602  auto *Node = DILocalVariable::get(
603  VMContext, Tag, cast_or_null<DILocalScope>(Context), Name, File, LineNo,
604  DITypeRef::get(Ty), ArgNo, Flags);
605  if (AlwaysPreserve) {
606  // The optimizer may remove local variables. If there is an interest
607  // to preserve variable info in such situation then stash it in a
608  // named mdnode.
609  DISubprogram *Fn = getDISubprogram(Scope);
610  assert(Fn && "Missing subprogram for local variable");
611  PreservedVariables[Fn].emplace_back(Node);
612  }
613  return Node;
614 }
615 
617  return DIExpression::get(VMContext, Addr);
618 }
619 
621  // TODO: Remove the callers of this signed version and delete.
622  SmallVector<uint64_t, 8> Addr(Signed.begin(), Signed.end());
623  return createExpression(Addr);
624 }
625 
627  unsigned SizeInBytes) {
628  uint64_t Addr[] = {dwarf::DW_OP_bit_piece, OffsetInBytes, SizeInBytes};
629  return DIExpression::get(VMContext, Addr);
630 }
631 
633  StringRef LinkageName, DIFile *File,
634  unsigned LineNo, DISubroutineType *Ty,
635  bool isLocalToUnit, bool isDefinition,
636  unsigned ScopeLine, unsigned Flags,
637  bool isOptimized, Function *Fn,
638  MDNode *TParams, MDNode *Decl) {
639  // dragonegg does not generate identifier for types, so using an empty map
640  // to resolve the context should be fine.
641  DITypeIdentifierMap EmptyMap;
642  return createFunction(Context.resolve(EmptyMap), Name, LinkageName, File,
643  LineNo, Ty, isLocalToUnit, isDefinition, ScopeLine,
644  Flags, isOptimized, Fn, TParams, Decl);
645 }
646 
648  StringRef LinkageName, DIFile *File,
649  unsigned LineNo, DISubroutineType *Ty,
650  bool isLocalToUnit, bool isDefinition,
651  unsigned ScopeLine, unsigned Flags,
652  bool isOptimized, Function *Fn,
653  MDNode *TParams, MDNode *Decl) {
654  assert(Ty->getTag() == dwarf::DW_TAG_subroutine_type &&
655  "function types should be subroutines");
656  auto *Node = DISubprogram::get(
657  VMContext, DIScopeRef::get(getNonCompileUnitScope(Context)), Name,
658  LinkageName, File, LineNo, Ty, isLocalToUnit, isDefinition, ScopeLine,
659  nullptr, 0, 0, Flags, isOptimized, Fn, cast_or_null<MDTuple>(TParams),
660  cast_or_null<DISubprogram>(Decl),
661  MDTuple::getTemporary(VMContext, None).release());
662 
663  if (isDefinition)
664  AllSubprograms.push_back(Node);
665  trackIfUnresolved(Node);
666  return Node;
667 }
668 
670  DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
671  unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
672  bool isDefinition, unsigned ScopeLine, unsigned Flags, bool isOptimized,
673  Function *Fn, MDNode *TParams, MDNode *Decl) {
675  VMContext, DIScopeRef::get(getNonCompileUnitScope(Context)), Name,
676  LinkageName, File, LineNo, Ty, isLocalToUnit, isDefinition,
677  ScopeLine, nullptr, 0, 0, Flags, isOptimized, Fn,
678  cast_or_null<MDTuple>(TParams), cast_or_null<DISubprogram>(Decl),
679  nullptr)
680  .release();
681 }
682 
683 DISubprogram *
685  DIFile *F, unsigned LineNo, DISubroutineType *Ty,
686  bool isLocalToUnit, bool isDefinition, unsigned VK,
687  unsigned VIndex, DIType *VTableHolder, unsigned Flags,
688  bool isOptimized, Function *Fn, MDNode *TParam) {
689  assert(Ty->getTag() == dwarf::DW_TAG_subroutine_type &&
690  "function types should be subroutines");
691  assert(getNonCompileUnitScope(Context) &&
692  "Methods should have both a Context and a context that isn't "
693  "the compile unit.");
694  // FIXME: Do we want to use different scope/lines?
695  auto *SP = DISubprogram::get(
696  VMContext, DIScopeRef::get(cast<DIScope>(Context)), Name, LinkageName, F,
697  LineNo, Ty, isLocalToUnit, isDefinition, LineNo,
698  DITypeRef::get(VTableHolder), VK, VIndex, Flags, isOptimized, Fn,
699  cast_or_null<MDTuple>(TParam), nullptr, nullptr);
700 
701  if (isDefinition)
702  AllSubprograms.push_back(SP);
703  trackIfUnresolved(SP);
704  return SP;
705 }
706 
708  DIFile *File, unsigned LineNo) {
709  return DINamespace::get(VMContext, getNonCompileUnitScope(Scope), File, Name,
710  LineNo);
711 }
712 
714  StringRef ConfigurationMacros,
715  StringRef IncludePath,
716  StringRef ISysRoot) {
717  return DIModule::get(VMContext, getNonCompileUnitScope(Scope), Name,
718  ConfigurationMacros, IncludePath, ISysRoot);
719 }
720 
722  DIFile *File,
723  unsigned Discriminator) {
724  return DILexicalBlockFile::get(VMContext, Scope, File, Discriminator);
725 }
726 
728  unsigned Line, unsigned Col) {
729  // Make these distinct, to avoid merging two lexical blocks on the same
730  // file/line/column.
731  return DILexicalBlock::getDistinct(VMContext, getNonCompileUnitScope(Scope),
732  File, Line, Col);
733 }
734 
736  assert(V && "no value passed to dbg intrinsic");
737  return MetadataAsValue::get(VMContext, ValueAsMetadata::get(V));
738 }
739 
741  I->setDebugLoc(const_cast<DILocation *>(DL));
742  return I;
743 }
744 
746  DIExpression *Expr, const DILocation *DL,
747  Instruction *InsertBefore) {
748  assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.declare");
749  assert(DL && "Expected debug loc");
750  assert(DL->getScope()->getSubprogram() ==
751  VarInfo->getScope()->getSubprogram() &&
752  "Expected matching subprograms");
753  if (!DeclareFn)
754  DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
755 
756  trackIfUnresolved(VarInfo);
757  trackIfUnresolved(Expr);
758  Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, Storage),
759  MetadataAsValue::get(VMContext, VarInfo),
760  MetadataAsValue::get(VMContext, Expr)};
761  return withDebugLoc(CallInst::Create(DeclareFn, Args, "", InsertBefore), DL);
762 }
763 
765  DIExpression *Expr, const DILocation *DL,
766  BasicBlock *InsertAtEnd) {
767  assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.declare");
768  assert(DL && "Expected debug loc");
769  assert(DL->getScope()->getSubprogram() ==
770  VarInfo->getScope()->getSubprogram() &&
771  "Expected matching subprograms");
772  if (!DeclareFn)
773  DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
774 
775  trackIfUnresolved(VarInfo);
776  trackIfUnresolved(Expr);
777  Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, Storage),
778  MetadataAsValue::get(VMContext, VarInfo),
779  MetadataAsValue::get(VMContext, Expr)};
780 
781  // If this block already has a terminator then insert this intrinsic
782  // before the terminator.
783  if (TerminatorInst *T = InsertAtEnd->getTerminator())
784  return withDebugLoc(CallInst::Create(DeclareFn, Args, "", T), DL);
785  return withDebugLoc(CallInst::Create(DeclareFn, Args, "", InsertAtEnd), DL);
786 }
787 
789  DILocalVariable *VarInfo,
790  DIExpression *Expr,
791  const DILocation *DL,
792  Instruction *InsertBefore) {
793  assert(V && "no value passed to dbg.value");
794  assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.value");
795  assert(DL && "Expected debug loc");
796  assert(DL->getScope()->getSubprogram() ==
797  VarInfo->getScope()->getSubprogram() &&
798  "Expected matching subprograms");
799  if (!ValueFn)
800  ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
801 
802  trackIfUnresolved(VarInfo);
803  trackIfUnresolved(Expr);
804  Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, V),
805  ConstantInt::get(Type::getInt64Ty(VMContext), Offset),
806  MetadataAsValue::get(VMContext, VarInfo),
807  MetadataAsValue::get(VMContext, Expr)};
808  return withDebugLoc(CallInst::Create(ValueFn, Args, "", InsertBefore), DL);
809 }
810 
812  DILocalVariable *VarInfo,
813  DIExpression *Expr,
814  const DILocation *DL,
815  BasicBlock *InsertAtEnd) {
816  assert(V && "no value passed to dbg.value");
817  assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.value");
818  assert(DL && "Expected debug loc");
819  assert(DL->getScope()->getSubprogram() ==
820  VarInfo->getScope()->getSubprogram() &&
821  "Expected matching subprograms");
822  if (!ValueFn)
823  ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
824 
825  trackIfUnresolved(VarInfo);
826  trackIfUnresolved(Expr);
827  Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, V),
828  ConstantInt::get(Type::getInt64Ty(VMContext), Offset),
829  MetadataAsValue::get(VMContext, VarInfo),
830  MetadataAsValue::get(VMContext, Expr)};
831 
832  return withDebugLoc(CallInst::Create(ValueFn, Args, "", InsertAtEnd), DL);
833 }
834 
836  DICompositeType *VTableHolder) {
837  {
839  N->replaceVTableHolder(DITypeRef::get(VTableHolder));
840  T = N.get();
841  }
842 
843  // If this didn't create a self-reference, just return.
844  if (T != VTableHolder)
845  return;
846 
847  // Look for unresolved operands. T will drop RAUW support, orphaning any
848  // cycles underneath it.
849  if (T->isResolved())
850  for (const MDOperand &O : T->operands())
851  if (auto *N = dyn_cast_or_null<MDNode>(O))
852  trackIfUnresolved(N);
853 }
854 
855 void DIBuilder::replaceArrays(DICompositeType *&T, DINodeArray Elements,
856  DINodeArray TParams) {
857  {
859  if (Elements)
860  N->replaceElements(Elements);
861  if (TParams)
862  N->replaceTemplateParams(DITemplateParameterArray(TParams));
863  T = N.get();
864  }
865 
866  // If T isn't resolved, there's no problem.
867  if (!T->isResolved())
868  return;
869 
870  // If T is resolved, it may be due to a self-reference cycle. Track the
871  // arrays explicitly if they're unresolved, or else the cycles will be
872  // orphaned.
873  if (Elements)
874  trackIfUnresolved(Elements.get());
875  if (TParams)
876  trackIfUnresolved(TParams.get());
877 }
void finalize()
Construct any deferred debug info descriptors.
Definition: DIBuilder.cpp:75
void toVector(SmallVectorImpl< char > &Out) const
Append the concatenated string into the given SmallString or SmallVector.
Definition: Twine.cpp:26
DIDerivedType * createObjCIVar(StringRef Name, DIFile *File, unsigned LineNo, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, DIType *Ty, MDNode *PropertyNode)
Create debugging information entry for Objective-C instance variable.
Definition: DIBuilder.cpp:320
Tracking metadata reference owned by Metadata.
Definition: Metadata.h:597
static Value * getDbgIntrinsicValueImpl(LLVMContext &VMContext, Value *V)
Definition: DIBuilder.cpp:735
DICompositeType * createArrayType(uint64_t Size, uint64_t AlignInBits, DIType *Ty, DINodeArray Subscripts)
Create debugging information entry for an array.
Definition: DIBuilder.cpp:454
bool isArtificial() const
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:114
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1036
static MDString * get(LLVMContext &Context, StringRef Str)
Definition: Metadata.cpp:360
DILocalScope * getScope() const
Get the local scope for this variable.
iterator end() const
Definition: ArrayRef.h:123
void addOperand(MDNode *M)
Definition: Metadata.cpp:971
static DIType * createTypeWithFlags(LLVMContext &Context, DIType *Ty, unsigned FlagsToSet)
Definition: DIBuilder.cpp:475
NamedMDNode * getOrInsertNamedMetadata(StringRef Name)
Return the named MDNode in the module with the specified name.
Definition: Module.cpp:262
DIDerivedType * createMemberPointerType(DIType *PointeeTy, DIType *Class, uint64_t SizeInBits, uint64_t AlignInBits=0)
Create debugging information entry for a pointer to member.
Definition: DIBuilder.cpp:248
DISubrange * getOrCreateSubrange(int64_t Lo, int64_t Count)
Create a descriptor for a value range.
Definition: DIBuilder.cpp:553
Metadata node.
Definition: Metadata.h:740
F(f)
static IntegerType * getInt64Ty(LLVMContext &C)
Definition: Type.cpp:240
Instruction * insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset, DILocalVariable *VarInfo, DIExpression *Expr, const DILocation *DL, BasicBlock *InsertAtEnd)
Insert a new llvm.dbg.value intrinsic call.
Definition: DIBuilder.cpp:811
DIType * createObjectPointerType(DIType *Ty)
Create a new DIType* with the "object pointer" flag set.
Definition: DIBuilder.cpp:489
DITypeRefArray getOrCreateTypeArray(ArrayRef< Metadata * > Elements)
Get a DITypeRefArray, create one if required.
Definition: DIBuilder.cpp:542
Tuple of metadata.
Definition: Metadata.h:972
Tagged DWARF-like metadata node.
void replaceRetainedTypes(DITypeArray N)
DILexicalBlockFile * createLexicalBlockFile(DIScope *Scope, DIFile *File, unsigned Discriminator=0)
This creates a descriptor for a lexical block with a new file attached.
Definition: DIBuilder.cpp:721
DINodeArray getOrCreateArray(ArrayRef< Metadata * > Elements)
Get a DINodeArray, create one if required.
Definition: DIBuilder.cpp:538
A tuple of MDNodes.
Definition: Metadata.h:1127
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:79
static CallInst * Create(Value *Func, ArrayRef< Value * > Args, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
DITemplateTypeParameter * createTemplateTypeParameter(DIScope *Scope, StringRef Name, DIType *Ty)
Create debugging information for template type parameter.
Definition: DIBuilder.cpp:342
Array subrange.
Instruction * insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo, DIExpression *Expr, const DILocation *DL, BasicBlock *InsertAtEnd)
Insert a new llvm.dbg.declare intrinsic call.
Definition: DIBuilder.cpp:764
DIDerivedType * createTypedef(DIType *Ty, StringRef Name, DIFile *File, unsigned LineNo, DIScope *Context)
Create debugging information entry for a typedef.
Definition: DIBuilder.cpp:264
DICompositeType * createEnumerationType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, DINodeArray Elements, DIType *UnderlyingType, StringRef UniqueIdentifier="")
Create debugging information entry for an enumeration.
Definition: DIBuilder.cpp:438
DIBasicType * createUnspecifiedType(StringRef Name)
Create a DWARF unspecified type.
Definition: DIBuilder.cpp:216
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APInt.h:33
DICompositeType * createStructType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang=0, DIType *VTableHolder=nullptr, StringRef UniqueIdentifier="")
Create debugging information entry for a struct.
Definition: DIBuilder.cpp:401
TypedDINodeRef< DINode > DINodeRef
DIDerivedType * createInheritance(DIType *Ty, DIType *BaseTy, uint64_t BaseOffset, unsigned Flags)
Create debugging information entry to establish inheritance relationship between two types...
Definition: DIBuilder.cpp:281
Pointer union between a subclass of DINode and MDString.
DISubprogram * getDISubprogram(const MDNode *Scope)
Find subprogram that is enclosing this scope.
Definition: DebugInfo.cpp:36
static DIImportedEntity * createImportedModule(LLVMContext &C, dwarf::Tag Tag, DIScope *Context, Metadata *NS, unsigned Line, StringRef Name, SmallVectorImpl< TrackingMDNodeRef > &AllImportedModules)
Definition: DIBuilder.cpp:168
T * resolve(const MapTy &Map) const
void resolveCycles()
Resolve cycles.
Definition: Metadata.cpp:520
DIEnumerator * createEnumerator(StringRef Name, int64_t Val)
Create a single enumerator value.
Definition: DIBuilder.cpp:211
Subprogram description.
DISubprogram * createTempFunctionFwdDecl(DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit, bool isDefinition, unsigned ScopeLine, unsigned Flags=0, bool isOptimized=false, Function *Fn=nullptr, MDNode *TParam=nullptr, MDNode *Decl=nullptr)
Identical to createFunction, except that the resulting DbgNode is meant to be RAUWed.
Definition: DIBuilder.cpp:669
DICompositeType * createReplaceableCompositeType(unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line, unsigned RuntimeLang=0, uint64_t SizeInBits=0, uint64_t AlignInBits=0, unsigned Flags=DINode::FlagFwdDecl, StringRef UniqueIdentifier="")
Create a temporary forward-declared type.
Definition: DIBuilder.cpp:522
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
Definition: SmallVector.h:57
Enumeration value.
DIExpression * createBitPieceExpression(unsigned OffsetInBits, unsigned SizeInBits)
Create a descriptor to describe one part of aggregate variable that is fragmented across multiple Val...
Definition: DIBuilder.cpp:626
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: ArrayRef.h:31
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
Definition: Function.cpp:866
static TempMDTuple getTemporary(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Return a temporary node.
Definition: Metadata.h:1017
Debug location.
static ConstantAsMetadata * get(Constant *C)
Definition: Metadata.h:318
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:134
DIBasicType * createNullPtrType()
Create C++11 nullptr type.
Definition: DIBuilder.cpp:221
static Instruction * withDebugLoc(Instruction *I, const DILocation *DL)
Definition: DIBuilder.cpp:740
void replaceElements(DINodeArray Elements)
Replace operands.
void replaceGlobalVariables(DIGlobalVariableArray N)
static MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
Definition: Metadata.cpp:75
#define true
Definition: ConvertUTF.c:66
DIType * createArtificialType(DIType *Ty)
Create a new DIType* with "artificial" flag set.
Definition: DIBuilder.cpp:482
static std::enable_if< std::is_base_of< MDNode, T >::value, T * >::type replaceWithUniqued(std::unique_ptr< T, TempMDNodeDeleter > N)
Replace a temporary node with a uniqued one.
Definition: Metadata.h:856
Subclasses of this class are all able to terminate a basic block.
Definition: InstrTypes.h:35
void setDebugLoc(DebugLoc Loc)
setDebugLoc - Set the debug location information for this instruction.
Definition: Instruction.h:227
void replaceVTableHolder(DICompositeType *&T, DICompositeType *VTableHolder)
Replace the vtable holder in the given composite type.
Definition: DIBuilder.cpp:835
LLVM Basic Block Representation.
Definition: BasicBlock.h:65
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:41
static void checkGlobalVariableScope(DIScope *Context)
Definition: DIBuilder.cpp:557
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:998
DILocalVariable * createLocalVariable(unsigned Tag, DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, DIType *Ty, bool AlwaysPreserve=false, unsigned Flags=0, unsigned ArgNo=0)
Create a new descriptor for the specified local variable.
Definition: DIBuilder.cpp:593
void replaceSubprograms(DISubprogramArray N)
This is an important base class in LLVM.
Definition: Constant.h:41
This file contains the declarations for the subclasses of Constant, which represent the different fla...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition: SmallPtrSet.h:264
void replaceArrays(DICompositeType *&T, DINodeArray Elements, DINodeArray TParems=DINodeArray())
Replace arrays on a composite type.
Definition: DIBuilder.cpp:855
DIGlobalVariable * createGlobalVariable(DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DIType *Ty, bool isLocalToUnit, llvm::Constant *Val, MDNode *Decl=nullptr)
Create a new descriptor for the specified variable.
Definition: DIBuilder.cpp:566
DIImportedEntity * createImportedDeclaration(DIScope *Context, DINode *Decl, unsigned Line, StringRef Name="")
Create a descriptor for an imported function.
Definition: DIBuilder.cpp:196
void replaceEnumTypes(DICompositeTypeArray N)
Replace arrays.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
iterator begin() const
Definition: ArrayRef.h:122
DIBasicType * createUnspecifiedParameter()
Create unspecified parameter type for a subroutine type.
Definition: DIBuilder.cpp:502
DICompileUnit * createCompileUnit(unsigned Lang, StringRef File, StringRef Dir, StringRef Producer, bool isOptimized, StringRef Flags, unsigned RV, StringRef SplitName=StringRef(), DebugEmissionKind Kind=FullDebug, uint64_t DWOId=0, bool EmitDebugInfo=true)
A CompileUnit provides an anchor for all debugging information generated during this instance of comp...
Definition: DIBuilder.cpp:136
bool isObjectPointer() const
DIDerivedType * createReferenceType(unsigned Tag, DIType *RTy)
Create debugging information entry for a c++ style reference or rvalue reference type.
Definition: DIBuilder.cpp:258
Typed tracking ref.
DIBasicType * createBasicType(StringRef Name, uint64_t SizeInBits, uint64_t AlignInBits, unsigned Encoding)
Create debugging information entry for a basic type.
Definition: DIBuilder.cpp:225
An imported module (C++ using directive or similar).
Base class for scope-like contexts.
DICompositeType * createUnionType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, DINodeArray Elements, unsigned RunTimeLang=0, StringRef UniqueIdentifier="")
Create debugging information entry for an union.
Definition: DIBuilder.cpp:417
DITemplateValueParameter * createTemplateValueParameter(DIScope *Scope, StringRef Name, DIType *Ty, Constant *Val)
Create debugging information for template value parameter.
Definition: DIBuilder.cpp:358
TempDIType clone() const
void retainType(DIType *T)
Retain DIType* in a module even if it is not referenced through debug info anchors.
Definition: DIBuilder.cpp:497
static DIScope * getNonCompileUnitScope(DIScope *N)
If N is compile unit return NULL otherwise return N.
Definition: DIBuilder.cpp:130
unsigned getTag() const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
Definition: SmallPtrSet.h:299
Base class for types.
DITemplateValueParameter * createTemplateParameterPack(DIScope *Scope, StringRef Name, DIType *Ty, DINodeArray Val)
Create debugging information for a template parameter pack.
Definition: DIBuilder.cpp:374
static ValueAsMetadata * get(Value *V)
Definition: Metadata.cpp:251
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:861
Module.h This file contains the declarations for the Module class.
DIGlobalVariable * createTempGlobalVariableFwdDecl(DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DIType *Ty, bool isLocalToUnit, llvm::Constant *Val, MDNode *Decl=nullptr)
Identical to createGlobalVariable except that the resulting DbgNode is temporary and meant to be RAUW...
Definition: DIBuilder.cpp:580
void replaceVTableHolder(DITypeRef VTableHolder)
static Twine utohexstr(const uint64_t &Val)
Definition: Twine.h:386
DIExpression * createExpression(ArrayRef< uint64_t > Addr=None)
Create a new descriptor for the specified variable which has a complex address expression for its add...
Definition: DIBuilder.cpp:616
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
Definition: Constants.cpp:582
DICompositeType * createForwardDecl(unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line, unsigned RuntimeLang=0, uint64_t SizeInBits=0, uint64_t AlignInBits=0, StringRef UniqueIdentifier="")
Create a permanent forward-declared type.
Definition: DIBuilder.cpp:505
DWARF expression.
DIDerivedType * createStaticMemberType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, DIType *Ty, unsigned Flags, llvm::Constant *Val)
Create debugging information entry for a C++ static data member.
Definition: DIBuilder.cpp:308
DIImportedEntity * createImportedModule(DIScope *Context, DINamespace *NS, unsigned Line)
Create a descriptor for an imported module.
Definition: DIBuilder.cpp:176
DICompositeType * createVectorType(uint64_t Size, uint64_t AlignInBits, DIType *Ty, DINodeArray Subscripts)
Create debugging information entry for a vector type.
Definition: DIBuilder.cpp:464
DISubprogram * createMethod(DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit, bool isDefinition, unsigned Virtuality=0, unsigned VTableIndex=0, DIType *VTableHolder=nullptr, unsigned Flags=0, bool isOptimized=false, Function *Fn=nullptr, MDNode *TParam=nullptr)
Create a new descriptor for the specified C++ method.
Definition: DIBuilder.cpp:684
A (clang) module that has been imported by the compile unit.
DIObjCProperty * createObjCProperty(StringRef Name, DIFile *File, unsigned LineNumber, StringRef GetterName, StringRef SetterName, unsigned PropertyAttributes, DIType *Ty)
Create debugging information entry for Objective-C property.
Definition: DIBuilder.cpp:333
static TempMDTuple getTemporary(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1039
DITemplateValueParameter * createTemplateTemplateParameter(DIScope *Scope, StringRef Name, DIType *Ty, StringRef Val)
Create debugging information for a template template parameter.
Definition: DIBuilder.cpp:366
static TypedDINodeRef get(const T *N)
Create a reference.
Type array for a subprogram.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1030
void emplace_back(ArgTypes &&...Args)
Definition: SmallVector.h:652
DISubroutineType * createSubroutineType(DIFile *File, DITypeRefArray ParameterTypes, unsigned Flags=0)
Create subroutine type.
Definition: DIBuilder.cpp:432
DILexicalBlock * createLexicalBlock(DIScope *Scope, DIFile *File, unsigned Line, unsigned Col)
This creates a descriptor for a lexical block with the specified parent context.
Definition: DIBuilder.cpp:727
#define I(x, y, z)
Definition: MD5.cpp:54
#define N
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Definition: BasicBlock.cpp:124
static DITemplateValueParameter * createTemplateValueParameterHelper(LLVMContext &VMContext, unsigned Tag, DIScope *Context, StringRef Name, DIType *Ty, Metadata *MD)
Definition: DIBuilder.cpp:349
op_range operands() const
Definition: Metadata.h:934
DINamespace * createNameSpace(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo)
This creates new descriptor for a namespace with the specified parent scope.
Definition: DIBuilder.cpp:707
const ARM::ArchExtKind Kind
static ConstantAsMetadata * getConstantOrNull(Constant *C)
Definition: DIBuilder.cpp:302
DIModule * createModule(DIScope *Scope, StringRef Name, StringRef ConfigurationMacros, StringRef IncludePath, StringRef ISysRoot)
This creates new descriptor for a module with the specified parent scope.
Definition: DIBuilder.cpp:713
LLVM Value Representation.
Definition: Value.h:69
DICompositeType * createClassType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, DIType *DerivedFrom, DINodeArray Elements, DIType *VTableHolder=nullptr, MDNode *TemplateParms=nullptr, StringRef UniqueIdentifier="")
Create debugging information entry for a class.
Definition: DIBuilder.cpp:381
void replaceTemplateParams(DITemplateParameterArray TemplateParams)
DIDerivedType * createMemberType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, DIType *Ty)
Create debugging information entry for a member.
Definition: DIBuilder.cpp:290
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40
A single uniqued string.
Definition: Metadata.h:508
DIDerivedType * createQualifiedType(unsigned Tag, DIType *FromTy)
Create debugging information entry for a qualified type, e.g.
Definition: DIBuilder.cpp:233
bool isResolved() const
Check if node is fully resolved.
Definition: Metadata.h:815
DISubprogram * getSubprogram() const
Get the subprogram for this scope.
Root of the metadata hierarchy.
Definition: Metadata.h:45
DIDerivedType * createFriend(DIType *Ty, DIType *FriendTy)
Create debugging information entry for a 'friend'.
Definition: DIBuilder.cpp:273
void replaceImportedEntities(DIImportedEntityArray N)
DISubprogram * createFunction(DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit, bool isDefinition, unsigned ScopeLine, unsigned Flags=0, bool isOptimized=false, Function *Fn=nullptr, MDNode *TParam=nullptr, MDNode *Decl=nullptr)
Create a new descriptor for the specified subprogram.
Definition: DIBuilder.cpp:647
DIDerivedType * createPointerType(DIType *PointeeTy, uint64_t SizeInBits, uint64_t AlignInBits=0, StringRef Name="")
Create debugging information entry for a pointer.
Definition: DIBuilder.cpp:238
bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:110
Basic type, like 'int' or 'float'.
DIFile * createFile(StringRef Filename, StringRef Directory)
Create a file descriptor to hold debugging information for a file.
Definition: DIBuilder.cpp:207