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