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())
70 CUNode->replaceEnumTypes(MDTuple::get(
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())
97 CUNode->replaceImportedEntities(MDTuple::get(
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 DISourceLanguageName Lang, DIFile *File, StringRef Producer,
135 bool isOptimized, 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(!CUNode && "Can only make one compile unit per DIBuilder instance");
143 VMContext, Lang, File, Producer, isOptimized, Flags, RunTimeVer,
144 SplitName, Kind, nullptr, nullptr, nullptr, nullptr, nullptr, DWOId,
145 SplitDebugInlining, DebugInfoForProfiling, NameTableKind,
146 RangesBaseAddress, SysRoot, SDK);
147
148 // Create a named metadata so that it is easier to find cu in a module.
149 NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
150 NMD->addOperand(CUNode);
151 trackIfUnresolved(CUNode);
152 return CUNode;
153}
154
155static DIImportedEntity *
157 Metadata *NS, DIFile *File, unsigned Line, StringRef Name,
158 DINodeArray Elements,
159 SmallVectorImpl<TrackingMDNodeRef> &ImportedModules) {
160 if (Line)
161 assert(File && "Source location has line number but no file");
162 unsigned EntitiesCount = C.pImpl->DIImportedEntitys.size();
163 auto *M = DIImportedEntity::get(C, Tag, Context, cast_or_null<DINode>(NS),
164 File, Line, Name, Elements);
165 if (EntitiesCount < C.pImpl->DIImportedEntitys.size())
166 // A new Imported Entity was just added to the context.
167 // Add it to the Imported Modules list.
168 ImportedModules.emplace_back(M);
169 return M;
170}
171
173 DINamespace *NS, DIFile *File,
174 unsigned Line,
175 DINodeArray Elements) {
176 return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
177 Context, NS, File, Line, StringRef(), Elements,
178 getImportTrackingVector(Context));
179}
180
183 DIFile *File, unsigned Line,
184 DINodeArray Elements) {
185 return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
186 Context, NS, File, Line, StringRef(), Elements,
187 getImportTrackingVector(Context));
188}
189
191 DIFile *File, unsigned Line,
192 DINodeArray Elements) {
193 return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
194 Context, M, File, Line, StringRef(), Elements,
195 getImportTrackingVector(Context));
196}
197
200 DIFile *File, unsigned Line,
201 StringRef Name, DINodeArray Elements) {
202 // Make sure to use the unique identifier based metadata reference for
203 // types that have one.
204 return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_declaration,
205 Context, Decl, File, Line, Name, Elements,
206 getImportTrackingVector(Context));
207}
208
210 std::optional<DIFile::ChecksumInfo<StringRef>> CS,
211 std::optional<StringRef> Source) {
212 return DIFile::get(VMContext, Filename, Directory, CS, Source);
213}
214
215DIMacro *DIBuilder::createMacro(DIMacroFile *Parent, unsigned LineNumber,
216 unsigned MacroType, StringRef Name,
218 assert(!Name.empty() && "Unable to create macro without name");
219 assert((MacroType == dwarf::DW_MACINFO_undef ||
220 MacroType == dwarf::DW_MACINFO_define) &&
221 "Unexpected macro type");
222 auto *M = DIMacro::get(VMContext, MacroType, LineNumber, Name, Value);
223 AllMacrosPerParent[Parent].insert(M);
224 return M;
225}
226
228 unsigned LineNumber, DIFile *File) {
230 LineNumber, File, DIMacroNodeArray())
231 .release();
232 AllMacrosPerParent[Parent].insert(MF);
233 // Add the new temporary DIMacroFile to the macro per parent map as a parent.
234 // This is needed to assure DIMacroFile with no children to have an entry in
235 // the map. Otherwise, it will not be resolved in DIBuilder::finalize().
236 AllMacrosPerParent.insert({MF, {}});
237 return MF;
238}
239
241 bool IsUnsigned) {
242 assert(!Name.empty() && "Unable to create enumerator without name");
243 return DIEnumerator::get(VMContext, APInt(64, Val, !IsUnsigned), IsUnsigned,
244 Name);
245}
246
248 assert(!Name.empty() && "Unable to create enumerator without name");
249 return DIEnumerator::get(VMContext, APInt(Value), Value.isUnsigned(), Name);
250}
251
253 assert(!Name.empty() && "Unable to create type without name");
254 return DIBasicType::get(VMContext, dwarf::DW_TAG_unspecified_type, Name);
255}
256
258 return createUnspecifiedType("decltype(nullptr)");
259}
260
262 unsigned Encoding,
263 DINode::DIFlags Flags,
264 uint32_t NumExtraInhabitants) {
265 assert(!Name.empty() && "Unable to create type without name");
266 return DIBasicType::get(VMContext, dwarf::DW_TAG_base_type, Name, SizeInBits,
267 0, Encoding, NumExtraInhabitants, Flags);
268}
269
272 uint32_t AlignInBits, unsigned Encoding,
273 DINode::DIFlags Flags, int Factor) {
274 return DIFixedPointType::get(VMContext, dwarf::DW_TAG_base_type, Name,
275 SizeInBits, AlignInBits, Encoding, Flags,
277 APInt(), APInt());
278}
279
282 uint32_t AlignInBits, unsigned Encoding,
283 DINode::DIFlags Flags, int Factor) {
284 return DIFixedPointType::get(VMContext, dwarf::DW_TAG_base_type, Name,
285 SizeInBits, AlignInBits, Encoding, Flags,
287 APInt(), APInt());
288}
289
292 uint32_t AlignInBits, unsigned Encoding,
293 DINode::DIFlags Flags, APInt Numerator,
294 APInt Denominator) {
295 return DIFixedPointType::get(VMContext, dwarf::DW_TAG_base_type, Name,
296 SizeInBits, AlignInBits, Encoding, Flags,
298 Numerator, Denominator);
299}
300
302 assert(!Name.empty() && "Unable to create type without name");
303 return DIStringType::get(VMContext, dwarf::DW_TAG_string_type, Name,
304 SizeInBits, 0);
305}
306
308 DIVariable *StringLength,
309 DIExpression *StrLocationExp) {
310 assert(!Name.empty() && "Unable to create type without name");
311 return DIStringType::get(VMContext, dwarf::DW_TAG_string_type, Name,
312 StringLength, nullptr, StrLocationExp, 0, 0, 0);
313}
314
316 DIExpression *StringLengthExp,
317 DIExpression *StrLocationExp) {
318 assert(!Name.empty() && "Unable to create type without name");
319 return DIStringType::get(VMContext, dwarf::DW_TAG_string_type, Name, nullptr,
320 StringLengthExp, StrLocationExp, 0, 0, 0);
321}
322
324 return DIDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr, FromTy,
325 (uint64_t)0, 0, (uint64_t)0, std::nullopt,
326 std::nullopt, DINode::FlagZero);
327}
328
330 DIType *FromTy, unsigned Key, bool IsAddressDiscriminated,
331 unsigned ExtraDiscriminator, bool IsaPointer,
332 bool AuthenticatesNullValues) {
333 return DIDerivedType::get(
334 VMContext, dwarf::DW_TAG_LLVM_ptrauth_type, "", nullptr, 0, nullptr,
335 FromTy, (uint64_t)0, 0, (uint64_t)0, std::nullopt,
336 std::optional<DIDerivedType::PtrAuthData>(
337 std::in_place, Key, IsAddressDiscriminated, ExtraDiscriminator,
338 IsaPointer, AuthenticatesNullValues),
339 DINode::FlagZero);
340}
341
344 uint32_t AlignInBits,
345 std::optional<unsigned> DWARFAddressSpace,
346 StringRef Name, DINodeArray Annotations) {
347 // FIXME: Why is there a name here?
348 return DIDerivedType::get(VMContext, dwarf::DW_TAG_pointer_type, Name,
349 nullptr, 0, nullptr, PointeeTy, SizeInBits,
350 AlignInBits, 0, DWARFAddressSpace, std::nullopt,
351 DINode::FlagZero, nullptr, Annotations);
352}
353
355 DIType *Base,
356 uint64_t SizeInBits,
357 uint32_t AlignInBits,
358 DINode::DIFlags Flags) {
359 return DIDerivedType::get(VMContext, dwarf::DW_TAG_ptr_to_member_type, "",
360 nullptr, 0, nullptr, PointeeTy, SizeInBits,
361 AlignInBits, 0, std::nullopt, std::nullopt, Flags,
362 Base);
363}
364
367 uint32_t AlignInBits,
368 std::optional<unsigned> DWARFAddressSpace) {
369 assert(RTy && "Unable to create reference type");
370 return DIDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr, RTy,
371 SizeInBits, AlignInBits, 0, DWARFAddressSpace, {},
372 DINode::FlagZero);
373}
374
376 DIFile *File, unsigned LineNo,
377 DIScope *Context, uint32_t AlignInBits,
378 DINode::DIFlags Flags,
379 DINodeArray Annotations) {
380 return DIDerivedType::get(VMContext, dwarf::DW_TAG_typedef, Name, File,
381 LineNo, getNonCompileUnitScope(Context), Ty,
382 (uint64_t)0, AlignInBits, (uint64_t)0, std::nullopt,
383 std::nullopt, Flags, nullptr, Annotations);
384}
385
388 unsigned LineNo, DIScope *Context,
389 DINodeArray TParams, uint32_t AlignInBits,
390 DINode::DIFlags Flags, DINodeArray Annotations) {
391 return DIDerivedType::get(VMContext, dwarf::DW_TAG_template_alias, Name, File,
392 LineNo, getNonCompileUnitScope(Context), Ty,
393 (uint64_t)0, AlignInBits, (uint64_t)0, std::nullopt,
394 std::nullopt, Flags, TParams.get(), Annotations);
395}
396
398 assert(Ty && "Invalid type!");
399 assert(FriendTy && "Invalid friend type!");
400 return DIDerivedType::get(VMContext, dwarf::DW_TAG_friend, "", nullptr, 0, Ty,
401 FriendTy, (uint64_t)0, 0, (uint64_t)0, std::nullopt,
402 std::nullopt, DINode::FlagZero);
403}
404
406 uint64_t BaseOffset,
407 uint32_t VBPtrOffset,
408 DINode::DIFlags Flags) {
409 assert(Ty && "Unable to create inheritance");
411 ConstantInt::get(IntegerType::get(VMContext, 32), VBPtrOffset));
412 return DIDerivedType::get(VMContext, dwarf::DW_TAG_inheritance, "", nullptr,
413 0, Ty, BaseTy, 0, 0, BaseOffset, std::nullopt,
414 std::nullopt, Flags, ExtraData);
415}
416
418 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
419 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
420 DINode::DIFlags Flags, DIType *Ty, DINodeArray Annotations) {
421 return DIDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File,
422 LineNumber, getNonCompileUnitScope(Scope), Ty,
423 SizeInBits, AlignInBits, OffsetInBits, std::nullopt,
424 std::nullopt, Flags, nullptr, Annotations);
425}
426
428 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
429 Metadata *SizeInBits, uint32_t AlignInBits, Metadata *OffsetInBits,
430 DINode::DIFlags Flags, DIType *Ty, DINodeArray Annotations) {
431 return DIDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File,
432 LineNumber, getNonCompileUnitScope(Scope), Ty,
433 SizeInBits, AlignInBits, OffsetInBits, std::nullopt,
434 std::nullopt, Flags, nullptr, Annotations);
435}
436
438 if (C)
440 return nullptr;
441}
442
444 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
445 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
446 Constant *Discriminant, DINode::DIFlags Flags, DIType *Ty) {
447 // "ExtraData" is overloaded for bit fields and for variants, so
448 // make sure to disallow this.
449 assert((Flags & DINode::FlagBitField) == 0);
450 return DIDerivedType::get(
451 VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
452 getNonCompileUnitScope(Scope), Ty, SizeInBits, AlignInBits, OffsetInBits,
453 std::nullopt, std::nullopt, Flags, getConstantOrNull(Discriminant));
454}
455
457 DINodeArray Elements,
458 Constant *Discriminant,
459 DIType *Ty) {
460 auto *V = DICompositeType::get(VMContext, dwarf::DW_TAG_variant, {}, nullptr,
461 0, getNonCompileUnitScope(Scope), {},
462 (uint64_t)0, 0, (uint64_t)0, DINode::FlagZero,
463 Elements, 0, {}, nullptr);
464
465 trackIfUnresolved(V);
466 return createVariantMemberType(Scope, {}, nullptr, 0, 0, 0, 0, Discriminant,
467 DINode::FlagZero, V);
468}
469
471 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
472 Metadata *SizeInBits, Metadata *OffsetInBits, uint64_t StorageOffsetInBits,
473 DINode::DIFlags Flags, DIType *Ty, DINodeArray Annotations) {
474 Flags |= DINode::FlagBitField;
475 return DIDerivedType::get(
476 VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
477 getNonCompileUnitScope(Scope), Ty, SizeInBits, /*AlignInBits=*/0,
478 OffsetInBits, std::nullopt, std::nullopt, Flags,
479 ConstantAsMetadata::get(ConstantInt::get(IntegerType::get(VMContext, 64),
480 StorageOffsetInBits)),
482}
483
485 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
486 uint64_t SizeInBits, uint64_t OffsetInBits, uint64_t StorageOffsetInBits,
487 DINode::DIFlags Flags, DIType *Ty, DINodeArray Annotations) {
488 Flags |= DINode::FlagBitField;
489 return DIDerivedType::get(
490 VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
491 getNonCompileUnitScope(Scope), Ty, SizeInBits, /*AlignInBits=*/0,
492 OffsetInBits, std::nullopt, std::nullopt, Flags,
493 ConstantAsMetadata::get(ConstantInt::get(IntegerType::get(VMContext, 64),
494 StorageOffsetInBits)),
496}
497
500 unsigned LineNumber, DIType *Ty,
502 unsigned Tag, uint32_t AlignInBits) {
503 Flags |= DINode::FlagStaticMember;
504 return DIDerivedType::get(VMContext, Tag, Name, File, LineNumber,
505 getNonCompileUnitScope(Scope), Ty, (uint64_t)0,
506 AlignInBits, (uint64_t)0, std::nullopt,
507 std::nullopt, Flags, getConstantOrNull(Val));
508}
509
511DIBuilder::createObjCIVar(StringRef Name, DIFile *File, unsigned LineNumber,
512 uint64_t SizeInBits, uint32_t AlignInBits,
513 uint64_t OffsetInBits, DINode::DIFlags Flags,
514 DIType *Ty, MDNode *PropertyNode) {
515 return DIDerivedType::get(VMContext, dwarf::DW_TAG_member, Name, File,
516 LineNumber, getNonCompileUnitScope(File), Ty,
517 SizeInBits, AlignInBits, OffsetInBits, std::nullopt,
518 std::nullopt, Flags, PropertyNode);
519}
520
522DIBuilder::createObjCProperty(StringRef Name, DIFile *File, unsigned LineNumber,
523 StringRef GetterName, StringRef SetterName,
524 unsigned PropertyAttributes, DIType *Ty) {
525 return DIObjCProperty::get(VMContext, Name, File, LineNumber, GetterName,
526 SetterName, PropertyAttributes, Ty);
527}
528
531 DIType *Ty, bool isDefault) {
532 assert((!Context || isa<DICompileUnit>(Context)) && "Expected compile unit");
533 return DITemplateTypeParameter::get(VMContext, Name, Ty, isDefault);
534}
535
538 DIScope *Context, StringRef Name, DIType *Ty,
539 bool IsDefault, Metadata *MD) {
540 assert((!Context || isa<DICompileUnit>(Context)) && "Expected compile unit");
541 return DITemplateValueParameter::get(VMContext, Tag, Name, Ty, IsDefault, MD);
542}
543
546 DIType *Ty, bool isDefault,
547 Constant *Val) {
549 VMContext, dwarf::DW_TAG_template_value_parameter, Context, Name, Ty,
550 isDefault, getConstantOrNull(Val));
551}
552
555 DIType *Ty, StringRef Val,
556 bool IsDefault) {
558 VMContext, dwarf::DW_TAG_GNU_template_template_param, Context, Name, Ty,
559 IsDefault, MDString::get(VMContext, Val));
560}
561
564 DIType *Ty, DINodeArray Val) {
566 VMContext, dwarf::DW_TAG_GNU_template_parameter_pack, Context, Name, Ty,
567 false, Val.get());
568}
569
571 DIScope *Context, StringRef Name, DIFile *File, unsigned LineNumber,
572 uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
573 DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements,
574 unsigned RunTimeLang, DIType *VTableHolder, MDNode *TemplateParams,
575 StringRef UniqueIdentifier) {
576 assert((!Context || isa<DIScope>(Context)) &&
577 "createClassType should be called with a valid Context");
578
579 auto *R = DICompositeType::get(
580 VMContext, dwarf::DW_TAG_class_type, Name, File, LineNumber,
581 getNonCompileUnitScope(Context), DerivedFrom, SizeInBits, AlignInBits,
582 OffsetInBits, Flags, Elements, RunTimeLang, /*EnumKind=*/std::nullopt,
583 VTableHolder, cast_or_null<MDTuple>(TemplateParams), UniqueIdentifier);
584 trackIfUnresolved(R);
585 return R;
586}
587
589 DIScope *Context, StringRef Name, DIFile *File, unsigned LineNumber,
590 Metadata *SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags,
591 DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang,
592 DIType *VTableHolder, StringRef UniqueIdentifier, DIType *Specification,
593 uint32_t NumExtraInhabitants) {
594 auto *R = DICompositeType::get(
595 VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber,
596 getNonCompileUnitScope(Context), DerivedFrom, SizeInBits, AlignInBits, 0,
597 Flags, Elements, RunTimeLang, /*EnumKind=*/std::nullopt, VTableHolder,
598 nullptr, UniqueIdentifier, nullptr, nullptr, nullptr, nullptr, nullptr,
599 nullptr, Specification, NumExtraInhabitants);
600 trackIfUnresolved(R);
601 return R;
602}
603
605 DIScope *Context, StringRef Name, DIFile *File, unsigned LineNumber,
606 uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags,
607 DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang,
608 DIType *VTableHolder, StringRef UniqueIdentifier, DIType *Specification,
609 uint32_t NumExtraInhabitants) {
610 auto *R = DICompositeType::get(
611 VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber,
612 getNonCompileUnitScope(Context), DerivedFrom, SizeInBits, AlignInBits, 0,
613 Flags, Elements, RunTimeLang, /*EnumKind=*/std::nullopt, VTableHolder,
614 nullptr, UniqueIdentifier, nullptr, nullptr, nullptr, nullptr, nullptr,
615 nullptr, Specification, NumExtraInhabitants);
616 trackIfUnresolved(R);
617 return R;
618}
619
621 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
622 uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags,
623 DINodeArray Elements, unsigned RunTimeLang, StringRef UniqueIdentifier) {
624 auto *R = DICompositeType::get(
625 VMContext, dwarf::DW_TAG_union_type, Name, File, LineNumber,
626 getNonCompileUnitScope(Scope), nullptr, SizeInBits, AlignInBits, 0, Flags,
627 Elements, RunTimeLang, /*EnumKind=*/std::nullopt, nullptr, nullptr,
628 UniqueIdentifier);
629 trackIfUnresolved(R);
630 return R;
631}
632
635 unsigned LineNumber, uint64_t SizeInBits,
636 uint32_t AlignInBits, DINode::DIFlags Flags,
637 DIDerivedType *Discriminator, DINodeArray Elements,
638 StringRef UniqueIdentifier) {
639 auto *R = DICompositeType::get(
640 VMContext, dwarf::DW_TAG_variant_part, Name, File, LineNumber,
641 getNonCompileUnitScope(Scope), nullptr, SizeInBits, AlignInBits, 0, Flags,
642 Elements, 0, /*EnumKind=*/std::nullopt, nullptr, nullptr,
643 UniqueIdentifier, Discriminator);
644 trackIfUnresolved(R);
645 return R;
646}
647
649 DINode::DIFlags Flags,
650 unsigned CC) {
651 return DISubroutineType::get(VMContext, Flags, CC, ParameterTypes);
652}
653
655 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
656 uint64_t SizeInBits, uint32_t AlignInBits, DINodeArray Elements,
657 DIType *UnderlyingType, unsigned RunTimeLang, StringRef UniqueIdentifier,
658 bool IsScoped, std::optional<uint32_t> EnumKind) {
659 auto *CTy = DICompositeType::get(
660 VMContext, dwarf::DW_TAG_enumeration_type, Name, File, LineNumber,
661 getNonCompileUnitScope(Scope), UnderlyingType, SizeInBits, AlignInBits, 0,
662 IsScoped ? DINode::FlagEnumClass : DINode::FlagZero, Elements,
663 RunTimeLang, EnumKind, nullptr, nullptr, UniqueIdentifier);
664 AllEnumTypes.emplace_back(CTy);
665 trackIfUnresolved(CTy);
666 return CTy;
667}
668
670 DIFile *File, unsigned LineNo,
671 uint64_t SizeInBits,
672 uint32_t AlignInBits, DIType *Ty) {
673 auto *R = DIDerivedType::get(VMContext, dwarf::DW_TAG_set_type, Name, File,
674 LineNo, getNonCompileUnitScope(Scope), Ty,
675 SizeInBits, AlignInBits, 0, std::nullopt,
676 std::nullopt, DINode::FlagZero);
677 trackIfUnresolved(R);
678 return R;
679}
680
683 DINodeArray Subscripts,
688 return createArrayType(nullptr, StringRef(), nullptr, 0, Size, AlignInBits,
689 Ty, Subscripts, DL, AS, AL, RK);
690}
691
693 DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
694 uint64_t Size, uint32_t AlignInBits, DIType *Ty, DINodeArray Subscripts,
699 auto *R = DICompositeType::get(
700 VMContext, dwarf::DW_TAG_array_type, Name, File, LineNumber,
701 getNonCompileUnitScope(Scope), Ty, Size, AlignInBits, 0, DINode::FlagZero,
702 Subscripts, 0, /*EnumKind=*/std::nullopt, nullptr, nullptr, "", nullptr,
711 nullptr, nullptr, 0, BitStride);
712 trackIfUnresolved(R);
713 return R;
714}
715
717 uint32_t AlignInBits, DIType *Ty,
718 DINodeArray Subscripts,
719 Metadata *BitStride) {
720 auto *R = DICompositeType::get(
721 VMContext, dwarf::DW_TAG_array_type, /*Name=*/"",
722 /*File=*/nullptr, /*Line=*/0, /*Scope=*/nullptr, /*BaseType=*/Ty,
723 /*SizeInBits=*/Size, /*AlignInBits=*/AlignInBits, /*OffsetInBits=*/0,
724 /*Flags=*/DINode::FlagVector, /*Elements=*/Subscripts,
725 /*RuntimeLang=*/0, /*EnumKind=*/std::nullopt, /*VTableHolder=*/nullptr,
726 /*TemplateParams=*/nullptr, /*Identifier=*/"",
727 /*Discriminator=*/nullptr, /*DataLocation=*/nullptr,
728 /*Associated=*/nullptr, /*Allocated=*/nullptr, /*Rank=*/nullptr,
729 /*Annotations=*/nullptr, /*Specification=*/nullptr,
730 /*NumExtraInhabitants=*/0,
731 /*BitStride=*/BitStride);
732 trackIfUnresolved(R);
733 return R;
734}
735
737 auto NewSP = SP->cloneWithFlags(SP->getFlags() | DINode::FlagArtificial);
738 return MDNode::replaceWithDistinct(std::move(NewSP));
739}
740
742 DINode::DIFlags FlagsToSet) {
743 auto NewTy = Ty->cloneWithFlags(Ty->getFlags() | FlagsToSet);
744 return MDNode::replaceWithUniqued(std::move(NewTy));
745}
746
748 // FIXME: Restrict this to the nodes where it's valid.
749 if (Ty->isArtificial())
750 return Ty;
751 return createTypeWithFlags(Ty, DINode::FlagArtificial);
752}
753
755 // FIXME: Restrict this to the nodes where it's valid.
756 if (Ty->isObjectPointer())
757 return Ty;
758 DINode::DIFlags Flags = DINode::FlagObjectPointer;
759
760 if (Implicit)
761 Flags |= DINode::FlagArtificial;
762
763 return createTypeWithFlags(Ty, Flags);
764}
765
767 assert(T && "Expected non-null type");
769 cast<DISubprogram>(T)->isDefinition() == false)) &&
770 "Expected type or subprogram declaration");
771 AllRetainTypes.emplace_back(T);
772}
773
775
777 unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line,
778 unsigned RuntimeLang, uint64_t SizeInBits, uint32_t AlignInBits,
779 StringRef UniqueIdentifier, std::optional<uint32_t> EnumKind) {
780 // FIXME: Define in terms of createReplaceableForwardDecl() by calling
781 // replaceWithUniqued().
782 auto *RetTy = DICompositeType::get(
783 VMContext, Tag, Name, F, Line, getNonCompileUnitScope(Scope), nullptr,
784 SizeInBits, AlignInBits, 0, DINode::FlagFwdDecl, nullptr, RuntimeLang,
785 /*EnumKind=*/EnumKind, nullptr, nullptr, UniqueIdentifier);
786 trackIfUnresolved(RetTy);
787 return RetTy;
788}
789
791 unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line,
792 unsigned RuntimeLang, uint64_t SizeInBits, uint32_t AlignInBits,
793 DINode::DIFlags Flags, StringRef UniqueIdentifier, DINodeArray Annotations,
794 std::optional<uint32_t> EnumKind) {
795 auto *RetTy =
797 VMContext, Tag, Name, F, Line, getNonCompileUnitScope(Scope), nullptr,
798 SizeInBits, AlignInBits, 0, Flags, nullptr, RuntimeLang, EnumKind,
799 nullptr, nullptr, UniqueIdentifier, nullptr, nullptr, nullptr,
800 nullptr, nullptr, Annotations)
801 .release();
802 trackIfUnresolved(RetTy);
803 return RetTy;
804}
805
807 return MDTuple::get(VMContext, Elements);
808}
809
810DIMacroNodeArray
812 return MDTuple::get(VMContext, Elements);
813}
814
817 for (Metadata *E : Elements) {
819 Elts.push_back(cast<DIType>(E));
820 else
821 Elts.push_back(E);
822 }
823 return DITypeRefArray(MDNode::get(VMContext, Elts));
824}
825
827 auto *LB = ConstantAsMetadata::get(
829 auto *CountNode = ConstantAsMetadata::get(
831 return DISubrange::get(VMContext, CountNode, LB, nullptr, nullptr);
832}
833
835 auto *LB = ConstantAsMetadata::get(
837 return DISubrange::get(VMContext, CountNode, LB, nullptr, nullptr);
838}
839
841 Metadata *UB, Metadata *Stride) {
842 return DISubrange::get(VMContext, CountNode, LB, UB, Stride);
843}
844
848 auto ConvToMetadata = [&](DIGenericSubrange::BoundType Bound) -> Metadata * {
849 return isa<DIExpression *>(Bound) ? (Metadata *)cast<DIExpression *>(Bound)
850 : (Metadata *)cast<DIVariable *>(Bound);
851 };
852 return DIGenericSubrange::get(VMContext, ConvToMetadata(CountNode),
853 ConvToMetadata(LB), ConvToMetadata(UB),
854 ConvToMetadata(Stride));
855}
856
858 StringRef Name, DIFile *File, unsigned LineNo, DIScope *Scope,
859 uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags,
860 DIType *Ty, Metadata *LowerBound, Metadata *UpperBound, Metadata *Stride,
861 Metadata *Bias) {
862 return DISubrangeType::get(VMContext, Name, File, LineNo, Scope, SizeInBits,
863 AlignInBits, Flags, Ty, LowerBound, UpperBound,
864 Stride, Bias);
865}
866
867static void checkGlobalVariableScope(DIScope *Context) {
868#ifndef NDEBUG
869 if (auto *CT =
871 assert(CT->getIdentifier().empty() &&
872 "Context of a global variable should not be a type with identifier");
873#endif
874}
875
877 DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *F,
878 unsigned LineNumber, DIType *Ty, bool IsLocalToUnit, bool isDefined,
879 DIExpression *Expr, MDNode *Decl, MDTuple *TemplateParams,
880 uint32_t AlignInBits, DINodeArray Annotations) {
882
884 VMContext, cast_or_null<DIScope>(Context), Name, LinkageName, F,
885 LineNumber, Ty, IsLocalToUnit, isDefined,
886 cast_or_null<DIDerivedType>(Decl), TemplateParams, AlignInBits,
888 if (!Expr)
889 Expr = createExpression();
890 auto *N = DIGlobalVariableExpression::get(VMContext, GV, Expr);
891 AllGVs.push_back(N);
892 return N;
893}
894
896 DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *F,
897 unsigned LineNumber, DIType *Ty, bool IsLocalToUnit, MDNode *Decl,
898 MDTuple *TemplateParams, uint32_t AlignInBits) {
900
902 VMContext, cast_or_null<DIScope>(Context), Name, LinkageName, F,
903 LineNumber, Ty, IsLocalToUnit, false,
904 cast_or_null<DIDerivedType>(Decl), TemplateParams, AlignInBits,
905 nullptr)
906 .release();
907}
908
910 LLVMContext &VMContext,
912 DIScope *Context, StringRef Name, unsigned ArgNo, DIFile *File,
913 unsigned LineNo, DIType *Ty, bool AlwaysPreserve, DINode::DIFlags Flags,
914 uint32_t AlignInBits, DINodeArray Annotations = nullptr) {
915 // FIXME: Why doesn't this check for a subprogram or lexical block (AFAICT
916 // the only valid scopes)?
917 auto *Scope = cast<DILocalScope>(Context);
918 auto *Node = DILocalVariable::get(VMContext, Scope, Name, File, LineNo, Ty,
919 ArgNo, Flags, AlignInBits, Annotations);
920 if (AlwaysPreserve) {
921 // The optimizer may remove local variables. If there is an interest
922 // to preserve variable info in such situation then stash it in a
923 // named mdnode.
924 PreservedNodes.emplace_back(Node);
925 }
926 return Node;
927}
928
930 DIFile *File, unsigned LineNo,
931 DIType *Ty, bool AlwaysPreserve,
932 DINode::DIFlags Flags,
933 uint32_t AlignInBits) {
934 assert(Scope && isa<DILocalScope>(Scope) &&
935 "Unexpected scope for a local variable.");
936 return createLocalVariable(
937 VMContext, getSubprogramNodesTrackingVector(Scope), Scope, Name,
938 /* ArgNo */ 0, File, LineNo, Ty, AlwaysPreserve, Flags, AlignInBits);
939}
940
942 DIScope *Scope, StringRef Name, unsigned ArgNo, DIFile *File,
943 unsigned LineNo, DIType *Ty, bool AlwaysPreserve, DINode::DIFlags Flags,
944 DINodeArray Annotations) {
945 assert(ArgNo && "Expected non-zero argument number for parameter");
946 assert(Scope && isa<DILocalScope>(Scope) &&
947 "Unexpected scope for a local variable.");
948 return createLocalVariable(
949 VMContext, getSubprogramNodesTrackingVector(Scope), Scope, Name, ArgNo,
950 File, LineNo, Ty, AlwaysPreserve, Flags, /*AlignInBits=*/0, Annotations);
951}
952
954 unsigned LineNo, unsigned Column,
955 bool IsArtificial,
956 std::optional<unsigned> CoroSuspendIdx,
957 bool AlwaysPreserve) {
958 auto *Scope = cast<DILocalScope>(Context);
959 auto *Node = DILabel::get(VMContext, Scope, Name, File, LineNo, Column,
960 IsArtificial, CoroSuspendIdx);
961
962 if (AlwaysPreserve) {
963 /// The optimizer may remove labels. If there is an interest
964 /// to preserve label info in such situation then append it to
965 /// the list of retained nodes of the DISubprogram.
966 getSubprogramNodesTrackingVector(Scope).emplace_back(Node);
967 }
968 return Node;
969}
970
974
975template <class... Ts>
976static DISubprogram *getSubprogram(bool IsDistinct, Ts &&...Args) {
977 if (IsDistinct)
978 return DISubprogram::getDistinct(std::forward<Ts>(Args)...);
979 return DISubprogram::get(std::forward<Ts>(Args)...);
980}
981
983 DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
984 unsigned LineNo, DISubroutineType *Ty, unsigned ScopeLine,
986 DITemplateParameterArray TParams, DISubprogram *Decl,
987 DITypeArray ThrownTypes, DINodeArray Annotations, StringRef TargetFuncName,
988 bool UseKeyInstructions) {
989 bool IsDefinition = SPFlags & DISubprogram::SPFlagDefinition;
990 auto *Node = getSubprogram(
991 /*IsDistinct=*/IsDefinition, VMContext, getNonCompileUnitScope(Context),
992 Name, LinkageName, File, LineNo, Ty, ScopeLine, nullptr, 0, 0, Flags,
993 SPFlags, IsDefinition ? CUNode : nullptr, TParams, Decl, nullptr,
994 ThrownTypes, Annotations, TargetFuncName, UseKeyInstructions);
995
996 AllSubprograms.push_back(Node);
997 trackIfUnresolved(Node);
998 return Node;
999}
1000
1002 DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
1003 unsigned LineNo, DISubroutineType *Ty, unsigned ScopeLine,
1005 DITemplateParameterArray TParams, DISubprogram *Decl,
1006 DITypeArray ThrownTypes) {
1007 bool IsDefinition = SPFlags & DISubprogram::SPFlagDefinition;
1008 return DISubprogram::getTemporary(VMContext, getNonCompileUnitScope(Context),
1009 Name, LinkageName, File, LineNo, Ty,
1010 ScopeLine, nullptr, 0, 0, Flags, SPFlags,
1011 IsDefinition ? CUNode : nullptr, TParams,
1012 Decl, nullptr, ThrownTypes)
1013 .release();
1014}
1015
1017 DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *F,
1018 unsigned LineNo, DISubroutineType *Ty, unsigned VIndex, int ThisAdjustment,
1019 DIType *VTableHolder, DINode::DIFlags Flags,
1020 DISubprogram::DISPFlags SPFlags, DITemplateParameterArray TParams,
1021 DITypeArray ThrownTypes, bool UseKeyInstructions) {
1022 assert(getNonCompileUnitScope(Context) &&
1023 "Methods should have both a Context and a context that isn't "
1024 "the compile unit.");
1025 // FIXME: Do we want to use different scope/lines?
1026 bool IsDefinition = SPFlags & DISubprogram::SPFlagDefinition;
1027 auto *SP = getSubprogram(
1028 /*IsDistinct=*/IsDefinition, VMContext, cast<DIScope>(Context), Name,
1029 LinkageName, F, LineNo, Ty, LineNo, VTableHolder, VIndex, ThisAdjustment,
1030 Flags, SPFlags, IsDefinition ? CUNode : nullptr, TParams, nullptr,
1031 nullptr, ThrownTypes, nullptr, "", IsDefinition && UseKeyInstructions);
1032
1033 AllSubprograms.push_back(SP);
1034 trackIfUnresolved(SP);
1035 return SP;
1036}
1037
1039 DIGlobalVariable *Decl,
1040 StringRef Name, DIFile *File,
1041 unsigned LineNo) {
1042 return DICommonBlock::get(VMContext, Scope, Decl, Name, File, LineNo);
1043}
1044
1046 bool ExportSymbols) {
1047
1048 // It is okay to *not* make anonymous top-level namespaces distinct, because
1049 // all nodes that have an anonymous namespace as their parent scope are
1050 // guaranteed to be unique and/or are linked to their containing
1051 // DICompileUnit. This decision is an explicit tradeoff of link time versus
1052 // memory usage versus code simplicity and may get revisited in the future.
1053 return DINamespace::get(VMContext, getNonCompileUnitScope(Scope), Name,
1054 ExportSymbols);
1055}
1056
1058 StringRef ConfigurationMacros,
1059 StringRef IncludePath, StringRef APINotesFile,
1060 DIFile *File, unsigned LineNo, bool IsDecl) {
1061 return DIModule::get(VMContext, File, getNonCompileUnitScope(Scope), Name,
1062 ConfigurationMacros, IncludePath, APINotesFile, LineNo,
1063 IsDecl);
1064}
1065
1067 DIFile *File,
1068 unsigned Discriminator) {
1069 return DILexicalBlockFile::get(VMContext, Scope, File, Discriminator);
1070}
1071
1073 unsigned Line, unsigned Col) {
1074 // Make these distinct, to avoid merging two lexical blocks on the same
1075 // file/line/column.
1076 return DILexicalBlock::getDistinct(VMContext, getNonCompileUnitScope(Scope),
1077 File, Line, Col);
1078}
1079
1081 DIExpression *Expr, const DILocation *DL,
1082 BasicBlock *InsertAtEnd) {
1083 // If this block already has a terminator then insert this intrinsic before
1084 // the terminator. Otherwise, put it at the end of the block.
1085 Instruction *InsertBefore = InsertAtEnd->getTerminator();
1086 return insertDeclare(Storage, VarInfo, Expr, DL,
1087 InsertBefore ? InsertBefore->getIterator()
1088 : InsertAtEnd->end());
1089}
1090
1092 DILocalVariable *SrcVar,
1093 DIExpression *ValExpr, Value *Addr,
1094 DIExpression *AddrExpr,
1095 const DILocation *DL) {
1096 auto *Link = cast_or_null<DIAssignID>(
1097 LinkedInstr->getMetadata(LLVMContext::MD_DIAssignID));
1098 assert(Link && "Linked instruction must have DIAssign metadata attached");
1099
1101 Val, SrcVar, ValExpr, Link, Addr, AddrExpr, DL);
1102 // Insert after LinkedInstr.
1103 BasicBlock::iterator NextIt = std::next(LinkedInstr->getIterator());
1104 NextIt.setHeadBit(true);
1105 insertDbgVariableRecord(DVR, NextIt);
1106 return DVR;
1107}
1108
1109/// Initialize IRBuilder for inserting dbg.declare and dbg.value intrinsics.
1110/// This abstracts over the various ways to specify an insert position.
1111static void initIRBuilder(IRBuilder<> &Builder, const DILocation *DL,
1112 InsertPosition InsertPt) {
1113 Builder.SetInsertPoint(InsertPt.getBasicBlock(), InsertPt);
1114 Builder.SetCurrentDebugLocation(DL);
1115}
1116
1118 assert(V && "no value passed to dbg intrinsic");
1119 return MetadataAsValue::get(VMContext, ValueAsMetadata::get(V));
1120}
1121
1123 DILocalVariable *VarInfo,
1124 DIExpression *Expr,
1125 const DILocation *DL,
1126 InsertPosition InsertPt) {
1127 DbgVariableRecord *DVR =
1129 insertDbgVariableRecord(DVR, InsertPt);
1130 return DVR;
1131}
1132
1134 DIExpression *Expr, const DILocation *DL,
1135 InsertPosition InsertPt) {
1136 assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.declare");
1137 assert(DL && "Expected debug loc");
1138 assert(DL->getScope()->getSubprogram() ==
1139 VarInfo->getScope()->getSubprogram() &&
1140 "Expected matching subprograms");
1141
1142 DbgVariableRecord *DVR =
1143 DbgVariableRecord::createDVRDeclare(Storage, VarInfo, Expr, DL);
1144 insertDbgVariableRecord(DVR, InsertPt);
1145 return DVR;
1146}
1147
1148void DIBuilder::insertDbgVariableRecord(DbgVariableRecord *DVR,
1149 InsertPosition InsertPt) {
1150 assert(InsertPt.isValid());
1151 trackIfUnresolved(DVR->getVariable());
1152 trackIfUnresolved(DVR->getExpression());
1153 if (DVR->isDbgAssign())
1154 trackIfUnresolved(DVR->getAddressExpression());
1155
1156 auto *BB = InsertPt.getBasicBlock();
1157 BB->insertDbgRecordBefore(DVR, InsertPt);
1158}
1159
1160Instruction *DIBuilder::insertDbgIntrinsic(llvm::Function *IntrinsicFn,
1161 Value *V, DILocalVariable *VarInfo,
1162 DIExpression *Expr,
1163 const DILocation *DL,
1164 InsertPosition InsertPt) {
1165 assert(IntrinsicFn && "must pass a non-null intrinsic function");
1166 assert(V && "must pass a value to a dbg intrinsic");
1167 assert(VarInfo &&
1168 "empty or invalid DILocalVariable* passed to debug intrinsic");
1169 assert(DL && "Expected debug loc");
1170 assert(DL->getScope()->getSubprogram() ==
1171 VarInfo->getScope()->getSubprogram() &&
1172 "Expected matching subprograms");
1173
1174 trackIfUnresolved(VarInfo);
1175 trackIfUnresolved(Expr);
1176 Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, V),
1177 MetadataAsValue::get(VMContext, VarInfo),
1178 MetadataAsValue::get(VMContext, Expr)};
1179
1180 IRBuilder<> B(DL->getContext());
1181 initIRBuilder(B, DL, InsertPt);
1182 return B.CreateCall(IntrinsicFn, Args);
1183}
1184
1186 InsertPosition InsertPt) {
1187 assert(LabelInfo && "empty or invalid DILabel* passed to dbg.label");
1188 assert(DL && "Expected debug loc");
1189 assert(DL->getScope()->getSubprogram() ==
1190 LabelInfo->getScope()->getSubprogram() &&
1191 "Expected matching subprograms");
1192
1193 trackIfUnresolved(LabelInfo);
1194 DbgLabelRecord *DLR = new DbgLabelRecord(LabelInfo, DL);
1195 if (InsertPt.isValid()) {
1196 auto *BB = InsertPt.getBasicBlock();
1197 BB->insertDbgRecordBefore(DLR, InsertPt);
1198 }
1199 return DLR;
1200}
1201
1203 {
1205 N->replaceVTableHolder(VTableHolder);
1206 T = N.get();
1207 }
1208
1209 // If this didn't create a self-reference, just return.
1210 if (T != VTableHolder)
1211 return;
1212
1213 // Look for unresolved operands. T will drop RAUW support, orphaning any
1214 // cycles underneath it.
1215 if (T->isResolved())
1216 for (const MDOperand &O : T->operands())
1217 if (auto *N = dyn_cast_or_null<MDNode>(O))
1218 trackIfUnresolved(N);
1219}
1220
1221void DIBuilder::replaceArrays(DICompositeType *&T, DINodeArray Elements,
1222 DINodeArray TParams) {
1223 {
1225 if (Elements)
1226 N->replaceElements(Elements);
1227 if (TParams)
1228 N->replaceTemplateParams(DITemplateParameterArray(TParams));
1229 T = N.get();
1230 }
1231
1232 // If T isn't resolved, there's no problem.
1233 if (!T->isResolved())
1234 return;
1235
1236 // If T is resolved, it may be due to a self-reference cycle. Track the
1237 // arrays explicitly if they're unresolved, or else the cycles will be
1238 // orphaned.
1239 if (Elements)
1240 trackIfUnresolved(Elements.get());
1241 if (TParams)
1242 trackIfUnresolved(TParams.get());
1243}
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)
static DIType * createTypeWithFlags(const DIType *Ty, DINode::DIFlags FlagsToSet)
static DIScope * getNonCompileUnitScope(DIScope *N)
If N is compile unit return NULL otherwise return N.
static void checkGlobalVariableScope(DIScope *Context)
static DISubprogram * getSubprogram(bool IsDistinct, Ts &&...Args)
static ConstantAsMetadata * getConstantOrNull(Constant *C)
static DITemplateValueParameter * createTemplateValueParameterHelper(LLVMContext &VMContext, unsigned Tag, DIScope *Context, StringRef Name, DIType *Ty, bool IsDefault, Metadata *MD)
static void initIRBuilder(IRBuilder<> &Builder, const DILocation *DL, InsertPosition InsertPt)
Initialize IRBuilder for inserting dbg.declare and dbg.value intrinsics.
static Value * getDbgIntrinsicValueImpl(LLVMContext &VMContext, Value *V)
static DIImportedEntity * createImportedModule(LLVMContext &C, dwarf::Tag Tag, DIScope *Context, Metadata *NS, DIFile *File, unsigned Line, StringRef Name, DINodeArray Elements, SmallVectorImpl< TrackingMDNodeRef > &ImportedModules)
This file contains constants used for implementing Dwarf debug support.
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
#define T
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:536
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.
LLVM_ABI DIBasicType * createUnspecifiedParameter()
Create unspecified parameter type for a subroutine type.
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...
LLVM_ABI DITemplateValueParameter * createTemplateTemplateParameter(DIScope *Scope, StringRef Name, DIType *Ty, StringRef Val, bool IsDefault=false)
Create debugging information for a template template parameter.
NodeTy * replaceTemporary(TempMDNode &&N, NodeTy *Replacement)
Replace a temporary node.
Definition DIBuilder.h:1197
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.
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.
LLVM_ABI DIMacro * createMacro(DIMacroFile *Parent, unsigned Line, unsigned MacroType, StringRef Name, StringRef Value=StringRef())
Create debugging information entry for a macro.
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.
LLVM_ABI DICompositeType * createVectorType(uint64_t Size, uint32_t AlignInBits, DIType *Ty, DINodeArray Subscripts, Metadata *BitStride=nullptr)
Create debugging information entry for a vector type.
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.
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.
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.
LLVM_ABI DILexicalBlockFile * createLexicalBlockFile(DIScope *Scope, DIFile *File, unsigned Discriminator=0)
This creates a descriptor for a lexical block with a new file attached.
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.
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.
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.
static LLVM_ABI DIType * createArtificialType(DIType *Ty)
Create a uniqued clone of Ty with FlagArtificial set.
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.
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.
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.
LLVM_ABI DINamespace * createNameSpace(DIScope *Scope, StringRef Name, bool ExportSymbols)
This creates new descriptor for a namespace with the specified parent scope.
LLVM_ABI DIStringType * createStringType(StringRef Name, uint64_t SizeInBits)
Create debugging information entry for a string type.
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.
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.
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.
LLVM_ABI DIMacroNodeArray getOrCreateMacroArray(ArrayRef< Metadata * > Elements)
Get a DIMacroNodeArray, create one if required.
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.
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.
LLVM_ABI void replaceVTableHolder(DICompositeType *&T, DIType *VTableHolder)
Replace the vtable holder in the given type.
LLVM_ABI DIBasicType * createNullPtrType()
Create C++11 nullptr type.
LLVM_ABI DICommonBlock * createCommonBlock(DIScope *Scope, DIGlobalVariable *decl, StringRef Name, DIFile *File, unsigned LineNo)
Create common block entry for a Fortran common block.
LLVM_ABI DIDerivedType * createFriend(DIType *Ty, DIType *FriendTy)
Create debugging information entry for a 'friend'.
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.
LLVM_ABI void retainType(DIScope *T)
Retain DIScope* in a module even if it is not referenced through debug info anchors.
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.
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.
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.
LLVM_ABI DbgInstPtr insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo, DIExpression *Expr, const DILocation *DL, BasicBlock *InsertAtEnd)
Insert a new llvm.dbg.declare intrinsic call.
LLVM_ABI DbgInstPtr insertDbgValueIntrinsic(llvm::Value *Val, DILocalVariable *VarInfo, DIExpression *Expr, const DILocation *DL, InsertPosition InsertPt)
Insert a new llvm.dbg.value intrinsic call.
LLVM_ABI DITemplateValueParameter * createTemplateParameterPack(DIScope *Scope, StringRef Name, DIType *Ty, DINodeArray Val)
Create debugging information for a template parameter pack.
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.
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.
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.
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.
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.
LLVM_ABI DISubrange * getOrCreateSubrange(int64_t Lo, int64_t Count)
Create a descriptor for a value range.
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.
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.
LLVM_ABI DIMacroFile * createTempMacroFile(DIMacroFile *Parent, unsigned Line, DIFile *File)
Create debugging information temporary entry for a macro file.
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.
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.
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.
LLVM_ABI DITypeRefArray getOrCreateTypeArray(ArrayRef< Metadata * > Elements)
Get a DITypeRefArray, create one if required.
LLVM_ABI DINodeArray getOrCreateArray(ArrayRef< Metadata * > Elements)
Get a DINodeArray, create one if required.
LLVM_ABI DICompileUnit * createCompileUnit(DISourceLanguageName 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...
LLVM_ABI DIEnumerator * createEnumerator(StringRef Name, const APSInt &Value)
Create a single enumerator value.
LLVM_ABI DITemplateTypeParameter * createTemplateTypeParameter(DIScope *Scope, StringRef Name, DIType *Ty, bool IsDefault)
Create debugging information for template type parameter.
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...
LLVM_ABI DIDerivedType * createPtrAuthQualifiedType(DIType *FromTy, unsigned Key, bool IsAddressDiscriminated, unsigned ExtraDiscriminator, bool IsaPointer, bool authenticatesNullValues)
Create a __ptrauth qualifier.
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.
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.
LLVM_ABI DIImportedEntity * createImportedModule(DIScope *Context, DINamespace *NS, DIFile *File, unsigned Line, DINodeArray Elements=nullptr)
Create a descriptor for an imported module.
LLVM_ABI DbgInstPtr insertLabel(DILabel *LabelInfo, const DILocation *DL, InsertPosition InsertPt)
Insert a new llvm.dbg.label intrinsic call.
LLVM_ABI DIImportedEntity * createImportedDeclaration(DIScope *Context, DINode *Decl, DIFile *File, unsigned Line, StringRef Name="", DINodeArray Elements=nullptr)
Create a descriptor for an imported function.
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.
static LLVM_ABI DISubprogram * createArtificialSubprogram(DISubprogram *SP)
Create a distinct clone of SP with FlagArtificial set.
LLVM_ABI DIGenericSubrange * getOrCreateGenericSubrange(DIGenericSubrange::BoundType Count, DIGenericSubrange::BoundType LowerBound, DIGenericSubrange::BoundType UpperBound, DIGenericSubrange::BoundType Stride)
LLVM_ABI DIBasicType * createUnspecifiedType(StringRef Name)
Create a DWARF unspecified type.
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.
LLVM_ABI DITemplateValueParameter * createTemplateValueParameter(DIScope *Scope, StringRef Name, DIType *Ty, bool IsDefault, Constant *Val)
Create debugging information for template value parameter.
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.
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.
LLVM_ABI void replaceArrays(DICompositeType *&T, DINodeArray Elements, DINodeArray TParams=DINodeArray())
Replace arrays on a composite type.
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.
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.
Debug common block.
Enumeration value.
DWARF expression.
@ FixedPointBinary
Scale factor 2^Factor.
@ FixedPointDecimal
Scale factor 10^Factor.
@ FixedPointRational
Arbitrary rational scale factor.
PointerUnion< DIVariable *, DIExpression * > BoundType
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.
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.
Wrapper structure that holds a language name and its version.
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.
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
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition IRBuilder.h:2783
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.
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:1078
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition Metadata.h:1577
static TempMDTuple getTemporary(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition Metadata.h:1581
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition Metadata.h:1569
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:1327
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:1317
Tracking metadata reference owned by Metadata.
Definition Metadata.h:900
static LLVM_ABI MDString * get(LLVMContext &Context, StringRef Str)
Definition Metadata.cpp:608
Tuple of metadata.
Definition Metadata.h:1497
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition Metadata.h:1526
static LLVM_ABI MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
Definition Metadata.cpp:104
Root of the metadata hierarchy.
Definition Metadata.h:64
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
A tuple of MDNodes.
Definition Metadata.h:1757
LLVM_ABI void addOperand(MDNode *M)
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
Definition Type.cpp:298
Typed tracking ref.
static LLVM_ABI ValueAsMetadata * get(Value *V)
Definition Metadata.cpp:503
LLVM Value Representation.
Definition Value.h:75
self_iterator getIterator()
Definition ilist_node.h:123
@ 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:35
@ DW_MACINFO_undef
Definition Dwarf.h:818
@ DW_MACINFO_start_file
Definition Dwarf.h:819
@ DW_MACINFO_define
Definition Dwarf.h:817
This is an optimization pass for GlobalISel generic memory operations.
TypedTrackingMDRef< MDNode > TrackingMDNodeRef
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:644
constexpr from_range_t from_range
auto cast_or_null(const Y &Val)
Definition Casting.h:715
bool isa_and_nonnull(const Y &Val)
Definition Casting.h:677
auto dyn_cast_or_null(const Y &Val)
Definition Casting.h:754
FunctionAddr VTableAddr Count
Definition InstrProf.h:139
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:548
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
IRBuilder(LLVMContext &, FolderTy, InserterTy, MDNode *, ArrayRef< OperandBundleDef >) -> IRBuilder< FolderTy, InserterTy >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:560
PointerUnion< Instruction *, DbgRecord * > DbgInstPtr
Definition DIBuilder.h:44
#define N
A single checksum, represented by a Kind and a Value (a string).