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