LLVM 20.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/APInt.h"
16#include "llvm/ADT/APSInt.h"
18#include "llvm/IR/Constants.h"
19#include "llvm/IR/DebugInfo.h"
20#include "llvm/IR/IRBuilder.h"
21#include "llvm/IR/Module.h"
22#include <optional>
23
24using namespace llvm;
25using namespace llvm::dwarf;
26
27DIBuilder::DIBuilder(Module &m, bool AllowUnresolvedNodes, DICompileUnit *CU)
28 : M(m), VMContext(M.getContext()), CUNode(CU), DeclareFn(nullptr),
29 ValueFn(nullptr), LabelFn(nullptr), AssignFn(nullptr),
30 AllowUnresolvedNodes(AllowUnresolvedNodes) {
31 if (CUNode) {
32 if (const auto &ETs = CUNode->getEnumTypes())
33 AllEnumTypes.assign(ETs.begin(), ETs.end());
34 if (const auto &RTs = CUNode->getRetainedTypes())
35 AllRetainTypes.assign(RTs.begin(), RTs.end());
36 if (const auto &GVs = CUNode->getGlobalVariables())
37 AllGVs.assign(GVs.begin(), GVs.end());
38 if (const auto &IMs = CUNode->getImportedEntities())
39 ImportedModules.assign(IMs.begin(), IMs.end());
40 if (const auto &MNs = CUNode->getMacros())
41 AllMacrosPerParent.insert({nullptr, {MNs.begin(), MNs.end()}});
42 }
43}
44
45void DIBuilder::trackIfUnresolved(MDNode *N) {
46 if (!N)
47 return;
48 if (N->isResolved())
49 return;
50
51 assert(AllowUnresolvedNodes && "Cannot handle unresolved nodes");
52 UnresolvedNodes.emplace_back(N);
53}
54
56 auto PN = SubprogramTrackedNodes.find(SP);
57 if (PN != SubprogramTrackedNodes.end())
58 SP->replaceRetainedNodes(
59 MDTuple::get(VMContext, SmallVector<Metadata *, 16>(PN->second.begin(),
60 PN->second.end())));
61}
62
64 if (!CUNode) {
65 assert(!AllowUnresolvedNodes &&
66 "creating type nodes without a CU is not supported");
67 return;
68 }
69
70 if (!AllEnumTypes.empty())
72 VMContext, SmallVector<Metadata *, 16>(AllEnumTypes.begin(),
73 AllEnumTypes.end())));
74
75 SmallVector<Metadata *, 16> RetainValues;
76 // Declarations and definitions of the same type may be retained. Some
77 // clients RAUW these pairs, leaving duplicates in the retained types
78 // list. Use a set to remove the duplicates while we transform the
79 // TrackingVHs back into Values.
81 for (const TrackingMDNodeRef &N : AllRetainTypes)
82 if (RetainSet.insert(N).second)
83 RetainValues.push_back(N);
84
85 if (!RetainValues.empty())
86 CUNode->replaceRetainedTypes(MDTuple::get(VMContext, RetainValues));
87
88 for (auto *SP : AllSubprograms)
90 for (auto *N : RetainValues)
91 if (auto *SP = dyn_cast<DISubprogram>(N))
93
94 if (!AllGVs.empty())
95 CUNode->replaceGlobalVariables(MDTuple::get(VMContext, AllGVs));
96
97 if (!ImportedModules.empty())
99 VMContext, SmallVector<Metadata *, 16>(ImportedModules.begin(),
100 ImportedModules.end())));
101
102 for (const auto &I : AllMacrosPerParent) {
103 // DIMacroNode's with nullptr parent are DICompileUnit direct children.
104 if (!I.first) {
105 CUNode->replaceMacros(MDTuple::get(VMContext, I.second.getArrayRef()));
106 continue;
107 }
108 // Otherwise, it must be a temporary DIMacroFile that need to be resolved.
109 auto *TMF = cast<DIMacroFile>(I.first);
111 TMF->getLine(), TMF->getFile(),
112 getOrCreateMacroArray(I.second.getArrayRef()));
113 replaceTemporary(llvm::TempDIMacroNode(TMF), MF);
114 }
115
116 // Now that all temp nodes have been replaced or deleted, resolve remaining
117 // cycles.
118 for (const auto &N : UnresolvedNodes)
119 if (N && !N->isResolved())
120 N->resolveCycles();
121 UnresolvedNodes.clear();
122
123 // Can't handle unresolved nodes anymore.
124 AllowUnresolvedNodes = false;
125}
126
127/// If N is compile unit return NULL otherwise return N.
129 if (!N || isa<DICompileUnit>(N))
130 return nullptr;
131 return cast<DIScope>(N);
132}
133
135 unsigned Lang, DIFile *File, StringRef Producer, bool isOptimized,
136 StringRef Flags, unsigned RunTimeVer, StringRef SplitName,
138 bool SplitDebugInlining, bool DebugInfoForProfiling,
139 DICompileUnit::DebugNameTableKind NameTableKind, bool RangesBaseAddress,
140 StringRef SysRoot, StringRef SDK) {
141
142 assert(((Lang <= dwarf::DW_LANG_Metal && Lang >= dwarf::DW_LANG_C89) ||
143 (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) &&
144 "Invalid Language tag");
145
146 assert(!CUNode && "Can only make one compile unit per DIBuilder instance");
148 VMContext, Lang, File, Producer, isOptimized, Flags, RunTimeVer,
149 SplitName, Kind, nullptr, nullptr, nullptr, nullptr, nullptr, DWOId,
150 SplitDebugInlining, DebugInfoForProfiling, NameTableKind,
151 RangesBaseAddress, SysRoot, SDK);
152
153 // Create a named metadata so that it is easier to find cu in a module.
154 NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
155 NMD->addOperand(CUNode);
156 trackIfUnresolved(CUNode);
157 return CUNode;
158}
159
160static DIImportedEntity *
162 Metadata *NS, DIFile *File, unsigned Line, StringRef Name,
163 DINodeArray Elements,
164 SmallVectorImpl<TrackingMDNodeRef> &ImportedModules) {
165 if (Line)
166 assert(File && "Source location has line number but no file");
167 unsigned EntitiesCount = C.pImpl->DIImportedEntitys.size();
168 auto *M = DIImportedEntity::get(C, Tag, Context, cast_or_null<DINode>(NS),
169 File, Line, Name, Elements);
170 if (EntitiesCount < C.pImpl->DIImportedEntitys.size())
171 // A new Imported Entity was just added to the context.
172 // Add it to the Imported Modules list.
173 ImportedModules.emplace_back(M);
174 return M;
175}
176
178 DINamespace *NS, DIFile *File,
179 unsigned Line,
180 DINodeArray Elements) {
181 return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
182 Context, NS, File, Line, StringRef(), Elements,
183 getImportTrackingVector(Context));
184}
185
188 DIFile *File, unsigned Line,
189 DINodeArray Elements) {
190 return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
191 Context, NS, File, Line, StringRef(), Elements,
192 getImportTrackingVector(Context));
193}
194
196 DIFile *File, unsigned Line,
197 DINodeArray Elements) {
198 return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
199 Context, M, File, Line, StringRef(), Elements,
200 getImportTrackingVector(Context));
201}
202
205 DIFile *File, unsigned Line,
206 StringRef Name, DINodeArray Elements) {
207 // Make sure to use the unique identifier based metadata reference for
208 // types that have one.
209 return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_declaration,
210 Context, Decl, File, Line, Name, Elements,
211 getImportTrackingVector(Context));
212}
213
215 std::optional<DIFile::ChecksumInfo<StringRef>> CS,
216 std::optional<StringRef> Source) {
217 return DIFile::get(VMContext, Filename, Directory, CS, Source);
218}
219
220DIMacro *DIBuilder::createMacro(DIMacroFile *Parent, unsigned LineNumber,
221 unsigned MacroType, StringRef Name,
223 assert(!Name.empty() && "Unable to create macro without name");
224 assert((MacroType == dwarf::DW_MACINFO_undef ||
225 MacroType == dwarf::DW_MACINFO_define) &&
226 "Unexpected macro type");
227 auto *M = DIMacro::get(VMContext, MacroType, LineNumber, Name, Value);
228 AllMacrosPerParent[Parent].insert(M);
229 return M;
230}
231
233 unsigned LineNumber, DIFile *File) {
235 LineNumber, File, DIMacroNodeArray())
236 .release();
237 AllMacrosPerParent[Parent].insert(MF);
238 // Add the new temporary DIMacroFile to the macro per parent map as a parent.
239 // This is needed to assure DIMacroFile with no children to have an entry in
240 // the map. Otherwise, it will not be resolved in DIBuilder::finalize().
241 AllMacrosPerParent.insert({MF, {}});
242 return MF;
243}
244
246 bool IsUnsigned) {
247 assert(!Name.empty() && "Unable to create enumerator without name");
248 return DIEnumerator::get(VMContext, APInt(64, Val, !IsUnsigned), IsUnsigned,
249 Name);
250}
251
253 assert(!Name.empty() && "Unable to create enumerator without name");
254 return DIEnumerator::get(VMContext, APInt(Value), Value.isUnsigned(), Name);
255}
256
258 assert(!Name.empty() && "Unable to create type without name");
259 return DIBasicType::get(VMContext, dwarf::DW_TAG_unspecified_type, Name);
260}
261
263 return createUnspecifiedType("decltype(nullptr)");
264}
265
267 unsigned Encoding,
268 DINode::DIFlags Flags,
269 uint32_t NumExtraInhabitants) {
270 assert(!Name.empty() && "Unable to create type without name");
271 return DIBasicType::get(VMContext, dwarf::DW_TAG_base_type, Name, SizeInBits,
272 0, Encoding, NumExtraInhabitants, Flags);
273}
274
276 assert(!Name.empty() && "Unable to create type without name");
277 return DIStringType::get(VMContext, dwarf::DW_TAG_string_type, Name,
278 SizeInBits, 0);
279}
280
282 DIVariable *StringLength,
283 DIExpression *StrLocationExp) {
284 assert(!Name.empty() && "Unable to create type without name");
285 return DIStringType::get(VMContext, dwarf::DW_TAG_string_type, Name,
286 StringLength, nullptr, StrLocationExp, 0, 0, 0);
287}
288
290 DIExpression *StringLengthExp,
291 DIExpression *StrLocationExp) {
292 assert(!Name.empty() && "Unable to create type without name");
293 return DIStringType::get(VMContext, dwarf::DW_TAG_string_type, Name, nullptr,
294 StringLengthExp, StrLocationExp, 0, 0, 0);
295}
296
298 return DIDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr, FromTy, 0,
299 0, 0, std::nullopt, std::nullopt, DINode::FlagZero);
300}
301
303 DIType *FromTy, unsigned Key, bool IsAddressDiscriminated,
304 unsigned ExtraDiscriminator, bool IsaPointer,
305 bool AuthenticatesNullValues) {
306 return DIDerivedType::get(VMContext, dwarf::DW_TAG_LLVM_ptrauth_type, "",
307 nullptr, 0, nullptr, FromTy, 0, 0, 0, std::nullopt,
308 std::optional<DIDerivedType::PtrAuthData>(
309 std::in_place, Key, IsAddressDiscriminated,
310 ExtraDiscriminator, IsaPointer,
311 AuthenticatesNullValues),
312 DINode::FlagZero);
313}
314
317 uint32_t AlignInBits,
318 std::optional<unsigned> DWARFAddressSpace,
319 StringRef Name, DINodeArray Annotations) {
320 // FIXME: Why is there a name here?
321 return DIDerivedType::get(VMContext, dwarf::DW_TAG_pointer_type, Name,
322 nullptr, 0, nullptr, PointeeTy, SizeInBits,
323 AlignInBits, 0, DWARFAddressSpace, std::nullopt,
324 DINode::FlagZero, nullptr, Annotations);
325}
326
328 DIType *Base,
329 uint64_t SizeInBits,
330 uint32_t AlignInBits,
331 DINode::DIFlags Flags) {
332 return DIDerivedType::get(VMContext, dwarf::DW_TAG_ptr_to_member_type, "",
333 nullptr, 0, nullptr, PointeeTy, SizeInBits,
334 AlignInBits, 0, std::nullopt, std::nullopt, Flags,
335 Base);
336}
337
340 uint32_t AlignInBits,
341 std::optional<unsigned> DWARFAddressSpace) {
342 assert(RTy && "Unable to create reference type");
343 return DIDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr, RTy,
344 SizeInBits, AlignInBits, 0, DWARFAddressSpace, {},
345 DINode::FlagZero);
346}
347
349 DIFile *File, unsigned LineNo,
350 DIScope *Context, uint32_t AlignInBits,
351 DINode::DIFlags Flags,
352 DINodeArray Annotations) {
353 return DIDerivedType::get(VMContext, dwarf::DW_TAG_typedef, Name, File,
354 LineNo, getNonCompileUnitScope(Context), Ty, 0,
355 AlignInBits, 0, std::nullopt, std::nullopt, Flags,
356 nullptr, Annotations);
357}
358
361 unsigned LineNo, DIScope *Context,
362 DINodeArray TParams, uint32_t AlignInBits,
363 DINode::DIFlags Flags, DINodeArray Annotations) {
364 return DIDerivedType::get(VMContext, dwarf::DW_TAG_template_alias, Name, File,
365 LineNo, getNonCompileUnitScope(Context), Ty, 0,
366 AlignInBits, 0, std::nullopt, std::nullopt, Flags,
367 TParams.get(), Annotations);
368}
369
371 assert(Ty && "Invalid type!");
372 assert(FriendTy && "Invalid friend type!");
373 return DIDerivedType::get(VMContext, dwarf::DW_TAG_friend, "", nullptr, 0, Ty,
374 FriendTy, 0, 0, 0, std::nullopt, std::nullopt,
375 DINode::FlagZero);
376}
377
379 uint64_t BaseOffset,
380 uint32_t VBPtrOffset,
381 DINode::DIFlags Flags) {
382 assert(Ty && "Unable to create inheritance");
384 ConstantInt::get(IntegerType::get(VMContext, 32), VBPtrOffset));
385 return DIDerivedType::get(VMContext, dwarf::DW_TAG_inheritance, "", nullptr,
386 0, Ty, BaseTy, 0, 0, BaseOffset, std::nullopt,
387 std::nullopt, Flags, ExtraData);
388}
389
391 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
392 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
393 DINode::DIFlags Flags, DIType *Ty, DINodeArray Annotations) {
394 return DIDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File,
395 LineNumber, getNonCompileUnitScope(Scope), Ty,
396 SizeInBits, AlignInBits, OffsetInBits, std::nullopt,
397 std::nullopt, Flags, nullptr, Annotations);
398}
399
401 if (C)
403 return nullptr;
404}
405
407 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
408 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
409 Constant *Discriminant, DINode::DIFlags Flags, DIType *Ty) {
410 return DIDerivedType::get(
411 VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
412 getNonCompileUnitScope(Scope), Ty, SizeInBits, AlignInBits, OffsetInBits,
413 std::nullopt, std::nullopt, Flags, getConstantOrNull(Discriminant));
414}
415
417 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
418 uint64_t SizeInBits, uint64_t OffsetInBits, uint64_t StorageOffsetInBits,
419 DINode::DIFlags Flags, DIType *Ty, DINodeArray Annotations) {
420 Flags |= DINode::FlagBitField;
421 return DIDerivedType::get(
422 VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
423 getNonCompileUnitScope(Scope), Ty, SizeInBits, /*AlignInBits=*/0,
424 OffsetInBits, std::nullopt, std::nullopt, Flags,
425 ConstantAsMetadata::get(ConstantInt::get(IntegerType::get(VMContext, 64),
426 StorageOffsetInBits)),
428}
429
432 unsigned LineNumber, DIType *Ty,
434 unsigned Tag, uint32_t AlignInBits) {
435 Flags |= DINode::FlagStaticMember;
436 return DIDerivedType::get(VMContext, Tag, Name, File, LineNumber,
437 getNonCompileUnitScope(Scope), Ty, 0, AlignInBits,
438 0, std::nullopt, std::nullopt, Flags,
439 getConstantOrNull(Val));
440}
441
443DIBuilder::createObjCIVar(StringRef Name, DIFile *File, unsigned LineNumber,
444 uint64_t SizeInBits, uint32_t AlignInBits,
445 uint64_t OffsetInBits, DINode::DIFlags Flags,
446 DIType *Ty, MDNode *PropertyNode) {
447 return DIDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File,
448 LineNumber, getNonCompileUnitScope(File), Ty,
449 SizeInBits, AlignInBits, OffsetInBits, std::nullopt,
450 std::nullopt, Flags, PropertyNode);
451}
452
455 StringRef GetterName, StringRef SetterName,
456 unsigned PropertyAttributes, DIType *Ty) {
457 return DIObjCProperty::get(VMContext, Name, File, LineNumber, GetterName,
458 SetterName, PropertyAttributes, Ty);
459}
460
463 DIType *Ty, bool isDefault) {
464 assert((!Context || isa<DICompileUnit>(Context)) && "Expected compile unit");
465 return DITemplateTypeParameter::get(VMContext, Name, Ty, isDefault);
466}
467
470 DIScope *Context, StringRef Name, DIType *Ty,
471 bool IsDefault, Metadata *MD) {
472 assert((!Context || isa<DICompileUnit>(Context)) && "Expected compile unit");
473 return DITemplateValueParameter::get(VMContext, Tag, Name, Ty, IsDefault, MD);
474}
475
478 DIType *Ty, bool isDefault,
479 Constant *Val) {
481 VMContext, dwarf::DW_TAG_template_value_parameter, Context, Name, Ty,
482 isDefault, getConstantOrNull(Val));
483}
484
487 DIType *Ty, StringRef Val,
488 bool IsDefault) {
490 VMContext, dwarf::DW_TAG_GNU_template_template_param, Context, Name, Ty,
491 IsDefault, MDString::get(VMContext, Val));
492}
493
496 DIType *Ty, DINodeArray Val) {
498 VMContext, dwarf::DW_TAG_GNU_template_parameter_pack, Context, Name, Ty,
499 false, Val.get());
500}
501
503 DIScope *Context, StringRef Name, DIFile *File, unsigned LineNumber,
504 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
505 DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements,
506 unsigned RunTimeLang, DIType *VTableHolder, MDNode *TemplateParams,
507 StringRef UniqueIdentifier) {
508 assert((!Context || isa<DIScope>(Context)) &&
509 "createClassType should be called with a valid Context");
510
511 auto *R = DICompositeType::get(
512 VMContext, dwarf::DW_TAG_class_type, Name, File, LineNumber,
513 getNonCompileUnitScope(Context), DerivedFrom, SizeInBits, AlignInBits,
514 OffsetInBits, Flags, Elements, RunTimeLang, VTableHolder,
515 cast_or_null<MDTuple>(TemplateParams), UniqueIdentifier);
516 trackIfUnresolved(R);
517 return R;
518}
519
521 DIScope *Context, StringRef Name, DIFile *File, unsigned LineNumber,
522 uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags,
523 DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang,
524 DIType *VTableHolder, StringRef UniqueIdentifier, DIType *Specification,
525 uint32_t NumExtraInhabitants) {
526 auto *R = DICompositeType::get(
527 VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber,
528 getNonCompileUnitScope(Context), DerivedFrom, SizeInBits, AlignInBits, 0,
529 Flags, Elements, RunTimeLang, VTableHolder, nullptr, UniqueIdentifier,
530 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, Specification,
531 NumExtraInhabitants);
532 trackIfUnresolved(R);
533 return R;
534}
535
537 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
538 uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags,
539 DINodeArray Elements, unsigned RunTimeLang, StringRef UniqueIdentifier) {
540 auto *R = DICompositeType::get(
541 VMContext, dwarf::DW_TAG_union_type, Name, File, LineNumber,
542 getNonCompileUnitScope(Scope), nullptr, SizeInBits, AlignInBits, 0, Flags,
543 Elements, RunTimeLang, nullptr, nullptr, UniqueIdentifier);
544 trackIfUnresolved(R);
545 return R;
546}
547
550 unsigned LineNumber, uint64_t SizeInBits,
551 uint32_t AlignInBits, DINode::DIFlags Flags,
552 DIDerivedType *Discriminator, DINodeArray Elements,
553 StringRef UniqueIdentifier) {
554 auto *R = DICompositeType::get(
555 VMContext, dwarf::DW_TAG_variant_part, Name, File, LineNumber,
556 getNonCompileUnitScope(Scope), nullptr, SizeInBits, AlignInBits, 0, Flags,
557 Elements, 0, nullptr, nullptr, UniqueIdentifier, Discriminator);
558 trackIfUnresolved(R);
559 return R;
560}
561
563 DINode::DIFlags Flags,
564 unsigned CC) {
565 return DISubroutineType::get(VMContext, Flags, CC, ParameterTypes);
566}
567
570 unsigned LineNumber, uint64_t SizeInBits,
571 uint32_t AlignInBits, DINodeArray Elements,
572 DIType *UnderlyingType, unsigned RunTimeLang,
573 StringRef UniqueIdentifier, bool IsScoped) {
574 auto *CTy = DICompositeType::get(
575 VMContext, dwarf::DW_TAG_enumeration_type, Name, File, LineNumber,
576 getNonCompileUnitScope(Scope), UnderlyingType, SizeInBits, AlignInBits, 0,
577 IsScoped ? DINode::FlagEnumClass : DINode::FlagZero, Elements,
578 RunTimeLang, nullptr, nullptr, UniqueIdentifier);
579 AllEnumTypes.emplace_back(CTy);
580 trackIfUnresolved(CTy);
581 return CTy;
582}
583
585 DIFile *File, unsigned LineNo,
586 uint64_t SizeInBits,
587 uint32_t AlignInBits, DIType *Ty) {
588 auto *R = DIDerivedType::get(VMContext, dwarf::DW_TAG_set_type, Name, File,
589 LineNo, getNonCompileUnitScope(Scope), Ty,
590 SizeInBits, AlignInBits, 0, std::nullopt,
591 std::nullopt, DINode::FlagZero);
592 trackIfUnresolved(R);
593 return R;
594}
595
598 DINodeArray Subscripts,
603 auto *R = DICompositeType::get(
604 VMContext, dwarf::DW_TAG_array_type, "", nullptr, 0, nullptr, Ty, Size,
605 AlignInBits, 0, DINode::FlagZero, Subscripts, 0, nullptr, nullptr, "",
606 nullptr,
607 isa<DIExpression *>(DL) ? (Metadata *)cast<DIExpression *>(DL)
608 : (Metadata *)cast<DIVariable *>(DL),
609 isa<DIExpression *>(AS) ? (Metadata *)cast<DIExpression *>(AS)
610 : (Metadata *)cast<DIVariable *>(AS),
611 isa<DIExpression *>(AL) ? (Metadata *)cast<DIExpression *>(AL)
612 : (Metadata *)cast<DIVariable *>(AL),
613 isa<DIExpression *>(RK) ? (Metadata *)cast<DIExpression *>(RK)
614 : (Metadata *)cast<DIVariable *>(RK));
615 trackIfUnresolved(R);
616 return R;
617}
618
620 uint32_t AlignInBits, DIType *Ty,
621 DINodeArray Subscripts) {
622 auto *R = DICompositeType::get(VMContext, dwarf::DW_TAG_array_type, "",
623 nullptr, 0, nullptr, Ty, Size, AlignInBits, 0,
624 DINode::FlagVector, Subscripts, 0, nullptr);
625 trackIfUnresolved(R);
626 return R;
627}
628
630 auto NewSP = SP->cloneWithFlags(SP->getFlags() | DINode::FlagArtificial);
631 return MDNode::replaceWithDistinct(std::move(NewSP));
632}
633
635 DINode::DIFlags FlagsToSet) {
636 auto NewTy = Ty->cloneWithFlags(Ty->getFlags() | FlagsToSet);
637 return MDNode::replaceWithUniqued(std::move(NewTy));
638}
639
641 // FIXME: Restrict this to the nodes where it's valid.
642 if (Ty->isArtificial())
643 return Ty;
644 return createTypeWithFlags(Ty, DINode::FlagArtificial);
645}
646
648 // FIXME: Restrict this to the nodes where it's valid.
649 if (Ty->isObjectPointer())
650 return Ty;
651 DINode::DIFlags Flags = DINode::FlagObjectPointer | DINode::FlagArtificial;
652 return createTypeWithFlags(Ty, Flags);
653}
654
656 assert(T && "Expected non-null type");
657 assert((isa<DIType>(T) || (isa<DISubprogram>(T) &&
658 cast<DISubprogram>(T)->isDefinition() == false)) &&
659 "Expected type or subprogram declaration");
660 AllRetainTypes.emplace_back(T);
661}
662
664
667 DIFile *F, unsigned Line, unsigned RuntimeLang,
668 uint64_t SizeInBits, uint32_t AlignInBits,
669 StringRef UniqueIdentifier) {
670 // FIXME: Define in terms of createReplaceableForwardDecl() by calling
671 // replaceWithUniqued().
673 VMContext, Tag, Name, F, Line, getNonCompileUnitScope(Scope), nullptr,
674 SizeInBits, AlignInBits, 0, DINode::FlagFwdDecl, nullptr, RuntimeLang,
675 nullptr, nullptr, UniqueIdentifier);
676 trackIfUnresolved(RetTy);
677 return RetTy;
678}
679
681 unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line,
682 unsigned RuntimeLang, uint64_t SizeInBits, uint32_t AlignInBits,
683 DINode::DIFlags Flags, StringRef UniqueIdentifier,
684 DINodeArray Annotations) {
685 auto *RetTy =
687 VMContext, Tag, Name, F, Line, getNonCompileUnitScope(Scope), nullptr,
688 SizeInBits, AlignInBits, 0, Flags, nullptr, RuntimeLang, nullptr,
689 nullptr, UniqueIdentifier, nullptr, nullptr, nullptr, nullptr,
690 nullptr, Annotations)
691 .release();
692 trackIfUnresolved(RetTy);
693 return RetTy;
694}
695
697 return MDTuple::get(VMContext, Elements);
698}
699
700DIMacroNodeArray
702 return MDTuple::get(VMContext, Elements);
703}
704
707 for (Metadata *E : Elements) {
708 if (isa_and_nonnull<MDNode>(E))
709 Elts.push_back(cast<DIType>(E));
710 else
711 Elts.push_back(E);
712 }
713 return DITypeRefArray(MDNode::get(VMContext, Elts));
714}
715
717 auto *LB = ConstantAsMetadata::get(
719 auto *CountNode = ConstantAsMetadata::get(
720 ConstantInt::getSigned(Type::getInt64Ty(VMContext), Count));
721 return DISubrange::get(VMContext, CountNode, LB, nullptr, nullptr);
722}
723
725 auto *LB = ConstantAsMetadata::get(
727 return DISubrange::get(VMContext, CountNode, LB, nullptr, nullptr);
728}
729
731 Metadata *UB, Metadata *Stride) {
732 return DISubrange::get(VMContext, CountNode, LB, UB, Stride);
733}
734
738 auto ConvToMetadata = [&](DIGenericSubrange::BoundType Bound) -> Metadata * {
739 return isa<DIExpression *>(Bound) ? (Metadata *)cast<DIExpression *>(Bound)
740 : (Metadata *)cast<DIVariable *>(Bound);
741 };
742 return DIGenericSubrange::get(VMContext, ConvToMetadata(CountNode),
743 ConvToMetadata(LB), ConvToMetadata(UB),
744 ConvToMetadata(Stride));
745}
746
747static void checkGlobalVariableScope(DIScope *Context) {
748#ifndef NDEBUG
749 if (auto *CT =
750 dyn_cast_or_null<DICompositeType>(getNonCompileUnitScope(Context)))
751 assert(CT->getIdentifier().empty() &&
752 "Context of a global variable should not be a type with identifier");
753#endif
754}
755
758 unsigned LineNumber, DIType *Ty, bool IsLocalToUnit, bool isDefined,
759 DIExpression *Expr, MDNode *Decl, MDTuple *TemplateParams,
760 uint32_t AlignInBits, DINodeArray Annotations) {
762
764 VMContext, cast_or_null<DIScope>(Context), Name, LinkageName, F,
765 LineNumber, Ty, IsLocalToUnit, isDefined,
766 cast_or_null<DIDerivedType>(Decl), TemplateParams, AlignInBits,
768 if (!Expr)
769 Expr = createExpression();
770 auto *N = DIGlobalVariableExpression::get(VMContext, GV, Expr);
771 AllGVs.push_back(N);
772 return N;
773}
774
777 unsigned LineNumber, DIType *Ty, bool IsLocalToUnit, MDNode *Decl,
778 MDTuple *TemplateParams, uint32_t AlignInBits) {
780
782 VMContext, cast_or_null<DIScope>(Context), Name, LinkageName, F,
783 LineNumber, Ty, IsLocalToUnit, false,
784 cast_or_null<DIDerivedType>(Decl), TemplateParams, AlignInBits,
785 nullptr)
786 .release();
787}
788
790 LLVMContext &VMContext,
792 DIScope *Context, StringRef Name, unsigned ArgNo, DIFile *File,
793 unsigned LineNo, DIType *Ty, bool AlwaysPreserve, DINode::DIFlags Flags,
794 uint32_t AlignInBits, DINodeArray Annotations = nullptr) {
795 // FIXME: Why doesn't this check for a subprogram or lexical block (AFAICT
796 // the only valid scopes)?
797 auto *Scope = cast<DILocalScope>(Context);
798 auto *Node = DILocalVariable::get(VMContext, Scope, Name, File, LineNo, Ty,
799 ArgNo, Flags, AlignInBits, Annotations);
800 if (AlwaysPreserve) {
801 // The optimizer may remove local variables. If there is an interest
802 // to preserve variable info in such situation then stash it in a
803 // named mdnode.
804 PreservedNodes.emplace_back(Node);
805 }
806 return Node;
807}
808
810 DIFile *File, unsigned LineNo,
811 DIType *Ty, bool AlwaysPreserve,
812 DINode::DIFlags Flags,
813 uint32_t AlignInBits) {
814 assert(Scope && isa<DILocalScope>(Scope) &&
815 "Unexpected scope for a local variable.");
816 return createLocalVariable(
817 VMContext, getSubprogramNodesTrackingVector(Scope), Scope, Name,
818 /* ArgNo */ 0, File, LineNo, Ty, AlwaysPreserve, Flags, AlignInBits);
819}
820
822 DIScope *Scope, StringRef Name, unsigned ArgNo, DIFile *File,
823 unsigned LineNo, DIType *Ty, bool AlwaysPreserve, DINode::DIFlags Flags,
824 DINodeArray Annotations) {
825 assert(ArgNo && "Expected non-zero argument number for parameter");
826 assert(Scope && isa<DILocalScope>(Scope) &&
827 "Unexpected scope for a local variable.");
828 return createLocalVariable(
829 VMContext, getSubprogramNodesTrackingVector(Scope), Scope, Name, ArgNo,
830 File, LineNo, Ty, AlwaysPreserve, Flags, /*AlignInBits=*/0, Annotations);
831}
832
834 unsigned LineNo, bool AlwaysPreserve) {
835 auto *Scope = cast<DILocalScope>(Context);
836 auto *Node = DILabel::get(VMContext, Scope, Name, File, LineNo);
837
838 if (AlwaysPreserve) {
839 /// The optimizer may remove labels. If there is an interest
840 /// to preserve label info in such situation then append it to
841 /// the list of retained nodes of the DISubprogram.
842 getSubprogramNodesTrackingVector(Scope).emplace_back(Node);
843 }
844 return Node;
845}
846
848 return DIExpression::get(VMContext, Addr);
849}
850
851template <class... Ts>
852static DISubprogram *getSubprogram(bool IsDistinct, Ts &&...Args) {
853 if (IsDistinct)
854 return DISubprogram::getDistinct(std::forward<Ts>(Args)...);
855 return DISubprogram::get(std::forward<Ts>(Args)...);
856}
857
860 unsigned LineNo, DISubroutineType *Ty, unsigned ScopeLine,
862 DITemplateParameterArray TParams, DISubprogram *Decl,
863 DITypeArray ThrownTypes, DINodeArray Annotations,
864 StringRef TargetFuncName) {
865 bool IsDefinition = SPFlags & DISubprogram::SPFlagDefinition;
866 auto *Node = getSubprogram(
867 /*IsDistinct=*/IsDefinition, VMContext, getNonCompileUnitScope(Context),
868 Name, LinkageName, File, LineNo, Ty, ScopeLine, nullptr, 0, 0, Flags,
869 SPFlags, IsDefinition ? CUNode : nullptr, TParams, Decl, nullptr,
870 ThrownTypes, Annotations, TargetFuncName);
871
872 if (IsDefinition)
873 AllSubprograms.push_back(Node);
874 trackIfUnresolved(Node);
875 return Node;
876}
877
880 unsigned LineNo, DISubroutineType *Ty, unsigned ScopeLine,
882 DITemplateParameterArray TParams, DISubprogram *Decl,
883 DITypeArray ThrownTypes) {
884 bool IsDefinition = SPFlags & DISubprogram::SPFlagDefinition;
885 return DISubprogram::getTemporary(VMContext, getNonCompileUnitScope(Context),
886 Name, LinkageName, File, LineNo, Ty,
887 ScopeLine, nullptr, 0, 0, Flags, SPFlags,
888 IsDefinition ? CUNode : nullptr, TParams,
889 Decl, nullptr, ThrownTypes)
890 .release();
891}
892
895 unsigned LineNo, DISubroutineType *Ty, unsigned VIndex, int ThisAdjustment,
896 DIType *VTableHolder, DINode::DIFlags Flags,
897 DISubprogram::DISPFlags SPFlags, DITemplateParameterArray TParams,
898 DITypeArray ThrownTypes) {
900 "Methods should have both a Context and a context that isn't "
901 "the compile unit.");
902 // FIXME: Do we want to use different scope/lines?
903 bool IsDefinition = SPFlags & DISubprogram::SPFlagDefinition;
904 auto *SP = getSubprogram(
905 /*IsDistinct=*/IsDefinition, VMContext, cast<DIScope>(Context), Name,
906 LinkageName, F, LineNo, Ty, LineNo, VTableHolder, VIndex, ThisAdjustment,
907 Flags, SPFlags, IsDefinition ? CUNode : nullptr, TParams, nullptr,
908 nullptr, ThrownTypes);
909
910 if (IsDefinition)
911 AllSubprograms.push_back(SP);
912 trackIfUnresolved(SP);
913 return SP;
914}
915
917 DIGlobalVariable *Decl,
918 StringRef Name, DIFile *File,
919 unsigned LineNo) {
920 return DICommonBlock::get(VMContext, Scope, Decl, Name, File, LineNo);
921}
922
924 bool ExportSymbols) {
925
926 // It is okay to *not* make anonymous top-level namespaces distinct, because
927 // all nodes that have an anonymous namespace as their parent scope are
928 // guaranteed to be unique and/or are linked to their containing
929 // DICompileUnit. This decision is an explicit tradeoff of link time versus
930 // memory usage versus code simplicity and may get revisited in the future.
931 return DINamespace::get(VMContext, getNonCompileUnitScope(Scope), Name,
932 ExportSymbols);
933}
934
936 StringRef ConfigurationMacros,
937 StringRef IncludePath, StringRef APINotesFile,
938 DIFile *File, unsigned LineNo, bool IsDecl) {
939 return DIModule::get(VMContext, File, getNonCompileUnitScope(Scope), Name,
940 ConfigurationMacros, IncludePath, APINotesFile, LineNo,
941 IsDecl);
942}
943
945 DIFile *File,
946 unsigned Discriminator) {
947 return DILexicalBlockFile::get(VMContext, Scope, File, Discriminator);
948}
949
951 unsigned Line, unsigned Col) {
952 // Make these distinct, to avoid merging two lexical blocks on the same
953 // file/line/column.
955 File, Line, Col);
956}
957
958DbgInstPtr DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
959 DIExpression *Expr, const DILocation *DL,
960 Instruction *InsertBefore) {
961 return insertDeclare(Storage, VarInfo, Expr, DL, InsertBefore->getParent(),
962 InsertBefore);
963}
964
965DbgInstPtr DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
966 DIExpression *Expr, const DILocation *DL,
967 BasicBlock *InsertAtEnd) {
968 // If this block already has a terminator then insert this intrinsic before
969 // the terminator. Otherwise, put it at the end of the block.
970 Instruction *InsertBefore = InsertAtEnd->getTerminator();
971 return insertDeclare(Storage, VarInfo, Expr, DL, InsertAtEnd, InsertBefore);
972}
973
975 DILocalVariable *SrcVar,
976 DIExpression *ValExpr, Value *Addr,
977 DIExpression *AddrExpr,
978 const DILocation *DL) {
979 auto *Link = cast_or_null<DIAssignID>(
980 LinkedInstr->getMetadata(LLVMContext::MD_DIAssignID));
981 assert(Link && "Linked instruction must have DIAssign metadata attached");
982
983 if (M.IsNewDbgInfoFormat) {
985 Val, SrcVar, ValExpr, Link, Addr, AddrExpr, DL);
986 BasicBlock *InsertBB = LinkedInstr->getParent();
987 // Insert after LinkedInstr.
988 BasicBlock::iterator NextIt = std::next(LinkedInstr->getIterator());
989 Instruction *InsertBefore = NextIt == InsertBB->end() ? nullptr : &*NextIt;
990 insertDbgVariableRecord(DVR, InsertBB, InsertBefore, true);
991 return DVR;
992 }
993
994 LLVMContext &Ctx = LinkedInstr->getContext();
995 Module *M = LinkedInstr->getModule();
996 if (!AssignFn)
997 AssignFn = Intrinsic::getOrInsertDeclaration(M, Intrinsic::dbg_assign);
998
999 std::array<Value *, 6> Args = {
1001 MetadataAsValue::get(Ctx, SrcVar),
1002 MetadataAsValue::get(Ctx, ValExpr),
1003 MetadataAsValue::get(Ctx, Link),
1005 MetadataAsValue::get(Ctx, AddrExpr),
1006 };
1007
1008 IRBuilder<> B(Ctx);
1009 B.SetCurrentDebugLocation(DL);
1010
1011 auto *DVI = cast<DbgAssignIntrinsic>(B.CreateCall(AssignFn, Args));
1012 DVI->insertAfter(LinkedInstr);
1013 return DVI;
1014}
1015
1016DbgInstPtr DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
1017 Instruction *InsertBefore) {
1018 return insertLabel(LabelInfo, DL,
1019 InsertBefore ? InsertBefore->getParent() : nullptr,
1020 InsertBefore);
1021}
1022
1023DbgInstPtr DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
1024 BasicBlock *InsertAtEnd) {
1025 return insertLabel(LabelInfo, DL, InsertAtEnd, nullptr);
1026}
1027
1028DbgInstPtr DIBuilder::insertDbgValueIntrinsic(Value *V,
1029 DILocalVariable *VarInfo,
1030 DIExpression *Expr,
1031 const DILocation *DL,
1032 Instruction *InsertBefore) {
1033 DbgInstPtr DVI = insertDbgValueIntrinsic(
1034 V, VarInfo, Expr, DL, InsertBefore ? InsertBefore->getParent() : nullptr,
1035 InsertBefore);
1036 if (auto *Inst = dyn_cast<Instruction *>(DVI))
1037 cast<CallInst>(Inst)->setTailCall();
1038 return DVI;
1039}
1040
1041DbgInstPtr DIBuilder::insertDbgValueIntrinsic(Value *V,
1042 DILocalVariable *VarInfo,
1043 DIExpression *Expr,
1044 const DILocation *DL,
1045 BasicBlock *InsertAtEnd) {
1046 return insertDbgValueIntrinsic(V, VarInfo, Expr, DL, InsertAtEnd, nullptr);
1047}
1048
1049/// Initialize IRBuilder for inserting dbg.declare and dbg.value intrinsics.
1050/// This abstracts over the various ways to specify an insert position.
1051static void initIRBuilder(IRBuilder<> &Builder, const DILocation *DL,
1052 BasicBlock *InsertBB, Instruction *InsertBefore) {
1053 if (InsertBefore)
1054 Builder.SetInsertPoint(InsertBefore);
1055 else if (InsertBB)
1056 Builder.SetInsertPoint(InsertBB);
1057 Builder.SetCurrentDebugLocation(DL);
1058}
1059
1061 assert(V && "no value passed to dbg intrinsic");
1062 return MetadataAsValue::get(VMContext, ValueAsMetadata::get(V));
1063}
1064
1066 return Intrinsic::getOrInsertDeclaration(&M, Intrinsic::dbg_declare);
1067}
1068
1069DbgInstPtr DIBuilder::insertDbgValueIntrinsic(
1070 llvm::Value *Val, DILocalVariable *VarInfo, DIExpression *Expr,
1071 const DILocation *DL, BasicBlock *InsertBB, Instruction *InsertBefore) {
1072 if (M.IsNewDbgInfoFormat) {
1073 DbgVariableRecord *DVR =
1075 insertDbgVariableRecord(DVR, InsertBB, InsertBefore);
1076 return DVR;
1077 }
1078
1079 if (!ValueFn)
1080 ValueFn = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::dbg_value);
1081 return insertDbgIntrinsic(ValueFn, Val, VarInfo, Expr, DL, InsertBB,
1082 InsertBefore);
1083}
1084
1085DbgInstPtr DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
1086 DIExpression *Expr, const DILocation *DL,
1087 BasicBlock *InsertBB,
1088 Instruction *InsertBefore) {
1089 assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.declare");
1090 assert(DL && "Expected debug loc");
1091 assert(DL->getScope()->getSubprogram() ==
1092 VarInfo->getScope()->getSubprogram() &&
1093 "Expected matching subprograms");
1094
1095 if (M.IsNewDbgInfoFormat) {
1096 DbgVariableRecord *DVR =
1097 DbgVariableRecord::createDVRDeclare(Storage, VarInfo, Expr, DL);
1098 insertDbgVariableRecord(DVR, InsertBB, InsertBefore);
1099 return DVR;
1100 }
1101
1102 if (!DeclareFn)
1103 DeclareFn = getDeclareIntrin(M);
1104
1105 trackIfUnresolved(VarInfo);
1106 trackIfUnresolved(Expr);
1107 Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, Storage),
1108 MetadataAsValue::get(VMContext, VarInfo),
1109 MetadataAsValue::get(VMContext, Expr)};
1110
1111 IRBuilder<> B(DL->getContext());
1112 initIRBuilder(B, DL, InsertBB, InsertBefore);
1113 return B.CreateCall(DeclareFn, Args);
1114}
1115
1116void DIBuilder::insertDbgVariableRecord(DbgVariableRecord *DVR,
1117 BasicBlock *InsertBB,
1118 Instruction *InsertBefore,
1119 bool InsertAtHead) {
1120 assert(InsertBefore || InsertBB);
1121 trackIfUnresolved(DVR->getVariable());
1122 trackIfUnresolved(DVR->getExpression());
1123 if (DVR->isDbgAssign())
1124 trackIfUnresolved(DVR->getAddressExpression());
1125
1126 BasicBlock::iterator InsertPt;
1127 if (InsertBB && InsertBefore)
1128 InsertPt = InsertBefore->getIterator();
1129 else if (InsertBB)
1130 InsertPt = InsertBB->end();
1131 InsertPt.setHeadBit(InsertAtHead);
1132 InsertBB->insertDbgRecordBefore(DVR, InsertPt);
1133}
1134
1135Instruction *DIBuilder::insertDbgIntrinsic(llvm::Function *IntrinsicFn,
1136 Value *V, DILocalVariable *VarInfo,
1137 DIExpression *Expr,
1138 const DILocation *DL,
1139 BasicBlock *InsertBB,
1140 Instruction *InsertBefore) {
1141 assert(IntrinsicFn && "must pass a non-null intrinsic function");
1142 assert(V && "must pass a value to a dbg intrinsic");
1143 assert(VarInfo &&
1144 "empty or invalid DILocalVariable* passed to debug intrinsic");
1145 assert(DL && "Expected debug loc");
1146 assert(DL->getScope()->getSubprogram() ==
1147 VarInfo->getScope()->getSubprogram() &&
1148 "Expected matching subprograms");
1149
1150 trackIfUnresolved(VarInfo);
1151 trackIfUnresolved(Expr);
1152 Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, V),
1153 MetadataAsValue::get(VMContext, VarInfo),
1154 MetadataAsValue::get(VMContext, Expr)};
1155
1156 IRBuilder<> B(DL->getContext());
1157 initIRBuilder(B, DL, InsertBB, InsertBefore);
1158 return B.CreateCall(IntrinsicFn, Args);
1159}
1160
1161DbgInstPtr DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
1162 BasicBlock *InsertBB,
1163 Instruction *InsertBefore) {
1164 assert(LabelInfo && "empty or invalid DILabel* passed to dbg.label");
1165 assert(DL && "Expected debug loc");
1166 assert(DL->getScope()->getSubprogram() ==
1167 LabelInfo->getScope()->getSubprogram() &&
1168 "Expected matching subprograms");
1169
1170 trackIfUnresolved(LabelInfo);
1171 if (M.IsNewDbgInfoFormat) {
1172 DbgLabelRecord *DLR = new DbgLabelRecord(LabelInfo, DL);
1173 if (InsertBB && InsertBefore)
1174 InsertBB->insertDbgRecordBefore(DLR, InsertBefore->getIterator());
1175 else if (InsertBB)
1176 InsertBB->insertDbgRecordBefore(DLR, InsertBB->end());
1177 return DLR;
1178 }
1179
1180 if (!LabelFn)
1181 LabelFn = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::dbg_label);
1182
1183 Value *Args[] = {MetadataAsValue::get(VMContext, LabelInfo)};
1184
1185 IRBuilder<> B(DL->getContext());
1186 initIRBuilder(B, DL, InsertBB, InsertBefore);
1187 return B.CreateCall(LabelFn, Args);
1188}
1189
1191 {
1193 N->replaceVTableHolder(VTableHolder);
1194 T = N.get();
1195 }
1196
1197 // If this didn't create a self-reference, just return.
1198 if (T != VTableHolder)
1199 return;
1200
1201 // Look for unresolved operands. T will drop RAUW support, orphaning any
1202 // cycles underneath it.
1203 if (T->isResolved())
1204 for (const MDOperand &O : T->operands())
1205 if (auto *N = dyn_cast_or_null<MDNode>(O))
1206 trackIfUnresolved(N);
1207}
1208
1209void DIBuilder::replaceArrays(DICompositeType *&T, DINodeArray Elements,
1210 DINodeArray TParams) {
1211 {
1213 if (Elements)
1214 N->replaceElements(Elements);
1215 if (TParams)
1216 N->replaceTemplateParams(DITemplateParameterArray(TParams));
1217 T = N.get();
1218 }
1219
1220 // If T isn't resolved, there's no problem.
1221 if (!T->isResolved())
1222 return;
1223
1224 // If T is resolved, it may be due to a self-reference cycle. Track the
1225 // arrays explicitly if they're unresolved, or else the cycles will be
1226 // orphaned.
1227 if (Elements)
1228 trackIfUnresolved(Elements.get());
1229 if (TParams)
1230 trackIfUnresolved(TParams.get());
1231}
This file implements a class to represent arbitrary precision integral constant values and operations...
This file implements the APSInt class, which is a simple class that represents an arbitrary sized int...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static DILocalVariable * createLocalVariable(LLVMContext &VMContext, SmallVectorImpl< TrackingMDNodeRef > &PreservedNodes, DIScope *Context, StringRef Name, unsigned ArgNo, DIFile *File, unsigned LineNo, DIType *Ty, bool AlwaysPreserve, DINode::DIFlags Flags, uint32_t AlignInBits, DINodeArray Annotations=nullptr)
Definition: DIBuilder.cpp:789
static Function * getDeclareIntrin(Module &M)
Definition: DIBuilder.cpp:1065
static DIType * createTypeWithFlags(const DIType *Ty, DINode::DIFlags FlagsToSet)
Definition: DIBuilder.cpp:634
static DIScope * getNonCompileUnitScope(DIScope *N)
If N is compile unit return NULL otherwise return N.
Definition: DIBuilder.cpp:128
static void checkGlobalVariableScope(DIScope *Context)
Definition: DIBuilder.cpp:747
static DISubprogram * getSubprogram(bool IsDistinct, Ts &&...Args)
Definition: DIBuilder.cpp:852
static ConstantAsMetadata * getConstantOrNull(Constant *C)
Definition: DIBuilder.cpp:400
static DITemplateValueParameter * createTemplateValueParameterHelper(LLVMContext &VMContext, unsigned Tag, DIScope *Context, StringRef Name, DIType *Ty, bool IsDefault, Metadata *MD)
Definition: DIBuilder.cpp:469
static Value * getDbgIntrinsicValueImpl(LLVMContext &VMContext, Value *V)
Definition: DIBuilder.cpp:1060
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:1051
static DIImportedEntity * createImportedModule(LLVMContext &C, dwarf::Tag Tag, DIScope *Context, Metadata *NS, DIFile *File, unsigned Line, StringRef Name, DINodeArray Elements, SmallVectorImpl< TrackingMDNodeRef > &ImportedModules)
Definition: DIBuilder.cpp:161
return RetTy
This file contains constants used for implementing Dwarf debug support.
uint64_t Addr
std::string Name
uint64_t Size
Module.h This file contains the declarations for the Module class.
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Class for arbitrary precision integers.
Definition: APInt.h:78
An arbitrary precision integer that knows its signedness.
Definition: APSInt.h:23
Annotations lets you mark points and ranges inside source code, for tests:
Definition: Annotations.h:53
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
LLVM Basic Block Representation.
Definition: BasicBlock.h:61
iterator end()
Definition: BasicBlock.h:461
void insertDbgRecordBefore(DbgRecord *DR, InstListType::iterator Here)
Insert a DbgRecord into a block at the position given by Here.
InstListType::iterator iterator
Instruction iterators...
Definition: BasicBlock.h:177
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:239
static ConstantAsMetadata * get(Constant *C)
Definition: Metadata.h:528
static ConstantInt * getSigned(IntegerType *Ty, int64_t V)
Return a ConstantInt with the specified value for the specified type.
Definition: Constants.h:126
This is an important base class in LLVM.
Definition: Constant.h:42
Basic type, like 'int' or 'float'.
DIBasicType * createUnspecifiedParameter()
Create unspecified parameter type for a subroutine type.
Definition: DIBuilder.cpp:663
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:775
DITemplateValueParameter * createTemplateTemplateParameter(DIScope *Scope, StringRef Name, DIType *Ty, StringRef Val, bool IsDefault=false)
Create debugging information for a template template parameter.
Definition: DIBuilder.cpp:486
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:416
NodeTy * replaceTemporary(TempMDNode &&N, NodeTy *Replacement)
Replace a temporary node.
Definition: DIBuilder.h:1061
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:348
void finalize()
Construct any deferred debug info descriptors.
Definition: DIBuilder.cpp:63
DISubroutineType * createSubroutineType(DITypeRefArray ParameterTypes, DINode::DIFlags Flags=DINode::FlagZero, unsigned CC=0)
Create subroutine type.
Definition: DIBuilder.cpp:562
DIMacro * createMacro(DIMacroFile *Parent, unsigned Line, unsigned MacroType, StringRef Name, StringRef Value=StringRef())
Create debugging information entry for a macro.
Definition: DIBuilder.cpp:220
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:378
DIDerivedType * createStaticMemberType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, DIType *Ty, DINode::DIFlags Flags, Constant *Val, unsigned Tag, uint32_t AlignInBits=0)
Create debugging information entry for a C++ static data member.
Definition: DIBuilder.cpp:431
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:406
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, unsigned RunTimeLang=0, DIType *VTableHolder=nullptr, MDNode *TemplateParms=nullptr, StringRef UniqueIdentifier="")
Create debugging information entry for a class.
Definition: DIBuilder.cpp:502
DICompositeType * createEnumerationType(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, DINodeArray Elements, DIType *UnderlyingType, unsigned RunTimeLang=0, StringRef UniqueIdentifier="", bool IsScoped=false)
Create debugging information entry for an enumeration.
Definition: DIBuilder.cpp:569
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:944
void finalizeSubprogram(DISubprogram *SP)
Finalize a specific subprogram - no new variables may be added to this subprogram afterwards.
Definition: DIBuilder.cpp:55
DIDerivedType * createQualifiedType(unsigned Tag, DIType *FromTy)
Create debugging information entry for a qualified type, e.g.
Definition: DIBuilder.cpp:297
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:134
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:878
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:443
static DIType * createArtificialType(DIType *Ty)
Create a uniqued clone of Ty with FlagArtificial set.
Definition: DIBuilder.cpp:640
DICompositeType * createVectorType(uint64_t Size, uint32_t AlignInBits, DIType *Ty, DINodeArray Subscripts)
Create debugging information entry for a vector type.
Definition: DIBuilder.cpp:619
static DIType * createObjectPointerType(DIType *Ty)
Create a uniqued clone of Ty with FlagObjectPointer and FlagArtificial set.
Definition: DIBuilder.cpp:647
DILabel * createLabel(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, bool AlwaysPreserve=false)
Create a new descriptor for an label.
Definition: DIBuilder.cpp:833
DINamespace * createNameSpace(DIScope *Scope, StringRef Name, bool ExportSymbols)
This creates new descriptor for a namespace with the specified parent scope.
Definition: DIBuilder.cpp:923
DIStringType * createStringType(StringRef Name, uint64_t SizeInBits)
Create debugging information entry for a string type.
Definition: DIBuilder.cpp:275
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:858
DbgInstPtr 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:974
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:950
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:536
DIMacroNodeArray getOrCreateMacroArray(ArrayRef< Metadata * > Elements)
Get a DIMacroNodeArray, create one if required.
Definition: DIBuilder.cpp:701
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:584
void replaceVTableHolder(DICompositeType *&T, DIType *VTableHolder)
Replace the vtable holder in the given type.
Definition: DIBuilder.cpp:1190
DIBasicType * createNullPtrType()
Create C++11 nullptr type.
Definition: DIBuilder.cpp:262
DICommonBlock * createCommonBlock(DIScope *Scope, DIGlobalVariable *decl, StringRef Name, DIFile *File, unsigned LineNo)
Create common block entry for a Fortran common block.
Definition: DIBuilder.cpp:916
DIDerivedType * createFriend(DIType *Ty, DIType *FriendTy)
Create debugging information entry for a 'friend'.
Definition: DIBuilder.cpp:370
void retainType(DIScope *T)
Retain DIScope* in a module even if it is not referenced through debug info anchors.
Definition: DIBuilder.cpp:655
DIDerivedType * createTemplateAlias(DIType *Ty, StringRef Name, DIFile *File, unsigned LineNo, DIScope *Context, DINodeArray TParams, uint32_t AlignInBits=0, DINode::DIFlags Flags=DINode::FlagZero, DINodeArray Annotations=nullptr)
Create debugging information entry for a template alias.
Definition: DIBuilder.cpp:360
DIDerivedType * createPointerType(DIType *PointeeTy, uint64_t SizeInBits, uint32_t AlignInBits=0, std::optional< unsigned > DWARFAddressSpace=std::nullopt, StringRef Name="", DINodeArray Annotations=nullptr)
Create debugging information entry for a pointer.
Definition: DIBuilder.cpp:316
DITemplateValueParameter * createTemplateParameterPack(DIScope *Scope, StringRef Name, DIType *Ty, DINodeArray Val)
Create debugging information for a template parameter pack.
Definition: DIBuilder.cpp:495
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:756
DIBasicType * createBasicType(StringRef Name, uint64_t SizeInBits, unsigned Encoding, DINode::DIFlags Flags=DINode::FlagZero, uint32_t NumExtraInhabitants=0)
Create debugging information entry for a basic type.
Definition: DIBuilder.cpp:266
DISubrange * getOrCreateSubrange(int64_t Lo, int64_t Count)
Create a descriptor for a value range.
Definition: DIBuilder.cpp:716
DIDerivedType * createReferenceType(unsigned Tag, DIType *RTy, uint64_t SizeInBits=0, uint32_t AlignInBits=0, std::optional< unsigned > DWARFAddressSpace=std::nullopt)
Create debugging information entry for a c++ style reference or rvalue reference type.
Definition: DIBuilder.cpp:339
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:893
DIMacroFile * createTempMacroFile(DIMacroFile *Parent, unsigned Line, DIFile *File)
Create debugging information temporary entry for a macro file.
Definition: DIBuilder.cpp:232
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:597
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:327
DITypeRefArray getOrCreateTypeArray(ArrayRef< Metadata * > Elements)
Get a DITypeRefArray, create one if required.
Definition: DIBuilder.cpp:705
DINodeArray getOrCreateArray(ArrayRef< Metadata * > Elements)
Get a DINodeArray, create one if required.
Definition: DIBuilder.cpp:696
DIEnumerator * createEnumerator(StringRef Name, const APSInt &Value)
Create a single enumerator value.
Definition: DIBuilder.cpp:252
DITemplateTypeParameter * createTemplateTypeParameter(DIScope *Scope, StringRef Name, DIType *Ty, bool IsDefault)
Create debugging information for template type parameter.
Definition: DIBuilder.cpp:462
DIBuilder(Module &M, bool AllowUnresolved=true, DICompileUnit *CU=nullptr)
Construct a builder for a module.
Definition: DIBuilder.cpp:27
DIExpression * createExpression(ArrayRef< uint64_t > Addr={})
Create a new descriptor for the specified variable which has a complex address expression for its add...
Definition: DIBuilder.cpp:847
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:680
DIDerivedType * createPtrAuthQualifiedType(DIType *FromTy, unsigned Key, bool IsAddressDiscriminated, unsigned ExtraDiscriminator, bool IsaPointer, bool authenticatesNullValues)
Create a __ptrauth qualifier.
Definition: DIBuilder.cpp:302
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:549
DIImportedEntity * createImportedModule(DIScope *Context, DINamespace *NS, DIFile *File, unsigned Line, DINodeArray Elements=nullptr)
Create a descriptor for an imported module.
Definition: DIBuilder.cpp:177
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:390
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:204
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:809
static DISubprogram * createArtificialSubprogram(DISubprogram *SP)
Create a distinct clone of SP with FlagArtificial set.
Definition: DIBuilder.cpp:629
DIGenericSubrange * getOrCreateGenericSubrange(DIGenericSubrange::BoundType Count, DIGenericSubrange::BoundType LowerBound, DIGenericSubrange::BoundType UpperBound, DIGenericSubrange::BoundType Stride)
Definition: DIBuilder.cpp:735
DIBasicType * createUnspecifiedType(StringRef Name)
Create a DWARF unspecified type.
Definition: DIBuilder.cpp:257
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:454
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:666
DITemplateValueParameter * createTemplateValueParameter(DIScope *Scope, StringRef Name, DIType *Ty, bool IsDefault, Constant *Val)
Create debugging information for template value parameter.
Definition: DIBuilder.cpp:477
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:821
DIFile * createFile(StringRef Filename, StringRef Directory, std::optional< DIFile::ChecksumInfo< StringRef > > Checksum=std::nullopt, std::optional< StringRef > Source=std::nullopt)
Create a file descriptor to hold debugging information for a file.
Definition: DIBuilder.cpp:214
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="", DIType *Specification=nullptr, uint32_t NumExtraInhabitants=0)
Create debugging information entry for a struct.
Definition: DIBuilder.cpp:520
void replaceArrays(DICompositeType *&T, DINodeArray Elements, DINodeArray TParams=DINodeArray())
Replace arrays on a composite type.
Definition: DIBuilder.cpp:1209
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:935
Debug common block.
DICompositeTypeArray getEnumTypes() const
void replaceEnumTypes(DICompositeTypeArray N)
Replace arrays.
DIMacroNodeArray getMacros() const
void replaceRetainedTypes(DITypeArray N)
void replaceGlobalVariables(DIGlobalVariableExpressionArray N)
void replaceMacros(DIMacroNodeArray N)
DIImportedEntityArray getImportedEntities() const
DIScopeArray getRetainedTypes() const
void replaceImportedEntities(DIImportedEntityArray N)
DIGlobalVariableExpressionArray getGlobalVariables() const
Enumeration value.
DWARF expression.
A pair of DIGlobalVariable and DIExpression.
An imported module (C++ using directive or similar).
DILocalScope * getScope() const
Get the local scope for this label.
Debug lexical block.
DISubprogram * getSubprogram() const
Get the subprogram for this scope.
DILocalScope * getScope() const
Get the local scope for this variable.
Debug location.
Represents a module in the programming language, for example, a Clang module, or a Fortran module.
Debug lexical block.
Tagged DWARF-like metadata node.
DIFlags
Debug info flags.
Base class for scope-like contexts.
String type, Fortran CHARACTER(n)
Subprogram description.
DISPFlags
Debug info subprogram flags.
Array subrange.
Type array for a subprogram.
Base class for types.
TempDIType cloneWithFlags(DIFlags NewFlags) const
Returns a new temporary DIType with updated Flags.
bool isObjectPointer() const
DIFlags getFlags() const
bool isArtificial() const
Base class for variables.
Records a position in IR for a source label (DILabel).
Record of a variable value-assignment, aka a non instruction representation of the dbg....
static DbgVariableRecord * createDbgVariableRecord(Value *Location, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI)
static DbgVariableRecord * createDVRDeclare(Value *Address, DILocalVariable *DV, DIExpression *Expr, const DILocation *DI)
DIExpression * getExpression() const
DILocalVariable * getVariable() const
static DbgVariableRecord * createDVRAssign(Value *Val, DILocalVariable *Variable, DIExpression *Expression, DIAssignID *AssignID, Value *Address, DIExpression *AddressExpression, const DILocation *DI)
DIExpression * getAddressExpression() const
void SetCurrentDebugLocation(DebugLoc L)
Set location information used by debugging information.
Definition: IRBuilder.h:217
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block.
Definition: IRBuilder.h:177
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition: IRBuilder.h:2697
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
Definition: Instruction.cpp:68
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
Definition: Instruction.h:390
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition: Type.cpp:311
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
Metadata node.
Definition: Metadata.h:1069
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1553
static TempMDTuple getTemporary(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1557
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1545
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:1311
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:1301
Tracking metadata reference owned by Metadata.
Definition: Metadata.h:891
static MDString * get(LLVMContext &Context, StringRef Str)
Definition: Metadata.cpp:606
Tuple of metadata.
Definition: Metadata.h:1475
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1502
static MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
Definition: Metadata.cpp:103
Root of the metadata hierarchy.
Definition: Metadata.h:62
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
bool IsNewDbgInfoFormat
Is this Module using intrinsics to record the position of debugging information, or non-intrinsic rec...
Definition: Module.h:217
NamedMDNode * getOrInsertNamedMetadata(StringRef Name)
Return the named MDNode in the module with the specified name.
Definition: Module.cpp:304
A tuple of MDNodes.
Definition: Metadata.h:1733
void addOperand(MDNode *M)
Definition: Metadata.cpp:1431
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
Definition: PointerUnion.h:118
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:384
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:519
bool empty() const
Definition: SmallVector.h:81
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:573
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:937
void push_back(const T &Elt)
Definition: SmallVector.h:413
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
static IntegerType * getInt64Ty(LLVMContext &C)
static ValueAsMetadata * get(Value *V)
Definition: Metadata.cpp:501
LLVM Value Representation.
Definition: Value.h:74
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:1075
const ParentTy * getParent() const
Definition: ilist_node.h:32
self_iterator getIterator()
Definition: ilist_node.h:132
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > Tys={})
Look up the Function declaration of the intrinsic id in the Module M.
Definition: Intrinsics.cpp:731
Calculates the starting offsets for various sections within the .debug_names section.
Definition: Dwarf.h:34
@ DW_LANG_lo_user
Definition: Dwarf.h:211
@ DW_MACINFO_undef
Definition: Dwarf.h:797
@ DW_MACINFO_start_file
Definition: Dwarf.h:798
@ DW_MACINFO_define
Definition: Dwarf.h:796
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
#define N
A single checksum, represented by a Kind and a Value (a string).