LLVM  6.0.0svn
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 "LLVMContextImpl.h"
16 #include "llvm/ADT/STLExtras.h"
18 #include "llvm/IR/Constants.h"
19 #include "llvm/IR/DebugInfo.h"
20 #include "llvm/IR/IntrinsicInst.h"
21 #include "llvm/IR/Module.h"
22 #include "llvm/Support/Debug.h"
23 
24 using namespace llvm;
25 using namespace llvm::dwarf;
26 
27 DIBuilder::DIBuilder(Module &m, bool AllowUnresolvedNodes)
28  : M(m), VMContext(M.getContext()), CUNode(nullptr),
29  DeclareFn(nullptr), ValueFn(nullptr),
30  AllowUnresolvedNodes(AllowUnresolvedNodes) {}
31 
32 void DIBuilder::trackIfUnresolved(MDNode *N) {
33  if (!N)
34  return;
35  if (N->isResolved())
36  return;
37 
38  assert(AllowUnresolvedNodes && "Cannot handle unresolved nodes");
39  UnresolvedNodes.emplace_back(N);
40 }
41 
43  MDTuple *Temp = SP->getVariables().get();
44  if (!Temp || !Temp->isTemporary())
45  return;
46 
48 
49  auto PV = PreservedVariables.find(SP);
50  if (PV != PreservedVariables.end())
51  Variables.append(PV->second.begin(), PV->second.end());
52 
53  DINodeArray AV = getOrCreateArray(Variables);
54  TempMDTuple(Temp)->replaceAllUsesWith(AV.get());
55 }
56 
58  if (!CUNode) {
59  assert(!AllowUnresolvedNodes &&
60  "creating type nodes without a CU is not supported");
61  return;
62  }
63 
64  CUNode->replaceEnumTypes(MDTuple::get(VMContext, AllEnumTypes));
65 
66  SmallVector<Metadata *, 16> RetainValues;
67  // Declarations and definitions of the same type may be retained. Some
68  // clients RAUW these pairs, leaving duplicates in the retained types
69  // list. Use a set to remove the duplicates while we transform the
70  // TrackingVHs back into Values.
72  for (unsigned I = 0, E = AllRetainTypes.size(); I < E; I++)
73  if (RetainSet.insert(AllRetainTypes[I]).second)
74  RetainValues.push_back(AllRetainTypes[I]);
75 
76  if (!RetainValues.empty())
77  CUNode->replaceRetainedTypes(MDTuple::get(VMContext, RetainValues));
78 
79  DISubprogramArray SPs = MDTuple::get(VMContext, AllSubprograms);
80  for (auto *SP : SPs)
82  for (auto *N : RetainValues)
83  if (auto *SP = dyn_cast<DISubprogram>(N))
85 
86  if (!AllGVs.empty())
87  CUNode->replaceGlobalVariables(MDTuple::get(VMContext, AllGVs));
88 
89  if (!AllImportedModules.empty())
91  VMContext, SmallVector<Metadata *, 16>(AllImportedModules.begin(),
92  AllImportedModules.end())));
93 
94  for (const auto &I : AllMacrosPerParent) {
95  // DIMacroNode's with nullptr parent are DICompileUnit direct children.
96  if (!I.first) {
97  CUNode->replaceMacros(MDTuple::get(VMContext, I.second.getArrayRef()));
98  continue;
99  }
100  // Otherwise, it must be a temporary DIMacroFile that need to be resolved.
101  auto *TMF = cast<DIMacroFile>(I.first);
102  auto *MF = DIMacroFile::get(VMContext, dwarf::DW_MACINFO_start_file,
103  TMF->getLine(), TMF->getFile(),
104  getOrCreateMacroArray(I.second.getArrayRef()));
105  replaceTemporary(llvm::TempDIMacroNode(TMF), MF);
106  }
107 
108  // Now that all temp nodes have been replaced or deleted, resolve remaining
109  // cycles.
110  for (const auto &N : UnresolvedNodes)
111  if (N && !N->isResolved())
112  N->resolveCycles();
113  UnresolvedNodes.clear();
114 
115  // Can't handle unresolved nodes anymore.
116  AllowUnresolvedNodes = false;
117 }
118 
119 /// If N is compile unit return NULL otherwise return N.
121  if (!N || isa<DICompileUnit>(N))
122  return nullptr;
123  return cast<DIScope>(N);
124 }
125 
127  unsigned Lang, DIFile *File, StringRef Producer, bool isOptimized,
128  StringRef Flags, unsigned RunTimeVer, StringRef SplitName,
129  DICompileUnit::DebugEmissionKind Kind, uint64_t DWOId,
130  bool SplitDebugInlining, bool DebugInfoForProfiling) {
131 
132  assert(((Lang <= dwarf::DW_LANG_Fortran08 && Lang >= dwarf::DW_LANG_C89) ||
133  (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) &&
134  "Invalid Language tag");
135 
136  assert(!CUNode && "Can only make one compile unit per DIBuilder instance");
138  VMContext, Lang, File, Producer, isOptimized, Flags, RunTimeVer,
139  SplitName, Kind, nullptr, nullptr, nullptr, nullptr, nullptr, DWOId,
140  SplitDebugInlining, DebugInfoForProfiling);
141 
142  // Create a named metadata so that it is easier to find cu in a module.
143  NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
144  NMD->addOperand(CUNode);
145  trackIfUnresolved(CUNode);
146  return CUNode;
147 }
148 
149 static DIImportedEntity *
151  Metadata *NS, DIFile *File, unsigned Line, StringRef Name,
152  SmallVectorImpl<TrackingMDNodeRef> &AllImportedModules) {
153  if (Line)
154  assert(File && "Source location has line number but no file");
155  unsigned EntitiesCount = C.pImpl->DIImportedEntitys.size();
156  auto *M =
157  DIImportedEntity::get(C, Tag, Context, DINodeRef(NS), File, Line, Name);
158  if (EntitiesCount < C.pImpl->DIImportedEntitys.size())
159  // A new Imported Entity was just added to the context.
160  // Add it to the Imported Modules list.
161  AllImportedModules.emplace_back(M);
162  return M;
163 }
164 
166  DINamespace *NS, DIFile *File,
167  unsigned Line) {
168  return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
169  Context, NS, File, Line, StringRef(),
170  AllImportedModules);
171 }
172 
174  DIImportedEntity *NS,
175  DIFile *File, unsigned Line) {
176  return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
177  Context, NS, File, Line, StringRef(),
178  AllImportedModules);
179 }
180 
182  DIFile *File, unsigned Line) {
183  return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
184  Context, M, File, Line, StringRef(),
185  AllImportedModules);
186 }
187 
189  DINode *Decl,
190  DIFile *File,
191  unsigned Line,
192  StringRef Name) {
193  // Make sure to use the unique identifier based metadata reference for
194  // types that have one.
195  return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_declaration,
196  Context, Decl, File, Line, Name,
197  AllImportedModules);
198 }
199 
201  DIFile::ChecksumKind CSKind, StringRef Checksum) {
202  return DIFile::get(VMContext, Filename, Directory, CSKind, Checksum);
203 }
204 
205 DIMacro *DIBuilder::createMacro(DIMacroFile *Parent, unsigned LineNumber,
206  unsigned MacroType, StringRef Name,
207  StringRef Value) {
208  assert(!Name.empty() && "Unable to create macro without name");
209  assert((MacroType == dwarf::DW_MACINFO_undef ||
210  MacroType == dwarf::DW_MACINFO_define) &&
211  "Unexpected macro type");
212  auto *M = DIMacro::get(VMContext, MacroType, LineNumber, Name, Value);
213  AllMacrosPerParent[Parent].insert(M);
214  return M;
215 }
216 
218  unsigned LineNumber, DIFile *File) {
220  LineNumber, File, DIMacroNodeArray())
221  .release();
222  AllMacrosPerParent[Parent].insert(MF);
223  // Add the new temporary DIMacroFile to the macro per parent map as a parent.
224  // This is needed to assure DIMacroFile with no children to have an entry in
225  // the map. Otherwise, it will not be resolved in DIBuilder::finalize().
226  AllMacrosPerParent.insert({MF, {}});
227  return MF;
228 }
229 
231  assert(!Name.empty() && "Unable to create enumerator without name");
232  return DIEnumerator::get(VMContext, Val, Name);
233 }
234 
236  assert(!Name.empty() && "Unable to create type without name");
237  return DIBasicType::get(VMContext, dwarf::DW_TAG_unspecified_type, Name);
238 }
239 
241  return createUnspecifiedType("decltype(nullptr)");
242 }
243 
245  unsigned Encoding) {
246  assert(!Name.empty() && "Unable to create type without name");
247  return DIBasicType::get(VMContext, dwarf::DW_TAG_base_type, Name, SizeInBits,
248  0, Encoding);
249 }
250 
252  return DIDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr, FromTy, 0,
253  0, 0, None, DINode::FlagZero);
254 }
255 
257  DIType *PointeeTy,
258  uint64_t SizeInBits,
259  uint32_t AlignInBits,
260  Optional<unsigned> DWARFAddressSpace,
261  StringRef Name) {
262  // FIXME: Why is there a name here?
263  return DIDerivedType::get(VMContext, dwarf::DW_TAG_pointer_type, Name,
264  nullptr, 0, nullptr, PointeeTy, SizeInBits,
265  AlignInBits, 0, DWARFAddressSpace,
266  DINode::FlagZero);
267 }
268 
270  DIType *Base,
271  uint64_t SizeInBits,
272  uint32_t AlignInBits,
274  return DIDerivedType::get(VMContext, dwarf::DW_TAG_ptr_to_member_type, "",
275  nullptr, 0, nullptr, PointeeTy, SizeInBits,
276  AlignInBits, 0, None, Flags, Base);
277 }
278 
280  unsigned Tag, DIType *RTy,
281  uint64_t SizeInBits,
282  uint32_t AlignInBits,
283  Optional<unsigned> DWARFAddressSpace) {
284  assert(RTy && "Unable to create reference type");
285  return DIDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr, RTy,
286  SizeInBits, AlignInBits, 0, DWARFAddressSpace,
287  DINode::FlagZero);
288 }
289 
291  DIFile *File, unsigned LineNo,
292  DIScope *Context) {
293  return DIDerivedType::get(VMContext, dwarf::DW_TAG_typedef, Name, File,
294  LineNo, getNonCompileUnitScope(Context), Ty, 0, 0,
295  0, None, DINode::FlagZero);
296 }
297 
299  assert(Ty && "Invalid type!");
300  assert(FriendTy && "Invalid friend type!");
301  return DIDerivedType::get(VMContext, dwarf::DW_TAG_friend, "", nullptr, 0, Ty,
302  FriendTy, 0, 0, 0, None, DINode::FlagZero);
303 }
304 
306  uint64_t BaseOffset,
308  assert(Ty && "Unable to create inheritance");
309  return DIDerivedType::get(VMContext, dwarf::DW_TAG_inheritance, "", nullptr,
310  0, Ty, BaseTy, 0, 0, BaseOffset, None, Flags);
311 }
312 
314  DIFile *File, unsigned LineNumber,
315  uint64_t SizeInBits,
316  uint32_t AlignInBits,
317  uint64_t OffsetInBits,
319  return DIDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File,
320  LineNumber, getNonCompileUnitScope(Scope), Ty,
321  SizeInBits, AlignInBits, OffsetInBits, None, Flags);
322 }
323 
325  if (C)
326  return ConstantAsMetadata::get(C);
327  return nullptr;
328 }
329 
331  DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
332  uint64_t SizeInBits, uint64_t OffsetInBits, uint64_t StorageOffsetInBits,
334  Flags |= DINode::FlagBitField;
335  return DIDerivedType::get(
336  VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
337  getNonCompileUnitScope(Scope), Ty, SizeInBits, /* AlignInBits */ 0,
338  OffsetInBits, None, Flags,
340  StorageOffsetInBits)));
341 }
342 
345  unsigned LineNumber, DIType *Ty,
347  uint32_t AlignInBits) {
348  Flags |= DINode::FlagStaticMember;
349  return DIDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File,
350  LineNumber, getNonCompileUnitScope(Scope), Ty, 0,
351  AlignInBits, 0, None, Flags,
352  getConstantOrNull(Val));
353 }
354 
357  uint64_t SizeInBits, uint32_t AlignInBits,
358  uint64_t OffsetInBits, DINode::DIFlags Flags,
359  DIType *Ty, MDNode *PropertyNode) {
360  return DIDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File,
361  LineNumber, getNonCompileUnitScope(File), Ty,
362  SizeInBits, AlignInBits, OffsetInBits, None, Flags,
363  PropertyNode);
364 }
365 
368  StringRef GetterName, StringRef SetterName,
369  unsigned PropertyAttributes, DIType *Ty) {
370  return DIObjCProperty::get(VMContext, Name, File, LineNumber, GetterName,
371  SetterName, PropertyAttributes, Ty);
372 }
373 
376  DIType *Ty) {
377  assert((!Context || isa<DICompileUnit>(Context)) && "Expected compile unit");
378  return DITemplateTypeParameter::get(VMContext, Name, Ty);
379 }
380 
384  Metadata *MD) {
385  assert((!Context || isa<DICompileUnit>(Context)) && "Expected compile unit");
386  return DITemplateValueParameter::get(VMContext, Tag, Name, Ty, MD);
387 }
388 
391  DIType *Ty, Constant *Val) {
393  VMContext, dwarf::DW_TAG_template_value_parameter, Context, Name, Ty,
394  getConstantOrNull(Val));
395 }
396 
399  DIType *Ty, StringRef Val) {
401  VMContext, dwarf::DW_TAG_GNU_template_template_param, Context, Name, Ty,
402  MDString::get(VMContext, Val));
403 }
404 
407  DIType *Ty, DINodeArray Val) {
409  VMContext, dwarf::DW_TAG_GNU_template_parameter_pack, Context, Name, Ty,
410  Val.get());
411 }
412 
414  DIScope *Context, StringRef Name, DIFile *File, unsigned LineNumber,
415  uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
416  DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements,
417  DIType *VTableHolder, MDNode *TemplateParams, StringRef UniqueIdentifier) {
418  assert((!Context || isa<DIScope>(Context)) &&
419  "createClassType should be called with a valid Context");
420 
421  auto *R = DICompositeType::get(
422  VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber,
423  getNonCompileUnitScope(Context), DerivedFrom, SizeInBits, AlignInBits,
424  OffsetInBits, Flags, Elements, 0, VTableHolder,
425  cast_or_null<MDTuple>(TemplateParams), UniqueIdentifier);
426  trackIfUnresolved(R);
427  return R;
428 }
429 
431  DIScope *Context, StringRef Name, DIFile *File, unsigned LineNumber,
432  uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags,
433  DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang,
434  DIType *VTableHolder, StringRef UniqueIdentifier) {
435  auto *R = DICompositeType::get(
436  VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber,
437  getNonCompileUnitScope(Context), DerivedFrom, SizeInBits, AlignInBits, 0,
438  Flags, Elements, RunTimeLang, VTableHolder, nullptr, UniqueIdentifier);
439  trackIfUnresolved(R);
440  return R;
441 }
442 
444  DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
445  uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags,
446  DINodeArray Elements, unsigned RunTimeLang, StringRef UniqueIdentifier) {
447  auto *R = DICompositeType::get(
448  VMContext, dwarf::DW_TAG_union_type, Name, File, LineNumber,
449  getNonCompileUnitScope(Scope), nullptr, SizeInBits, AlignInBits, 0, Flags,
450  Elements, RunTimeLang, nullptr, nullptr, UniqueIdentifier);
451  trackIfUnresolved(R);
452  return R;
453 }
454 
457  unsigned CC) {
458  return DISubroutineType::get(VMContext, Flags, CC, ParameterTypes);
459 }
460 
462  DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
463  uint64_t SizeInBits, uint32_t AlignInBits, DINodeArray Elements,
464  DIType *UnderlyingType, StringRef UniqueIdentifier) {
465  auto *CTy = DICompositeType::get(
466  VMContext, dwarf::DW_TAG_enumeration_type, Name, File, LineNumber,
467  getNonCompileUnitScope(Scope), UnderlyingType, SizeInBits, AlignInBits, 0,
468  DINode::FlagZero, Elements, 0, nullptr, nullptr, UniqueIdentifier);
469  AllEnumTypes.push_back(CTy);
470  trackIfUnresolved(CTy);
471  return CTy;
472 }
473 
475  uint32_t AlignInBits, DIType *Ty,
476  DINodeArray Subscripts) {
477  auto *R = DICompositeType::get(VMContext, dwarf::DW_TAG_array_type, "",
478  nullptr, 0, nullptr, Ty, Size, AlignInBits, 0,
479  DINode::FlagZero, Subscripts, 0, nullptr);
480  trackIfUnresolved(R);
481  return R;
482 }
483 
485  uint32_t AlignInBits, DIType *Ty,
486  DINodeArray Subscripts) {
487  auto *R = DICompositeType::get(VMContext, dwarf::DW_TAG_array_type, "",
488  nullptr, 0, nullptr, Ty, Size, AlignInBits, 0,
489  DINode::FlagVector, Subscripts, 0, nullptr);
490  trackIfUnresolved(R);
491  return R;
492 }
493 
495  DINode::DIFlags FlagsToSet) {
496  auto NewTy = Ty->clone();
497  NewTy->setFlags(NewTy->getFlags() | FlagsToSet);
498  return MDNode::replaceWithUniqued(std::move(NewTy));
499 }
500 
502  // FIXME: Restrict this to the nodes where it's valid.
503  if (Ty->isArtificial())
504  return Ty;
505  return createTypeWithFlags(VMContext, Ty, DINode::FlagArtificial);
506 }
507 
509  // FIXME: Restrict this to the nodes where it's valid.
510  if (Ty->isObjectPointer())
511  return Ty;
512  DINode::DIFlags Flags = DINode::FlagObjectPointer | DINode::FlagArtificial;
513  return createTypeWithFlags(VMContext, Ty, Flags);
514 }
515 
517  assert(T && "Expected non-null type");
518  assert((isa<DIType>(T) || (isa<DISubprogram>(T) &&
519  cast<DISubprogram>(T)->isDefinition() == false)) &&
520  "Expected type or subprogram declaration");
521  AllRetainTypes.emplace_back(T);
522 }
523 
525 
528  DIFile *F, unsigned Line, unsigned RuntimeLang,
529  uint64_t SizeInBits, uint32_t AlignInBits,
530  StringRef UniqueIdentifier) {
531  // FIXME: Define in terms of createReplaceableForwardDecl() by calling
532  // replaceWithUniqued().
533  auto *RetTy = DICompositeType::get(
534  VMContext, Tag, Name, F, Line, getNonCompileUnitScope(Scope), nullptr,
535  SizeInBits, AlignInBits, 0, DINode::FlagFwdDecl, nullptr, RuntimeLang,
536  nullptr, nullptr, UniqueIdentifier);
537  trackIfUnresolved(RetTy);
538  return RetTy;
539 }
540 
542  unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line,
543  unsigned RuntimeLang, uint64_t SizeInBits, uint32_t AlignInBits,
544  DINode::DIFlags Flags, StringRef UniqueIdentifier) {
545  auto *RetTy =
547  VMContext, Tag, Name, F, Line, getNonCompileUnitScope(Scope), nullptr,
548  SizeInBits, AlignInBits, 0, Flags, nullptr, RuntimeLang, nullptr,
549  nullptr, UniqueIdentifier)
550  .release();
551  trackIfUnresolved(RetTy);
552  return RetTy;
553 }
554 
556  return MDTuple::get(VMContext, Elements);
557 }
558 
559 DIMacroNodeArray
561  return MDTuple::get(VMContext, Elements);
562 }
563 
566  for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
567  if (Elements[i] && isa<MDNode>(Elements[i]))
568  Elts.push_back(cast<DIType>(Elements[i]));
569  else
570  Elts.push_back(Elements[i]);
571  }
572  return DITypeRefArray(MDNode::get(VMContext, Elts));
573 }
574 
575 DISubrange *DIBuilder::getOrCreateSubrange(int64_t Lo, int64_t Count) {
576  return DISubrange::get(VMContext, Count, Lo);
577 }
578 
580 #ifndef NDEBUG
581  if (auto *CT =
582  dyn_cast_or_null<DICompositeType>(getNonCompileUnitScope(Context)))
583  assert(CT->getIdentifier().empty() &&
584  "Context of a global variable should not be a type with identifier");
585 #endif
586 }
587 
590  unsigned LineNumber, DIType *Ty, bool isLocalToUnit, DIExpression *Expr,
591  MDNode *Decl, uint32_t AlignInBits) {
592  checkGlobalVariableScope(Context);
593 
595  VMContext, cast_or_null<DIScope>(Context), Name, LinkageName, F,
596  LineNumber, Ty, isLocalToUnit, true, cast_or_null<DIDerivedType>(Decl),
597  AlignInBits);
598  auto *N = DIGlobalVariableExpression::get(VMContext, GV, Expr);
599  AllGVs.push_back(N);
600  return N;
601 }
602 
605  unsigned LineNumber, DIType *Ty, bool isLocalToUnit, MDNode *Decl,
606  uint32_t AlignInBits) {
607  checkGlobalVariableScope(Context);
608 
610  VMContext, cast_or_null<DIScope>(Context), Name, LinkageName, F,
611  LineNumber, Ty, isLocalToUnit, false,
612  cast_or_null<DIDerivedType>(Decl), AlignInBits)
613  .release();
614 }
615 
617  LLVMContext &VMContext,
618  DenseMap<MDNode *, SmallVector<TrackingMDNodeRef, 1>> &PreservedVariables,
619  DIScope *Scope, StringRef Name, unsigned ArgNo, DIFile *File,
620  unsigned LineNo, DIType *Ty, bool AlwaysPreserve, DINode::DIFlags Flags,
621  uint32_t AlignInBits) {
622  // FIXME: Why getNonCompileUnitScope()?
623  // FIXME: Why is "!Context" okay here?
624  // FIXME: Why doesn't this check for a subprogram or lexical block (AFAICT
625  // the only valid scopes)?
627 
628  auto *Node =
629  DILocalVariable::get(VMContext, cast_or_null<DILocalScope>(Context), Name,
630  File, LineNo, Ty, ArgNo, Flags, AlignInBits);
631  if (AlwaysPreserve) {
632  // The optimizer may remove local variables. If there is an interest
633  // to preserve variable info in such situation then stash it in a
634  // named mdnode.
635  DISubprogram *Fn = getDISubprogram(Scope);
636  assert(Fn && "Missing subprogram for local variable");
637  PreservedVariables[Fn].emplace_back(Node);
638  }
639  return Node;
640 }
641 
643  DIFile *File, unsigned LineNo,
644  DIType *Ty, bool AlwaysPreserve,
646  uint32_t AlignInBits) {
647  return createLocalVariable(VMContext, PreservedVariables, Scope, Name,
648  /* ArgNo */ 0, File, LineNo, Ty, AlwaysPreserve,
649  Flags, AlignInBits);
650 }
651 
653  DIScope *Scope, StringRef Name, unsigned ArgNo, DIFile *File,
654  unsigned LineNo, DIType *Ty, bool AlwaysPreserve, DINode::DIFlags Flags) {
655  assert(ArgNo && "Expected non-zero argument number for parameter");
656  return createLocalVariable(VMContext, PreservedVariables, Scope, Name, ArgNo,
657  File, LineNo, Ty, AlwaysPreserve, Flags,
658  /* AlignInBits */0);
659 }
660 
662  return DIExpression::get(VMContext, Addr);
663 }
664 
666  // TODO: Remove the callers of this signed version and delete.
667  SmallVector<uint64_t, 8> Addr(Signed.begin(), Signed.end());
668  return createExpression(Addr);
669 }
670 
672  unsigned SizeInBytes) {
673  uint64_t Addr[] = {dwarf::DW_OP_LLVM_fragment, OffsetInBytes, SizeInBytes};
674  return DIExpression::get(VMContext, Addr);
675 }
676 
677 template <class... Ts>
678 static DISubprogram *getSubprogram(bool IsDistinct, Ts &&... Args) {
679  if (IsDistinct)
680  return DISubprogram::getDistinct(std::forward<Ts>(Args)...);
681  return DISubprogram::get(std::forward<Ts>(Args)...);
682 }
683 
686  unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
687  bool isDefinition, unsigned ScopeLine, DINode::DIFlags Flags,
688  bool isOptimized, DITemplateParameterArray TParams, DISubprogram *Decl,
689  DITypeArray ThrownTypes) {
690  auto *Node = getSubprogram(
691  /* IsDistinct = */ isDefinition, VMContext,
692  getNonCompileUnitScope(Context), Name, LinkageName, File, LineNo, Ty,
693  isLocalToUnit, isDefinition, ScopeLine, nullptr, 0, 0, 0, Flags,
694  isOptimized, isDefinition ? CUNode : nullptr, TParams, Decl,
695  MDTuple::getTemporary(VMContext, None).release(), ThrownTypes);
696 
697  if (isDefinition)
698  AllSubprograms.push_back(Node);
699  trackIfUnresolved(Node);
700  return Node;
701 }
702 
705  unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
706  bool isDefinition, unsigned ScopeLine, DINode::DIFlags Flags,
707  bool isOptimized, DITemplateParameterArray TParams, DISubprogram *Decl,
708  DITypeArray ThrownTypes) {
710  VMContext, getNonCompileUnitScope(Context), Name, LinkageName,
711  File, LineNo, Ty, isLocalToUnit, isDefinition, ScopeLine, nullptr,
712  0, 0, 0, Flags, isOptimized, isDefinition ? CUNode : nullptr,
713  TParams, Decl, nullptr, ThrownTypes)
714  .release();
715 }
716 
719  unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
720  bool isDefinition, unsigned VK, unsigned VIndex, int ThisAdjustment,
721  DIType *VTableHolder, DINode::DIFlags Flags, bool isOptimized,
722  DITemplateParameterArray TParams, DITypeArray ThrownTypes) {
723  assert(getNonCompileUnitScope(Context) &&
724  "Methods should have both a Context and a context that isn't "
725  "the compile unit.");
726  // FIXME: Do we want to use different scope/lines?
727  auto *SP = getSubprogram(
728  /* IsDistinct = */ isDefinition, VMContext, cast<DIScope>(Context), Name,
729  LinkageName, F, LineNo, Ty, isLocalToUnit, isDefinition, LineNo,
730  VTableHolder, VK, VIndex, ThisAdjustment, Flags, isOptimized,
731  isDefinition ? CUNode : nullptr, TParams, nullptr, nullptr, ThrownTypes);
732 
733  if (isDefinition)
734  AllSubprograms.push_back(SP);
735  trackIfUnresolved(SP);
736  return SP;
737 }
738 
740  bool ExportSymbols) {
741 
742  // It is okay to *not* make anonymous top-level namespaces distinct, because
743  // all nodes that have an anonymous namespace as their parent scope are
744  // guaranteed to be unique and/or are linked to their containing
745  // DICompileUnit. This decision is an explicit tradeoff of link time versus
746  // memory usage versus code simplicity and may get revisited in the future.
747  return DINamespace::get(VMContext, getNonCompileUnitScope(Scope), Name,
748  ExportSymbols);
749 }
750 
752  StringRef ConfigurationMacros,
753  StringRef IncludePath,
754  StringRef ISysRoot) {
755  return DIModule::get(VMContext, getNonCompileUnitScope(Scope), Name,
756  ConfigurationMacros, IncludePath, ISysRoot);
757 }
758 
760  DIFile *File,
761  unsigned Discriminator) {
762  return DILexicalBlockFile::get(VMContext, Scope, File, Discriminator);
763 }
764 
766  unsigned Line, unsigned Col) {
767  // Make these distinct, to avoid merging two lexical blocks on the same
768  // file/line/column.
769  return DILexicalBlock::getDistinct(VMContext, getNonCompileUnitScope(Scope),
770  File, Line, Col);
771 }
772 
774  assert(V && "no value passed to dbg intrinsic");
775  return MetadataAsValue::get(VMContext, ValueAsMetadata::get(V));
776 }
777 
779  I->setDebugLoc(const_cast<DILocation *>(DL));
780  return I;
781 }
782 
784  DIExpression *Expr, const DILocation *DL,
785  Instruction *InsertBefore) {
786  assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.declare");
787  assert(DL && "Expected debug loc");
788  assert(DL->getScope()->getSubprogram() ==
789  VarInfo->getScope()->getSubprogram() &&
790  "Expected matching subprograms");
791  if (!DeclareFn)
792  DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
793 
794  trackIfUnresolved(VarInfo);
795  trackIfUnresolved(Expr);
796  Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, Storage),
797  MetadataAsValue::get(VMContext, VarInfo),
798  MetadataAsValue::get(VMContext, Expr)};
799  return withDebugLoc(CallInst::Create(DeclareFn, Args, "", InsertBefore), DL);
800 }
801 
803  DIExpression *Expr, const DILocation *DL,
804  BasicBlock *InsertAtEnd) {
805  assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.declare");
806  assert(DL && "Expected debug loc");
807  assert(DL->getScope()->getSubprogram() ==
808  VarInfo->getScope()->getSubprogram() &&
809  "Expected matching subprograms");
810  if (!DeclareFn)
811  DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
812 
813  trackIfUnresolved(VarInfo);
814  trackIfUnresolved(Expr);
815  Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, Storage),
816  MetadataAsValue::get(VMContext, VarInfo),
817  MetadataAsValue::get(VMContext, Expr)};
818 
819  // If this block already has a terminator then insert this intrinsic
820  // before the terminator.
821  if (TerminatorInst *T = InsertAtEnd->getTerminator())
822  return withDebugLoc(CallInst::Create(DeclareFn, Args, "", T), DL);
823  return withDebugLoc(CallInst::Create(DeclareFn, Args, "", InsertAtEnd), DL);
824 }
825 
827  DILocalVariable *VarInfo,
828  DIExpression *Expr,
829  const DILocation *DL,
830  Instruction *InsertBefore) {
831  assert(V && "no value passed to dbg.value");
832  assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.value");
833  assert(DL && "Expected debug loc");
834  assert(DL->getScope()->getSubprogram() ==
835  VarInfo->getScope()->getSubprogram() &&
836  "Expected matching subprograms");
837  if (!ValueFn)
838  ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
839 
840  trackIfUnresolved(VarInfo);
841  trackIfUnresolved(Expr);
842  Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, V),
843  ConstantInt::get(Type::getInt64Ty(VMContext), Offset),
844  MetadataAsValue::get(VMContext, VarInfo),
845  MetadataAsValue::get(VMContext, Expr)};
846  return withDebugLoc(CallInst::Create(ValueFn, Args, "", InsertBefore), DL);
847 }
848 
850  DILocalVariable *VarInfo,
851  DIExpression *Expr,
852  const DILocation *DL,
853  BasicBlock *InsertAtEnd) {
854  assert(V && "no value passed to dbg.value");
855  assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.value");
856  assert(DL && "Expected debug loc");
857  assert(DL->getScope()->getSubprogram() ==
858  VarInfo->getScope()->getSubprogram() &&
859  "Expected matching subprograms");
860  if (!ValueFn)
861  ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
862 
863  trackIfUnresolved(VarInfo);
864  trackIfUnresolved(Expr);
865  Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, V),
866  ConstantInt::get(Type::getInt64Ty(VMContext), Offset),
867  MetadataAsValue::get(VMContext, VarInfo),
868  MetadataAsValue::get(VMContext, Expr)};
869 
870  return withDebugLoc(CallInst::Create(ValueFn, Args, "", InsertAtEnd), DL);
871 }
872 
874  DICompositeType *VTableHolder) {
875  {
877  N->replaceVTableHolder(VTableHolder);
878  T = N.get();
879  }
880 
881  // If this didn't create a self-reference, just return.
882  if (T != VTableHolder)
883  return;
884 
885  // Look for unresolved operands. T will drop RAUW support, orphaning any
886  // cycles underneath it.
887  if (T->isResolved())
888  for (const MDOperand &O : T->operands())
889  if (auto *N = dyn_cast_or_null<MDNode>(O))
890  trackIfUnresolved(N);
891 }
892 
893 void DIBuilder::replaceArrays(DICompositeType *&T, DINodeArray Elements,
894  DINodeArray TParams) {
895  {
897  if (Elements)
898  N->replaceElements(Elements);
899  if (TParams)
900  N->replaceTemplateParams(DITemplateParameterArray(TParams));
901  T = N.get();
902  }
903 
904  // If T isn't resolved, there's no problem.
905  if (!T->isResolved())
906  return;
907 
908  // If T is resolved, it may be due to a self-reference cycle. Track the
909  // arrays explicitly if they're unresolved, or else the cycles will be
910  // orphaned.
911  if (Elements)
912  trackIfUnresolved(Elements.get());
913  if (TParams)
914  trackIfUnresolved(TParams.get());
915 }
void finalize()
Construct any deferred debug info descriptors.
Definition: DIBuilder.cpp:57
DISubprogram * createTempFunctionFwdDecl(DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit, bool isDefinition, unsigned ScopeLine, DINode::DIFlags Flags=DINode::FlagZero, bool isOptimized=false, DITemplateParameterArray TParams=nullptr, DISubprogram *Decl=nullptr, DITypeArray ThrownTypes=nullptr)
Identical to createFunction, except that the resulting DbgNode is meant to be RAUWed.
Definition: DIBuilder.cpp:703
bool isObjectPointer() const
uint64_t CallInst * C
DISubprogram * createFunction(DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit, bool isDefinition, unsigned ScopeLine, DINode::DIFlags Flags=DINode::FlagZero, bool isOptimized=false, DITemplateParameterArray TParams=nullptr, DISubprogram *Decl=nullptr, DITypeArray ThrownTypes=nullptr)
Create a new descriptor for the specified subprogram.
Definition: DIBuilder.cpp:684
Tracking metadata reference owned by Metadata.
Definition: Metadata.h:709
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata *> MDs)
Definition: Metadata.h:1131
DIDerivedType * createPointerType(DIType *PointeeTy, uint64_t SizeInBits, uint32_t AlignInBits=0, Optional< unsigned > DWARFAddressSpace=None, StringRef Name="")
Create debugging information entry for a pointer.
Definition: DIBuilder.cpp:256
static Value * getDbgIntrinsicValueImpl(LLVMContext &VMContext, Value *V)
Definition: DIBuilder.cpp:773
LLVMContext & Context
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
DIGlobalVariableExpression * createGlobalVariableExpression(DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DIType *Ty, bool isLocalToUnit, DIExpression *Expr=nullptr, MDNode *Decl=nullptr, uint32_t AlignInBits=0)
Create a new descriptor for the specified variable.
Definition: DIBuilder.cpp:588
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:63
iterator begin() const
Definition: ArrayRef.h:137
void replaceTemplateParams(DITemplateParameterArray TemplateParams)
DINamespace * createNameSpace(DIScope *Scope, StringRef Name, bool ExportSymbols)
This creates new descriptor for a namespace with the specified parent scope.
Definition: DIBuilder.cpp:739
static MDString * get(LLVMContext &Context, StringRef Str)
Definition: Metadata.cpp:446
DIDerivedType * createBitFieldMemberType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, uint64_t SizeInBits, uint64_t OffsetInBits, uint64_t StorageOffsetInBits, DINode::DIFlags Flags, DIType *Ty)
Create debugging information entry for a bit field member.
Definition: DIBuilder.cpp:330
DICompositeType * createUnionType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags, DINodeArray Elements, unsigned RunTimeLang=0, StringRef UniqueIdentifier="")
Create debugging information entry for an union.
Definition: DIBuilder.cpp:443
void addOperand(MDNode *M)
Definition: Metadata.cpp:1079
DICompositeType * createArrayType(uint64_t Size, uint32_t AlignInBits, DIType *Ty, DINodeArray Subscripts)
Create debugging information entry for an array.
Definition: DIBuilder.cpp:474
DICompositeType * createReplaceableCompositeType(unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line, unsigned RuntimeLang=0, uint64_t SizeInBits=0, uint32_t AlignInBits=0, DINode::DIFlags Flags=DINode::FlagFwdDecl, StringRef UniqueIdentifier="")
Create a temporary forward-declared type.
Definition: DIBuilder.cpp:541
NamedMDNode * getOrInsertNamedMetadata(StringRef Name)
Return the named MDNode in the module with the specified name.
Definition: Module.cpp:251
DICompositeType * createClassType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements, DIType *VTableHolder=nullptr, MDNode *TemplateParms=nullptr, StringRef UniqueIdentifier="")
Create debugging information entry for a class.
Definition: DIBuilder.cpp:413
DIGlobalVariable * createTempGlobalVariableFwdDecl(DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DIType *Ty, bool isLocalToUnit, MDNode *Decl=nullptr, uint32_t AlignInBits=0)
Identical to createGlobalVariable except that the resulting DbgNode is temporary and meant to be RAUW...
Definition: DIBuilder.cpp:603
DISubrange * getOrCreateSubrange(int64_t Lo, int64_t Count)
Create a descriptor for a value range.
Definition: DIBuilder.cpp:575
Metadata node.
Definition: Metadata.h:862
static CallInst * Create(Value *Func, ArrayRef< Value *> Args, ArrayRef< OperandBundleDef > Bundles=None, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
DIMacro * createMacro(DIMacroFile *Parent, unsigned Line, unsigned MacroType, StringRef Name, StringRef Value=StringRef())
Create debugging information entry for a macro.
Definition: DIBuilder.cpp:205
static IntegerType * getInt64Ty(LLVMContext &C)
Definition: Type.cpp:177
void replaceArrays(DICompositeType *&T, DINodeArray Elements, DINodeArray TParams=DINodeArray())
Replace arrays on a composite type.
Definition: DIBuilder.cpp:893
DICompositeType * createForwardDecl(unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line, unsigned RuntimeLang=0, uint64_t SizeInBits=0, uint32_t AlignInBits=0, StringRef UniqueIdentifier="")
Create a permanent forward-declared type.
Definition: DIBuilder.cpp:527
DIDerivedType * createStaticMemberType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, DIType *Ty, DINode::DIFlags Flags, Constant *Val, uint32_t AlignInBits=0)
Create debugging information entry for a C++ static data member.
Definition: DIBuilder.cpp:344
TempDIType clone() const
DISubprogram * createMethod(DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit, bool isDefinition, unsigned Virtuality=0, unsigned VTableIndex=0, int ThisAdjustment=0, DIType *VTableHolder=nullptr, DINode::DIFlags Flags=DINode::FlagZero, bool isOptimized=false, DITemplateParameterArray TParams=nullptr, DITypeArray ThrownTypes=nullptr)
Create a new descriptor for the specified C++ method.
Definition: DIBuilder.cpp:717
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:849
DIType * createObjectPointerType(DIType *Ty)
Create a new DIType* with the "object pointer" flag set.
Definition: DIBuilder.cpp:508
DIImportedEntity * createImportedModule(DIScope *Context, DINamespace *NS, DIFile *File, unsigned Line)
Create a descriptor for an imported module.
Definition: DIBuilder.cpp:165
DIMacroNodeArray getOrCreateMacroArray(ArrayRef< Metadata *> Elements)
Get a DIMacroNodeArray, create one if required.
Definition: DIBuilder.cpp:560
DIDerivedType * createMemberType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, DINode::DIFlags Flags, DIType *Ty)
Create debugging information entry for a member.
Definition: DIBuilder.cpp:313
Tuple of metadata.
Definition: Metadata.h:1104
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:759
static DIImportedEntity * createImportedModule(LLVMContext &C, dwarf::Tag Tag, DIScope *Context, Metadata *NS, DIFile *File, unsigned Line, StringRef Name, SmallVectorImpl< TrackingMDNodeRef > &AllImportedModules)
Definition: DIBuilder.cpp:150
A tuple of MDNodes.
Definition: Metadata.h:1316
DITemplateTypeParameter * createTemplateTypeParameter(DIScope *Scope, StringRef Name, DIType *Ty)
Create debugging information for template type parameter.
Definition: DIBuilder.cpp:375
bool isResolved() const
Check if node is fully resolved.
Definition: Metadata.h:938
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:802
DIDerivedType * createTypedef(DIType *Ty, StringRef Name, DIFile *File, unsigned LineNo, DIScope *Context)
Create debugging information entry for a typedef.
Definition: DIBuilder.cpp:290
DIBasicType * createUnspecifiedType(StringRef Name)
Create a DWARF unspecified type.
Definition: DIBuilder.cpp:235
DIMacroFile * createTempMacroFile(DIMacroFile *Parent, unsigned Line, DIFile *File)
Create debugging information temporary entry for a macro file.
Definition: DIBuilder.cpp:217
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
DISubroutineType * createSubroutineType(DITypeRefArray ParameterTypes, DINode::DIFlags Flags=DINode::FlagZero, unsigned CC=0)
Create subroutine type.
Definition: DIBuilder.cpp:455
static TempMDTuple getTemporary(LLVMContext &Context, ArrayRef< Metadata *> MDs)
Definition: Metadata.h:1176
Only used in LLVM metadata.
Definition: Dwarf.h:123
DISubprogram * getDISubprogram(const MDNode *Scope)
Find subprogram that is enclosing this scope.
Definition: DebugInfo.cpp:41
void resolveCycles()
Resolve cycles.
Definition: Metadata.cpp:613
DIEnumerator * createEnumerator(StringRef Name, int64_t Val)
Create a single enumerator value.
Definition: DIBuilder.cpp:230
Subprogram description.
#define F(x, y, z)
Definition: MD5.cpp:55
op_range operands() const
Definition: Metadata.h:1065
Enumeration value.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:133
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
Debug location.
static ConstantAsMetadata * get(Constant *C)
Definition: Metadata.h:408
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:975
DIBasicType * createNullPtrType()
Create C++11 nullptr type.
Definition: DIBuilder.cpp:240
DICompositeType * createEnumerationType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, DINodeArray Elements, DIType *UnderlyingType, StringRef UniqueIdentifier="")
Create debugging information entry for an enumeration.
Definition: DIBuilder.cpp:461
const char * Name
static Instruction * withDebugLoc(Instruction *I, const DILocation *DL)
Definition: DIBuilder.cpp:778
DITypeRefArray getOrCreateTypeArray(ArrayRef< Metadata *> Elements)
Get a DITypeRefArray, create one if required.
Definition: DIBuilder.cpp:564
static MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
Definition: Metadata.cpp:106
void replaceVTableHolder(DITypeRef VTableHolder)
DICompositeType * createStructType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang=0, DIType *VTableHolder=nullptr, StringRef UniqueIdentifier="")
Create debugging information entry for a struct.
Definition: DIBuilder.cpp:430
DINodeArray getOrCreateArray(ArrayRef< Metadata *> Elements)
Get a DINodeArray, create one if required.
Definition: DIBuilder.cpp:555
static TempMDTuple getTemporary(LLVMContext &Context, ArrayRef< Metadata *> MDs)
Return a temporary node.
Definition: Metadata.h:1151
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata *> MDs)
Definition: Metadata.h:1164
DIType * createArtificialType(DIType *Ty)
Create a new DIType* with "artificial" flag set.
Definition: DIBuilder.cpp:501
DIFile * createFile(StringRef Filename, StringRef Directory, DIFile::ChecksumKind CSKind=DIFile::CSK_None, StringRef Checksum=StringRef())
Create a file descriptor to hold debugging information for a file.
Definition: DIBuilder.cpp:200
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:979
DIDerivedType * createReferenceType(unsigned Tag, DIType *RTy, uint64_t SizeInBits=0, uint32_t AlignInBits=0, Optional< unsigned > DWARFAddressSpace=None)
Create debugging information entry for a c++ style reference or rvalue reference type.
Definition: DIBuilder.cpp:279
TypedDINodeRef< DINode > DINodeRef
Subclasses of this class are all able to terminate a basic block.
Definition: InstrTypes.h:54
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
Definition: Instruction.h:277
void replaceVTableHolder(DICompositeType *&T, DICompositeType *VTableHolder)
Replace the vtable holder in the given composite type.
Definition: DIBuilder.cpp:873
LLVM Basic Block Representation.
Definition: BasicBlock.h:59
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
static void checkGlobalVariableScope(DIScope *Context)
Definition: DIBuilder.cpp:579
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:149
This is an important base class in LLVM.
Definition: Constant.h:42
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata *> MDs)
Definition: Metadata.h:1172
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
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:372
A pair of DIGlobalVariable and DIExpression.
void replaceEnumTypes(DICompositeTypeArray N)
Replace arrays.
DIBasicType * createUnspecifiedParameter()
Create unspecified parameter type for a subroutine type.
Definition: DIBuilder.cpp:524
DIBuilder(Module &M, bool AllowUnresolved=true)
Construct a builder for a module.
Definition: DIBuilder.cpp:27
static DILocalVariable * createLocalVariable(LLVMContext &VMContext, DenseMap< MDNode *, SmallVector< TrackingMDNodeRef, 1 >> &PreservedVariables, DIScope *Scope, StringRef Name, unsigned ArgNo, DIFile *File, unsigned LineNo, DIType *Ty, bool AlwaysPreserve, DINode::DIFlags Flags, uint32_t AlignInBits)
Definition: DIBuilder.cpp:616
DIExpression * createFragmentExpression(unsigned OffsetInBits, unsigned SizeInBits)
Create a descriptor to describe one part of aggregate variable that is fragmented across multiple Val...
Definition: DIBuilder.cpp:671
static DISubprogram * getSubprogram(bool IsDistinct, Ts &&... Args)
Definition: DIBuilder.cpp:678
Typed tracking ref.
LLVMContextImpl *const pImpl
Definition: LLVMContext.h:70
void retainType(DIScope *T)
Retain DIScope* in a module even if it is not referenced through debug info anchors.
Definition: DIBuilder.cpp:516
An imported module (C++ using directive or similar).
Base class for scope-like contexts.
DITemplateValueParameter * createTemplateValueParameter(DIScope *Scope, StringRef Name, DIType *Ty, Constant *Val)
Create debugging information for template value parameter.
Definition: DIBuilder.cpp:390
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition: Type.cpp:240
static DIScope * getNonCompileUnitScope(DIScope *N)
If N is compile unit return NULL otherwise return N.
Definition: DIBuilder.cpp:120
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
Definition: SmallPtrSet.h:423
Base class for types.
#define E
Definition: LargeTest.cpp:27
DITemplateValueParameter * createTemplateParameterPack(DIScope *Scope, StringRef Name, DIType *Ty, DINodeArray Val)
Create debugging information for a template parameter pack.
Definition: DIBuilder.cpp:406
static ValueAsMetadata * get(Value *V)
Definition: Metadata.cpp:341
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:864
Module.h This file contains the declarations for the Module class.
iterator end() const
Definition: ArrayRef.h:138
const size_t N
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:661
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:560
DWARF expression.
DISubprogram * getSubprogram() const
Get the subprogram for this scope.
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:367
DIBasicType * createBasicType(StringRef Name, uint64_t SizeInBits, unsigned Encoding)
Create debugging information entry for a basic type.
Definition: DIBuilder.cpp:244
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
Definition: SmallVector.h:398
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
DITemplateValueParameter * createTemplateTemplateParameter(DIScope *Scope, StringRef Name, DIType *Ty, StringRef Val)
Create debugging information for a template template parameter.
Definition: DIBuilder.cpp:398
Type array for a subprogram.
static std::vector< std::string > Flags
Definition: FlagsTest.cpp:8
NodeTy * replaceTemporary(TempMDNode &&N, NodeTy *Replacement)
Replace a temporary node.
Definition: DIBuilder.h:780
DICompositeType * createVectorType(uint64_t Size, uint32_t AlignInBits, DIType *Ty, DINodeArray Subscripts)
Create debugging information entry for a vector type.
Definition: DIBuilder.cpp:484
DIFlags
Debug info flags.
bool isArtificial() const
DIDerivedType * createObjCIVar(StringRef Name, DIFile *File, unsigned LineNo, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, DINode::DIFlags Flags, DIType *Ty, MDNode *PropertyNode)
Create debugging information entry for Objective-C instance variable.
Definition: DIBuilder.cpp:356
void emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:656
LLVM_NODISCARD bool empty() const
Definition: SmallVector.h:61
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:765
DILocalVariable * createAutoVariable(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, DIType *Ty, bool AlwaysPreserve=false, DINode::DIFlags Flags=DINode::FlagZero, uint32_t AlignInBits=0)
Create a new descriptor for an auto variable.
Definition: DIBuilder.cpp:642
#define I(x, y, z)
Definition: MD5.cpp:58
static DITemplateValueParameter * createTemplateValueParameterHelper(LLVMContext &VMContext, unsigned Tag, DIScope *Context, StringRef Name, DIType *Ty, Metadata *MD)
Definition: DIBuilder.cpp:382
void finalizeSubprogram(DISubprogram *SP)
Finalize a specific subprogram - no new variables may be added to this subprogram afterwards...
Definition: DIBuilder.cpp:42
DIDerivedType * createInheritance(DIType *Ty, DIType *BaseTy, uint64_t BaseOffset, DINode::DIFlags Flags)
Create debugging information entry to establish inheritance relationship between two types...
Definition: DIBuilder.cpp:305
const unsigned Kind
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
DIImportedEntity * createImportedDeclaration(DIScope *Context, DINode *Decl, DIFile *File, unsigned Line, StringRef Name="")
Create a descriptor for an imported function.
Definition: DIBuilder.cpp:188
static ConstantAsMetadata * getConstantOrNull(Constant *C)
Definition: DIBuilder.cpp:324
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:751
LLVM Value Representation.
Definition: Value.h:73
void replaceGlobalVariables(DIGlobalVariableExpressionArray N)
bool isTemporary() const
Definition: Metadata.h:942
void replaceMacros(DIMacroNodeArray N)
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
DIDerivedType * createQualifiedType(unsigned Tag, DIType *FromTy)
Create debugging information entry for a qualified type, e.g.
Definition: DIBuilder.cpp:251
const TerminatorInst * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Definition: BasicBlock.cpp:120
DICompileUnit * createCompileUnit(unsigned Lang, DIFile *File, StringRef Producer, bool isOptimized, StringRef Flags, unsigned RV, StringRef SplitName=StringRef(), DICompileUnit::DebugEmissionKind Kind=DICompileUnit::DebugEmissionKind::FullDebug, uint64_t DWOId=0, bool SplitDebugInlining=true, bool DebugInfoForProfiling=false)
A CompileUnit provides an anchor for all debugging information generated during this instance of comp...
Definition: DIBuilder.cpp:126
DILocalScope * getScope() const
Get the local scope for this variable.
DILocalVariable * createParameterVariable(DIScope *Scope, StringRef Name, unsigned ArgNo, DIFile *File, unsigned LineNo, DIType *Ty, bool AlwaysPreserve=false, DINode::DIFlags Flags=DINode::FlagZero)
Create a new descriptor for a parameter variable.
Definition: DIBuilder.cpp:652
void replaceElements(DINodeArray Elements)
Replace operands.
DIDerivedType * createMemberPointerType(DIType *PointeeTy, DIType *Class, uint64_t SizeInBits, uint32_t AlignInBits=0, DINode::DIFlags Flags=DINode::FlagZero)
Create debugging information entry for a pointer to member.
Definition: DIBuilder.cpp:269
static DIType * createTypeWithFlags(LLVMContext &Context, DIType *Ty, DINode::DIFlags FlagsToSet)
Definition: DIBuilder.cpp:494
Root of the metadata hierarchy.
Definition: Metadata.h:58
DIDerivedType * createFriend(DIType *Ty, DIType *FriendTy)
Create debugging information entry for a &#39;friend&#39;.
Definition: DIBuilder.cpp:298
void replaceImportedEntities(DIImportedEntityArray N)
Basic type, like &#39;int&#39; or &#39;float&#39;.