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