LLVM  16.0.0git
DIBuilder.cpp
Go to the documentation of this file.
1 //===--- DIBuilder.cpp - Debug Information Builder ------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the DIBuilder.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "llvm/IR/DIBuilder.h"
14 #include "LLVMContextImpl.h"
15 #include "llvm/ADT/Optional.h"
17 #include "llvm/IR/Constants.h"
18 #include "llvm/IR/DebugInfo.h"
19 #include "llvm/IR/IRBuilder.h"
20 #include "llvm/IR/Module.h"
22 
23 using namespace llvm;
24 using namespace llvm::dwarf;
25 
26 static cl::opt<bool>
27  UseDbgAddr("use-dbg-addr",
28  llvm::cl::desc("Use llvm.dbg.addr for all local variables"),
29  cl::init(false), cl::Hidden);
30 
31 DIBuilder::DIBuilder(Module &m, bool AllowUnresolvedNodes, DICompileUnit *CU)
32  : M(m), VMContext(M.getContext()), CUNode(CU), DeclareFn(nullptr),
33  ValueFn(nullptr), LabelFn(nullptr), AddrFn(nullptr), AssignFn(nullptr),
34  AllowUnresolvedNodes(AllowUnresolvedNodes) {
35  if (CUNode) {
36  if (const auto &ETs = CUNode->getEnumTypes())
37  AllEnumTypes.assign(ETs.begin(), ETs.end());
38  if (const auto &RTs = CUNode->getRetainedTypes())
39  AllRetainTypes.assign(RTs.begin(), RTs.end());
40  if (const auto &GVs = CUNode->getGlobalVariables())
41  AllGVs.assign(GVs.begin(), GVs.end());
42  if (const auto &IMs = CUNode->getImportedEntities())
43  AllImportedModules.assign(IMs.begin(), IMs.end());
44  if (const auto &MNs = CUNode->getMacros())
45  AllMacrosPerParent.insert({nullptr, {MNs.begin(), MNs.end()}});
46  }
47 }
48 
49 void DIBuilder::trackIfUnresolved(MDNode *N) {
50  if (!N)
51  return;
52  if (N->isResolved())
53  return;
54 
55  assert(AllowUnresolvedNodes && "Cannot handle unresolved nodes");
56  UnresolvedNodes.emplace_back(N);
57 }
58 
60  MDTuple *Temp = SP->getRetainedNodes().get();
61  if (!Temp || !Temp->isTemporary())
62  return;
63 
64  SmallVector<Metadata *, 16> RetainedNodes;
65 
66  auto PV = PreservedVariables.find(SP);
67  if (PV != PreservedVariables.end())
68  RetainedNodes.append(PV->second.begin(), PV->second.end());
69 
70  auto PL = PreservedLabels.find(SP);
71  if (PL != PreservedLabels.end())
72  RetainedNodes.append(PL->second.begin(), PL->second.end());
73 
74  DINodeArray Node = getOrCreateArray(RetainedNodes);
75 
76  TempMDTuple(Temp)->replaceAllUsesWith(Node.get());
77 }
78 
80  if (!CUNode) {
81  assert(!AllowUnresolvedNodes &&
82  "creating type nodes without a CU is not supported");
83  return;
84  }
85 
86  if (!AllEnumTypes.empty())
88  VMContext, SmallVector<Metadata *, 16>(AllEnumTypes.begin(),
89  AllEnumTypes.end())));
90 
91  SmallVector<Metadata *, 16> RetainValues;
92  // Declarations and definitions of the same type may be retained. Some
93  // clients RAUW these pairs, leaving duplicates in the retained types
94  // list. Use a set to remove the duplicates while we transform the
95  // TrackingVHs back into Values.
97  for (unsigned I = 0, E = AllRetainTypes.size(); I < E; I++)
98  if (RetainSet.insert(AllRetainTypes[I]).second)
99  RetainValues.push_back(AllRetainTypes[I]);
100 
101  if (!RetainValues.empty())
102  CUNode->replaceRetainedTypes(MDTuple::get(VMContext, RetainValues));
103 
104  DISubprogramArray SPs = MDTuple::get(VMContext, AllSubprograms);
105  for (auto *SP : SPs)
106  finalizeSubprogram(SP);
107  for (auto *N : RetainValues)
108  if (auto *SP = dyn_cast<DISubprogram>(N))
109  finalizeSubprogram(SP);
110 
111  if (!AllGVs.empty())
112  CUNode->replaceGlobalVariables(MDTuple::get(VMContext, AllGVs));
113 
114  if (!AllImportedModules.empty())
116  VMContext, SmallVector<Metadata *, 16>(AllImportedModules.begin(),
117  AllImportedModules.end())));
118 
119  for (const auto &I : AllMacrosPerParent) {
120  // DIMacroNode's with nullptr parent are DICompileUnit direct children.
121  if (!I.first) {
122  CUNode->replaceMacros(MDTuple::get(VMContext, I.second.getArrayRef()));
123  continue;
124  }
125  // Otherwise, it must be a temporary DIMacroFile that need to be resolved.
126  auto *TMF = cast<DIMacroFile>(I.first);
127  auto *MF = DIMacroFile::get(VMContext, dwarf::DW_MACINFO_start_file,
128  TMF->getLine(), TMF->getFile(),
129  getOrCreateMacroArray(I.second.getArrayRef()));
130  replaceTemporary(llvm::TempDIMacroNode(TMF), MF);
131  }
132 
133  // Now that all temp nodes have been replaced or deleted, resolve remaining
134  // cycles.
135  for (const auto &N : UnresolvedNodes)
136  if (N && !N->isResolved())
137  N->resolveCycles();
138  UnresolvedNodes.clear();
139 
140  // Can't handle unresolved nodes anymore.
141  AllowUnresolvedNodes = false;
142 }
143 
144 /// If N is compile unit return NULL otherwise return N.
146  if (!N || isa<DICompileUnit>(N))
147  return nullptr;
148  return cast<DIScope>(N);
149 }
150 
152  unsigned Lang, DIFile *File, StringRef Producer, bool isOptimized,
153  StringRef Flags, unsigned RunTimeVer, StringRef SplitName,
155  bool SplitDebugInlining, bool DebugInfoForProfiling,
156  DICompileUnit::DebugNameTableKind NameTableKind, bool RangesBaseAddress,
157  StringRef SysRoot, StringRef SDK) {
158 
159  assert(((Lang <= dwarf::DW_LANG_Fortran08 && Lang >= dwarf::DW_LANG_C89) ||
160  (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) &&
161  "Invalid Language tag");
162 
163  assert(!CUNode && "Can only make one compile unit per DIBuilder instance");
165  VMContext, Lang, File, Producer, isOptimized, Flags, RunTimeVer,
166  SplitName, Kind, nullptr, nullptr, nullptr, nullptr, nullptr, DWOId,
167  SplitDebugInlining, DebugInfoForProfiling, NameTableKind,
168  RangesBaseAddress, SysRoot, SDK);
169 
170  // Create a named metadata so that it is easier to find cu in a module.
171  NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
172  NMD->addOperand(CUNode);
173  trackIfUnresolved(CUNode);
174  return CUNode;
175 }
176 
177 static DIImportedEntity *
179  Metadata *NS, DIFile *File, unsigned Line, StringRef Name,
180  DINodeArray Elements,
181  SmallVectorImpl<TrackingMDNodeRef> &AllImportedModules) {
182  if (Line)
183  assert(File && "Source location has line number but no file");
184  unsigned EntitiesCount = C.pImpl->DIImportedEntitys.size();
185  auto *M = DIImportedEntity::get(C, Tag, Context, cast_or_null<DINode>(NS),
186  File, Line, Name, Elements);
187  if (EntitiesCount < C.pImpl->DIImportedEntitys.size())
188  // A new Imported Entity was just added to the context.
189  // Add it to the Imported Modules list.
190  AllImportedModules.emplace_back(M);
191  return M;
192 }
193 
195  DINamespace *NS, DIFile *File,
196  unsigned Line,
197  DINodeArray Elements) {
198  return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
199  Context, NS, File, Line, StringRef(), Elements,
200  AllImportedModules);
201 }
202 
204  DIImportedEntity *NS,
205  DIFile *File, unsigned Line,
206  DINodeArray Elements) {
207  return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
208  Context, NS, File, Line, StringRef(), Elements,
209  AllImportedModules);
210 }
211 
213  DIFile *File, unsigned Line,
214  DINodeArray Elements) {
215  return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
216  Context, M, File, Line, StringRef(), Elements,
217  AllImportedModules);
218 }
219 
222  DIFile *File, unsigned Line,
223  StringRef Name, DINodeArray Elements) {
224  // Make sure to use the unique identifier based metadata reference for
225  // types that have one.
226  return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_declaration,
227  Context, Decl, File, Line, Name, Elements,
228  AllImportedModules);
229 }
230 
234  return DIFile::get(VMContext, Filename, Directory, CS, Source);
235 }
236 
237 DIMacro *DIBuilder::createMacro(DIMacroFile *Parent, unsigned LineNumber,
238  unsigned MacroType, StringRef Name,
239  StringRef Value) {
240  assert(!Name.empty() && "Unable to create macro without name");
241  assert((MacroType == dwarf::DW_MACINFO_undef ||
242  MacroType == dwarf::DW_MACINFO_define) &&
243  "Unexpected macro type");
244  auto *M = DIMacro::get(VMContext, MacroType, LineNumber, Name, Value);
245  AllMacrosPerParent[Parent].insert(M);
246  return M;
247 }
248 
250  unsigned LineNumber, DIFile *File) {
252  LineNumber, File, DIMacroNodeArray())
253  .release();
254  AllMacrosPerParent[Parent].insert(MF);
255  // Add the new temporary DIMacroFile to the macro per parent map as a parent.
256  // This is needed to assure DIMacroFile with no children to have an entry in
257  // the map. Otherwise, it will not be resolved in DIBuilder::finalize().
258  AllMacrosPerParent.insert({MF, {}});
259  return MF;
260 }
261 
263  bool IsUnsigned) {
264  assert(!Name.empty() && "Unable to create enumerator without name");
265  return DIEnumerator::get(VMContext, APInt(64, Val, !IsUnsigned), IsUnsigned,
266  Name);
267 }
268 
270  assert(!Name.empty() && "Unable to create enumerator without name");
271  return DIEnumerator::get(VMContext, APInt(Value), Value.isUnsigned(), Name);
272 }
273 
275  assert(!Name.empty() && "Unable to create type without name");
276  return DIBasicType::get(VMContext, dwarf::DW_TAG_unspecified_type, Name);
277 }
278 
280  return createUnspecifiedType("decltype(nullptr)");
281 }
282 
284  unsigned Encoding,
285  DINode::DIFlags Flags) {
286  assert(!Name.empty() && "Unable to create type without name");
287  return DIBasicType::get(VMContext, dwarf::DW_TAG_base_type, Name, SizeInBits,
288  0, Encoding, Flags);
289 }
290 
292  assert(!Name.empty() && "Unable to create type without name");
293  return DIStringType::get(VMContext, dwarf::DW_TAG_string_type, Name,
294  SizeInBits, 0);
295 }
296 
298  DIVariable *StringLength,
299  DIExpression *StrLocationExp) {
300  assert(!Name.empty() && "Unable to create type without name");
301  return DIStringType::get(VMContext, dwarf::DW_TAG_string_type, Name,
302  StringLength, nullptr, StrLocationExp, 0, 0, 0);
303 }
304 
306  DIExpression *StringLengthExp,
307  DIExpression *StrLocationExp) {
308  assert(!Name.empty() && "Unable to create type without name");
309  return DIStringType::get(VMContext, dwarf::DW_TAG_string_type, Name, nullptr,
310  StringLengthExp, StrLocationExp, 0, 0, 0);
311 }
312 
314  return DIDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr, FromTy, 0,
315  0, 0, None, DINode::FlagZero);
316 }
317 
320  uint32_t AlignInBits,
321  Optional<unsigned> DWARFAddressSpace,
322  StringRef Name, DINodeArray Annotations) {
323  // FIXME: Why is there a name here?
324  return DIDerivedType::get(VMContext, dwarf::DW_TAG_pointer_type, Name,
325  nullptr, 0, nullptr, PointeeTy, SizeInBits,
326  AlignInBits, 0, DWARFAddressSpace, DINode::FlagZero,
327  nullptr, Annotations);
328 }
329 
331  DIType *Base,
332  uint64_t SizeInBits,
333  uint32_t AlignInBits,
334  DINode::DIFlags Flags) {
335  return DIDerivedType::get(VMContext, dwarf::DW_TAG_ptr_to_member_type, "",
336  nullptr, 0, nullptr, PointeeTy, SizeInBits,
337  AlignInBits, 0, None, Flags, Base);
338 }
339 
342  uint32_t AlignInBits,
343  Optional<unsigned> DWARFAddressSpace) {
344  assert(RTy && "Unable to create reference type");
345  return DIDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr, RTy,
346  SizeInBits, AlignInBits, 0, DWARFAddressSpace,
347  DINode::FlagZero);
348 }
349 
351  DIFile *File, unsigned LineNo,
352  DIScope *Context, uint32_t AlignInBits,
353  DINode::DIFlags Flags,
354  DINodeArray Annotations) {
355  return DIDerivedType::get(VMContext, dwarf::DW_TAG_typedef, Name, File,
356  LineNo, getNonCompileUnitScope(Context), Ty, 0,
357  AlignInBits, 0, None, Flags, nullptr, Annotations);
358 }
359 
361  assert(Ty && "Invalid type!");
362  assert(FriendTy && "Invalid friend type!");
363  return DIDerivedType::get(VMContext, dwarf::DW_TAG_friend, "", nullptr, 0, Ty,
364  FriendTy, 0, 0, 0, None, DINode::FlagZero);
365 }
366 
368  uint64_t BaseOffset,
369  uint32_t VBPtrOffset,
370  DINode::DIFlags Flags) {
371  assert(Ty && "Unable to create inheritance");
372  Metadata *ExtraData = ConstantAsMetadata::get(
373  ConstantInt::get(IntegerType::get(VMContext, 32), VBPtrOffset));
374  return DIDerivedType::get(VMContext, dwarf::DW_TAG_inheritance, "", nullptr,
375  0, Ty, BaseTy, 0, 0, BaseOffset, None, Flags,
376  ExtraData);
377 }
378 
380  DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
381  uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
382  DINode::DIFlags Flags, DIType *Ty, DINodeArray Annotations) {
383  return DIDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File,
384  LineNumber, getNonCompileUnitScope(Scope), Ty,
385  SizeInBits, AlignInBits, OffsetInBits, None, Flags,
386  nullptr, Annotations);
387 }
388 
390  if (C)
391  return ConstantAsMetadata::get(C);
392  return nullptr;
393 }
394 
396  DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
397  uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
398  Constant *Discriminant, DINode::DIFlags Flags, DIType *Ty) {
399  return DIDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File,
400  LineNumber, getNonCompileUnitScope(Scope), Ty,
401  SizeInBits, AlignInBits, OffsetInBits, None, Flags,
402  getConstantOrNull(Discriminant));
403 }
404 
406  DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
407  uint64_t SizeInBits, uint64_t OffsetInBits, uint64_t StorageOffsetInBits,
408  DINode::DIFlags Flags, DIType *Ty, DINodeArray Annotations) {
409  Flags |= DINode::FlagBitField;
410  return DIDerivedType::get(
411  VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
412  getNonCompileUnitScope(Scope), Ty, SizeInBits, /*AlignInBits=*/0,
413  OffsetInBits, None, Flags,
415  StorageOffsetInBits)),
416  Annotations);
417 }
418 
421  unsigned LineNumber, DIType *Ty,
422  DINode::DIFlags Flags, llvm::Constant *Val,
423  uint32_t AlignInBits) {
424  Flags |= DINode::FlagStaticMember;
425  return DIDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File,
426  LineNumber, getNonCompileUnitScope(Scope), Ty, 0,
427  AlignInBits, 0, None, Flags,
428  getConstantOrNull(Val));
429 }
430 
432 DIBuilder::createObjCIVar(StringRef Name, DIFile *File, unsigned LineNumber,
433  uint64_t SizeInBits, uint32_t AlignInBits,
434  uint64_t OffsetInBits, DINode::DIFlags Flags,
435  DIType *Ty, MDNode *PropertyNode) {
436  return DIDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File,
437  LineNumber, getNonCompileUnitScope(File), Ty,
438  SizeInBits, AlignInBits, OffsetInBits, None, Flags,
439  PropertyNode);
440 }
441 
443 DIBuilder::createObjCProperty(StringRef Name, DIFile *File, unsigned LineNumber,
444  StringRef GetterName, StringRef SetterName,
445  unsigned PropertyAttributes, DIType *Ty) {
446  return DIObjCProperty::get(VMContext, Name, File, LineNumber, GetterName,
447  SetterName, PropertyAttributes, Ty);
448 }
449 
452  DIType *Ty, bool isDefault) {
453  assert((!Context || isa<DICompileUnit>(Context)) && "Expected compile unit");
454  return DITemplateTypeParameter::get(VMContext, Name, Ty, isDefault);
455 }
456 
459  DIScope *Context, StringRef Name, DIType *Ty,
460  bool IsDefault, Metadata *MD) {
461  assert((!Context || isa<DICompileUnit>(Context)) && "Expected compile unit");
462  return DITemplateValueParameter::get(VMContext, Tag, Name, Ty, IsDefault, MD);
463 }
464 
467  DIType *Ty, bool isDefault,
468  Constant *Val) {
470  VMContext, dwarf::DW_TAG_template_value_parameter, Context, Name, Ty,
471  isDefault, getConstantOrNull(Val));
472 }
473 
476  DIType *Ty, StringRef Val) {
478  VMContext, dwarf::DW_TAG_GNU_template_template_param, Context, Name, Ty,
479  false, MDString::get(VMContext, Val));
480 }
481 
484  DIType *Ty, DINodeArray Val) {
486  VMContext, dwarf::DW_TAG_GNU_template_parameter_pack, Context, Name, Ty,
487  false, Val.get());
488 }
489 
491  DIScope *Context, StringRef Name, DIFile *File, unsigned LineNumber,
492  uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
493  DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements,
494  DIType *VTableHolder, MDNode *TemplateParams, StringRef UniqueIdentifier) {
495  assert((!Context || isa<DIScope>(Context)) &&
496  "createClassType should be called with a valid Context");
497 
498  auto *R = DICompositeType::get(
499  VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber,
500  getNonCompileUnitScope(Context), DerivedFrom, SizeInBits, AlignInBits,
501  OffsetInBits, Flags, Elements, 0, VTableHolder,
502  cast_or_null<MDTuple>(TemplateParams), UniqueIdentifier);
503  trackIfUnresolved(R);
504  return R;
505 }
506 
508  DIScope *Context, StringRef Name, DIFile *File, unsigned LineNumber,
509  uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags,
510  DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang,
511  DIType *VTableHolder, StringRef UniqueIdentifier) {
512  auto *R = DICompositeType::get(
513  VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber,
514  getNonCompileUnitScope(Context), DerivedFrom, SizeInBits, AlignInBits, 0,
515  Flags, Elements, RunTimeLang, VTableHolder, nullptr, UniqueIdentifier);
516  trackIfUnresolved(R);
517  return R;
518 }
519 
521  DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
522  uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags,
523  DINodeArray Elements, unsigned RunTimeLang, StringRef UniqueIdentifier) {
524  auto *R = DICompositeType::get(
525  VMContext, dwarf::DW_TAG_union_type, Name, File, LineNumber,
526  getNonCompileUnitScope(Scope), nullptr, SizeInBits, AlignInBits, 0, Flags,
527  Elements, RunTimeLang, nullptr, nullptr, UniqueIdentifier);
528  trackIfUnresolved(R);
529  return R;
530 }
531 
534  unsigned LineNumber, uint64_t SizeInBits,
535  uint32_t AlignInBits, DINode::DIFlags Flags,
536  DIDerivedType *Discriminator, DINodeArray Elements,
537  StringRef UniqueIdentifier) {
538  auto *R = DICompositeType::get(
539  VMContext, dwarf::DW_TAG_variant_part, Name, File, LineNumber,
540  getNonCompileUnitScope(Scope), nullptr, SizeInBits, AlignInBits, 0, Flags,
541  Elements, 0, nullptr, nullptr, UniqueIdentifier, Discriminator);
542  trackIfUnresolved(R);
543  return R;
544 }
545 
547  DINode::DIFlags Flags,
548  unsigned CC) {
549  return DISubroutineType::get(VMContext, Flags, CC, ParameterTypes);
550 }
551 
553  DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
554  uint64_t SizeInBits, uint32_t AlignInBits, DINodeArray Elements,
555  DIType *UnderlyingType, StringRef UniqueIdentifier, bool IsScoped) {
556  auto *CTy = DICompositeType::get(
557  VMContext, dwarf::DW_TAG_enumeration_type, Name, File, LineNumber,
558  getNonCompileUnitScope(Scope), UnderlyingType, SizeInBits, AlignInBits, 0,
559  IsScoped ? DINode::FlagEnumClass : DINode::FlagZero, Elements, 0, nullptr,
560  nullptr, UniqueIdentifier);
561  AllEnumTypes.emplace_back(CTy);
562  trackIfUnresolved(CTy);
563  return CTy;
564 }
565 
567  DIFile *File, unsigned LineNo,
568  uint64_t SizeInBits,
569  uint32_t AlignInBits, DIType *Ty) {
570  auto *R =
571  DIDerivedType::get(VMContext, dwarf::DW_TAG_set_type, Name, File, LineNo,
572  getNonCompileUnitScope(Scope), Ty, SizeInBits,
573  AlignInBits, 0, None, DINode::FlagZero);
574  trackIfUnresolved(R);
575  return R;
576 }
577 
580  DINodeArray Subscripts,
585  auto *R = DICompositeType::get(
586  VMContext, dwarf::DW_TAG_array_type, "", nullptr, 0, nullptr, Ty, Size,
587  AlignInBits, 0, DINode::FlagZero, Subscripts, 0, nullptr, nullptr, "",
588  nullptr,
589  DL.is<DIExpression *>() ? (Metadata *)DL.get<DIExpression *>()
590  : (Metadata *)DL.get<DIVariable *>(),
591  AS.is<DIExpression *>() ? (Metadata *)AS.get<DIExpression *>()
592  : (Metadata *)AS.get<DIVariable *>(),
593  AL.is<DIExpression *>() ? (Metadata *)AL.get<DIExpression *>()
594  : (Metadata *)AL.get<DIVariable *>(),
595  RK.is<DIExpression *>() ? (Metadata *)RK.get<DIExpression *>()
596  : (Metadata *)RK.get<DIVariable *>());
597  trackIfUnresolved(R);
598  return R;
599 }
600 
602  uint32_t AlignInBits, DIType *Ty,
603  DINodeArray Subscripts) {
604  auto *R = DICompositeType::get(VMContext, dwarf::DW_TAG_array_type, "",
605  nullptr, 0, nullptr, Ty, Size, AlignInBits, 0,
606  DINode::FlagVector, Subscripts, 0, nullptr);
607  trackIfUnresolved(R);
608  return R;
609 }
610 
612  auto NewSP = SP->cloneWithFlags(SP->getFlags() | DINode::FlagArtificial);
613  return MDNode::replaceWithDistinct(std::move(NewSP));
614 }
615 
617  DINode::DIFlags FlagsToSet) {
618  auto NewTy = Ty->cloneWithFlags(Ty->getFlags() | FlagsToSet);
619  return MDNode::replaceWithUniqued(std::move(NewTy));
620 }
621 
623  // FIXME: Restrict this to the nodes where it's valid.
624  if (Ty->isArtificial())
625  return Ty;
626  return createTypeWithFlags(Ty, DINode::FlagArtificial);
627 }
628 
630  // FIXME: Restrict this to the nodes where it's valid.
631  if (Ty->isObjectPointer())
632  return Ty;
633  DINode::DIFlags Flags = DINode::FlagObjectPointer | DINode::FlagArtificial;
634  return createTypeWithFlags(Ty, Flags);
635 }
636 
638  assert(T && "Expected non-null type");
639  assert((isa<DIType>(T) || (isa<DISubprogram>(T) &&
640  cast<DISubprogram>(T)->isDefinition() == false)) &&
641  "Expected type or subprogram declaration");
642  AllRetainTypes.emplace_back(T);
643 }
644 
646 
649  DIFile *F, unsigned Line, unsigned RuntimeLang,
650  uint64_t SizeInBits, uint32_t AlignInBits,
651  StringRef UniqueIdentifier) {
652  // FIXME: Define in terms of createReplaceableForwardDecl() by calling
653  // replaceWithUniqued().
654  auto *RetTy = DICompositeType::get(
655  VMContext, Tag, Name, F, Line, getNonCompileUnitScope(Scope), nullptr,
656  SizeInBits, AlignInBits, 0, DINode::FlagFwdDecl, nullptr, RuntimeLang,
657  nullptr, nullptr, UniqueIdentifier);
658  trackIfUnresolved(RetTy);
659  return RetTy;
660 }
661 
663  unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line,
664  unsigned RuntimeLang, uint64_t SizeInBits, uint32_t AlignInBits,
665  DINode::DIFlags Flags, StringRef UniqueIdentifier,
666  DINodeArray Annotations) {
667  auto *RetTy =
669  VMContext, Tag, Name, F, Line, getNonCompileUnitScope(Scope), nullptr,
670  SizeInBits, AlignInBits, 0, Flags, nullptr, RuntimeLang, nullptr,
671  nullptr, UniqueIdentifier, nullptr, nullptr, nullptr, nullptr,
672  nullptr, Annotations)
673  .release();
674  trackIfUnresolved(RetTy);
675  return RetTy;
676 }
677 
679  return MDTuple::get(VMContext, Elements);
680 }
681 
682 DIMacroNodeArray
684  return MDTuple::get(VMContext, Elements);
685 }
686 
689  for (Metadata *E : Elements) {
690  if (isa_and_nonnull<MDNode>(E))
691  Elts.push_back(cast<DIType>(E));
692  else
693  Elts.push_back(E);
694  }
695  return DITypeRefArray(MDNode::get(VMContext, Elts));
696 }
697 
698 DISubrange *DIBuilder::getOrCreateSubrange(int64_t Lo, int64_t Count) {
699  auto *LB = ConstantAsMetadata::get(
700  ConstantInt::getSigned(Type::getInt64Ty(VMContext), Lo));
701  auto *CountNode = ConstantAsMetadata::get(
702  ConstantInt::getSigned(Type::getInt64Ty(VMContext), Count));
703  return DISubrange::get(VMContext, CountNode, LB, nullptr, nullptr);
704 }
705 
707  auto *LB = ConstantAsMetadata::get(
708  ConstantInt::getSigned(Type::getInt64Ty(VMContext), Lo));
709  return DISubrange::get(VMContext, CountNode, LB, nullptr, nullptr);
710 }
711 
713  Metadata *UB, Metadata *Stride) {
714  return DISubrange::get(VMContext, CountNode, LB, UB, Stride);
715 }
716 
720  auto ConvToMetadata = [&](DIGenericSubrange::BoundType Bound) -> Metadata * {
721  return Bound.is<DIExpression *>() ? (Metadata *)Bound.get<DIExpression *>()
722  : (Metadata *)Bound.get<DIVariable *>();
723  };
724  return DIGenericSubrange::get(VMContext, ConvToMetadata(CountNode),
725  ConvToMetadata(LB), ConvToMetadata(UB),
726  ConvToMetadata(Stride));
727 }
728 
730 #ifndef NDEBUG
731  if (auto *CT =
732  dyn_cast_or_null<DICompositeType>(getNonCompileUnitScope(Context)))
733  assert(CT->getIdentifier().empty() &&
734  "Context of a global variable should not be a type with identifier");
735 #endif
736 }
737 
739  DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *F,
740  unsigned LineNumber, DIType *Ty, bool IsLocalToUnit, bool isDefined,
741  DIExpression *Expr, MDNode *Decl, MDTuple *TemplateParams,
742  uint32_t AlignInBits, DINodeArray Annotations) {
744 
746  VMContext, cast_or_null<DIScope>(Context), Name, LinkageName, F,
747  LineNumber, Ty, IsLocalToUnit, isDefined,
748  cast_or_null<DIDerivedType>(Decl), TemplateParams, AlignInBits,
749  Annotations);
750  if (!Expr)
751  Expr = createExpression();
752  auto *N = DIGlobalVariableExpression::get(VMContext, GV, Expr);
753  AllGVs.push_back(N);
754  return N;
755 }
756 
758  DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *F,
759  unsigned LineNumber, DIType *Ty, bool IsLocalToUnit, MDNode *Decl,
760  MDTuple *TemplateParams, uint32_t AlignInBits) {
762 
764  VMContext, cast_or_null<DIScope>(Context), Name, LinkageName, F,
765  LineNumber, Ty, IsLocalToUnit, false,
766  cast_or_null<DIDerivedType>(Decl), TemplateParams, AlignInBits,
767  nullptr)
768  .release();
769 }
770 
772  LLVMContext &VMContext,
773  DenseMap<MDNode *, SmallVector<TrackingMDNodeRef, 1>> &PreservedVariables,
774  DIScope *Scope, StringRef Name, unsigned ArgNo, DIFile *File,
775  unsigned LineNo, DIType *Ty, bool AlwaysPreserve, DINode::DIFlags Flags,
776  uint32_t AlignInBits, DINodeArray Annotations = nullptr) {
777  // FIXME: Why getNonCompileUnitScope()?
778  // FIXME: Why is "!Context" okay here?
779  // FIXME: Why doesn't this check for a subprogram or lexical block (AFAICT
780  // the only valid scopes)?
782 
783  auto *Node = DILocalVariable::get(
784  VMContext, cast_or_null<DILocalScope>(Context), Name, File, LineNo, Ty,
785  ArgNo, Flags, AlignInBits, Annotations);
786  if (AlwaysPreserve) {
787  // The optimizer may remove local variables. If there is an interest
788  // to preserve variable info in such situation then stash it in a
789  // named mdnode.
790  DISubprogram *Fn = getDISubprogram(Scope);
791  assert(Fn && "Missing subprogram for local variable");
792  PreservedVariables[Fn].emplace_back(Node);
793  }
794  return Node;
795 }
796 
798  DIFile *File, unsigned LineNo,
799  DIType *Ty, bool AlwaysPreserve,
800  DINode::DIFlags Flags,
801  uint32_t AlignInBits) {
802  return createLocalVariable(VMContext, PreservedVariables, Scope, Name,
803  /* ArgNo */ 0, File, LineNo, Ty, AlwaysPreserve,
804  Flags, AlignInBits);
805 }
806 
808  DIScope *Scope, StringRef Name, unsigned ArgNo, DIFile *File,
809  unsigned LineNo, DIType *Ty, bool AlwaysPreserve, DINode::DIFlags Flags,
810  DINodeArray Annotations) {
811  assert(ArgNo && "Expected non-zero argument number for parameter");
812  return createLocalVariable(VMContext, PreservedVariables, Scope, Name, ArgNo,
813  File, LineNo, Ty, AlwaysPreserve, Flags,
814  /*AlignInBits=*/0, Annotations);
815 }
816 
818  unsigned LineNo, bool AlwaysPreserve) {
820 
821  auto *Node = DILabel::get(VMContext, cast_or_null<DILocalScope>(Context),
822  Name, File, LineNo);
823 
824  if (AlwaysPreserve) {
825  /// The optimizer may remove labels. If there is an interest
826  /// to preserve label info in such situation then append it to
827  /// the list of retained nodes of the DISubprogram.
828  DISubprogram *Fn = getDISubprogram(Scope);
829  assert(Fn && "Missing subprogram for label");
830  PreservedLabels[Fn].emplace_back(Node);
831  }
832  return Node;
833 }
834 
836  return DIExpression::get(VMContext, Addr);
837 }
838 
839 template <class... Ts>
840 static DISubprogram *getSubprogram(bool IsDistinct, Ts &&...Args) {
841  if (IsDistinct)
842  return DISubprogram::getDistinct(std::forward<Ts>(Args)...);
843  return DISubprogram::get(std::forward<Ts>(Args)...);
844 }
845 
847  DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
848  unsigned LineNo, DISubroutineType *Ty, unsigned ScopeLine,
850  DITemplateParameterArray TParams, DISubprogram *Decl,
851  DITypeArray ThrownTypes, DINodeArray Annotations,
852  StringRef TargetFuncName) {
853  bool IsDefinition = SPFlags & DISubprogram::SPFlagDefinition;
854  auto *Node = getSubprogram(
855  /*IsDistinct=*/IsDefinition, VMContext, getNonCompileUnitScope(Context),
856  Name, LinkageName, File, LineNo, Ty, ScopeLine, nullptr, 0, 0, Flags,
857  SPFlags, IsDefinition ? CUNode : nullptr, TParams, Decl,
858  MDTuple::getTemporary(VMContext, None).release(), ThrownTypes,
859  Annotations, TargetFuncName);
860 
861  if (IsDefinition)
862  AllSubprograms.push_back(Node);
863  trackIfUnresolved(Node);
864  return Node;
865 }
866 
868  DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
869  unsigned LineNo, DISubroutineType *Ty, unsigned ScopeLine,
871  DITemplateParameterArray TParams, DISubprogram *Decl,
872  DITypeArray ThrownTypes) {
873  bool IsDefinition = SPFlags & DISubprogram::SPFlagDefinition;
875  Name, LinkageName, File, LineNo, Ty,
876  ScopeLine, nullptr, 0, 0, Flags, SPFlags,
877  IsDefinition ? CUNode : nullptr, TParams,
878  Decl, nullptr, ThrownTypes)
879  .release();
880 }
881 
883  DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *F,
884  unsigned LineNo, DISubroutineType *Ty, unsigned VIndex, int ThisAdjustment,
885  DIType *VTableHolder, DINode::DIFlags Flags,
886  DISubprogram::DISPFlags SPFlags, DITemplateParameterArray TParams,
887  DITypeArray ThrownTypes) {
889  "Methods should have both a Context and a context that isn't "
890  "the compile unit.");
891  // FIXME: Do we want to use different scope/lines?
892  bool IsDefinition = SPFlags & DISubprogram::SPFlagDefinition;
893  auto *SP = getSubprogram(
894  /*IsDistinct=*/IsDefinition, VMContext, cast<DIScope>(Context), Name,
895  LinkageName, F, LineNo, Ty, LineNo, VTableHolder, VIndex, ThisAdjustment,
896  Flags, SPFlags, IsDefinition ? CUNode : nullptr, TParams, nullptr,
897  nullptr, ThrownTypes);
898 
899  if (IsDefinition)
900  AllSubprograms.push_back(SP);
901  trackIfUnresolved(SP);
902  return SP;
903 }
904 
906  DIGlobalVariable *Decl,
907  StringRef Name, DIFile *File,
908  unsigned LineNo) {
909  return DICommonBlock::get(VMContext, Scope, Decl, Name, File, LineNo);
910 }
911 
913  bool ExportSymbols) {
914 
915  // It is okay to *not* make anonymous top-level namespaces distinct, because
916  // all nodes that have an anonymous namespace as their parent scope are
917  // guaranteed to be unique and/or are linked to their containing
918  // DICompileUnit. This decision is an explicit tradeoff of link time versus
919  // memory usage versus code simplicity and may get revisited in the future.
920  return DINamespace::get(VMContext, getNonCompileUnitScope(Scope), Name,
921  ExportSymbols);
922 }
923 
925  StringRef ConfigurationMacros,
926  StringRef IncludePath, StringRef APINotesFile,
927  DIFile *File, unsigned LineNo, bool IsDecl) {
928  return DIModule::get(VMContext, File, getNonCompileUnitScope(Scope), Name,
929  ConfigurationMacros, IncludePath, APINotesFile, LineNo,
930  IsDecl);
931 }
932 
934  DIFile *File,
935  unsigned Discriminator) {
936  return DILexicalBlockFile::get(VMContext, Scope, File, Discriminator);
937 }
938 
940  unsigned Line, unsigned Col) {
941  // Make these distinct, to avoid merging two lexical blocks on the same
942  // file/line/column.
943  return DILexicalBlock::getDistinct(VMContext, getNonCompileUnitScope(Scope),
944  File, Line, Col);
945 }
946 
947 Instruction *DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
948  DIExpression *Expr, const DILocation *DL,
949  Instruction *InsertBefore) {
950  return insertDeclare(Storage, VarInfo, Expr, DL, InsertBefore->getParent(),
951  InsertBefore);
952 }
953 
954 Instruction *DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
955  DIExpression *Expr, const DILocation *DL,
956  BasicBlock *InsertAtEnd) {
957  // If this block already has a terminator then insert this intrinsic before
958  // the terminator. Otherwise, put it at the end of the block.
959  Instruction *InsertBefore = InsertAtEnd->getTerminator();
960  return insertDeclare(Storage, VarInfo, Expr, DL, InsertAtEnd, InsertBefore);
961 }
962 
965  DILocalVariable *SrcVar, DIExpression *ValExpr,
966  Value *Addr, DIExpression *AddrExpr,
967  const DILocation *DL) {
968  LLVMContext &Ctx = LinkedInstr->getContext();
969  Module *M = LinkedInstr->getModule();
970  if (!AssignFn)
971  AssignFn = Intrinsic::getDeclaration(M, Intrinsic::dbg_assign);
972 
973  auto *Link = LinkedInstr->getMetadata(LLVMContext::MD_DIAssignID);
974  assert(Link && "Linked instruction must have DIAssign metadata attached");
975 
976  std::array<Value *, 6> Args = {
978  MetadataAsValue::get(Ctx, SrcVar),
979  MetadataAsValue::get(Ctx, ValExpr),
982  MetadataAsValue::get(Ctx, AddrExpr),
983  };
984 
985  IRBuilder<> B(Ctx);
986  B.SetCurrentDebugLocation(DL);
987 
988  auto *DVI = cast<DbgAssignIntrinsic>(B.CreateCall(AssignFn, Args));
989  DVI->insertAfter(LinkedInstr);
990  return DVI;
991 }
992 
993 Instruction *DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
994  Instruction *InsertBefore) {
995  return insertLabel(LabelInfo, DL,
996  InsertBefore ? InsertBefore->getParent() : nullptr,
997  InsertBefore);
998 }
999 
1000 Instruction *DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
1001  BasicBlock *InsertAtEnd) {
1002  return insertLabel(LabelInfo, DL, InsertAtEnd, nullptr);
1003 }
1004 
1005 Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V,
1006  DILocalVariable *VarInfo,
1007  DIExpression *Expr,
1008  const DILocation *DL,
1009  Instruction *InsertBefore) {
1010  return insertDbgValueIntrinsic(
1011  V, VarInfo, Expr, DL, InsertBefore ? InsertBefore->getParent() : nullptr,
1012  InsertBefore);
1013 }
1014 
1015 Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V,
1016  DILocalVariable *VarInfo,
1017  DIExpression *Expr,
1018  const DILocation *DL,
1019  BasicBlock *InsertAtEnd) {
1020  return insertDbgValueIntrinsic(V, VarInfo, Expr, DL, InsertAtEnd, nullptr);
1021 }
1022 
1023 Instruction *DIBuilder::insertDbgAddrIntrinsic(Value *V,
1024  DILocalVariable *VarInfo,
1025  DIExpression *Expr,
1026  const DILocation *DL,
1027  Instruction *InsertBefore) {
1028  return insertDbgAddrIntrinsic(
1029  V, VarInfo, Expr, DL, InsertBefore ? InsertBefore->getParent() : nullptr,
1030  InsertBefore);
1031 }
1032 
1033 Instruction *DIBuilder::insertDbgAddrIntrinsic(Value *V,
1034  DILocalVariable *VarInfo,
1035  DIExpression *Expr,
1036  const DILocation *DL,
1037  BasicBlock *InsertAtEnd) {
1038  return insertDbgAddrIntrinsic(V, VarInfo, Expr, DL, InsertAtEnd, nullptr);
1039 }
1040 
1041 /// Initialize IRBuilder for inserting dbg.declare and dbg.value intrinsics.
1042 /// This abstracts over the various ways to specify an insert position.
1044  BasicBlock *InsertBB, Instruction *InsertBefore) {
1045  if (InsertBefore)
1046  Builder.SetInsertPoint(InsertBefore);
1047  else if (InsertBB)
1048  Builder.SetInsertPoint(InsertBB);
1049  Builder.SetCurrentDebugLocation(DL);
1050 }
1051 
1053  assert(V && "no value passed to dbg intrinsic");
1054  return MetadataAsValue::get(VMContext, ValueAsMetadata::get(V));
1055 }
1056 
1058  return Intrinsic::getDeclaration(&M, UseDbgAddr ? Intrinsic::dbg_addr
1059  : Intrinsic::dbg_declare);
1060 }
1061 
1062 Instruction *DIBuilder::insertDbgValueIntrinsic(
1063  llvm::Value *Val, DILocalVariable *VarInfo, DIExpression *Expr,
1064  const DILocation *DL, BasicBlock *InsertBB, Instruction *InsertBefore) {
1065  if (!ValueFn)
1066  ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
1067  return insertDbgIntrinsic(ValueFn, Val, VarInfo, Expr, DL, InsertBB,
1068  InsertBefore);
1069 }
1070 
1071 Instruction *DIBuilder::insertDbgAddrIntrinsic(
1072  llvm::Value *Val, DILocalVariable *VarInfo, DIExpression *Expr,
1073  const DILocation *DL, BasicBlock *InsertBB, Instruction *InsertBefore) {
1074  if (!AddrFn)
1075  AddrFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_addr);
1076  return insertDbgIntrinsic(AddrFn, Val, VarInfo, Expr, DL, InsertBB,
1077  InsertBefore);
1078 }
1079 
1080 Instruction *DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
1081  DIExpression *Expr, const DILocation *DL,
1082  BasicBlock *InsertBB,
1083  Instruction *InsertBefore) {
1084  assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.declare");
1085  assert(DL && "Expected debug loc");
1086  assert(DL->getScope()->getSubprogram() ==
1087  VarInfo->getScope()->getSubprogram() &&
1088  "Expected matching subprograms");
1089  if (!DeclareFn)
1090  DeclareFn = getDeclareIntrin(M);
1091 
1092  trackIfUnresolved(VarInfo);
1093  trackIfUnresolved(Expr);
1094  Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, Storage),
1095  MetadataAsValue::get(VMContext, VarInfo),
1096  MetadataAsValue::get(VMContext, Expr)};
1097 
1098  IRBuilder<> B(DL->getContext());
1099  initIRBuilder(B, DL, InsertBB, InsertBefore);
1100  return B.CreateCall(DeclareFn, Args);
1101 }
1102 
1103 Instruction *DIBuilder::insertDbgIntrinsic(llvm::Function *IntrinsicFn,
1104  Value *V, DILocalVariable *VarInfo,
1105  DIExpression *Expr,
1106  const DILocation *DL,
1107  BasicBlock *InsertBB,
1108  Instruction *InsertBefore) {
1109  assert(IntrinsicFn && "must pass a non-null intrinsic function");
1110  assert(V && "must pass a value to a dbg intrinsic");
1111  assert(VarInfo &&
1112  "empty or invalid DILocalVariable* passed to debug intrinsic");
1113  assert(DL && "Expected debug loc");
1114  assert(DL->getScope()->getSubprogram() ==
1115  VarInfo->getScope()->getSubprogram() &&
1116  "Expected matching subprograms");
1117 
1118  trackIfUnresolved(VarInfo);
1119  trackIfUnresolved(Expr);
1120  Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, V),
1121  MetadataAsValue::get(VMContext, VarInfo),
1122  MetadataAsValue::get(VMContext, Expr)};
1123 
1124  IRBuilder<> B(DL->getContext());
1125  initIRBuilder(B, DL, InsertBB, InsertBefore);
1126  return B.CreateCall(IntrinsicFn, Args);
1127 }
1128 
1129 Instruction *DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
1130  BasicBlock *InsertBB,
1131  Instruction *InsertBefore) {
1132  assert(LabelInfo && "empty or invalid DILabel* passed to dbg.label");
1133  assert(DL && "Expected debug loc");
1134  assert(DL->getScope()->getSubprogram() ==
1135  LabelInfo->getScope()->getSubprogram() &&
1136  "Expected matching subprograms");
1137  if (!LabelFn)
1138  LabelFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_label);
1139 
1140  trackIfUnresolved(LabelInfo);
1141  Value *Args[] = {MetadataAsValue::get(VMContext, LabelInfo)};
1142 
1143  IRBuilder<> B(DL->getContext());
1144  initIRBuilder(B, DL, InsertBB, InsertBefore);
1145  return B.CreateCall(LabelFn, Args);
1146 }
1147 
1149  {
1151  N->replaceVTableHolder(VTableHolder);
1152  T = N.get();
1153  }
1154 
1155  // If this didn't create a self-reference, just return.
1156  if (T != VTableHolder)
1157  return;
1158 
1159  // Look for unresolved operands. T will drop RAUW support, orphaning any
1160  // cycles underneath it.
1161  if (T->isResolved())
1162  for (const MDOperand &O : T->operands())
1163  if (auto *N = dyn_cast_or_null<MDNode>(O))
1164  trackIfUnresolved(N);
1165 }
1166 
1167 void DIBuilder::replaceArrays(DICompositeType *&T, DINodeArray Elements,
1168  DINodeArray TParams) {
1169  {
1171  if (Elements)
1172  N->replaceElements(Elements);
1173  if (TParams)
1174  N->replaceTemplateParams(DITemplateParameterArray(TParams));
1175  T = N.get();
1176  }
1177 
1178  // If T isn't resolved, there's no problem.
1179  if (!T->isResolved())
1180  return;
1181 
1182  // If T is resolved, it may be due to a self-reference cycle. Track the
1183  // arrays explicitly if they're unresolved, or else the cycles will be
1184  // orphaned.
1185  if (Elements)
1186  trackIfUnresolved(Elements.get());
1187  if (TParams)
1188  trackIfUnresolved(TParams.get());
1189 }
llvm::DIBuilder::createModule
DIModule * createModule(DIScope *Scope, StringRef Name, StringRef ConfigurationMacros, StringRef IncludePath, StringRef APINotesFile={}, DIFile *File=nullptr, unsigned LineNo=0, bool IsDecl=false)
This creates new descriptor for a module with the specified parent scope.
Definition: DIBuilder.cpp:924
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::DIType
Base class for types.
Definition: DebugInfoMetadata.h:696
llvm::DILocalScope::getSubprogram
DISubprogram * getSubprogram() const
Get the subprogram for this scope.
Definition: DebugInfoMetadata.cpp:961
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::Instruction::getModule
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
Definition: Instruction.cpp:69
llvm::DIBuilder::getOrCreateTypeArray
DITypeRefArray getOrCreateTypeArray(ArrayRef< Metadata * > Elements)
Get a DITypeRefArray, create one if required.
Definition: DIBuilder.cpp:687
llvm::AArch64CC::AL
@ AL
Definition: AArch64BaseInfo.h:269
llvm::NamedMDNode
A tuple of MDNodes.
Definition: Metadata.h:1588
llvm::DIBuilder::finalize
void finalize()
Construct any deferred debug info descriptors.
Definition: DIBuilder.cpp:79
Optional.h
llvm::dwarf
Definition: Dwarf.h:35
llvm::DIBuilder::replaceVTableHolder
void replaceVTableHolder(DICompositeType *&T, DIType *VTableHolder)
Replace the vtable holder in the given type.
Definition: DIBuilder.cpp:1148
llvm::Intrinsic::getDeclaration
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:1481
llvm::DICompileUnit::getMacros
DIMacroNodeArray getMacros() const
Definition: DebugInfoMetadata.h:1511
llvm::DIGenericSubrange
Definition: DebugInfoMetadata.h:401
llvm::Function
Definition: Function.h:60
llvm::DIBuilder::finalizeSubprogram
void finalizeSubprogram(DISubprogram *SP)
Finalize a specific subprogram - no new variables may be added to this subprogram afterwards.
Definition: DIBuilder.cpp:59
llvm::DIBuilder::createBitFieldMemberType
DIDerivedType * createBitFieldMemberType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, uint64_t SizeInBits, uint64_t OffsetInBits, uint64_t StorageOffsetInBits, DINode::DIFlags Flags, DIType *Ty, DINodeArray Annotations=nullptr)
Create debugging information entry for a bit field member.
Definition: DIBuilder.cpp:405
llvm::lltok::NameTableKind
@ NameTableKind
Definition: LLToken.h:449
llvm::DILexicalBlockFile
Definition: DebugInfoMetadata.h:2178
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1199
llvm::DIBuilder::createPointerType
DIDerivedType * createPointerType(DIType *PointeeTy, uint64_t SizeInBits, uint32_t AlignInBits=0, Optional< unsigned > DWARFAddressSpace=None, StringRef Name="", DINodeArray Annotations=nullptr)
Create debugging information entry for a pointer.
Definition: DIBuilder.cpp:319
llvm::DIStringType
String type, Fortran CHARACTER(n)
Definition: DebugInfoMetadata.h:870
llvm::DIFile::ChecksumInfo
A single checksum, represented by a Kind and a Value (a string).
Definition: DebugInfoMetadata.h:584
getDeclareIntrin
static Function * getDeclareIntrin(Module &M)
Definition: DIBuilder.cpp:1057
llvm::DICompileUnit::replaceRetainedTypes
void replaceRetainedTypes(DITypeArray N)
Definition: DebugInfoMetadata.h:1545
llvm::DIBuilder::createTempGlobalVariableFwdDecl
DIGlobalVariable * createTempGlobalVariableFwdDecl(DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DIType *Ty, bool IsLocalToUnit, MDNode *Decl=nullptr, MDTuple *TemplateParams=nullptr, uint32_t AlignInBits=0)
Identical to createGlobalVariable except that the resulting DbgNode is temporary and meant to be RAUW...
Definition: DIBuilder.cpp:757
createLocalVariable
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, DINodeArray Annotations=nullptr)
Definition: DIBuilder.cpp:771
llvm::IRBuilder<>
llvm::DIType::cloneWithFlags
TempDIType cloneWithFlags(DIFlags NewFlags) const
Returns a new temporary DIType with updated Flags.
Definition: DebugInfoMetadata.h:748
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:140
llvm::DILocation
Debug location.
Definition: DebugInfoMetadata.h:1595
llvm::getDISubprogram
DISubprogram * getDISubprogram(const MDNode *Scope)
Find subprogram that is enclosing this scope.
Definition: DebugInfo.cpp:138
llvm::DIBuilder::insertDbgAssign
DbgAssignIntrinsic * insertDbgAssign(Instruction *LinkedInstr, Value *Val, DILocalVariable *SrcVar, DIExpression *ValExpr, Value *Addr, DIExpression *AddrExpr, const DILocation *DL)
Insert a new llvm.dbg.assign intrinsic call.
Definition: DIBuilder.cpp:964
llvm::AtomicOrderingCABI::release
@ release
llvm::DIBuilder::createTempFunctionFwdDecl
DISubprogram * createTempFunctionFwdDecl(DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, unsigned ScopeLine, DINode::DIFlags Flags=DINode::FlagZero, DISubprogram::DISPFlags SPFlags=DISubprogram::SPFlagZero, 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:867
Module.h
llvm::Optional
Definition: APInt.h:33
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::ConstantAsMetadata::get
static ConstantAsMetadata * get(Constant *C)
Definition: Metadata.h:420
llvm::SmallPtrSet
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:450
llvm::ValueAsMetadata::get
static ValueAsMetadata * get(Value *V)
Definition: Metadata.cpp:393
llvm::codeview::Link
@ Link
Definition: CodeView.h:151
llvm::DIBuilder::createMemberType
DIDerivedType * createMemberType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, DINode::DIFlags Flags, DIType *Ty, DINodeArray Annotations=nullptr)
Create debugging information entry for a member.
Definition: DIBuilder.cpp:379
llvm::DIBuilder::createSubroutineType
DISubroutineType * createSubroutineType(DITypeRefArray ParameterTypes, DINode::DIFlags Flags=DINode::FlagZero, unsigned CC=0)
Create subroutine type.
Definition: DIBuilder.cpp:546
llvm::DIExpression
DWARF expression.
Definition: DebugInfoMetadata.h:2596
llvm::DIBuilder::createQualifiedType
DIDerivedType * createQualifiedType(unsigned Tag, DIType *FromTy)
Create debugging information entry for a qualified type, e.g.
Definition: DIBuilder.cpp:313
llvm::dwarf::Tag
Tag
Definition: Dwarf.h:105
llvm::DIBuilder::DIBuilder
DIBuilder(Module &M, bool AllowUnresolved=true, DICompileUnit *CU=nullptr)
Construct a builder for a module.
Definition: DIBuilder.cpp:31
llvm::DINameKind::LinkageName
@ LinkageName
llvm::DIBuilder::createStringType
DIStringType * createStringType(StringRef Name, uint64_t SizeInBits)
Create debugging information entry for a string type.
Definition: DIBuilder.cpp:291
llvm::DIBuilder::createObjCProperty
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:443
llvm::DICompileUnit::DebugEmissionKind
DebugEmissionKind
Definition: DebugInfoMetadata.h:1365
llvm::DIBuilder::createReplaceableCompositeType
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="", DINodeArray Annotations=nullptr)
Create a temporary forward-declared type.
Definition: DIBuilder.cpp:662
llvm::PointerUnion::get
T get() const
Returns the value of the specified pointer type.
Definition: PointerUnion.h:155
llvm::DINamespace
Definition: DebugInfoMetadata.h:2296
llvm::DILexicalBlock
Definition: DebugInfoMetadata.h:2125
llvm::DIBuilder::createFile
DIFile * createFile(StringRef Filename, StringRef Directory, Optional< DIFile::ChecksumInfo< StringRef >> Checksum=None, Optional< StringRef > Source=None)
Create a file descriptor to hold debugging information for a file.
Definition: DIBuilder.cpp:231
llvm::MDNode::get
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1400
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::DIBuilder::createTemplateParameterPack
DITemplateValueParameter * createTemplateParameterPack(DIScope *Scope, StringRef Name, DIType *Ty, DINodeArray Val)
Create debugging information for a template parameter pack.
Definition: DIBuilder.cpp:483
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:55
llvm::PointerUnion::is
bool is() const
Test if the Union currently holds the type matching T.
Definition: PointerUnion.h:150
llvm::Annotations
Annotations lets you mark points and ranges inside source code, for tests:
Definition: Annotations.h:54
llvm::DIBuilder::createAutoVariable
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:797
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::DITypeRefArray
Definition: DebugInfoMetadata.h:71
llvm::DIBuilder::createSetType
DIDerivedType * createSetType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, uint64_t SizeInBits, uint32_t AlignInBits, DIType *Ty)
Create debugging information entry for a set.
Definition: DIBuilder.cpp:566
llvm::NamedMDNode::addOperand
void addOperand(MDNode *M)
Definition: Metadata.cpp:1222
CommandLine.h
llvm::DIBuilder::createArtificialType
static DIType * createArtificialType(DIType *Ty)
Create a uniqued clone of Ty with FlagArtificial set.
Definition: DIBuilder.cpp:622
llvm::DIObjCProperty
Definition: DebugInfoMetadata.h:3251
llvm::DIBuilder::replaceTemporary
NodeTy * replaceTemporary(TempMDNode &&N, NodeTy *Replacement)
Replace a temporary node.
Definition: DIBuilder.h:1038
llvm::DIType::getFlags
DIFlags getFlags() const
Definition: DebugInfoMetadata.h:739
createTemplateValueParameterHelper
static DITemplateValueParameter * createTemplateValueParameterHelper(LLVMContext &VMContext, unsigned Tag, DIScope *Context, StringRef Name, DIType *Ty, bool IsDefault, Metadata *MD)
Definition: DIBuilder.cpp:458
llvm::DIBuilder::createStaticMemberType
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:420
Constants.h
llvm::DICompileUnit::replaceEnumTypes
void replaceEnumTypes(DICompositeTypeArray N)
Replace arrays.
Definition: DebugInfoMetadata.h:1542
llvm::DILocalVariable
Local variable.
Definition: DebugInfoMetadata.h:3096
getConstantOrNull
static ConstantAsMetadata * getConstantOrNull(Constant *C)
Definition: DIBuilder.cpp:389
llvm::DIMacro
Definition: DebugInfoMetadata.h:3486
llvm::DIBuilder::createMacro
DIMacro * createMacro(DIMacroFile *Parent, unsigned Line, unsigned MacroType, StringRef Name, StringRef Value=StringRef())
Create debugging information entry for a macro.
Definition: DIBuilder.cpp:237
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::DIBuilder::createTempMacroFile
DIMacroFile * createTempMacroFile(DIMacroFile *Parent, unsigned Line, DIFile *File)
Create debugging information temporary entry for a macro file.
Definition: DIBuilder.cpp:249
llvm::DICompileUnit::replaceImportedEntities
void replaceImportedEntities(DIImportedEntityArray N)
Definition: DebugInfoMetadata.h:1549
llvm::DIBuilder::createCommonBlock
DICommonBlock * createCommonBlock(DIScope *Scope, DIGlobalVariable *decl, StringRef Name, DIFile *File, unsigned LineNo)
Create common block entry for a Fortran common block.
Definition: DIBuilder.cpp:905
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::DIBuilder::createTypedef
DIDerivedType * createTypedef(DIType *Ty, StringRef Name, DIFile *File, unsigned LineNo, DIScope *Context, uint32_t AlignInBits=0, DINode::DIFlags Flags=DINode::FlagZero, DINodeArray Annotations=nullptr)
Create debugging information entry for a typedef.
Definition: DIBuilder.cpp:350
llvm::DIBuilder::retainType
void retainType(DIScope *T)
Retain DIScope* in a module even if it is not referenced through debug info anchors.
Definition: DIBuilder.cpp:637
llvm::DISubprogram::DISPFlags
DISPFlags
Debug info subprogram flags.
Definition: DebugInfoMetadata.h:1856
llvm::MDTuple
Tuple of metadata.
Definition: Metadata.h:1329
llvm::DIBuilder::createEnumerator
DIEnumerator * createEnumerator(StringRef Name, const APSInt &Value)
Create a single enumerator value.
Definition: DIBuilder.cpp:269
llvm::DISubrange
Array subrange.
Definition: DebugInfoMetadata.h:338
llvm::DIBuilder::createFriend
DIDerivedType * createFriend(DIType *Ty, DIType *FriendTy)
Create debugging information entry for a 'friend'.
Definition: DIBuilder.cpp:360
llvm::DITemplateTypeParameter
Definition: DebugInfoMetadata.h:2441
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::Instruction
Definition: Instruction.h:42
LLVMContextImpl.h
llvm::APSInt
An arbitrary precision integer that knows its signedness.
Definition: APSInt.h:23
llvm::DIBuilder::createUnionType
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:520
llvm::MDNode::getTemporary
static TempMDTuple getTemporary(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1412
initIRBuilder
static void initIRBuilder(IRBuilder<> &Builder, const DILocation *DL, BasicBlock *InsertBB, Instruction *InsertBefore)
Initialize IRBuilder for inserting dbg.declare and dbg.value intrinsics.
Definition: DIBuilder.cpp:1043
llvm::ConstantInt::get
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:879
llvm::AArch64CC::PL
@ PL
Definition: AArch64BaseInfo.h:260
llvm::SmallVectorImpl::append
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
Definition: SmallVector.h:687
createImportedModule
static DIImportedEntity * createImportedModule(LLVMContext &C, dwarf::Tag Tag, DIScope *Context, Metadata *NS, DIFile *File, unsigned Line, StringRef Name, DINodeArray Elements, SmallVectorImpl< TrackingMDNodeRef > &AllImportedModules)
Definition: DIBuilder.cpp:178
llvm::DIBuilder::createVariantPart
DICompositeType * createVariantPart(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags, DIDerivedType *Discriminator, DINodeArray Elements, StringRef UniqueIdentifier="")
Create debugging information entry for a variant part.
Definition: DIBuilder.cpp:533
llvm::Metadata
Root of the metadata hierarchy.
Definition: Metadata.h:62
llvm::DIBuilder::replaceArrays
void replaceArrays(DICompositeType *&T, DINodeArray Elements, DINodeArray TParams=DINodeArray())
Replace arrays on a composite type.
Definition: DIBuilder.cpp:1167
createTypeWithFlags
static DIType * createTypeWithFlags(const DIType *Ty, DINode::DIFlags FlagsToSet)
Definition: DIBuilder.cpp:616
llvm::Instruction::getMetadata
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
Definition: Instruction.h:271
llvm::DIBuilder::createObjectPointerType
static DIType * createObjectPointerType(DIType *Ty)
Create a uniqued clone of Ty with FlagObjectPointer and FlagArtificial set.
Definition: DIBuilder.cpp:629
llvm::DILocalVariable::getScope
DILocalScope * getScope() const
Get the local scope for this variable.
Definition: DebugInfoMetadata.h:3154
llvm::DICommonBlock
Definition: DebugInfoMetadata.h:3037
llvm::DIBuilder::createReferenceType
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:341
llvm::dwarf::DW_LANG_lo_user
@ DW_LANG_lo_user
Definition: Dwarf.h:205
llvm::cl::opt< bool >
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:264
getNonCompileUnitScope
static DIScope * getNonCompileUnitScope(DIScope *N)
If N is compile unit return NULL otherwise return N.
Definition: DIBuilder.cpp:145
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::DIEnumerator
Enumeration value.
Definition: DebugInfoMetadata.h:449
llvm::DIBuilder::createMethod
DISubprogram * createMethod(DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, unsigned VTableIndex=0, int ThisAdjustment=0, DIType *VTableHolder=nullptr, DINode::DIFlags Flags=DINode::FlagZero, DISubprogram::DISPFlags SPFlags=DISubprogram::SPFlagZero, DITemplateParameterArray TParams=nullptr, DITypeArray ThrownTypes=nullptr)
Create a new descriptor for the specified C++ method.
Definition: DIBuilder.cpp:882
llvm::DICompileUnit::getGlobalVariables
DIGlobalVariableExpressionArray getGlobalVariables() const
Definition: DebugInfoMetadata.h:1505
uint64_t
llvm::DIBuilder::createForwardDecl
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:648
llvm::DIBuilder::createArrayType
DICompositeType * createArrayType(uint64_t Size, uint32_t AlignInBits, DIType *Ty, DINodeArray Subscripts, PointerUnion< DIExpression *, DIVariable * > DataLocation=nullptr, PointerUnion< DIExpression *, DIVariable * > Associated=nullptr, PointerUnion< DIExpression *, DIVariable * > Allocated=nullptr, PointerUnion< DIExpression *, DIVariable * > Rank=nullptr)
Create debugging information entry for an array.
Definition: DIBuilder.cpp:579
Addr
uint64_t Addr
Definition: ELFObjHandler.cpp:79
llvm::DIBuilder::createEnumerationType
DICompositeType * createEnumerationType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, DINodeArray Elements, DIType *UnderlyingType, StringRef UniqueIdentifier="", bool IsScoped=false)
Create debugging information entry for an enumeration.
Definition: DIBuilder.cpp:552
llvm::DIBuilder::createClassType
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:490
llvm::DIBuilder::createExpression
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:835
llvm::DIGlobalVariable
Global variables.
Definition: DebugInfoMetadata.h:2952
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::MDNode::replaceWithUniqued
static std::enable_if_t< std::is_base_of< MDNode, T >::value, T * > replaceWithUniqued(std::unique_ptr< T, TempMDNodeDeleter > N)
Replace a temporary node with a uniqued one.
Definition: Metadata.h:1168
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
llvm::DIBuilder::createTemplateTemplateParameter
DITemplateValueParameter * createTemplateTemplateParameter(DIScope *Scope, StringRef Name, DIType *Ty, StringRef Val)
Create debugging information for a template template parameter.
Definition: DIBuilder.cpp:475
llvm::DenseMap
Definition: DenseMap.h:714
DebugInfo.h
llvm::DICompileUnit::getEnumTypes
DICompositeTypeArray getEnumTypes() const
Definition: DebugInfoMetadata.h:1499
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::DICompileUnit::replaceGlobalVariables
void replaceGlobalVariables(DIGlobalVariableExpressionArray N)
Definition: DebugInfoMetadata.h:1546
llvm::DIBuilder::createMemberPointerType
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:330
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:447
DIBuilder.h
llvm::DICompileUnit
Compile unit.
Definition: DebugInfoMetadata.h:1360
llvm::DIImportedEntity
An imported module (C++ using directive or similar).
Definition: DebugInfoMetadata.h:3331
getSubprogram
static DISubprogram * getSubprogram(bool IsDistinct, Ts &&...Args)
Definition: DIBuilder.cpp:840
llvm::MDString::get
static MDString * get(LLVMContext &Context, StringRef Str)
Definition: Metadata.cpp:498
llvm::DIMacroFile
Definition: DebugInfoMetadata.h:3537
llvm::DIBuilder::createArtificialSubprogram
static DISubprogram * createArtificialSubprogram(DISubprogram *SP)
Create a distinct clone of SP with FlagArtificial set.
Definition: DIBuilder.cpp:611
IRBuilder.h
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::MDTuple::get
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1357
checkGlobalVariableScope
static void checkGlobalVariableScope(DIScope *Context)
Definition: DIBuilder.cpp:729
llvm::DIBuilder::createLabel
DILabel * createLabel(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, bool AlwaysPreserve=false)
Create a new descriptor for an label.
Definition: DIBuilder.cpp:817
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::MDNode
Metadata node.
Definition: Metadata.h:944
llvm::DIBuilder::createImportedDeclaration
DIImportedEntity * createImportedDeclaration(DIScope *Context, DINode *Decl, DIFile *File, unsigned Line, StringRef Name="", DINodeArray Elements=nullptr)
Create a descriptor for an imported function.
Definition: DIBuilder.cpp:221
Builder
assume Assume Builder
Definition: AssumeBundleBuilder.cpp:651
llvm::DIBasicType
Basic type, like 'int' or 'float'.
Definition: DebugInfoMetadata.h:802
llvm::APInt
Class for arbitrary precision integers.
Definition: APInt.h:75
llvm::DISubroutineType
Type array for a subprogram.
Definition: DebugInfoMetadata.h:1303
llvm::DICompositeType
Composite types.
Definition: DebugInfoMetadata.h:1080
llvm::DIBuilder::createImportedModule
DIImportedEntity * createImportedModule(DIScope *Context, DINamespace *NS, DIFile *File, unsigned Line, DINodeArray Elements=nullptr)
Create a descriptor for an imported module.
Definition: DIBuilder.cpp:194
llvm::Sched::Source
@ Source
Definition: TargetLowering.h:99
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::DIBuilder::createLexicalBlockFile
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:933
llvm::DICompileUnit::DebugNameTableKind
DebugNameTableKind
Definition: DebugInfoMetadata.h:1373
llvm::DIBuilder::createVariantMemberType
DIDerivedType * createVariantMemberType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, Constant *Discriminant, DINode::DIFlags Flags, DIType *Ty)
Create debugging information entry for a variant.
Definition: DIBuilder.cpp:395
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Dwarf.h
llvm::DINode
Tagged DWARF-like metadata node.
Definition: DebugInfoMetadata.h:131
uint32_t
llvm::Value::getContext
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:994
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::DbgAssignIntrinsic
This represents the llvm.dbg.assign instruction.
Definition: IntrinsicInst.h:411
CC
auto CC
Definition: RISCVRedundantCopyElimination.cpp:79
llvm::dwarf::DW_MACINFO_define
@ DW_MACINFO_define
Definition: Dwarf.h:386
llvm::MDTuple::getTemporary
static TempMDTuple getTemporary(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Return a temporary node.
Definition: Metadata.h:1377
llvm::DIVariable
Base class for variables.
Definition: DebugInfoMetadata.h:2530
llvm::MDNode::getDistinct
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1408
llvm::DIBuilder::getOrCreateGenericSubrange
DIGenericSubrange * getOrCreateGenericSubrange(DIGenericSubrange::BoundType Count, DIGenericSubrange::BoundType LowerBound, DIGenericSubrange::BoundType UpperBound, DIGenericSubrange::BoundType Stride)
Definition: DIBuilder.cpp:717
llvm::DIBuilder::createLexicalBlock
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:939
llvm::PointerUnion
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
Definition: PointerUnion.h:112
llvm::DIBuilder::createTemplateTypeParameter
DITemplateTypeParameter * createTemplateTypeParameter(DIScope *Scope, StringRef Name, DIType *Ty, bool IsDefault)
Create debugging information for template type parameter.
Definition: DIBuilder.cpp:451
llvm::DIBuilder::createInheritance
DIDerivedType * createInheritance(DIType *Ty, DIType *BaseTy, uint64_t BaseOffset, uint32_t VBPtrOffset, DINode::DIFlags Flags)
Create debugging information entry to establish inheritance relationship between two types.
Definition: DIBuilder.cpp:367
llvm::DIBuilder::createCompileUnit
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, DICompileUnit::DebugNameTableKind NameTableKind=DICompileUnit::DebugNameTableKind::Default, bool RangesBaseAddress=false, StringRef SysRoot={}, StringRef SDK={})
A CompileUnit provides an anchor for all debugging information generated during this instance of comp...
Definition: DIBuilder.cpp:151
llvm::ConstantAsMetadata
Definition: Metadata.h:413
llvm::DIBuilder::createNameSpace
DINamespace * createNameSpace(DIScope *Scope, StringRef Name, bool ExportSymbols)
This creates new descriptor for a namespace with the specified parent scope.
Definition: DIBuilder.cpp:912
llvm::DIBuilder::createStructType
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:507
llvm::Type::getInt64Ty
static IntegerType * getInt64Ty(LLVMContext &C)
Definition: Type.cpp:240
llvm::DILabel::getScope
DILocalScope * getScope() const
Get the local scope for this label.
Definition: DebugInfoMetadata.h:3226
llvm::None
constexpr std::nullopt_t None
Definition: None.h:27
llvm::DIBuilder::createUnspecifiedType
DIBasicType * createUnspecifiedType(StringRef Name)
Create a DWARF unspecified type.
Definition: DIBuilder.cpp:274
llvm::DIScope
Base class for scope-like contexts.
Definition: DebugInfoMetadata.h:509
llvm::DIBuilder::createObjCIVar
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:432
llvm::MetadataAsValue::get
static MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
Definition: Metadata.cpp:103
llvm::ConstantInt::getSigned
static ConstantInt * getSigned(IntegerType *Ty, int64_t V)
Return a ConstantInt with the specified value for the specified type.
Definition: Constants.cpp:893
llvm::dwarf::DW_MACINFO_start_file
@ DW_MACINFO_start_file
Definition: Dwarf.h:388
llvm::DIBuilder::createVectorType
DICompositeType * createVectorType(uint64_t Size, uint32_t AlignInBits, DIType *Ty, DINodeArray Subscripts)
Create debugging information entry for a vector type.
Definition: DIBuilder.cpp:601
llvm::DIBuilder::getOrCreateArray
DINodeArray getOrCreateArray(ArrayRef< Metadata * > Elements)
Get a DINodeArray, create one if required.
Definition: DIBuilder.cpp:678
llvm::Module::getOrInsertNamedMetadata
NamedMDNode * getOrInsertNamedMetadata(StringRef Name)
Return the named MDNode in the module with the specified name.
Definition: Module.cpp:261
llvm::dwarf::DW_MACINFO_undef
@ DW_MACINFO_undef
Definition: Dwarf.h:387
llvm::DIBuilder::createParameterVariable
DILocalVariable * createParameterVariable(DIScope *Scope, StringRef Name, unsigned ArgNo, DIFile *File, unsigned LineNo, DIType *Ty, bool AlwaysPreserve=false, DINode::DIFlags Flags=DINode::FlagZero, DINodeArray Annotations=nullptr)
Create a new descriptor for a parameter variable.
Definition: DIBuilder.cpp:807
llvm::DICompileUnit::getRetainedTypes
DIScopeArray getRetainedTypes() const
Definition: DebugInfoMetadata.h:1502
llvm::DIBuilder::createGlobalVariableExpression
DIGlobalVariableExpression * createGlobalVariableExpression(DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DIType *Ty, bool IsLocalToUnit, bool isDefined=true, DIExpression *Expr=nullptr, MDNode *Decl=nullptr, MDTuple *TemplateParams=nullptr, uint32_t AlignInBits=0, DINodeArray Annotations=nullptr)
Create a new descriptor for the specified variable.
Definition: DIBuilder.cpp:738
llvm::DIDerivedType
Derived types.
Definition: DebugInfoMetadata.h:962
llvm::DIGlobalVariableExpression
A pair of DIGlobalVariable and DIExpression.
Definition: DebugInfoMetadata.h:3396
llvm::DIBuilder::createTemplateValueParameter
DITemplateValueParameter * createTemplateValueParameter(DIScope *Scope, StringRef Name, DIType *Ty, bool IsDefault, Constant *Val)
Create debugging information for template value parameter.
Definition: DIBuilder.cpp:466
llvm::MDNode::replaceWithDistinct
static std::enable_if_t< std::is_base_of< MDNode, T >::value, T * > replaceWithDistinct(std::unique_ptr< T, TempMDNodeDeleter > N)
Replace a temporary node with a distinct one.
Definition: Metadata.h:1178
llvm::DITemplateValueParameter
Definition: DebugInfoMetadata.h:2480
llvm::DIBuilder::createFunction
DISubprogram * createFunction(DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned LineNo, DISubroutineType *Ty, unsigned ScopeLine, DINode::DIFlags Flags=DINode::FlagZero, DISubprogram::DISPFlags SPFlags=DISubprogram::SPFlagZero, DITemplateParameterArray TParams=nullptr, DISubprogram *Decl=nullptr, DITypeArray ThrownTypes=nullptr, DINodeArray Annotations=nullptr, StringRef TargetFuncName="")
Create a new descriptor for the specified subprogram.
Definition: DIBuilder.cpp:846
llvm::MDNode::isTemporary
bool isTemporary() const
Definition: Metadata.h:1128
llvm::DIBuilder::createNullPtrType
DIBasicType * createNullPtrType()
Create C++11 nullptr type.
Definition: DIBuilder.cpp:279
llvm::TypedTrackingMDRef
Typed tracking ref.
Definition: TrackingMDRef.h:106
llvm::DIBuilder::getOrCreateSubrange
DISubrange * getOrCreateSubrange(int64_t Lo, int64_t Count)
Create a descriptor for a value range.
Definition: DIBuilder.cpp:698
llvm::DIBuilder::getOrCreateMacroArray
DIMacroNodeArray getOrCreateMacroArray(ArrayRef< Metadata * > Elements)
Get a DIMacroNodeArray, create one if required.
Definition: DIBuilder.cpp:683
llvm::DINode::DIFlags
DIFlags
Debug info flags.
Definition: DebugInfoMetadata.h:170
N
#define N
llvm::Instruction::getParent
const BasicBlock * getParent() const
Definition: Instruction.h:91
llvm::BasicBlock::getTerminator
const Instruction * 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.h:119
llvm::DISubprogram
Subprogram description.
Definition: DebugInfoMetadata.h:1841
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
llvm::DIModule
Represents a module in the programming language, for example, a Clang module, or a Fortran module.
Definition: DebugInfoMetadata.h:2345
llvm::IntegerType::get
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition: Type.cpp:311
UseDbgAddr
static cl::opt< bool > UseDbgAddr("use-dbg-addr", llvm::cl::desc("Use llvm.dbg.addr for all local variables"), cl::init(false), cl::Hidden)
llvm::DILabel
Label.
Definition: DebugInfoMetadata.h:3186
llvm::DIBuilder::createBasicType
DIBasicType * createBasicType(StringRef Name, uint64_t SizeInBits, unsigned Encoding, DINode::DIFlags Flags=DINode::FlagZero)
Create debugging information entry for a basic type.
Definition: DIBuilder.cpp:283
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:394
llvm::cl::desc
Definition: CommandLine.h:413
llvm::DICompileUnit::getImportedEntities
DIImportedEntityArray getImportedEntities() const
Definition: DebugInfoMetadata.h:1508
llvm::DIType::isArtificial
bool isArtificial() const
Definition: DebugInfoMetadata.h:766
getDbgIntrinsicValueImpl
static Value * getDbgIntrinsicValueImpl(LLVMContext &VMContext, Value *V)
Definition: DIBuilder.cpp:1052
llvm::DIType::isObjectPointer
bool isObjectPointer() const
Definition: DebugInfoMetadata.h:767
CU
Definition: AArch64AsmBackend.cpp:504
llvm::DICompileUnit::replaceMacros
void replaceMacros(DIMacroNodeArray N)
Definition: DebugInfoMetadata.h:1552
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::MDOperand
Tracking metadata reference owned by Metadata.
Definition: Metadata.h:773
llvm::DIBuilder::createUnspecifiedParameter
DIBasicType * createUnspecifiedParameter()
Create unspecified parameter type for a subroutine type.
Definition: DIBuilder.cpp:645
llvm::sampleprof::Base
@ Base
Definition: Discriminator.h:58
llvm::DIFile
File.
Definition: DebugInfoMetadata.h:563
llvm::SmallVectorImpl::emplace_back
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:941
llvm::SmallPtrSetImpl::insert
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:365