Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
DebugInfoMetadata.cpp
Go to the documentation of this file.
1//===- DebugInfoMetadata.cpp - Implement debug info metadata --------------===//
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 debug info Metadata classes.
10//
11//===----------------------------------------------------------------------===//
12
13#include "llvm/IR/DebugInfoMetadata.h"
14#include "LLVMContextImpl.h"
15#include "MetadataImpl.h"
16#include "llvm/ADT/SmallPtrSet.h"
17#include "llvm/ADT/StringSwitch.h"
18#include "llvm/BinaryFormat/Dwarf.h"
19#include "llvm/IR/DebugProgramInstruction.h"
20#include "llvm/IR/Function.h"
21#include "llvm/IR/IntrinsicInst.h"
22#include "llvm/IR/Type.h"
23#include "llvm/IR/Value.h"
24
25#include <numeric>
26#include <optional>
27
28using namespacellvm;
29
30namespacellvm {
31// Use FS-AFDO discriminator.
32cl::opt<bool>EnableFSDiscriminator(
33"enable-fs-discriminator",cl::Hidden,
34cl::desc("Enable adding flow sensitive discriminators"));
35}// namespace llvm
36
37uint32_tDIType::getAlignInBits() const{
38return (getTag() == dwarf::DW_TAG_LLVM_ptrauth_type ? 0 :SubclassData32);
39}
40
41constDIExpression::FragmentInfo DebugVariable::DefaultFragment = {
42 std::numeric_limits<uint64_t>::max(), std::numeric_limits<uint64_t>::min()};
43
44DebugVariable::DebugVariable(constDbgVariableIntrinsic *DII)
45 : Variable(DII->getVariable()),
46 Fragment(DII->getExpression()->getFragmentInfo()),
47 InlinedAt(DII->getDebugLoc().getInlinedAt()) {}
48
49DebugVariable::DebugVariable(constDbgVariableRecord *DVR)
50 : Variable(DVR->getVariable()),
51 Fragment(DVR->getExpression()->getFragmentInfo()),
52 InlinedAt(DVR->getDebugLoc().getInlinedAt()) {}
53
54DebugVariableAggregate::DebugVariableAggregate(constDbgVariableIntrinsic *DVI)
55 :DebugVariable(DVI->getVariable(),std::nullopt,
56 DVI->getDebugLoc()->getInlinedAt()) {}
57
58DILocation::DILocation(LLVMContext &C, StorageType Storage,unsigned Line,
59unsigned Column,ArrayRef<Metadata *> MDs,
60bool ImplicitCode)
61 :MDNode(C, DILocationKind, Storage, MDs) {
62assert((MDs.size() == 1 || MDs.size() == 2) &&
63"Expected a scope and optional inlined-at");
64
65// Set line and column.
66assert(Column < (1u << 16) &&"Expected 16-bit column");
67
68 SubclassData32 = Line;
69 SubclassData16 = Column;
70
71 setImplicitCode(ImplicitCode);
72}
73
74staticvoidadjustColumn(unsigned &Column) {
75// Set to unknown on overflow. We only have 16 bits to play with here.
76if (Column >= (1u << 16))
77 Column = 0;
78}
79
80DILocation *DILocation::getImpl(LLVMContext &Context,unsigned Line,
81unsigned Column,Metadata *Scope,
82Metadata *InlinedAt,bool ImplicitCode,
83 StorageType Storage,bool ShouldCreate) {
84// Fixup column.
85adjustColumn(Column);
86
87if (Storage ==Uniqued) {
88if (auto *N =getUniqued(Context.pImpl->DILocations,
89 DILocationInfo::KeyTy(Line,Column,Scope,
90InlinedAt,ImplicitCode)))
91returnN;
92if (!ShouldCreate)
93returnnullptr;
94 }else {
95assert(ShouldCreate &&"Expected non-uniqued nodes to always be created");
96 }
97
98SmallVector<Metadata *, 2> Ops;
99 Ops.push_back(Scope);
100if (InlinedAt)
101 Ops.push_back(InlinedAt);
102returnstoreImpl(new (Ops.size(),Storage)DILocation(
103 Context,Storage,Line,Column, Ops,ImplicitCode),
104Storage, Context.pImpl->DILocations);
105}
106
107DILocation *DILocation::getMergedLocations(ArrayRef<DILocation *> Locs) {
108if (Locs.empty())
109returnnullptr;
110if (Locs.size() == 1)
111return Locs[0];
112auto *Merged = Locs[0];
113for (DILocation *L :llvm::drop_begin(Locs)) {
114 Merged =getMergedLocation(Merged, L);
115if (Merged ==nullptr)
116break;
117 }
118return Merged;
119}
120
121DILocation *DILocation::getMergedLocation(DILocation *LocA,DILocation *LocB) {
122if (!LocA || !LocB)
123returnnullptr;
124
125if (LocA == LocB)
126return LocA;
127
128LLVMContext &C = LocA->getContext();
129
130usingLocVec =SmallVector<const DILocation *>;
131 LocVec ALocs;
132 LocVec BLocs;
133SmallDenseMap<std::pair<const DISubprogram *, const DILocation *>,unsigned,
134 4>
135 ALookup;
136
137// Walk through LocA and its inlined-at locations, populate them in ALocs and
138// save the index for the subprogram and inlined-at pair, which we use to find
139// a matching starting location in LocB's chain.
140for (auto [L,I] = std::make_pair(LocA, 0U); L; L = L->getInlinedAt(),I++) {
141 ALocs.push_back(L);
142auto Res = ALookup.try_emplace(
143 {L->getScope()->getSubprogram(), L->getInlinedAt()},I);
144assert(Res.second &&"Multiple <SP, InlinedAt> pairs in a location chain?");
145 (void)Res;
146 }
147
148 LocVec::reverse_iterator ARIt = ALocs.rend();
149 LocVec::reverse_iterator BRIt = BLocs.rend();
150
151// Populate BLocs and look for a matching starting location, the first
152// location with the same subprogram and inlined-at location as in LocA's
153// chain. Since the two locations have the same inlined-at location we do
154// not need to look at those parts of the chains.
155for (auto [L,I] = std::make_pair(LocB, 0U); L; L = L->getInlinedAt(),I++) {
156 BLocs.push_back(L);
157
158if (ARIt != ALocs.rend())
159// We have already found a matching starting location.
160continue;
161
162autoIT = ALookup.find({L->getScope()->getSubprogram(), L->getInlinedAt()});
163if (IT == ALookup.end())
164continue;
165
166// The + 1 is to account for the &*rev_it = &(it - 1) relationship.
167 ARIt = LocVec::reverse_iterator(ALocs.begin() +IT->second + 1);
168 BRIt = LocVec::reverse_iterator(BLocs.begin() +I + 1);
169
170// If we have found a matching starting location we do not need to add more
171// locations to BLocs, since we will only look at location pairs preceding
172// the matching starting location, and adding more elements to BLocs could
173// invalidate the iterator that we initialized here.
174break;
175 }
176
177// Merge the two locations if possible, using the supplied
178// inlined-at location for the created location.
179auto MergeLocPair = [&C](constDILocation *L1,constDILocation *L2,
180DILocation *InlinedAt) ->DILocation * {
181if (L1 == L2)
182returnDILocation::get(C, L1->getLine(), L1->getColumn(), L1->getScope(),
183InlinedAt);
184
185// If the locations originate from different subprograms we can't produce
186// a common location.
187if (L1->getScope()->getSubprogram() != L2->getScope()->getSubprogram())
188returnnullptr;
189
190// Return the nearest common scope inside a subprogram.
191auto GetNearestCommonScope = [](DIScope *S1,DIScope *S2) ->DIScope * {
192SmallPtrSet<DIScope *, 8> Scopes;
193for (;S1;S1 =S1->getScope()) {
194 Scopes.insert(S1);
195if (isa<DISubprogram>(S1))
196break;
197 }
198
199for (; S2; S2 = S2->getScope()) {
200if (Scopes.count(S2))
201return S2;
202if (isa<DISubprogram>(S2))
203break;
204 }
205
206returnnullptr;
207 };
208
209autoScope = GetNearestCommonScope(L1->getScope(), L2->getScope());
210assert(Scope &&"No common scope in the same subprogram?");
211
212bool SameLine = L1->getLine() == L2->getLine();
213bool SameCol = L1->getColumn() == L2->getColumn();
214unsignedLine = SameLine ? L1->getLine() : 0;
215unsigned Col = SameLine && SameCol ? L1->getColumn() : 0;
216
217returnDILocation::get(C,Line, Col,Scope,InlinedAt);
218 };
219
220DILocation *Result = ARIt != ALocs.rend() ? (*ARIt)->getInlinedAt() :nullptr;
221
222// If we have found a common starting location, walk up the inlined-at chains
223// and try to produce common locations.
224for (; ARIt != ALocs.rend() && BRIt != BLocs.rend(); ++ARIt, ++BRIt) {
225DILocation *Tmp = MergeLocPair(*ARIt, *BRIt, Result);
226
227if (!Tmp)
228// We have walked up to a point in the chains where the two locations
229// are irreconsilable. At this point Result contains the nearest common
230// location in the inlined-at chains of LocA and LocB, so we break here.
231break;
232
233 Result = Tmp;
234 }
235
236if (Result)
237return Result;
238
239// We ended up with LocA and LocB as irreconsilable locations. Produce a
240// location at 0:0 with one of the locations' scope. The function has
241// historically picked A's scope, and a nullptr inlined-at location, so that
242// behavior is mimicked here but I am not sure if this is always the correct
243// way to handle this.
244returnDILocation::get(C, 0, 0, LocA->getScope(),nullptr);
245}
246
247std::optional<unsigned>
248DILocation::encodeDiscriminator(unsigned BD,unsignedDF,unsigned CI) {
249 std::array<unsigned, 3> Components = {BD,DF, CI};
250uint64_t RemainingWork = 0U;
251// We use RemainingWork to figure out if we have no remaining components to
252// encode. For example: if BD != 0 but DF == 0 && CI == 0, we don't need to
253// encode anything for the latter 2.
254// Since any of the input components is at most 32 bits, their sum will be
255// less than 34 bits, and thus RemainingWork won't overflow.
256 RemainingWork =
257 std::accumulate(Components.begin(), Components.end(), RemainingWork);
258
259intI = 0;
260unsigned Ret = 0;
261unsigned NextBitInsertionIndex = 0;
262while (RemainingWork > 0) {
263unsignedC = Components[I++];
264 RemainingWork -=C;
265unsigned EC =encodeComponent(C);
266 Ret |= (EC << NextBitInsertionIndex);
267 NextBitInsertionIndex +=encodingBits(C);
268 }
269
270// Encoding may be unsuccessful because of overflow. We determine success by
271// checking equivalence of components before & after encoding. Alternatively,
272// we could determine Success during encoding, but the current alternative is
273// simpler.
274unsigned TBD, TDF, TCI = 0;
275decodeDiscriminator(Ret, TBD, TDF, TCI);
276if (TBD == BD && TDF ==DF && TCI == CI)
277return Ret;
278return std::nullopt;
279}
280
281voidDILocation::decodeDiscriminator(unsignedD,unsigned &BD,unsigned &DF,
282unsigned &CI) {
283 BD =getUnsignedFromPrefixEncoding(D);
284DF =getUnsignedFromPrefixEncoding(getNextComponentInDiscriminator(D));
285 CI =getUnsignedFromPrefixEncoding(
286getNextComponentInDiscriminator(getNextComponentInDiscriminator(D)));
287}
288dwarf::TagDINode::getTag() const{return (dwarf::Tag)SubclassData16; }
289
290DINode::DIFlagsDINode::getFlag(StringRef Flag) {
291returnStringSwitch<DIFlags>(Flag)
292#define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME)
293#include "llvm/IR/DebugInfoFlags.def"
294 .Default(DINode::FlagZero);
295}
296
297StringRefDINode::getFlagString(DIFlags Flag) {
298switch (Flag) {
299#define HANDLE_DI_FLAG(ID, NAME) \
300 case Flag##NAME: \
301 return "DIFlag" #NAME;
302#include "llvm/IR/DebugInfoFlags.def"
303 }
304return"";
305}
306
307DINode::DIFlagsDINode::splitFlags(DIFlags Flags,
308SmallVectorImpl<DIFlags> &SplitFlags) {
309// Flags that are packed together need to be specially handled, so
310// that, for example, we emit "DIFlagPublic" and not
311// "DIFlagPrivate | DIFlagProtected".
312if (DIFlagsA = Flags &FlagAccessibility) {
313if (A == FlagPrivate)
314 SplitFlags.push_back(FlagPrivate);
315elseif (A == FlagProtected)
316 SplitFlags.push_back(FlagProtected);
317else
318 SplitFlags.push_back(FlagPublic);
319 Flags &= ~A;
320 }
321if (DIFlags R = Flags &FlagPtrToMemberRep) {
322if (R == FlagSingleInheritance)
323 SplitFlags.push_back(FlagSingleInheritance);
324elseif (R == FlagMultipleInheritance)
325 SplitFlags.push_back(FlagMultipleInheritance);
326else
327 SplitFlags.push_back(FlagVirtualInheritance);
328 Flags &= ~R;
329 }
330if ((Flags & FlagIndirectVirtualBase) == FlagIndirectVirtualBase) {
331 Flags &= ~FlagIndirectVirtualBase;
332 SplitFlags.push_back(FlagIndirectVirtualBase);
333 }
334
335#define HANDLE_DI_FLAG(ID, NAME) \
336 if (DIFlags Bit = Flags & Flag##NAME) { \
337 SplitFlags.push_back(Bit); \
338 Flags &= ~Bit; \
339 }
340#include "llvm/IR/DebugInfoFlags.def"
341return Flags;
342}
343
344DIScope *DIScope::getScope() const{
345if (auto *T = dyn_cast<DIType>(this))
346returnT->getScope();
347
348if (auto *SP = dyn_cast<DISubprogram>(this))
349return SP->getScope();
350
351if (auto *LB = dyn_cast<DILexicalBlockBase>(this))
352return LB->getScope();
353
354if (auto *NS = dyn_cast<DINamespace>(this))
355return NS->getScope();
356
357if (auto *CB = dyn_cast<DICommonBlock>(this))
358return CB->getScope();
359
360if (auto *M = dyn_cast<DIModule>(this))
361return M->getScope();
362
363assert((isa<DIFile>(this) || isa<DICompileUnit>(this)) &&
364"Unhandled type of scope.");
365returnnullptr;
366}
367
368StringRefDIScope::getName() const{
369if (auto *T = dyn_cast<DIType>(this))
370returnT->getName();
371if (auto *SP = dyn_cast<DISubprogram>(this))
372return SP->getName();
373if (auto *NS = dyn_cast<DINamespace>(this))
374return NS->getName();
375if (auto *CB = dyn_cast<DICommonBlock>(this))
376return CB->getName();
377if (auto *M = dyn_cast<DIModule>(this))
378return M->getName();
379assert((isa<DILexicalBlockBase>(this) || isa<DIFile>(this) ||
380 isa<DICompileUnit>(this)) &&
381"Unhandled type of scope.");
382return"";
383}
384
385#ifndef NDEBUG
386staticboolisCanonical(constMDString *S) {
387return !S || !S->getString().empty();
388}
389#endif
390
391dwarf::TagGenericDINode::getTag() const{return (dwarf::Tag)SubclassData16; }
392GenericDINode *GenericDINode::getImpl(LLVMContext &Context,unsignedTag,
393MDString *Header,
394ArrayRef<Metadata *> DwarfOps,
395 StorageType Storage,bool ShouldCreate) {
396unsigned Hash = 0;
397if (Storage ==Uniqued) {
398 GenericDINodeInfo::KeyTy Key(Tag,Header,DwarfOps);
399if (auto *N =getUniqued(Context.pImpl->GenericDINodes, Key))
400returnN;
401if (!ShouldCreate)
402returnnullptr;
403 Hash = Key.getHash();
404 }else {
405assert(ShouldCreate &&"Expected non-uniqued nodes to always be created");
406 }
407
408// Use a nullptr for empty headers.
409assert(isCanonical(Header) &&"Expected canonical MDString");
410Metadata *PreOps[] = {Header};
411returnstoreImpl(new (DwarfOps.size() + 1,Storage)GenericDINode(
412 Context,Storage, Hash,Tag, PreOps,DwarfOps),
413Storage, Context.pImpl->GenericDINodes);
414}
415
416void GenericDINode::recalculateHash() {
417 setHash(GenericDINodeInfo::KeyTy::calculateHash(this));
418}
419
420#define UNWRAP_ARGS_IMPL(...) __VA_ARGS__
421#define UNWRAP_ARGS(ARGS) UNWRAP_ARGS_IMPL ARGS
422#define DEFINE_GETIMPL_LOOKUP(CLASS, ARGS) \
423 do { \
424 if (Storage == Uniqued) { \
425 if (auto *N = getUniqued(Context.pImpl->CLASS##s, \
426 CLASS##Info::KeyTy(UNWRAP_ARGS(ARGS)))) \
427 return N; \
428 if (!ShouldCreate) \
429 return nullptr; \
430 } else { \
431 assert(ShouldCreate && \
432 "Expected non-uniqued nodes to always be created"); \
433 } \
434 } while (false)
435#define DEFINE_GETIMPL_STORE(CLASS, ARGS, OPS) \
436 return storeImpl(new (std::size(OPS), Storage) \
437 CLASS(Context, Storage, UNWRAP_ARGS(ARGS), OPS), \
438 Storage, Context.pImpl->CLASS##s)
439#define DEFINE_GETIMPL_STORE_NO_OPS(CLASS, ARGS) \
440 return storeImpl(new (0u, Storage) \
441 CLASS(Context, Storage, UNWRAP_ARGS(ARGS)), \
442 Storage, Context.pImpl->CLASS##s)
443#define DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(CLASS, OPS) \
444 return storeImpl(new (std::size(OPS), Storage) CLASS(Context, Storage, OPS), \
445 Storage, Context.pImpl->CLASS##s)
446#define DEFINE_GETIMPL_STORE_N(CLASS, ARGS, OPS, NUM_OPS) \
447 return storeImpl(new (NUM_OPS, Storage) \
448 CLASS(Context, Storage, UNWRAP_ARGS(ARGS), OPS), \
449 Storage, Context.pImpl->CLASS##s)
450
451DISubrange::DISubrange(LLVMContext &C, StorageType Storage,
452ArrayRef<Metadata *> Ops)
453 :DINode(C, DISubrangeKind, Storage, dwarf::DW_TAG_subrange_type, Ops) {}
454DISubrange *DISubrange::getImpl(LLVMContext &Context, int64_t Count, int64_tLo,
455 StorageType Storage,bool ShouldCreate) {
456auto *CountNode =ConstantAsMetadata::get(
457ConstantInt::getSigned(Type::getInt64Ty(Context), Count));
458auto *LB =ConstantAsMetadata::get(
459ConstantInt::getSigned(Type::getInt64Ty(Context),Lo));
460return getImpl(Context,CountNode, LB,nullptr,nullptr,Storage,
461 ShouldCreate);
462}
463
464DISubrange *DISubrange::getImpl(LLVMContext &Context,Metadata *CountNode,
465 int64_tLo, StorageType Storage,
466bool ShouldCreate) {
467auto *LB =ConstantAsMetadata::get(
468ConstantInt::getSigned(Type::getInt64Ty(Context),Lo));
469return getImpl(Context,CountNode, LB,nullptr,nullptr,Storage,
470 ShouldCreate);
471}
472
473DISubrange *DISubrange::getImpl(LLVMContext &Context,Metadata *CountNode,
474Metadata *LB,Metadata *UB,Metadata *Stride,
475 StorageType Storage,bool ShouldCreate) {
476DEFINE_GETIMPL_LOOKUP(DISubrange, (CountNode, LB, UB, Stride));
477Metadata *Ops[] = {CountNode, LB, UB, Stride};
478DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DISubrange, Ops);
479}
480
481DISubrange::BoundTypeDISubrange::getCount() const{
482Metadata *CB = getRawCountNode();
483if (!CB)
484return BoundType();
485
486assert((isa<ConstantAsMetadata>(CB) || isa<DIVariable>(CB) ||
487 isa<DIExpression>(CB)) &&
488"Count must be signed constant or DIVariable or DIExpression");
489
490if (auto *MD = dyn_cast<ConstantAsMetadata>(CB))
491return BoundType(cast<ConstantInt>(MD->getValue()));
492
493if (auto *MD = dyn_cast<DIVariable>(CB))
494return BoundType(MD);
495
496if (auto *MD = dyn_cast<DIExpression>(CB))
497return BoundType(MD);
498
499return BoundType();
500}
501
502DISubrange::BoundTypeDISubrange::getLowerBound() const{
503Metadata *LB = getRawLowerBound();
504if (!LB)
505return BoundType();
506
507assert((isa<ConstantAsMetadata>(LB) || isa<DIVariable>(LB) ||
508 isa<DIExpression>(LB)) &&
509"LowerBound must be signed constant or DIVariable or DIExpression");
510
511if (auto *MD = dyn_cast<ConstantAsMetadata>(LB))
512return BoundType(cast<ConstantInt>(MD->getValue()));
513
514if (auto *MD = dyn_cast<DIVariable>(LB))
515return BoundType(MD);
516
517if (auto *MD = dyn_cast<DIExpression>(LB))
518return BoundType(MD);
519
520return BoundType();
521}
522
523DISubrange::BoundTypeDISubrange::getUpperBound() const{
524Metadata *UB = getRawUpperBound();
525if (!UB)
526return BoundType();
527
528assert((isa<ConstantAsMetadata>(UB) || isa<DIVariable>(UB) ||
529 isa<DIExpression>(UB)) &&
530"UpperBound must be signed constant or DIVariable or DIExpression");
531
532if (auto *MD = dyn_cast<ConstantAsMetadata>(UB))
533return BoundType(cast<ConstantInt>(MD->getValue()));
534
535if (auto *MD = dyn_cast<DIVariable>(UB))
536return BoundType(MD);
537
538if (auto *MD = dyn_cast<DIExpression>(UB))
539return BoundType(MD);
540
541return BoundType();
542}
543
544DISubrange::BoundTypeDISubrange::getStride() const{
545Metadata *ST = getRawStride();
546if (!ST)
547return BoundType();
548
549assert((isa<ConstantAsMetadata>(ST) || isa<DIVariable>(ST) ||
550 isa<DIExpression>(ST)) &&
551"Stride must be signed constant or DIVariable or DIExpression");
552
553if (auto *MD = dyn_cast<ConstantAsMetadata>(ST))
554return BoundType(cast<ConstantInt>(MD->getValue()));
555
556if (auto *MD = dyn_cast<DIVariable>(ST))
557return BoundType(MD);
558
559if (auto *MD = dyn_cast<DIExpression>(ST))
560return BoundType(MD);
561
562return BoundType();
563}
564DIGenericSubrange::DIGenericSubrange(LLVMContext &C, StorageType Storage,
565ArrayRef<Metadata *> Ops)
566 :DINode(C, DIGenericSubrangeKind, Storage, dwarf::DW_TAG_generic_subrange,
567 Ops) {}
568
569DIGenericSubrange *DIGenericSubrange::getImpl(LLVMContext &Context,
570Metadata *CountNode,Metadata *LB,
571Metadata *UB,Metadata *Stride,
572 StorageType Storage,
573bool ShouldCreate) {
574DEFINE_GETIMPL_LOOKUP(DIGenericSubrange, (CountNode, LB, UB, Stride));
575Metadata *Ops[] = {CountNode, LB, UB, Stride};
576DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIGenericSubrange, Ops);
577}
578
579DIGenericSubrange::BoundTypeDIGenericSubrange::getCount() const{
580Metadata *CB =getRawCountNode();
581if (!CB)
582returnBoundType();
583
584assert((isa<DIVariable>(CB) || isa<DIExpression>(CB)) &&
585"Count must be signed constant or DIVariable or DIExpression");
586
587if (auto *MD = dyn_cast<DIVariable>(CB))
588returnBoundType(MD);
589
590if (auto *MD = dyn_cast<DIExpression>(CB))
591returnBoundType(MD);
592
593returnBoundType();
594}
595
596DIGenericSubrange::BoundTypeDIGenericSubrange::getLowerBound() const{
597Metadata *LB =getRawLowerBound();
598if (!LB)
599returnBoundType();
600
601assert((isa<DIVariable>(LB) || isa<DIExpression>(LB)) &&
602"LowerBound must be signed constant or DIVariable or DIExpression");
603
604if (auto *MD = dyn_cast<DIVariable>(LB))
605returnBoundType(MD);
606
607if (auto *MD = dyn_cast<DIExpression>(LB))
608returnBoundType(MD);
609
610returnBoundType();
611}
612
613DIGenericSubrange::BoundTypeDIGenericSubrange::getUpperBound() const{
614Metadata *UB =getRawUpperBound();
615if (!UB)
616returnBoundType();
617
618assert((isa<DIVariable>(UB) || isa<DIExpression>(UB)) &&
619"UpperBound must be signed constant or DIVariable or DIExpression");
620
621if (auto *MD = dyn_cast<DIVariable>(UB))
622returnBoundType(MD);
623
624if (auto *MD = dyn_cast<DIExpression>(UB))
625returnBoundType(MD);
626
627returnBoundType();
628}
629
630DIGenericSubrange::BoundTypeDIGenericSubrange::getStride() const{
631Metadata *ST =getRawStride();
632if (!ST)
633returnBoundType();
634
635assert((isa<DIVariable>(ST) || isa<DIExpression>(ST)) &&
636"Stride must be signed constant or DIVariable or DIExpression");
637
638if (auto *MD = dyn_cast<DIVariable>(ST))
639returnBoundType(MD);
640
641if (auto *MD = dyn_cast<DIExpression>(ST))
642returnBoundType(MD);
643
644returnBoundType();
645}
646
647DIEnumerator::DIEnumerator(LLVMContext &C, StorageType Storage,
648constAPInt &Value,bool IsUnsigned,
649ArrayRef<Metadata *> Ops)
650 :DINode(C, DIEnumeratorKind, Storage, dwarf::DW_TAG_enumerator, Ops),
651Value(Value) {
652SubclassData32 = IsUnsigned;
653}
654DIEnumerator *DIEnumerator::getImpl(LLVMContext &Context,constAPInt &Value,
655bool IsUnsigned,MDString *Name,
656 StorageType Storage,bool ShouldCreate) {
657assert(isCanonical(Name) &&"Expected canonical MDString");
658DEFINE_GETIMPL_LOOKUP(DIEnumerator, (Value,IsUnsigned,Name));
659Metadata *Ops[] = {Name};
660DEFINE_GETIMPL_STORE(DIEnumerator, (Value,IsUnsigned), Ops);
661}
662
663DIBasicType *DIBasicType::getImpl(LLVMContext &Context,unsignedTag,
664MDString *Name,uint64_t SizeInBits,
665uint32_t AlignInBits,unsigned Encoding,
666uint32_t NumExtraInhabitants, DIFlags Flags,
667 StorageType Storage,bool ShouldCreate) {
668assert(isCanonical(Name) &&"Expected canonical MDString");
669DEFINE_GETIMPL_LOOKUP(DIBasicType, (Tag,Name,SizeInBits,AlignInBits,
670 Encoding,NumExtraInhabitants,Flags));
671Metadata *Ops[] = {nullptr,nullptr,Name};
672DEFINE_GETIMPL_STORE(
673DIBasicType,
674 (Tag,SizeInBits,AlignInBits, Encoding,NumExtraInhabitants,Flags),
675 Ops);
676}
677
678std::optional<DIBasicType::Signedness>DIBasicType::getSignedness() const{
679switch (getEncoding()) {
680case dwarf::DW_ATE_signed:
681case dwarf::DW_ATE_signed_char:
682returnSignedness::Signed;
683case dwarf::DW_ATE_unsigned:
684case dwarf::DW_ATE_unsigned_char:
685returnSignedness::Unsigned;
686default:
687return std::nullopt;
688 }
689}
690
691DIStringType *DIStringType::getImpl(LLVMContext &Context,unsignedTag,
692MDString *Name,Metadata *StringLength,
693Metadata *StringLengthExp,
694Metadata *StringLocationExp,
695uint64_t SizeInBits,uint32_t AlignInBits,
696unsigned Encoding, StorageType Storage,
697bool ShouldCreate) {
698assert(isCanonical(Name) &&"Expected canonical MDString");
699DEFINE_GETIMPL_LOOKUP(DIStringType,
700 (Tag,Name,StringLength,StringLengthExp,
701StringLocationExp,SizeInBits,AlignInBits, Encoding));
702Metadata *Ops[] = {nullptr,nullptr,Name,
703StringLength,StringLengthExp,StringLocationExp};
704DEFINE_GETIMPL_STORE(DIStringType, (Tag,SizeInBits,AlignInBits, Encoding),
705 Ops);
706}
707DIType *DIDerivedType::getClassType() const{
708assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
709return cast_or_null<DIType>(getExtraData());
710}
711uint32_tDIDerivedType::getVBPtrOffset() const{
712assert(getTag() == dwarf::DW_TAG_inheritance);
713if (auto *CM = cast_or_null<ConstantAsMetadata>(getExtraData()))
714if (auto *CI = dyn_cast_or_null<ConstantInt>(CM->getValue()))
715returnstatic_cast<uint32_t>(CI->getZExtValue());
716return 0;
717}
718Constant *DIDerivedType::getStorageOffsetInBits() const{
719assert(getTag() == dwarf::DW_TAG_member &&isBitField());
720if (auto *C = cast_or_null<ConstantAsMetadata>(getExtraData()))
721returnC->getValue();
722returnnullptr;
723}
724
725Constant *DIDerivedType::getConstant() const{
726assert((getTag() == dwarf::DW_TAG_member ||
727getTag() == dwarf::DW_TAG_variable) &&
728isStaticMember());
729if (auto *C = cast_or_null<ConstantAsMetadata>(getExtraData()))
730returnC->getValue();
731returnnullptr;
732}
733Constant *DIDerivedType::getDiscriminantValue() const{
734assert(getTag() == dwarf::DW_TAG_member && !isStaticMember());
735if (auto *C = cast_or_null<ConstantAsMetadata>(getExtraData()))
736returnC->getValue();
737returnnullptr;
738}
739
740DIDerivedType *DIDerivedType::getImpl(
741LLVMContext &Context,unsignedTag,MDString *Name,Metadata *File,
742unsigned Line,Metadata *Scope,Metadata *BaseType,uint64_t SizeInBits,
743uint32_t AlignInBits,uint64_t OffsetInBits,
744 std::optional<unsigned> DWARFAddressSpace,
745 std::optional<PtrAuthData> PtrAuthData, DIFlags Flags,Metadata *ExtraData,
746Metadata *Annotations, StorageType Storage,bool ShouldCreate) {
747assert(isCanonical(Name) &&"Expected canonical MDString");
748DEFINE_GETIMPL_LOOKUP(DIDerivedType,
749 (Tag,Name,File,Line,Scope,BaseType,SizeInBits,
750AlignInBits,OffsetInBits, DWARFAddressSpace,
751 PtrAuthData,Flags,ExtraData,Annotations));
752Metadata *Ops[] = {File,Scope,Name,BaseType,ExtraData,Annotations};
753DEFINE_GETIMPL_STORE(DIDerivedType,
754 (Tag,Line,SizeInBits,AlignInBits,OffsetInBits,
755 DWARFAddressSpace, PtrAuthData,Flags),
756 Ops);
757}
758
759std::optional<DIDerivedType::PtrAuthData>
760DIDerivedType::getPtrAuthData() const{
761returngetTag() == dwarf::DW_TAG_LLVM_ptrauth_type
762 ? std::optional<PtrAuthData>(PtrAuthData(SubclassData32))
763 :std::nullopt;
764}
765
766DICompositeType *DICompositeType::getImpl(
767LLVMContext &Context,unsignedTag,MDString *Name,Metadata *File,
768unsigned Line,Metadata *Scope,Metadata *BaseType,uint64_t SizeInBits,
769uint32_t AlignInBits,uint64_t OffsetInBits, DIFlags Flags,
770Metadata *Elements,unsigned RuntimeLang,Metadata *VTableHolder,
771Metadata *TemplateParams,MDString *Identifier,Metadata *Discriminator,
772Metadata *DataLocation,Metadata *Associated,Metadata *Allocated,
773Metadata *Rank,Metadata *Annotations,Metadata *Specification,
774uint32_t NumExtraInhabitants, StorageType Storage,bool ShouldCreate) {
775assert(isCanonical(Name) &&"Expected canonical MDString");
776
777// Keep this in sync with buildODRType.
778DEFINE_GETIMPL_LOOKUP(
779DICompositeType,
780 (Tag,Name,File,Line,Scope,BaseType,SizeInBits,AlignInBits,
781OffsetInBits,Flags,Elements, RuntimeLang,VTableHolder,TemplateParams,
782Identifier,Discriminator,DataLocation,Associated,Allocated,Rank,
783Annotations,Specification,NumExtraInhabitants));
784Metadata *Ops[] = {File,Scope,Name,BaseType,
785Elements,VTableHolder,TemplateParams,Identifier,
786Discriminator,DataLocation,Associated,Allocated,
787Rank,Annotations,Specification};
788DEFINE_GETIMPL_STORE(DICompositeType,
789 (Tag,Line, RuntimeLang,SizeInBits,AlignInBits,
790OffsetInBits,NumExtraInhabitants,Flags),
791 Ops);
792}
793
794DICompositeType *DICompositeType::buildODRType(
795LLVMContext &Context,MDString &Identifier,unsignedTag,MDString *Name,
796Metadata *File,unsigned Line,Metadata *Scope,Metadata *BaseType,
797uint64_t SizeInBits,uint32_t AlignInBits,uint64_t OffsetInBits,
798Metadata *Specification,uint32_t NumExtraInhabitants,DIFlags Flags,
799Metadata *Elements,unsigned RuntimeLang,Metadata *VTableHolder,
800Metadata *TemplateParams,Metadata *Discriminator,Metadata *DataLocation,
801Metadata *Associated,Metadata *Allocated,Metadata *Rank,
802Metadata *Annotations) {
803assert(!Identifier.getString().empty() &&"Expected valid identifier");
804if (!Context.isODRUniquingDebugTypes())
805returnnullptr;
806auto *&CT = (*Context.pImpl->DITypeMap)[&Identifier];
807if (!CT)
808return CT =DICompositeType::getDistinct(
809 Context,Tag,Name,File,Line,Scope,BaseType,SizeInBits,
810AlignInBits,OffsetInBits,Flags,Elements, RuntimeLang,
811VTableHolder,TemplateParams, &Identifier,Discriminator,
812DataLocation,Associated,Allocated,Rank,Annotations,
813Specification,NumExtraInhabitants);
814if (CT->getTag() !=Tag)
815returnnullptr;
816
817// Only mutate CT if it's a forward declaration and the new operands aren't.
818assert(CT->getRawIdentifier() == &Identifier &&"Wrong ODR identifier?");
819if (!CT->isForwardDecl() || (Flags & DINode::FlagFwdDecl))
820return CT;
821
822// Mutate CT in place. Keep this in sync with getImpl.
823 CT->mutate(Tag,Line, RuntimeLang,SizeInBits,AlignInBits,OffsetInBits,
824NumExtraInhabitants,Flags);
825Metadata *Ops[] = {File,Scope,Name,BaseType,
826Elements,VTableHolder,TemplateParams, &Identifier,
827Discriminator,DataLocation,Associated,Allocated,
828Rank,Annotations,Specification};
829assert((std::end(Ops) - std::begin(Ops)) == (int)CT->getNumOperands() &&
830"Mismatched number of operands");
831for (unsignedI = 0, E = CT->getNumOperands();I != E; ++I)
832if (Ops[I] != CT->getOperand(I))
833 CT->setOperand(I, Ops[I]);
834return CT;
835}
836
837DICompositeType *DICompositeType::getODRType(
838LLVMContext &Context,MDString &Identifier,unsignedTag,MDString *Name,
839Metadata *File,unsigned Line,Metadata *Scope,Metadata *BaseType,
840uint64_t SizeInBits,uint32_t AlignInBits,uint64_t OffsetInBits,
841Metadata *Specification,uint32_t NumExtraInhabitants, DIFlags Flags,
842Metadata *Elements,unsigned RuntimeLang,Metadata *VTableHolder,
843Metadata *TemplateParams,Metadata *Discriminator,Metadata *DataLocation,
844Metadata *Associated,Metadata *Allocated,Metadata *Rank,
845Metadata *Annotations) {
846assert(!Identifier.getString().empty() &&"Expected valid identifier");
847if (!Context.isODRUniquingDebugTypes())
848returnnullptr;
849auto *&CT = (*Context.pImpl->DITypeMap)[&Identifier];
850if (!CT) {
851 CT =DICompositeType::getDistinct(
852 Context,Tag,Name,File,Line,Scope,BaseType,SizeInBits,
853AlignInBits,OffsetInBits,Flags,Elements, RuntimeLang,VTableHolder,
854TemplateParams, &Identifier,Discriminator,DataLocation,Associated,
855Allocated,Rank,Annotations,Specification,NumExtraInhabitants);
856 }else {
857if (CT->getTag() !=Tag)
858returnnullptr;
859 }
860return CT;
861}
862
863DICompositeType *DICompositeType::getODRTypeIfExists(LLVMContext &Context,
864MDString &Identifier) {
865assert(!Identifier.getString().empty() &&"Expected valid identifier");
866if (!Context.isODRUniquingDebugTypes())
867returnnullptr;
868return Context.pImpl->DITypeMap->lookup(&Identifier);
869}
870DISubroutineType::DISubroutineType(LLVMContext &C, StorageType Storage,
871 DIFlags Flags,uint8_tCC,
872ArrayRef<Metadata *> Ops)
873 :DIType(C, DISubroutineTypeKind, Storage, dwarf::DW_TAG_subroutine_type, 0,
874 0, 0, 0, 0, Flags, Ops),
875CC(CC) {}
876
877DISubroutineType *DISubroutineType::getImpl(LLVMContext &Context, DIFlags Flags,
878uint8_tCC,Metadata *TypeArray,
879 StorageType Storage,
880bool ShouldCreate) {
881DEFINE_GETIMPL_LOOKUP(DISubroutineType, (Flags, CC,TypeArray));
882Metadata *Ops[] = {nullptr,nullptr,nullptr,TypeArray};
883DEFINE_GETIMPL_STORE(DISubroutineType, (Flags, CC), Ops);
884}
885
886DIFile::DIFile(LLVMContext &C, StorageType Storage,
887 std::optional<ChecksumInfo<MDString *>> CS,MDString *Src,
888ArrayRef<Metadata *> Ops)
889 :DIScope(C, DIFileKind, Storage, dwarf::DW_TAG_file_type, Ops),
890 Checksum(CS),Source(Src) {}
891
892// FIXME: Implement this string-enum correspondence with a .def file and macros,
893// so that the association is explicit rather than implied.
894staticconstchar *ChecksumKindName[DIFile::CSK_Last] = {
895"CSK_MD5",
896"CSK_SHA1",
897"CSK_SHA256",
898};
899
900StringRef DIFile::getChecksumKindAsString(ChecksumKind CSKind) {
901assert(CSKind <=DIFile::CSK_Last &&"Invalid checksum kind");
902// The first space was originally the CSK_None variant, which is now
903// obsolete, but the space is still reserved in ChecksumKind, so we account
904// for it here.
905returnChecksumKindName[CSKind - 1];
906}
907
908std::optional<DIFile::ChecksumKind>
909DIFile::getChecksumKind(StringRef CSKindStr) {
910returnStringSwitch<std::optional<DIFile::ChecksumKind>>(CSKindStr)
911 .Case("CSK_MD5",DIFile::CSK_MD5)
912 .Case("CSK_SHA1",DIFile::CSK_SHA1)
913 .Case("CSK_SHA256",DIFile::CSK_SHA256)
914 .Default(std::nullopt);
915}
916
917DIFile *DIFile::getImpl(LLVMContext &Context,MDString *Filename,
918MDString *Directory,
919 std::optional<DIFile::ChecksumInfo<MDString *>> CS,
920MDString *Source, StorageType Storage,
921bool ShouldCreate) {
922assert(isCanonical(Filename) &&"Expected canonical MDString");
923assert(isCanonical(Directory) &&"Expected canonical MDString");
924assert((!CS ||isCanonical(CS->Value)) &&"Expected canonical MDString");
925// We do *NOT* expect Source to be a canonical MDString because nullptr
926// means none, so we need something to represent the empty file.
927DEFINE_GETIMPL_LOOKUP(DIFile, (Filename,Directory,CS, Source));
928Metadata *Ops[] = {Filename,Directory,CS ?CS->Value :nullptr, Source};
929DEFINE_GETIMPL_STORE(DIFile, (CS, Source), Ops);
930}
931DICompileUnit::DICompileUnit(LLVMContext &C, StorageType Storage,
932unsignedSourceLanguage,bool IsOptimized,
933unsigned RuntimeVersion,unsigned EmissionKind,
934uint64_t DWOId,bool SplitDebugInlining,
935bool DebugInfoForProfiling,unsigned NameTableKind,
936bool RangesBaseAddress,ArrayRef<Metadata *> Ops)
937 :DIScope(C, DICompileUnitKind, Storage, dwarf::DW_TAG_compile_unit, Ops),
938SourceLanguage(SourceLanguage), RuntimeVersion(RuntimeVersion),
939 DWOId(DWOId),EmissionKind(EmissionKind),NameTableKind(NameTableKind),
940 IsOptimized(IsOptimized), SplitDebugInlining(SplitDebugInlining),
941 DebugInfoForProfiling(DebugInfoForProfiling),
942 RangesBaseAddress(RangesBaseAddress) {
943assert(Storage !=Uniqued);
944}
945
946DICompileUnit *DICompileUnit::getImpl(
947LLVMContext &Context,unsignedSourceLanguage,Metadata *File,
948MDString *Producer,bool IsOptimized,MDString *Flags,
949unsigned RuntimeVersion,MDString *SplitDebugFilename,
950unsigned EmissionKind,Metadata *EnumTypes,Metadata *RetainedTypes,
951Metadata *GlobalVariables,Metadata *ImportedEntities,Metadata *Macros,
952uint64_t DWOId,bool SplitDebugInlining,bool DebugInfoForProfiling,
953unsigned NameTableKind,bool RangesBaseAddress,MDString *SysRoot,
954MDString *SDK, StorageType Storage,bool ShouldCreate) {
955assert(Storage !=Uniqued &&"Cannot unique DICompileUnit");
956assert(isCanonical(Producer) &&"Expected canonical MDString");
957assert(isCanonical(Flags) &&"Expected canonical MDString");
958assert(isCanonical(SplitDebugFilename) &&"Expected canonical MDString");
959
960Metadata *Ops[] = {File,
961Producer,
962Flags,
963SplitDebugFilename,
964EnumTypes,
965RetainedTypes,
966GlobalVariables,
967ImportedEntities,
968Macros,
969SysRoot,
970SDK};
971returnstoreImpl(new (std::size(Ops),Storage)DICompileUnit(
972 Context,Storage,SourceLanguage, IsOptimized,
973 RuntimeVersion, EmissionKind, DWOId, SplitDebugInlining,
974 DebugInfoForProfiling, NameTableKind, RangesBaseAddress,
975 Ops),
976Storage);
977}
978
979std::optional<DICompileUnit::DebugEmissionKind>
980DICompileUnit::getEmissionKind(StringRef Str) {
981returnStringSwitch<std::optional<DebugEmissionKind>>(Str)
982 .Case("NoDebug",NoDebug)
983 .Case("FullDebug",FullDebug)
984 .Case("LineTablesOnly",LineTablesOnly)
985 .Case("DebugDirectivesOnly",DebugDirectivesOnly)
986 .Default(std::nullopt);
987}
988
989std::optional<DICompileUnit::DebugNameTableKind>
990DICompileUnit::getNameTableKind(StringRef Str) {
991returnStringSwitch<std::optional<DebugNameTableKind>>(Str)
992 .Case("Default",DebugNameTableKind::Default)
993 .Case("GNU",DebugNameTableKind::GNU)
994 .Case("Apple",DebugNameTableKind::Apple)
995 .Case("None",DebugNameTableKind::None)
996 .Default(std::nullopt);
997}
998
999constchar *DICompileUnit::emissionKindString(DebugEmissionKind EK) {
1000switch (EK) {
1001caseNoDebug:
1002return"NoDebug";
1003caseFullDebug:
1004return"FullDebug";
1005caseLineTablesOnly:
1006return"LineTablesOnly";
1007caseDebugDirectivesOnly:
1008return"DebugDirectivesOnly";
1009 }
1010returnnullptr;
1011}
1012
1013constchar *DICompileUnit::nameTableKindString(DebugNameTableKind NTK) {
1014switch (NTK) {
1015caseDebugNameTableKind::Default:
1016returnnullptr;
1017caseDebugNameTableKind::GNU:
1018return"GNU";
1019caseDebugNameTableKind::Apple:
1020return"Apple";
1021caseDebugNameTableKind::None:
1022return"None";
1023 }
1024returnnullptr;
1025}
1026DISubprogram::DISubprogram(LLVMContext &C, StorageType Storage,unsigned Line,
1027unsigned ScopeLine,unsigned VirtualIndex,
1028int ThisAdjustment, DIFlags Flags, DISPFlags SPFlags,
1029ArrayRef<Metadata *> Ops)
1030 :DILocalScope(C, DISubprogramKind, Storage, dwarf::DW_TAG_subprogram, Ops),
1031 Line(Line), ScopeLine(ScopeLine), VirtualIndex(VirtualIndex),
1032 ThisAdjustment(ThisAdjustment), Flags(Flags), SPFlags(SPFlags) {
1033static_assert(dwarf::DW_VIRTUALITY_max < 4,"Virtuality out of range");
1034}
1035DISubprogram::DISPFlags
1036DISubprogram::toSPFlags(bool IsLocalToUnit,bool IsDefinition,bool IsOptimized,
1037unsigned Virtuality,bool IsMainSubprogram) {
1038// We're assuming virtuality is the low-order field.
1039static_assert(int(SPFlagVirtual) == int(dwarf::DW_VIRTUALITY_virtual) &&
1040 int(SPFlagPureVirtual) ==
1041 int(dwarf::DW_VIRTUALITY_pure_virtual),
1042"Virtuality constant mismatch");
1043returnstatic_cast<DISPFlags>(
1044 (Virtuality &SPFlagVirtuality) |
1045 (IsLocalToUnit ? SPFlagLocalToUnit : SPFlagZero) |
1046 (IsDefinition ? SPFlagDefinition : SPFlagZero) |
1047 (IsOptimized ? SPFlagOptimized : SPFlagZero) |
1048 (IsMainSubprogram ? SPFlagMainSubprogram : SPFlagZero));
1049}
1050
1051DISubprogram *DILocalScope::getSubprogram() const{
1052if (auto *Block = dyn_cast<DILexicalBlockBase>(this))
1053returnBlock->getScope()->getSubprogram();
1054returnconst_cast<DISubprogram *>(cast<DISubprogram>(this));
1055}
1056
1057DILocalScope *DILocalScope::getNonLexicalBlockFileScope() const{
1058if (auto *File = dyn_cast<DILexicalBlockFile>(this))
1059return File->getScope()->getNonLexicalBlockFileScope();
1060returnconst_cast<DILocalScope *>(this);
1061}
1062
1063DILocalScope *DILocalScope::cloneScopeForSubprogram(
1064DILocalScope &RootScope,DISubprogram &NewSP,LLVMContext &Ctx,
1065DenseMap<const MDNode *, MDNode *> &Cache) {
1066SmallVector<DIScope *> ScopeChain;
1067DIScope *CachedResult =nullptr;
1068
1069for (DIScope *Scope = &RootScope; !isa<DISubprogram>(Scope);
1070 Scope = Scope->getScope()) {
1071if (auto It = Cache.find(Scope); It != Cache.end()) {
1072 CachedResult = cast<DIScope>(It->second);
1073break;
1074 }
1075 ScopeChain.push_back(Scope);
1076 }
1077
1078// Recreate the scope chain, bottom-up, starting at the new subprogram (or a
1079// cached result).
1080DIScope *UpdatedScope = CachedResult ? CachedResult : &NewSP;
1081for (DIScope *ScopeToUpdate :reverse(ScopeChain)) {
1082 TempMDNode ClonedScope = ScopeToUpdate->clone();
1083 cast<DILexicalBlockBase>(*ClonedScope).replaceScope(UpdatedScope);
1084 UpdatedScope =
1085 cast<DIScope>(MDNode::replaceWithUniqued(std::move(ClonedScope)));
1086 Cache[ScopeToUpdate] = UpdatedScope;
1087 }
1088
1089return cast<DILocalScope>(UpdatedScope);
1090}
1091
1092DISubprogram::DISPFlagsDISubprogram::getFlag(StringRef Flag) {
1093returnStringSwitch<DISPFlags>(Flag)
1094#define HANDLE_DISP_FLAG(ID, NAME) .Case("DISPFlag" #NAME, SPFlag##NAME)
1095#include "llvm/IR/DebugInfoFlags.def"
1096 .Default(SPFlagZero);
1097}
1098
1099StringRefDISubprogram::getFlagString(DISPFlags Flag) {
1100switch (Flag) {
1101// Appease a warning.
1102caseSPFlagVirtuality:
1103return"";
1104#define HANDLE_DISP_FLAG(ID, NAME) \
1105 case SPFlag##NAME: \
1106 return "DISPFlag" #NAME;
1107#include "llvm/IR/DebugInfoFlags.def"
1108 }
1109return"";
1110}
1111
1112DISubprogram::DISPFlags
1113DISubprogram::splitFlags(DISPFlags Flags,
1114SmallVectorImpl<DISPFlags> &SplitFlags) {
1115// Multi-bit fields can require special handling. In our case, however, the
1116// only multi-bit field is virtuality, and all its values happen to be
1117// single-bit values, so the right behavior just falls out.
1118#define HANDLE_DISP_FLAG(ID, NAME) \
1119 if (DISPFlags Bit = Flags & SPFlag##NAME) { \
1120 SplitFlags.push_back(Bit); \
1121 Flags &= ~Bit; \
1122 }
1123#include "llvm/IR/DebugInfoFlags.def"
1124return Flags;
1125}
1126
1127DISubprogram *DISubprogram::getImpl(
1128LLVMContext &Context,Metadata *Scope,MDString *Name,
1129MDString *LinkageName,Metadata *File,unsigned Line,Metadata *Type,
1130unsigned ScopeLine,Metadata *ContainingType,unsigned VirtualIndex,
1131int ThisAdjustment, DIFlags Flags, DISPFlags SPFlags,Metadata *Unit,
1132Metadata *TemplateParams,Metadata *Declaration,Metadata *RetainedNodes,
1133Metadata *ThrownTypes,Metadata *Annotations,MDString *TargetFuncName,
1134 StorageType Storage,bool ShouldCreate) {
1135assert(isCanonical(Name) &&"Expected canonical MDString");
1136assert(isCanonical(LinkageName) &&"Expected canonical MDString");
1137assert(isCanonical(TargetFuncName) &&"Expected canonical MDString");
1138DEFINE_GETIMPL_LOOKUP(DISubprogram,
1139 (Scope,Name,LinkageName,File, Line,Type, ScopeLine,
1140ContainingType, VirtualIndex, ThisAdjustment, Flags,
1141 SPFlags,Unit,TemplateParams,Declaration,
1142RetainedNodes,ThrownTypes,Annotations,
1143TargetFuncName));
1144SmallVector<Metadata *, 13> Ops = {
1145File,Scope,Name,LinkageName,
1146Type,Unit,Declaration,RetainedNodes,
1147ContainingType,TemplateParams,ThrownTypes,Annotations,
1148TargetFuncName};
1149if (!TargetFuncName) {
1150 Ops.pop_back();
1151if (!Annotations) {
1152 Ops.pop_back();
1153if (!ThrownTypes) {
1154 Ops.pop_back();
1155if (!TemplateParams) {
1156 Ops.pop_back();
1157if (!ContainingType)
1158 Ops.pop_back();
1159 }
1160 }
1161 }
1162 }
1163DEFINE_GETIMPL_STORE_N(
1164DISubprogram,
1165 (Line, ScopeLine, VirtualIndex, ThisAdjustment, Flags, SPFlags), Ops,
1166 Ops.size());
1167}
1168
1169bool DISubprogram::describes(constFunction *F) const{
1170assert(F &&"Invalid function");
1171returnF->getSubprogram() ==this;
1172}
1173DILexicalBlockBase::DILexicalBlockBase(LLVMContext &C,unsignedID,
1174StorageType Storage,
1175ArrayRef<Metadata *> Ops)
1176 :DILocalScope(C,ID, Storage, dwarf::DW_TAG_lexical_block, Ops) {}
1177
1178DILexicalBlock *DILexicalBlock::getImpl(LLVMContext &Context,Metadata *Scope,
1179Metadata *File,unsigned Line,
1180unsigned Column, StorageType Storage,
1181bool ShouldCreate) {
1182// Fixup column.
1183adjustColumn(Column);
1184
1185assert(Scope &&"Expected scope");
1186DEFINE_GETIMPL_LOOKUP(DILexicalBlock, (Scope,File,Line, Column));
1187Metadata *Ops[] = {File,Scope};
1188DEFINE_GETIMPL_STORE(DILexicalBlock, (Line, Column), Ops);
1189}
1190
1191DILexicalBlockFile *DILexicalBlockFile::getImpl(LLVMContext &Context,
1192Metadata *Scope,Metadata *File,
1193unsigned Discriminator,
1194 StorageType Storage,
1195bool ShouldCreate) {
1196assert(Scope &&"Expected scope");
1197DEFINE_GETIMPL_LOOKUP(DILexicalBlockFile, (Scope,File,Discriminator));
1198Metadata *Ops[] = {File,Scope};
1199DEFINE_GETIMPL_STORE(DILexicalBlockFile, (Discriminator), Ops);
1200}
1201
1202DINamespace::DINamespace(LLVMContext &Context, StorageType Storage,
1203bool ExportSymbols,ArrayRef<Metadata *> Ops)
1204 :DIScope(Context, DINamespaceKind, Storage, dwarf::DW_TAG_namespace, Ops) {
1205SubclassData1 = ExportSymbols;
1206}
1207DINamespace *DINamespace::getImpl(LLVMContext &Context,Metadata *Scope,
1208MDString *Name,bool ExportSymbols,
1209 StorageType Storage,bool ShouldCreate) {
1210assert(isCanonical(Name) &&"Expected canonical MDString");
1211DEFINE_GETIMPL_LOOKUP(DINamespace, (Scope,Name,ExportSymbols));
1212// The nullptr is for DIScope's File operand. This should be refactored.
1213Metadata *Ops[] = {nullptr,Scope,Name};
1214DEFINE_GETIMPL_STORE(DINamespace, (ExportSymbols), Ops);
1215}
1216
1217DICommonBlock::DICommonBlock(LLVMContext &Context, StorageType Storage,
1218unsigned LineNo,ArrayRef<Metadata *> Ops)
1219 :DIScope(Context, DICommonBlockKind, Storage, dwarf::DW_TAG_common_block,
1220 Ops) {
1221SubclassData32 = LineNo;
1222}
1223DICommonBlock *DICommonBlock::getImpl(LLVMContext &Context,Metadata *Scope,
1224Metadata *Decl,MDString *Name,
1225Metadata *File,unsigned LineNo,
1226 StorageType Storage,bool ShouldCreate) {
1227assert(isCanonical(Name) &&"Expected canonical MDString");
1228DEFINE_GETIMPL_LOOKUP(DICommonBlock, (Scope,Decl,Name,File,LineNo));
1229// The nullptr is for DIScope's File operand. This should be refactored.
1230Metadata *Ops[] = {Scope,Decl,Name,File};
1231DEFINE_GETIMPL_STORE(DICommonBlock, (LineNo), Ops);
1232}
1233
1234DIModule::DIModule(LLVMContext &Context, StorageType Storage,unsigned LineNo,
1235bool IsDecl,ArrayRef<Metadata *> Ops)
1236 :DIScope(Context, DIModuleKind, Storage, dwarf::DW_TAG_module, Ops) {
1237SubclassData1 = IsDecl;
1238SubclassData32 = LineNo;
1239}
1240DIModule *DIModule::getImpl(LLVMContext &Context,Metadata *File,
1241Metadata *Scope,MDString *Name,
1242MDString *ConfigurationMacros,
1243MDString *IncludePath,MDString *APINotesFile,
1244unsigned LineNo,bool IsDecl, StorageType Storage,
1245bool ShouldCreate) {
1246assert(isCanonical(Name) &&"Expected canonical MDString");
1247DEFINE_GETIMPL_LOOKUP(DIModule, (File,Scope,Name,ConfigurationMacros,
1248IncludePath,APINotesFile,LineNo, IsDecl));
1249Metadata *Ops[] = {File,Scope,Name,ConfigurationMacros,
1250IncludePath,APINotesFile};
1251DEFINE_GETIMPL_STORE(DIModule, (LineNo, IsDecl), Ops);
1252}
1253DITemplateTypeParameter::DITemplateTypeParameter(LLVMContext &Context,
1254 StorageType Storage,
1255bool IsDefault,
1256ArrayRef<Metadata *> Ops)
1257 :DITemplateParameter(Context, DITemplateTypeParameterKind, Storage,
1258 dwarf::DW_TAG_template_type_parameter, IsDefault,
1259 Ops) {}
1260
1261DITemplateTypeParameter *
1262DITemplateTypeParameter::getImpl(LLVMContext &Context,MDString *Name,
1263Metadata *Type,bool isDefault,
1264 StorageType Storage,bool ShouldCreate) {
1265assert(isCanonical(Name) &&"Expected canonical MDString");
1266DEFINE_GETIMPL_LOOKUP(DITemplateTypeParameter, (Name,Type,isDefault));
1267Metadata *Ops[] = {Name,Type};
1268DEFINE_GETIMPL_STORE(DITemplateTypeParameter, (isDefault), Ops);
1269}
1270
1271DITemplateValueParameter *DITemplateValueParameter::getImpl(
1272LLVMContext &Context,unsignedTag,MDString *Name,Metadata *Type,
1273bool isDefault,Metadata *Value, StorageType Storage,bool ShouldCreate) {
1274assert(isCanonical(Name) &&"Expected canonical MDString");
1275DEFINE_GETIMPL_LOOKUP(DITemplateValueParameter,
1276 (Tag,Name,Type,isDefault,Value));
1277Metadata *Ops[] = {Name,Type,Value};
1278DEFINE_GETIMPL_STORE(DITemplateValueParameter, (Tag,isDefault), Ops);
1279}
1280
1281DIGlobalVariable *
1282DIGlobalVariable::getImpl(LLVMContext &Context,Metadata *Scope,MDString *Name,
1283MDString *LinkageName,Metadata *File,unsigned Line,
1284Metadata *Type,bool IsLocalToUnit,bool IsDefinition,
1285Metadata *StaticDataMemberDeclaration,
1286Metadata *TemplateParams,uint32_t AlignInBits,
1287Metadata *Annotations, StorageType Storage,
1288bool ShouldCreate) {
1289assert(isCanonical(Name) &&"Expected canonical MDString");
1290assert(isCanonical(LinkageName) &&"Expected canonical MDString");
1291DEFINE_GETIMPL_LOOKUP(
1292DIGlobalVariable,
1293 (Scope,Name,LinkageName,File,Line,Type, IsLocalToUnit, IsDefinition,
1294StaticDataMemberDeclaration,TemplateParams,AlignInBits,Annotations));
1295Metadata *Ops[] = {Scope,
1296Name,
1297File,
1298Type,
1299Name,
1300LinkageName,
1301StaticDataMemberDeclaration,
1302TemplateParams,
1303Annotations};
1304DEFINE_GETIMPL_STORE(DIGlobalVariable,
1305 (Line, IsLocalToUnit, IsDefinition,AlignInBits), Ops);
1306}
1307
1308DILocalVariable *
1309DILocalVariable::getImpl(LLVMContext &Context,Metadata *Scope,MDString *Name,
1310Metadata *File,unsigned Line,Metadata *Type,
1311unsigned Arg, DIFlags Flags,uint32_t AlignInBits,
1312Metadata *Annotations, StorageType Storage,
1313bool ShouldCreate) {
1314// 64K ought to be enough for any frontend.
1315assert(Arg <= UINT16_MAX &&"Expected argument number to fit in 16-bits");
1316
1317assert(Scope &&"Expected scope");
1318assert(isCanonical(Name) &&"Expected canonical MDString");
1319DEFINE_GETIMPL_LOOKUP(DILocalVariable, (Scope,Name,File,Line,Type, Arg,
1320 Flags,AlignInBits,Annotations));
1321Metadata *Ops[] = {Scope,Name,File,Type,Annotations};
1322DEFINE_GETIMPL_STORE(DILocalVariable, (Line, Arg, Flags,AlignInBits), Ops);
1323}
1324
1325DIVariable::DIVariable(LLVMContext &C,unsignedID,StorageType Storage,
1326signed Line,ArrayRef<Metadata *> Ops,
1327uint32_t AlignInBits)
1328 :DINode(C,ID, Storage, dwarf::DW_TAG_variable, Ops), Line(Line) {
1329SubclassData32 = AlignInBits;
1330}
1331std::optional<uint64_t>DIVariable::getSizeInBits() const{
1332// This is used by the Verifier so be mindful of broken types.
1333constMetadata *RawType =getRawType();
1334while (RawType) {
1335// Try to get the size directly.
1336if (auto *T = dyn_cast<DIType>(RawType))
1337if (uint64_tSize =T->getSizeInBits())
1338returnSize;
1339
1340if (auto *DT = dyn_cast<DIDerivedType>(RawType)) {
1341// Look at the base type.
1342 RawType = DT->getRawBaseType();
1343continue;
1344 }
1345
1346// Missing type or size.
1347break;
1348 }
1349
1350// Fail gracefully.
1351return std::nullopt;
1352}
1353
1354DILabel::DILabel(LLVMContext &C, StorageType Storage,unsigned Line,
1355ArrayRef<Metadata *> Ops)
1356 :DINode(C, DILabelKind, Storage, dwarf::DW_TAG_label, Ops) {
1357SubclassData32 = Line;
1358}
1359DILabel *DILabel::getImpl(LLVMContext &Context,Metadata *Scope,MDString *Name,
1360Metadata *File,unsigned Line, StorageType Storage,
1361bool ShouldCreate) {
1362assert(Scope &&"Expected scope");
1363assert(isCanonical(Name) &&"Expected canonical MDString");
1364DEFINE_GETIMPL_LOOKUP(DILabel, (Scope,Name,File,Line));
1365Metadata *Ops[] = {Scope,Name,File};
1366DEFINE_GETIMPL_STORE(DILabel, (Line), Ops);
1367}
1368
1369DIExpression *DIExpression::getImpl(LLVMContext &Context,
1370ArrayRef<uint64_t> Elements,
1371 StorageType Storage,bool ShouldCreate) {
1372DEFINE_GETIMPL_LOOKUP(DIExpression, (Elements));
1373DEFINE_GETIMPL_STORE_NO_OPS(DIExpression, (Elements));
1374}
1375boolDIExpression::isEntryValue() const{
1376if (auto singleLocElts =getSingleLocationExpressionElements()) {
1377return singleLocElts->size() > 0 &&
1378 (*singleLocElts)[0] ==dwarf::DW_OP_LLVM_entry_value;
1379 }
1380returnfalse;
1381}
1382boolDIExpression::startsWithDeref() const{
1383if (auto singleLocElts =getSingleLocationExpressionElements())
1384return singleLocElts->size() > 0 &&
1385 (*singleLocElts)[0] == dwarf::DW_OP_deref;
1386returnfalse;
1387}
1388boolDIExpression::isDeref() const{
1389if (auto singleLocElts =getSingleLocationExpressionElements())
1390return singleLocElts->size() == 1 &&
1391 (*singleLocElts)[0] == dwarf::DW_OP_deref;
1392returnfalse;
1393}
1394
1395DIAssignID *DIAssignID::getImpl(LLVMContext &Context, StorageType Storage,
1396bool ShouldCreate) {
1397// Uniqued DIAssignID are not supported as the instance address *is* the ID.
1398assert(Storage !=StorageType::Uniqued &&"uniqued DIAssignID unsupported");
1399returnstoreImpl(new (0u,Storage)DIAssignID(Context,Storage),Storage);
1400}
1401
1402unsignedDIExpression::ExprOperand::getSize() const{
1403uint64_tOp =getOp();
1404
1405if (Op >= dwarf::DW_OP_breg0 &&Op <= dwarf::DW_OP_breg31)
1406return 2;
1407
1408switch (Op) {
1409casedwarf::DW_OP_LLVM_convert:
1410casedwarf::DW_OP_LLVM_fragment:
1411casedwarf::DW_OP_LLVM_extract_bits_sext:
1412casedwarf::DW_OP_LLVM_extract_bits_zext:
1413case dwarf::DW_OP_bregx:
1414return 3;
1415case dwarf::DW_OP_constu:
1416case dwarf::DW_OP_consts:
1417case dwarf::DW_OP_deref_size:
1418case dwarf::DW_OP_plus_uconst:
1419casedwarf::DW_OP_LLVM_tag_offset:
1420casedwarf::DW_OP_LLVM_entry_value:
1421casedwarf::DW_OP_LLVM_arg:
1422case dwarf::DW_OP_regx:
1423return 2;
1424default:
1425return 1;
1426 }
1427}
1428
1429boolDIExpression::isValid() const{
1430for (autoI =expr_op_begin(), E =expr_op_end();I != E; ++I) {
1431// Check that there's space for the operand.
1432if (I->get() +I->getSize() > E->get())
1433returnfalse;
1434
1435uint64_tOp =I->getOp();
1436if ((Op >= dwarf::DW_OP_reg0 &&Op <= dwarf::DW_OP_reg31) ||
1437 (Op >= dwarf::DW_OP_breg0 &&Op <= dwarf::DW_OP_breg31))
1438returntrue;
1439
1440// Check that the operand is valid.
1441switch (Op) {
1442default:
1443returnfalse;
1444casedwarf::DW_OP_LLVM_fragment:
1445// A fragment operator must appear at the end.
1446returnI->get() +I->getSize() == E->get();
1447case dwarf::DW_OP_stack_value: {
1448// Must be the last one or followed by a DW_OP_LLVM_fragment.
1449if (I->get() +I->getSize() == E->get())
1450break;
1451auto J =I;
1452if ((++J)->getOp() !=dwarf::DW_OP_LLVM_fragment)
1453returnfalse;
1454break;
1455 }
1456case dwarf::DW_OP_swap: {
1457// Must be more than one implicit element on the stack.
1458
1459// FIXME: A better way to implement this would be to add a local variable
1460// that keeps track of the stack depth and introduce something like a
1461// DW_LLVM_OP_implicit_location as a placeholder for the location this
1462// DIExpression is attached to, or else pass the number of implicit stack
1463// elements into isValid.
1464if (getNumElements() == 1)
1465returnfalse;
1466break;
1467 }
1468casedwarf::DW_OP_LLVM_entry_value: {
1469// An entry value operator must appear at the beginning or immediately
1470// following `DW_OP_LLVM_arg 0`, and the number of operations it cover can
1471// currently only be 1, because we support only entry values of a simple
1472// register location. One reason for this is that we currently can't
1473// calculate the size of the resulting DWARF block for other expressions.
1474auto FirstOp =expr_op_begin();
1475if (FirstOp->getOp() ==dwarf::DW_OP_LLVM_arg && FirstOp->getArg(0) == 0)
1476 ++FirstOp;
1477returnI->get() == FirstOp->get() &&I->getArg(0) == 1;
1478 }
1479casedwarf::DW_OP_LLVM_implicit_pointer:
1480casedwarf::DW_OP_LLVM_convert:
1481casedwarf::DW_OP_LLVM_arg:
1482casedwarf::DW_OP_LLVM_tag_offset:
1483casedwarf::DW_OP_LLVM_extract_bits_sext:
1484casedwarf::DW_OP_LLVM_extract_bits_zext:
1485case dwarf::DW_OP_constu:
1486case dwarf::DW_OP_plus_uconst:
1487case dwarf::DW_OP_plus:
1488case dwarf::DW_OP_minus:
1489case dwarf::DW_OP_mul:
1490case dwarf::DW_OP_div:
1491case dwarf::DW_OP_mod:
1492case dwarf::DW_OP_or:
1493case dwarf::DW_OP_and:
1494case dwarf::DW_OP_xor:
1495case dwarf::DW_OP_shl:
1496case dwarf::DW_OP_shr:
1497case dwarf::DW_OP_shra:
1498case dwarf::DW_OP_deref:
1499case dwarf::DW_OP_deref_size:
1500case dwarf::DW_OP_xderef:
1501case dwarf::DW_OP_lit0:
1502case dwarf::DW_OP_not:
1503case dwarf::DW_OP_dup:
1504case dwarf::DW_OP_regx:
1505case dwarf::DW_OP_bregx:
1506case dwarf::DW_OP_push_object_address:
1507case dwarf::DW_OP_over:
1508case dwarf::DW_OP_consts:
1509case dwarf::DW_OP_eq:
1510case dwarf::DW_OP_ne:
1511case dwarf::DW_OP_gt:
1512case dwarf::DW_OP_ge:
1513case dwarf::DW_OP_lt:
1514case dwarf::DW_OP_le:
1515break;
1516 }
1517 }
1518returntrue;
1519}
1520
1521boolDIExpression::isImplicit() const{
1522if (!isValid())
1523returnfalse;
1524
1525if (getNumElements() == 0)
1526returnfalse;
1527
1528for (constauto &It :expr_ops()) {
1529switch (It.getOp()) {
1530default:
1531break;
1532case dwarf::DW_OP_stack_value:
1533returntrue;
1534 }
1535 }
1536
1537returnfalse;
1538}
1539
1540boolDIExpression::isComplex() const{
1541if (!isValid())
1542returnfalse;
1543
1544if (getNumElements() == 0)
1545returnfalse;
1546
1547// If there are any elements other than fragment or tag_offset, then some
1548// kind of complex computation occurs.
1549for (constauto &It :expr_ops()) {
1550switch (It.getOp()) {
1551casedwarf::DW_OP_LLVM_tag_offset:
1552casedwarf::DW_OP_LLVM_fragment:
1553casedwarf::DW_OP_LLVM_arg:
1554continue;
1555default:
1556returntrue;
1557 }
1558 }
1559
1560returnfalse;
1561}
1562
1563boolDIExpression::isSingleLocationExpression() const{
1564if (!isValid())
1565returnfalse;
1566
1567if (getNumElements() == 0)
1568returntrue;
1569
1570auto ExprOpBegin =expr_ops().begin();
1571auto ExprOpEnd =expr_ops().end();
1572if (ExprOpBegin->getOp() ==dwarf::DW_OP_LLVM_arg) {
1573if (ExprOpBegin->getArg(0) != 0)
1574returnfalse;
1575 ++ExprOpBegin;
1576 }
1577
1578return !std::any_of(ExprOpBegin, ExprOpEnd, [](autoOp) {
1579returnOp.getOp() ==dwarf::DW_OP_LLVM_arg;
1580 });
1581}
1582
1583std::optional<ArrayRef<uint64_t>>
1584DIExpression::getSingleLocationExpressionElements() const{
1585// Check for `isValid` covered by `isSingleLocationExpression`.
1586if (!isSingleLocationExpression())
1587return std::nullopt;
1588
1589// An empty expression is already non-variadic.
1590if (!getNumElements())
1591returnArrayRef<uint64_t>();
1592
1593// If Expr does not have a leading DW_OP_LLVM_arg then we don't need to do
1594// anything.
1595if (getElements()[0] ==dwarf::DW_OP_LLVM_arg)
1596returngetElements().drop_front(2);
1597returngetElements();
1598}
1599
1600constDIExpression *
1601DIExpression::convertToUndefExpression(constDIExpression *Expr) {
1602SmallVector<uint64_t, 3> UndefOps;
1603if (autoFragmentInfo = Expr->getFragmentInfo()) {
1604 UndefOps.append({dwarf::DW_OP_LLVM_fragment,FragmentInfo->OffsetInBits,
1605FragmentInfo->SizeInBits});
1606 }
1607returnDIExpression::get(Expr->getContext(), UndefOps);
1608}
1609
1610constDIExpression *
1611DIExpression::convertToVariadicExpression(constDIExpression *Expr) {
1612if (any_of(Expr->expr_ops(), [](auto ExprOp) {
1613 return ExprOp.getOp() == dwarf::DW_OP_LLVM_arg;
1614 }))
1615return Expr;
1616SmallVector<uint64_t> NewOps;
1617 NewOps.reserve(Expr->getNumElements() + 2);
1618 NewOps.append({dwarf::DW_OP_LLVM_arg, 0});
1619 NewOps.append(Expr->elements_begin(), Expr->elements_end());
1620returnDIExpression::get(Expr->getContext(), NewOps);
1621}
1622
1623std::optional<const DIExpression *>
1624DIExpression::convertToNonVariadicExpression(constDIExpression *Expr) {
1625if (!Expr)
1626return std::nullopt;
1627
1628if (auto Elts = Expr->getSingleLocationExpressionElements())
1629returnDIExpression::get(Expr->getContext(), *Elts);
1630
1631return std::nullopt;
1632}
1633
1634voidDIExpression::canonicalizeExpressionOps(SmallVectorImpl<uint64_t> &Ops,
1635constDIExpression *Expr,
1636bool IsIndirect) {
1637// If Expr is not already variadic, insert the implied `DW_OP_LLVM_arg 0`
1638// to the existing expression ops.
1639if (none_of(Expr->expr_ops(), [](auto ExprOp) {
1640 return ExprOp.getOp() == dwarf::DW_OP_LLVM_arg;
1641 }))
1642 Ops.append({dwarf::DW_OP_LLVM_arg, 0});
1643// If Expr is not indirect, we only need to insert the expression elements and
1644// we're done.
1645if (!IsIndirect) {
1646 Ops.append(Expr->elements_begin(), Expr->elements_end());
1647return;
1648 }
1649// If Expr is indirect, insert the implied DW_OP_deref at the end of the
1650// expression but before DW_OP_{stack_value, LLVM_fragment} if they are
1651// present.
1652for (autoOp : Expr->expr_ops()) {
1653if (Op.getOp() == dwarf::DW_OP_stack_value ||
1654Op.getOp() ==dwarf::DW_OP_LLVM_fragment) {
1655 Ops.push_back(dwarf::DW_OP_deref);
1656 IsIndirect =false;
1657 }
1658Op.appendToVector(Ops);
1659 }
1660if (IsIndirect)
1661 Ops.push_back(dwarf::DW_OP_deref);
1662}
1663
1664boolDIExpression::isEqualExpression(constDIExpression *FirstExpr,
1665bool FirstIndirect,
1666constDIExpression *SecondExpr,
1667bool SecondIndirect) {
1668SmallVector<uint64_t> FirstOps;
1669DIExpression::canonicalizeExpressionOps(FirstOps, FirstExpr, FirstIndirect);
1670SmallVector<uint64_t> SecondOps;
1671DIExpression::canonicalizeExpressionOps(SecondOps, SecondExpr,
1672 SecondIndirect);
1673return FirstOps == SecondOps;
1674}
1675
1676std::optional<DIExpression::FragmentInfo>
1677DIExpression::getFragmentInfo(expr_op_iterator Start,expr_op_iteratorEnd) {
1678for (autoI = Start;I !=End; ++I)
1679if (I->getOp() ==dwarf::DW_OP_LLVM_fragment) {
1680DIExpression::FragmentInfoInfo = {I->getArg(1),I->getArg(0)};
1681returnInfo;
1682 }
1683return std::nullopt;
1684}
1685
1686std::optional<uint64_t>DIExpression::getActiveBits(DIVariable *Var) {
1687 std::optional<uint64_t> InitialActiveBits = Var->getSizeInBits();
1688 std::optional<uint64_t> ActiveBits = InitialActiveBits;
1689for (autoOp :expr_ops()) {
1690switch (Op.getOp()) {
1691default:
1692// We assume the worst case for anything we don't currently handle and
1693// revert to the initial active bits.
1694 ActiveBits = InitialActiveBits;
1695break;
1696casedwarf::DW_OP_LLVM_extract_bits_zext:
1697casedwarf::DW_OP_LLVM_extract_bits_sext: {
1698// We can't handle an extract whose sign doesn't match that of the
1699// variable.
1700 std::optional<DIBasicType::Signedness> VarSign = Var->getSignedness();
1701bool VarSigned = (VarSign ==DIBasicType::Signedness::Signed);
1702bool OpSigned = (Op.getOp() ==dwarf::DW_OP_LLVM_extract_bits_sext);
1703if (!VarSign || VarSigned != OpSigned) {
1704 ActiveBits = InitialActiveBits;
1705break;
1706 }
1707 [[fallthrough]];
1708 }
1709casedwarf::DW_OP_LLVM_fragment:
1710// Extract or fragment narrows the active bits
1711if (ActiveBits)
1712 ActiveBits = std::min(*ActiveBits,Op.getArg(1));
1713else
1714 ActiveBits =Op.getArg(1);
1715break;
1716 }
1717 }
1718return ActiveBits;
1719}
1720
1721voidDIExpression::appendOffset(SmallVectorImpl<uint64_t> &Ops,
1722 int64_tOffset) {
1723if (Offset > 0) {
1724 Ops.push_back(dwarf::DW_OP_plus_uconst);
1725 Ops.push_back(Offset);
1726 }elseif (Offset < 0) {
1727 Ops.push_back(dwarf::DW_OP_constu);
1728// Avoid UB when encountering LLONG_MIN, because in 2's complement
1729// abs(LLONG_MIN) is LLONG_MAX+1.
1730uint64_t AbsMinusOne = -(Offset+1);
1731 Ops.push_back(AbsMinusOne + 1);
1732 Ops.push_back(dwarf::DW_OP_minus);
1733 }
1734}
1735
1736boolDIExpression::extractIfOffset(int64_t &Offset) const{
1737auto SingleLocEltsOpt =getSingleLocationExpressionElements();
1738if (!SingleLocEltsOpt)
1739returnfalse;
1740auto SingleLocElts = *SingleLocEltsOpt;
1741
1742if (SingleLocElts.size() == 0) {
1743Offset = 0;
1744returntrue;
1745 }
1746
1747if (SingleLocElts.size() == 2 &&
1748 SingleLocElts[0] == dwarf::DW_OP_plus_uconst) {
1749Offset = SingleLocElts[1];
1750returntrue;
1751 }
1752
1753if (SingleLocElts.size() == 3 && SingleLocElts[0] == dwarf::DW_OP_constu) {
1754if (SingleLocElts[2] == dwarf::DW_OP_plus) {
1755Offset = SingleLocElts[1];
1756returntrue;
1757 }
1758if (SingleLocElts[2] == dwarf::DW_OP_minus) {
1759Offset = -SingleLocElts[1];
1760returntrue;
1761 }
1762 }
1763
1764returnfalse;
1765}
1766
1767boolDIExpression::extractLeadingOffset(
1768 int64_t &OffsetInBytes,SmallVectorImpl<uint64_t> &RemainingOps) const{
1769 OffsetInBytes = 0;
1770 RemainingOps.clear();
1771
1772auto SingleLocEltsOpt =getSingleLocationExpressionElements();
1773if (!SingleLocEltsOpt)
1774returnfalse;
1775
1776auto ExprOpEnd =expr_op_iterator(SingleLocEltsOpt->end());
1777auto ExprOpIt =expr_op_iterator(SingleLocEltsOpt->begin());
1778while (ExprOpIt != ExprOpEnd) {
1779uint64_tOp = ExprOpIt->getOp();
1780if (Op == dwarf::DW_OP_deref ||Op == dwarf::DW_OP_deref_size ||
1781Op == dwarf::DW_OP_deref_type ||Op ==dwarf::DW_OP_LLVM_fragment ||
1782Op ==dwarf::DW_OP_LLVM_extract_bits_zext ||
1783Op ==dwarf::DW_OP_LLVM_extract_bits_sext) {
1784break;
1785 }elseif (Op == dwarf::DW_OP_plus_uconst) {
1786 OffsetInBytes += ExprOpIt->getArg(0);
1787 }elseif (Op == dwarf::DW_OP_constu) {
1788uint64_tValue = ExprOpIt->getArg(0);
1789 ++ExprOpIt;
1790if (ExprOpIt->getOp() == dwarf::DW_OP_plus)
1791 OffsetInBytes +=Value;
1792elseif (ExprOpIt->getOp() == dwarf::DW_OP_minus)
1793 OffsetInBytes -=Value;
1794else
1795returnfalse;
1796 }else {
1797// Not a const plus/minus operation or deref.
1798returnfalse;
1799 }
1800 ++ExprOpIt;
1801 }
1802 RemainingOps.append(ExprOpIt.getBase(), ExprOpEnd.getBase());
1803returntrue;
1804}
1805
1806boolDIExpression::hasAllLocationOps(unsignedN) const{
1807SmallDenseSet<uint64_t, 4> SeenOps;
1808for (auto ExprOp :expr_ops())
1809if (ExprOp.getOp() ==dwarf::DW_OP_LLVM_arg)
1810 SeenOps.insert(ExprOp.getArg(0));
1811for (uint64_tIdx = 0;Idx <N; ++Idx)
1812if (!SeenOps.contains(Idx))
1813returnfalse;
1814returntrue;
1815}
1816
1817constDIExpression *DIExpression::extractAddressClass(constDIExpression *Expr,
1818unsigned &AddrClass) {
1819// FIXME: This seems fragile. Nothing that verifies that these elements
1820// actually map to ops and not operands.
1821auto SingleLocEltsOpt = Expr->getSingleLocationExpressionElements();
1822if (!SingleLocEltsOpt)
1823returnnullptr;
1824auto SingleLocElts = *SingleLocEltsOpt;
1825
1826constunsigned PatternSize = 4;
1827if (SingleLocElts.size() >= PatternSize &&
1828 SingleLocElts[PatternSize - 4] == dwarf::DW_OP_constu &&
1829 SingleLocElts[PatternSize - 2] == dwarf::DW_OP_swap &&
1830 SingleLocElts[PatternSize - 1] == dwarf::DW_OP_xderef) {
1831 AddrClass = SingleLocElts[PatternSize - 3];
1832
1833if (SingleLocElts.size() == PatternSize)
1834returnnullptr;
1835returnDIExpression::get(
1836 Expr->getContext(),
1837ArrayRef(&*SingleLocElts.begin(), SingleLocElts.size() - PatternSize));
1838 }
1839return Expr;
1840}
1841
1842DIExpression *DIExpression::prepend(constDIExpression *Expr,uint8_t Flags,
1843 int64_tOffset) {
1844SmallVector<uint64_t, 8> Ops;
1845if (Flags &DIExpression::DerefBefore)
1846 Ops.push_back(dwarf::DW_OP_deref);
1847
1848appendOffset(Ops,Offset);
1849if (Flags &DIExpression::DerefAfter)
1850 Ops.push_back(dwarf::DW_OP_deref);
1851
1852boolStackValue = Flags &DIExpression::StackValue;
1853boolEntryValue = Flags &DIExpression::EntryValue;
1854
1855returnprependOpcodes(Expr, Ops,StackValue,EntryValue);
1856}
1857
1858DIExpression *DIExpression::appendOpsToArg(constDIExpression *Expr,
1859ArrayRef<uint64_t> Ops,
1860unsigned ArgNo,boolStackValue) {
1861assert(Expr &&"Can't add ops to this expression");
1862
1863// Handle non-variadic intrinsics by prepending the opcodes.
1864if (!any_of(Expr->expr_ops(),
1865 [](autoOp) { return Op.getOp() == dwarf::DW_OP_LLVM_arg; })) {
1866assert(ArgNo == 0 &&
1867"Location Index must be 0 for a non-variadic expression.");
1868SmallVector<uint64_t, 8> NewOps(Ops);
1869returnDIExpression::prependOpcodes(Expr, NewOps,StackValue);
1870 }
1871
1872SmallVector<uint64_t, 8> NewOps;
1873for (autoOp : Expr->expr_ops()) {
1874// A DW_OP_stack_value comes at the end, but before a DW_OP_LLVM_fragment.
1875if (StackValue) {
1876if (Op.getOp() == dwarf::DW_OP_stack_value)
1877StackValue =false;
1878elseif (Op.getOp() ==dwarf::DW_OP_LLVM_fragment) {
1879 NewOps.push_back(dwarf::DW_OP_stack_value);
1880StackValue =false;
1881 }
1882 }
1883Op.appendToVector(NewOps);
1884if (Op.getOp() ==dwarf::DW_OP_LLVM_arg &&Op.getArg(0) == ArgNo)
1885 NewOps.insert(NewOps.end(), Ops.begin(), Ops.end());
1886 }
1887if (StackValue)
1888 NewOps.push_back(dwarf::DW_OP_stack_value);
1889
1890returnDIExpression::get(Expr->getContext(), NewOps);
1891}
1892
1893DIExpression *DIExpression::replaceArg(constDIExpression *Expr,
1894uint64_t OldArg,uint64_t NewArg) {
1895assert(Expr &&"Can't replace args in this expression");
1896
1897SmallVector<uint64_t, 8> NewOps;
1898
1899for (autoOp : Expr->expr_ops()) {
1900if (Op.getOp() !=dwarf::DW_OP_LLVM_arg ||Op.getArg(0) < OldArg) {
1901Op.appendToVector(NewOps);
1902continue;
1903 }
1904 NewOps.push_back(dwarf::DW_OP_LLVM_arg);
1905uint64_t Arg =Op.getArg(0) == OldArg ? NewArg :Op.getArg(0);
1906// OldArg has been deleted from the Op list, so decrement all indices
1907// greater than it.
1908if (Arg > OldArg)
1909 --Arg;
1910 NewOps.push_back(Arg);
1911 }
1912returnDIExpression::get(Expr->getContext(), NewOps);
1913}
1914
1915DIExpression *DIExpression::prependOpcodes(constDIExpression *Expr,
1916SmallVectorImpl<uint64_t> &Ops,
1917boolStackValue,boolEntryValue) {
1918assert(Expr &&"Can't prepend ops to this expression");
1919
1920if (EntryValue) {
1921 Ops.push_back(dwarf::DW_OP_LLVM_entry_value);
1922// Use a block size of 1 for the target register operand. The
1923// DWARF backend currently cannot emit entry values with a block
1924// size > 1.
1925 Ops.push_back(1);
1926 }
1927
1928// If there are no ops to prepend, do not even add the DW_OP_stack_value.
1929if (Ops.empty())
1930StackValue =false;
1931for (autoOp : Expr->expr_ops()) {
1932// A DW_OP_stack_value comes at the end, but before a DW_OP_LLVM_fragment.
1933if (StackValue) {
1934if (Op.getOp() == dwarf::DW_OP_stack_value)
1935StackValue =false;
1936elseif (Op.getOp() ==dwarf::DW_OP_LLVM_fragment) {
1937 Ops.push_back(dwarf::DW_OP_stack_value);
1938StackValue =false;
1939 }
1940 }
1941Op.appendToVector(Ops);
1942 }
1943if (StackValue)
1944 Ops.push_back(dwarf::DW_OP_stack_value);
1945returnDIExpression::get(Expr->getContext(), Ops);
1946}
1947
1948DIExpression *DIExpression::append(constDIExpression *Expr,
1949ArrayRef<uint64_t> Ops) {
1950assert(Expr && !Ops.empty() &&"Can't append ops to this expression");
1951
1952// Copy Expr's current op list.
1953SmallVector<uint64_t, 16> NewOps;
1954for (autoOp : Expr->expr_ops()) {
1955// Append new opcodes before DW_OP_{stack_value, LLVM_fragment}.
1956if (Op.getOp() == dwarf::DW_OP_stack_value ||
1957Op.getOp() ==dwarf::DW_OP_LLVM_fragment) {
1958 NewOps.append(Ops.begin(), Ops.end());
1959
1960// Ensure that the new opcodes are only appended once.
1961 Ops = {};
1962 }
1963Op.appendToVector(NewOps);
1964 }
1965 NewOps.append(Ops.begin(), Ops.end());
1966auto *result =
1967DIExpression::get(Expr->getContext(), NewOps)->foldConstantMath();
1968assert(result->isValid() &&"concatenated expression is not valid");
1969return result;
1970}
1971
1972DIExpression *DIExpression::appendToStack(constDIExpression *Expr,
1973ArrayRef<uint64_t> Ops) {
1974assert(Expr && !Ops.empty() &&"Can't append ops to this expression");
1975assert(std::none_of(expr_op_iterator(Ops.begin()),
1976expr_op_iterator(Ops.end()),
1977 [](autoOp) {
1978 return Op.getOp() == dwarf::DW_OP_stack_value ||
1979 Op.getOp() == dwarf::DW_OP_LLVM_fragment;
1980 }) &&
1981"Can't append this op");
1982
1983// Append a DW_OP_deref after Expr's current op list if it's non-empty and
1984// has no DW_OP_stack_value.
1985//
1986// Match .* DW_OP_stack_value (DW_OP_LLVM_fragment A B)?.
1987 std::optional<FragmentInfo> FI = Expr->getFragmentInfo();
1988unsigned DropUntilStackValue = FI ? 3 : 0;
1989ArrayRef<uint64_t> ExprOpsBeforeFragment =
1990 Expr->getElements().drop_back(DropUntilStackValue);
1991bool NeedsDeref = (Expr->getNumElements() > DropUntilStackValue) &&
1992 (ExprOpsBeforeFragment.back() != dwarf::DW_OP_stack_value);
1993bool NeedsStackValue = NeedsDeref || ExprOpsBeforeFragment.empty();
1994
1995// Append a DW_OP_deref after Expr's current op list if needed, then append
1996// the new ops, and finally ensure that a single DW_OP_stack_value is present.
1997SmallVector<uint64_t, 16> NewOps;
1998if (NeedsDeref)
1999 NewOps.push_back(dwarf::DW_OP_deref);
2000 NewOps.append(Ops.begin(), Ops.end());
2001if (NeedsStackValue)
2002 NewOps.push_back(dwarf::DW_OP_stack_value);
2003returnDIExpression::append(Expr, NewOps);
2004}
2005
2006std::optional<DIExpression *>DIExpression::createFragmentExpression(
2007constDIExpression *Expr,unsigned OffsetInBits,unsigned SizeInBits) {
2008SmallVector<uint64_t, 8> Ops;
2009// Track whether it's safe to split the value at the top of the DWARF stack,
2010// assuming that it'll be used as an implicit location value.
2011bool CanSplitValue =true;
2012// Track whether we need to add a fragment expression to the end of Expr.
2013bool EmitFragment =true;
2014// Copy over the expression, but leave off any trailing DW_OP_LLVM_fragment.
2015if (Expr) {
2016for (autoOp : Expr->expr_ops()) {
2017switch (Op.getOp()) {
2018default:
2019break;
2020case dwarf::DW_OP_shr:
2021case dwarf::DW_OP_shra:
2022case dwarf::DW_OP_shl:
2023case dwarf::DW_OP_plus:
2024case dwarf::DW_OP_plus_uconst:
2025case dwarf::DW_OP_minus:
2026// We can't safely split arithmetic or shift operations into multiple
2027// fragments because we can't express carry-over between fragments.
2028//
2029// FIXME: We *could* preserve the lowest fragment of a constant offset
2030// operation if the offset fits into SizeInBits.
2031 CanSplitValue =false;
2032break;
2033case dwarf::DW_OP_deref:
2034case dwarf::DW_OP_deref_size:
2035case dwarf::DW_OP_deref_type:
2036case dwarf::DW_OP_xderef:
2037case dwarf::DW_OP_xderef_size:
2038case dwarf::DW_OP_xderef_type:
2039// Preceeding arithmetic operations have been applied to compute an
2040// address. It's okay to split the value loaded from that address.
2041 CanSplitValue =true;
2042break;
2043case dwarf::DW_OP_stack_value:
2044// Bail if this expression computes a value that cannot be split.
2045if (!CanSplitValue)
2046return std::nullopt;
2047break;
2048casedwarf::DW_OP_LLVM_fragment: {
2049// If we've decided we don't need a fragment then give up if we see that
2050// there's already a fragment expression.
2051// FIXME: We could probably do better here
2052if (!EmitFragment)
2053return std::nullopt;
2054// Make the new offset point into the existing fragment.
2055uint64_t FragmentOffsetInBits =Op.getArg(0);
2056uint64_t FragmentSizeInBits =Op.getArg(1);
2057 (void)FragmentSizeInBits;
2058assert((OffsetInBits + SizeInBits <= FragmentSizeInBits) &&
2059"new fragment outside of original fragment");
2060 OffsetInBits += FragmentOffsetInBits;
2061continue;
2062 }
2063casedwarf::DW_OP_LLVM_extract_bits_zext:
2064casedwarf::DW_OP_LLVM_extract_bits_sext: {
2065// If we're extracting bits from inside of the fragment that we're
2066// creating then we don't have a fragment after all, and just need to
2067// adjust the offset that we're extracting from.
2068uint64_t ExtractOffsetInBits =Op.getArg(0);
2069uint64_t ExtractSizeInBits =Op.getArg(1);
2070if (ExtractOffsetInBits >= OffsetInBits &&
2071 ExtractOffsetInBits + ExtractSizeInBits <=
2072 OffsetInBits + SizeInBits) {
2073 Ops.push_back(Op.getOp());
2074 Ops.push_back(ExtractOffsetInBits - OffsetInBits);
2075 Ops.push_back(ExtractSizeInBits);
2076 EmitFragment =false;
2077continue;
2078 }
2079// If the extracted bits aren't fully contained within the fragment then
2080// give up.
2081// FIXME: We could probably do better here
2082return std::nullopt;
2083 }
2084 }
2085Op.appendToVector(Ops);
2086 }
2087 }
2088assert((!Expr->isImplicit() || CanSplitValue) &&"Expr can't be split");
2089assert(Expr &&"Unknown DIExpression");
2090if (EmitFragment) {
2091 Ops.push_back(dwarf::DW_OP_LLVM_fragment);
2092 Ops.push_back(OffsetInBits);
2093 Ops.push_back(SizeInBits);
2094 }
2095returnDIExpression::get(Expr->getContext(), Ops);
2096}
2097
2098/// See declaration for more info.
2099boolDIExpression::calculateFragmentIntersect(
2100constDataLayout &DL,constValue *SliceStart,uint64_t SliceOffsetInBits,
2101uint64_t SliceSizeInBits,constValue *DbgPtr, int64_t DbgPtrOffsetInBits,
2102 int64_t DbgExtractOffsetInBits,DIExpression::FragmentInfo VarFrag,
2103 std::optional<DIExpression::FragmentInfo> &Result,
2104 int64_t &OffsetFromLocationInBits) {
2105
2106if (VarFrag.SizeInBits == 0)
2107returnfalse;// Variable size is unknown.
2108
2109// Difference between mem slice start and the dbg location start.
2110// 0 4 8 12 16 ...
2111// | |
2112// dbg location start
2113// |
2114// mem slice start
2115// Here MemStartRelToDbgStartInBits is 8. Note this can be negative.
2116 int64_t MemStartRelToDbgStartInBits;
2117 {
2118auto MemOffsetFromDbgInBytes = SliceStart->getPointerOffsetFrom(DbgPtr,DL);
2119if (!MemOffsetFromDbgInBytes)
2120returnfalse;// Can't calculate difference in addresses.
2121// Difference between the pointers.
2122 MemStartRelToDbgStartInBits = *MemOffsetFromDbgInBytes * 8;
2123// Add the difference of the offsets.
2124 MemStartRelToDbgStartInBits +=
2125 SliceOffsetInBits - (DbgPtrOffsetInBits + DbgExtractOffsetInBits);
2126 }
2127
2128// Out-param. Invert offset to get offset from debug location.
2129 OffsetFromLocationInBits = -MemStartRelToDbgStartInBits;
2130
2131// Check if the variable fragment sits outside (before) this memory slice.
2132 int64_t MemEndRelToDbgStart = MemStartRelToDbgStartInBits + SliceSizeInBits;
2133if (MemEndRelToDbgStart < 0) {
2134 Result = {0, 0};// Out-param.
2135returntrue;
2136 }
2137
2138// Work towards creating SliceOfVariable which is the bits of the variable
2139// that the memory region covers.
2140// 0 4 8 12 16 ...
2141// | |
2142// dbg location start with VarFrag offset=32
2143// |
2144// mem slice start: SliceOfVariable offset=40
2145 int64_t MemStartRelToVarInBits =
2146 MemStartRelToDbgStartInBits + VarFrag.OffsetInBits;
2147 int64_t MemEndRelToVarInBits = MemStartRelToVarInBits + SliceSizeInBits;
2148// If the memory region starts before the debug location the fragment
2149// offset would be negative, which we can't encode. Limit those to 0. This
2150// is fine because those bits necessarily don't overlap with the existing
2151// variable fragment.
2152 int64_t MemFragStart = std::max<int64_t>(0, MemStartRelToVarInBits);
2153 int64_t MemFragSize =
2154 std::max<int64_t>(0, MemEndRelToVarInBits - MemFragStart);
2155DIExpression::FragmentInfo SliceOfVariable(MemFragSize, MemFragStart);
2156
2157// Intersect the memory region fragment with the variable location fragment.
2158DIExpression::FragmentInfo TrimmedSliceOfVariable =
2159DIExpression::FragmentInfo::intersect(SliceOfVariable, VarFrag);
2160if (TrimmedSliceOfVariable == VarFrag)
2161 Result = std::nullopt;// Out-param.
2162else
2163 Result = TrimmedSliceOfVariable;// Out-param.
2164returntrue;
2165}
2166
2167std::pair<DIExpression *, const ConstantInt *>
2168DIExpression::constantFold(constConstantInt *CI) {
2169// Copy the APInt so we can modify it.
2170APInt NewInt = CI->getValue();
2171SmallVector<uint64_t, 8> Ops;
2172
2173// Fold operators only at the beginning of the expression.
2174boolFirst =true;
2175bool Changed =false;
2176for (autoOp :expr_ops()) {
2177switch (Op.getOp()) {
2178default:
2179// We fold only the leading part of the expression; if we get to a part
2180// that we're going to copy unchanged, and haven't done any folding,
2181// then the entire expression is unchanged and we can return early.
2182if (!Changed)
2183return {this, CI};
2184First =false;
2185break;
2186casedwarf::DW_OP_LLVM_convert:
2187if (!First)
2188break;
2189 Changed =true;
2190if (Op.getArg(1) == dwarf::DW_ATE_signed)
2191 NewInt = NewInt.sextOrTrunc(Op.getArg(0));
2192else {
2193assert(Op.getArg(1) == dwarf::DW_ATE_unsigned &&"Unexpected operand");
2194 NewInt = NewInt.zextOrTrunc(Op.getArg(0));
2195 }
2196continue;
2197 }
2198Op.appendToVector(Ops);
2199 }
2200if (!Changed)
2201return {this, CI};
2202return {DIExpression::get(getContext(), Ops),
2203 ConstantInt::get(getContext(), NewInt)};
2204}
2205
2206uint64_tDIExpression::getNumLocationOperands() const{
2207uint64_t Result = 0;
2208for (auto ExprOp :expr_ops())
2209if (ExprOp.getOp() ==dwarf::DW_OP_LLVM_arg)
2210 Result = std::max(Result, ExprOp.getArg(0) + 1);
2211assert(hasAllLocationOps(Result) &&
2212"Expression is missing one or more location operands.");
2213return Result;
2214}
2215
2216std::optional<DIExpression::SignedOrUnsignedConstant>
2217DIExpression::isConstant() const{
2218
2219// Recognize signed and unsigned constants.
2220// An signed constants can be represented as DW_OP_consts C DW_OP_stack_value
2221// (DW_OP_LLVM_fragment of Len).
2222// An unsigned constant can be represented as
2223// DW_OP_constu C DW_OP_stack_value (DW_OP_LLVM_fragment of Len).
2224
2225if ((getNumElements() != 2 &&getNumElements() != 3 &&
2226getNumElements() != 6) ||
2227 (getElement(0) != dwarf::DW_OP_consts &&
2228getElement(0) != dwarf::DW_OP_constu))
2229return std::nullopt;
2230
2231if (getNumElements() == 2 &&getElement(0) == dwarf::DW_OP_consts)
2232returnSignedOrUnsignedConstant::SignedConstant;
2233
2234if ((getNumElements() == 3 &&getElement(2) != dwarf::DW_OP_stack_value) ||
2235 (getNumElements() == 6 && (getElement(2) != dwarf::DW_OP_stack_value ||
2236getElement(3) !=dwarf::DW_OP_LLVM_fragment)))
2237return std::nullopt;
2238returngetElement(0) == dwarf::DW_OP_constu
2239 ?SignedOrUnsignedConstant::UnsignedConstant
2240 :SignedOrUnsignedConstant::SignedConstant;
2241}
2242
2243DIExpression::ExtOpsDIExpression::getExtOps(unsigned FromSize,unsigned ToSize,
2244boolSigned) {
2245dwarf::TypeKind TK =Signed ? dwarf::DW_ATE_signed : dwarf::DW_ATE_unsigned;
2246DIExpression::ExtOps Ops{{dwarf::DW_OP_LLVM_convert, FromSize, TK,
2247dwarf::DW_OP_LLVM_convert, ToSize, TK}};
2248return Ops;
2249}
2250
2251DIExpression *DIExpression::appendExt(constDIExpression *Expr,
2252unsigned FromSize,unsigned ToSize,
2253boolSigned) {
2254returnappendToStack(Expr,getExtOps(FromSize, ToSize,Signed));
2255}
2256
2257DIGlobalVariableExpression *
2258DIGlobalVariableExpression::getImpl(LLVMContext &Context,Metadata *Variable,
2259Metadata *Expression,StorageTypeStorage,
2260bool ShouldCreate) {
2261DEFINE_GETIMPL_LOOKUP(DIGlobalVariableExpression, (Variable,Expression));
2262Metadata *Ops[] = {Variable,Expression};
2263DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIGlobalVariableExpression, Ops);
2264}
2265DIObjCProperty::DIObjCProperty(LLVMContext &C,StorageTypeStorage,
2266unsigned Line,unsigned Attributes,
2267ArrayRef<Metadata *> Ops)
2268 :DINode(C, DIObjCPropertyKind,Storage, dwarf::DW_TAG_APPLE_property, Ops),
2269Line(Line),Attributes(Attributes) {}
2270
2271DIObjCProperty *DIObjCProperty::getImpl(
2272LLVMContext &Context,MDString *Name,Metadata *File,unsigned Line,
2273MDString *GetterName,MDString *SetterName,unsigned Attributes,
2274Metadata *Type, StorageType Storage,bool ShouldCreate) {
2275assert(isCanonical(Name) &&"Expected canonical MDString");
2276assert(isCanonical(GetterName) &&"Expected canonical MDString");
2277assert(isCanonical(SetterName) &&"Expected canonical MDString");
2278DEFINE_GETIMPL_LOOKUP(DIObjCProperty, (Name,File, Line,GetterName,
2279SetterName, Attributes,Type));
2280Metadata *Ops[] = {Name,File,GetterName,SetterName,Type};
2281DEFINE_GETIMPL_STORE(DIObjCProperty, (Line, Attributes), Ops);
2282}
2283
2284DIImportedEntity *DIImportedEntity::getImpl(LLVMContext &Context,unsignedTag,
2285Metadata *Scope,Metadata *Entity,
2286Metadata *File,unsigned Line,
2287MDString *Name,Metadata *Elements,
2288 StorageType Storage,
2289bool ShouldCreate) {
2290assert(isCanonical(Name) &&"Expected canonical MDString");
2291DEFINE_GETIMPL_LOOKUP(DIImportedEntity,
2292 (Tag,Scope,Entity,File,Line,Name, Elements));
2293Metadata *Ops[] = {Scope,Entity,Name,File,Elements};
2294DEFINE_GETIMPL_STORE(DIImportedEntity, (Tag,Line), Ops);
2295}
2296
2297DIMacro *DIMacro::getImpl(LLVMContext &Context,unsigned MIType,unsigned Line,
2298MDString *Name,MDString *Value, StorageType Storage,
2299bool ShouldCreate) {
2300assert(isCanonical(Name) &&"Expected canonical MDString");
2301DEFINE_GETIMPL_LOOKUP(DIMacro, (MIType,Line,Name,Value));
2302Metadata *Ops[] = {Name,Value};
2303DEFINE_GETIMPL_STORE(DIMacro, (MIType,Line), Ops);
2304}
2305
2306DIMacroFile *DIMacroFile::getImpl(LLVMContext &Context,unsigned MIType,
2307unsigned Line,Metadata *File,
2308Metadata *Elements, StorageType Storage,
2309bool ShouldCreate) {
2310DEFINE_GETIMPL_LOOKUP(DIMacroFile, (MIType,Line,File,Elements));
2311Metadata *Ops[] = {File,Elements};
2312DEFINE_GETIMPL_STORE(DIMacroFile, (MIType,Line), Ops);
2313}
2314
2315DIArgList *DIArgList::get(LLVMContext &Context,
2316ArrayRef<ValueAsMetadata *> Args) {
2317auto ExistingIt = Context.pImpl->DIArgLists.find_as(DIArgListKeyInfo(Args));
2318if (ExistingIt != Context.pImpl->DIArgLists.end())
2319return *ExistingIt;
2320DIArgList *NewArgList =newDIArgList(Context, Args);
2321 Context.pImpl->DIArgLists.insert(NewArgList);
2322return NewArgList;
2323}
2324
2325voidDIArgList::handleChangedOperand(void *Ref,Metadata *New) {
2326ValueAsMetadata **OldVMPtr =static_cast<ValueAsMetadata **>(Ref);
2327assert((!New || isa<ValueAsMetadata>(New)) &&
2328"DIArgList must be passed a ValueAsMetadata");
2329 untrack();
2330// We need to update the set storage once the Args are updated since they
2331// form the key to the DIArgLists store.
2332getContext().pImpl->DIArgLists.erase(this);
2333ValueAsMetadata *NewVM = cast_or_null<ValueAsMetadata>(New);
2334for (ValueAsMetadata *&VM : Args) {
2335if (&VM == OldVMPtr) {
2336if (NewVM)
2337 VM = NewVM;
2338else
2339 VM =ValueAsMetadata::get(PoisonValue::get(VM->getValue()->getType()));
2340 }
2341 }
2342// We've changed the contents of this DIArgList, and the set storage may
2343// already contain a DIArgList with our new set of args; if it does, then we
2344// must RAUW this with the existing DIArgList, otherwise we simply insert this
2345// back into the set storage.
2346DIArgList *ExistingArgList =getUniqued(getContext().pImpl->DIArgLists,this);
2347if (ExistingArgList) {
2348replaceAllUsesWith(ExistingArgList);
2349// Clear this here so we don't try to untrack in the destructor.
2350 Args.clear();
2351deletethis;
2352return;
2353 }
2354getContext().pImpl->DIArgLists.insert(this);
2355 track();
2356}
2357void DIArgList::track() {
2358for (ValueAsMetadata *&VAM : Args)
2359if (VAM)
2360MetadataTracking::track(&VAM, *VAM, *this);
2361}
2362void DIArgList::untrack() {
2363for (ValueAsMetadata *&VAM : Args)
2364if (VAM)
2365MetadataTracking::untrack(&VAM, *VAM);
2366}
2367void DIArgList::dropAllReferences(bool Untrack) {
2368if (Untrack)
2369 untrack();
2370Args.clear();
2371ReplaceableMetadataImpl::resolveAllUses(/* ResolveUsers */false);
2372}
S1
static const LLT S1
Definition:AMDGPULegalizerInfo.cpp:282
Attributes
AMDGPU Kernel Attributes
Definition:AMDGPULowerKernelAttributes.cpp:370
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition:ARMSLSHardening.cpp:73
IT
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate any type of IT block"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow complex IT blocks")))
A
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Info
Analysis containing CSE Info
Definition:CSEInfo.cpp:27
getSubprogram
static DISubprogram * getSubprogram(bool IsDistinct, Ts &&...Args)
Definition:DIBuilder.cpp:856
Idx
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
Definition:DeadArgumentElimination.cpp:353
ChecksumKindName
static const char * ChecksumKindName[DIFile::CSK_Last]
Definition:DebugInfoMetadata.cpp:894
DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS
#define DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(CLASS, OPS)
Definition:DebugInfoMetadata.cpp:443
adjustColumn
static void adjustColumn(unsigned &Column)
Definition:DebugInfoMetadata.cpp:74
DEFINE_GETIMPL_STORE_N
#define DEFINE_GETIMPL_STORE_N(CLASS, ARGS, OPS, NUM_OPS)
Definition:DebugInfoMetadata.cpp:446
isCanonical
static bool isCanonical(const MDString *S)
Definition:DebugInfoMetadata.cpp:386
DEFINE_GETIMPL_STORE
#define DEFINE_GETIMPL_STORE(CLASS, ARGS, OPS)
Definition:DebugInfoMetadata.cpp:435
DEFINE_GETIMPL_LOOKUP
#define DEFINE_GETIMPL_LOOKUP(CLASS, ARGS)
Definition:DebugInfoMetadata.cpp:422
DEFINE_GETIMPL_STORE_NO_OPS
#define DEFINE_GETIMPL_STORE_NO_OPS(CLASS, ARGS)
Definition:DebugInfoMetadata.cpp:439
DebugInfoMetadata.h
DebugProgramInstruction.h
DF
static RegisterPass< DebugifyFunctionPass > DF("debugify-function", "Attach debug info to a function")
encodingBits
static unsigned encodingBits(unsigned C)
Definition:Discriminator.h:49
encodeComponent
static unsigned encodeComponent(unsigned C)
Definition:Discriminator.h:45
getNextComponentInDiscriminator
static unsigned getNextComponentInDiscriminator(unsigned D)
Returns the next component stored in discriminator.
Definition:Discriminator.h:38
getUnsignedFromPrefixEncoding
static unsigned getUnsignedFromPrefixEncoding(unsigned U)
Reverse transformation as getPrefixEncodingFromUnsigned.
Definition:Discriminator.h:30
Dwarf.h
This file contains constants used for implementing Dwarf debug support.
Name
std::string Name
Definition:ELFObjHandler.cpp:77
Size
uint64_t Size
Definition:ELFObjHandler.cpp:81
End
bool End
Definition:ELF_riscv.cpp:480
Function.h
IntrinsicInst.h
Type.h
Value.h
LLVMContextImpl.h
F
#define F(x, y, z)
Definition:MD5.cpp:55
I
#define I(x, y, z)
Definition:MD5.cpp:58
getDebugLoc
static DebugLoc getDebugLoc(MachineBasicBlock::instr_iterator FirstMI, MachineBasicBlock::instr_iterator LastMI)
Return the first found DebugLoc that has a DILocation, given a range of instructions.
Definition:MachineInstrBundle.cpp:109
MetadataImpl.h
Signed
@ Signed
Definition:NVPTXISelLowering.cpp:4789
CC
auto CC
Definition:RISCVRedundantCopyElimination.cpp:79
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SourceLanguage
SourceLanguage
Definition:SPIRVEmitNonSemanticDI.cpp:77
SmallPtrSet.h
This file defines the SmallPtrSet class.
StringSwitch.h
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
Lo
support::ulittle16_t & Lo
Definition:aarch32.cpp:204
BaseType
T
llvm::APInt
Class for arbitrary precision integers.
Definition:APInt.h:78
llvm::APInt::zextOrTrunc
APInt zextOrTrunc(unsigned width) const
Zero extend or truncate to width.
Definition:APInt.cpp:1007
llvm::APInt::sextOrTrunc
APInt sextOrTrunc(unsigned width) const
Sign extend or truncate to width.
Definition:APInt.cpp:1015
llvm::Annotations
Annotations lets you mark points and ranges inside source code, for tests:
Definition:Annotations.h:53
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition:ArrayRef.h:41
llvm::ArrayRef::back
const T & back() const
back - Get the last element.
Definition:ArrayRef.h:177
llvm::ArrayRef::drop_front
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
Definition:ArrayRef.h:207
llvm::ArrayRef::end
iterator end() const
Definition:ArrayRef.h:157
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition:ArrayRef.h:168
llvm::ArrayRef::drop_back
ArrayRef< T > drop_back(size_t N=1) const
Drop the last N elements of the array.
Definition:ArrayRef.h:213
llvm::ArrayRef::begin
iterator begin() const
Definition:ArrayRef.h:156
llvm::ArrayRef::empty
bool empty() const
empty - Check if the array is empty.
Definition:ArrayRef.h:163
llvm::ConstantAsMetadata::get
static ConstantAsMetadata * get(Constant *C)
Definition:Metadata.h:532
llvm::ConstantInt
This is the shared class of boolean and integer constants.
Definition:Constants.h:83
llvm::ConstantInt::getSigned
static ConstantInt * getSigned(IntegerType *Ty, int64_t V)
Return a ConstantInt with the specified value for the specified type.
Definition:Constants.h:126
llvm::ConstantInt::getValue
const APInt & getValue() const
Return the constant as an APInt value reference.
Definition:Constants.h:148
llvm::Constant
This is an important base class in LLVM.
Definition:Constant.h:42
llvm::DIArgList
List of ValueAsMetadata, to be used as an argument to a dbg.value intrinsic.
Definition:DebugInfoMetadata.h:3976
llvm::DIArgList::handleChangedOperand
void handleChangedOperand(void *Ref, Metadata *New)
Definition:DebugInfoMetadata.cpp:2325
llvm::DIArgList::get
static DIArgList * get(LLVMContext &Context, ArrayRef< ValueAsMetadata * > Args)
Definition:DebugInfoMetadata.cpp:2315
llvm::DIAssignID
Assignment ID.
Definition:DebugInfoMetadata.h:309
llvm::DIBasicType
Basic type, like 'int' or 'float'.
Definition:DebugInfoMetadata.h:823
llvm::DIBasicType::Tag
unsigned Tag
Definition:DebugInfoMetadata.h:863
llvm::DIBasicType::Flags
unsigned StringRef uint64_t FlagZero unsigned StringRef uint64_t uint32_t unsigned DIFlags Flags
Definition:DebugInfoMetadata.h:870
llvm::DIBasicType::Signedness::Signed
@ Signed
llvm::DIBasicType::Signedness::Unsigned
@ Unsigned
llvm::DIBasicType::SizeInBits
unsigned StringRef uint64_t SizeInBits
Definition:DebugInfoMetadata.h:863
llvm::DIBasicType::getSignedness
std::optional< Signedness > getSignedness() const
Return the signedness of this type, or std::nullopt if this type is neither signed nor unsigned.
Definition:DebugInfoMetadata.cpp:678
llvm::DIBasicType::getEncoding
unsigned getEncoding() const
Definition:DebugInfoMetadata.h:891
llvm::DIBasicType::NumExtraInhabitants
unsigned StringRef uint64_t FlagZero unsigned StringRef uint64_t uint32_t unsigned DIFlags Flags unsigned StringRef uint64_t uint32_t unsigned uint32_t NumExtraInhabitants
Definition:DebugInfoMetadata.h:879
llvm::DIBasicType::Name
unsigned StringRef Name
Definition:DebugInfoMetadata.h:863
llvm::DIBasicType::AlignInBits
unsigned StringRef uint64_t FlagZero unsigned StringRef uint64_t uint32_t AlignInBits
Definition:DebugInfoMetadata.h:870
llvm::DICommonBlock
Debug common block.
Definition:DebugInfoMetadata.h:3403
llvm::DICommonBlock::Decl
Metadata Metadata * Decl
Definition:DebugInfoMetadata.h:3433
llvm::DICommonBlock::LineNo
Metadata Metadata MDString Metadata unsigned LineNo
Definition:DebugInfoMetadata.h:3434
llvm::DICommonBlock::Name
Metadata Metadata MDString * Name
Definition:DebugInfoMetadata.h:3433
llvm::DICommonBlock::File
Metadata Metadata MDString Metadata * File
Definition:DebugInfoMetadata.h:3434
llvm::DICommonBlock::Scope
Metadata * Scope
Definition:DebugInfoMetadata.h:3433
llvm::DICompileUnit
Compile unit.
Definition:DebugInfoMetadata.h:1469
llvm::DICompileUnit::nameTableKindString
static const char * nameTableKindString(DebugNameTableKind PK)
Definition:DebugInfoMetadata.cpp:1013
llvm::DICompileUnit::emissionKindString
static const char * emissionKindString(DebugEmissionKind EK)
Definition:DebugInfoMetadata.cpp:999
llvm::DICompileUnit::getEmissionKind
DebugEmissionKind getEmissionKind() const
Definition:DebugInfoMetadata.h:1595
llvm::DICompileUnit::File
unsigned Metadata * File
Definition:DebugInfoMetadata.h:1577
llvm::DICompileUnit::Macros
unsigned Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata Metadata Metadata * Macros
Definition:DebugInfoMetadata.h:1581
llvm::DICompileUnit::Flags
unsigned Metadata MDString bool MDString * Flags
Definition:DebugInfoMetadata.h:1578
llvm::DICompileUnit::DebugNameTableKind
DebugNameTableKind
Definition:DebugInfoMetadata.h:1482
llvm::DICompileUnit::DebugNameTableKind::None
@ None
llvm::DICompileUnit::DebugNameTableKind::Default
@ Default
llvm::DICompileUnit::DebugNameTableKind::Apple
@ Apple
llvm::DICompileUnit::DebugNameTableKind::GNU
@ GNU
llvm::DICompileUnit::EnumTypes
unsigned Metadata MDString bool MDString unsigned MDString unsigned Metadata * EnumTypes
Definition:DebugInfoMetadata.h:1579
llvm::DICompileUnit::RetainedTypes
unsigned Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata * RetainedTypes
Definition:DebugInfoMetadata.h:1580
llvm::DICompileUnit::getNameTableKind
DebugNameTableKind getNameTableKind() const
Definition:DebugInfoMetadata.h:1602
llvm::DICompileUnit::GlobalVariables
unsigned Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata * GlobalVariables
Definition:DebugInfoMetadata.h:1580
llvm::DICompileUnit::SDK
unsigned Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata Metadata Metadata uint64_t bool bool unsigned bool MDString MDString * SDK
Definition:DebugInfoMetadata.h:1584
llvm::DICompileUnit::Producer
unsigned Metadata MDString * Producer
Definition:DebugInfoMetadata.h:1577
llvm::DICompileUnit::SysRoot
unsigned Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata Metadata Metadata uint64_t bool bool unsigned bool MDString * SysRoot
Definition:DebugInfoMetadata.h:1583
llvm::DICompileUnit::SplitDebugFilename
unsigned Metadata MDString bool MDString unsigned MDString * SplitDebugFilename
Definition:DebugInfoMetadata.h:1579
llvm::DICompileUnit::ImportedEntities
unsigned Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata Metadata * ImportedEntities
Definition:DebugInfoMetadata.h:1581
llvm::DICompileUnit::DebugEmissionKind
DebugEmissionKind
Definition:DebugInfoMetadata.h:1474
llvm::DICompileUnit::LineTablesOnly
@ LineTablesOnly
Definition:DebugInfoMetadata.h:1477
llvm::DICompileUnit::FullDebug
@ FullDebug
Definition:DebugInfoMetadata.h:1476
llvm::DICompileUnit::DebugDirectivesOnly
@ DebugDirectivesOnly
Definition:DebugInfoMetadata.h:1478
llvm::DICompileUnit::NoDebug
@ NoDebug
Definition:DebugInfoMetadata.h:1475
llvm::DICompositeType
Composite types.
Definition:DebugInfoMetadata.h:1174
llvm::DICompositeType::AlignInBits
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t AlignInBits
Definition:DebugInfoMetadata.h:1264
llvm::DICompositeType::Line
unsigned MDString Metadata unsigned Line
Definition:DebugInfoMetadata.h:1262
llvm::DICompositeType::Elements
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata * Elements
Definition:DebugInfoMetadata.h:1265
llvm::DICompositeType::Specification
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned Metadata Metadata MDString Metadata Metadata Metadata Metadata Metadata Metadata Metadata * Specification
Definition:DebugInfoMetadata.h:1270
llvm::DICompositeType::TemplateParams
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned Metadata Metadata * TemplateParams
Definition:DebugInfoMetadata.h:1266
llvm::DICompositeType::NumExtraInhabitants
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned Metadata Metadata MDString Metadata Metadata Metadata Metadata Metadata Metadata Metadata uint32_t NumExtraInhabitants
Definition:DebugInfoMetadata.h:1270
llvm::DICompositeType::Rank
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned Metadata Metadata MDString Metadata Metadata Metadata Metadata Metadata * Rank
Definition:DebugInfoMetadata.h:1269
llvm::DICompositeType::getODRTypeIfExists
static DICompositeType * getODRTypeIfExists(LLVMContext &Context, MDString &Identifier)
Definition:DebugInfoMetadata.cpp:863
llvm::DICompositeType::Tag
unsigned Tag
Definition:DebugInfoMetadata.h:1262
llvm::DICompositeType::Name
unsigned MDString * Name
Definition:DebugInfoMetadata.h:1262
llvm::DICompositeType::OffsetInBits
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t OffsetInBits
Definition:DebugInfoMetadata.h:1264
llvm::DICompositeType::Scope
unsigned MDString Metadata unsigned Metadata * Scope
Definition:DebugInfoMetadata.h:1263
llvm::DICompositeType::File
unsigned MDString Metadata * File
Definition:DebugInfoMetadata.h:1262
llvm::DICompositeType::Allocated
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned Metadata Metadata MDString Metadata Metadata Metadata Metadata * Allocated
Definition:DebugInfoMetadata.h:1268
llvm::DICompositeType::BaseType
unsigned MDString Metadata unsigned Metadata Metadata * BaseType
Definition:DebugInfoMetadata.h:1263
llvm::DICompositeType::Flags
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Flags
Definition:DebugInfoMetadata.h:1264
llvm::DICompositeType::Discriminator
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned Metadata Metadata MDString Metadata * Discriminator
Definition:DebugInfoMetadata.h:1267
llvm::DICompositeType::Annotations
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned Metadata Metadata MDString Metadata Metadata Metadata Metadata Metadata Metadata * Annotations
Definition:DebugInfoMetadata.h:1269
llvm::DICompositeType::DataLocation
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned Metadata Metadata MDString Metadata Metadata * DataLocation
Definition:DebugInfoMetadata.h:1267
llvm::DICompositeType::Identifier
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned Metadata Metadata MDString * Identifier
Definition:DebugInfoMetadata.h:1266
llvm::DICompositeType::SizeInBits
unsigned MDString Metadata unsigned Metadata Metadata uint64_t SizeInBits
Definition:DebugInfoMetadata.h:1263
llvm::DICompositeType::buildODRType
static DICompositeType * buildODRType(LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, Metadata *Specification, uint32_t NumExtraInhabitants, DIFlags Flags, Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder, Metadata *TemplateParams, Metadata *Discriminator, Metadata *DataLocation, Metadata *Associated, Metadata *Allocated, Metadata *Rank, Metadata *Annotations)
Build a DICompositeType with the given ODR identifier.
Definition:DebugInfoMetadata.cpp:794
llvm::DICompositeType::Associated
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned Metadata Metadata MDString Metadata Metadata Metadata * Associated
Definition:DebugInfoMetadata.h:1268
llvm::DICompositeType::VTableHolder
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned Metadata * VTableHolder
Definition:DebugInfoMetadata.h:1265
llvm::DIDerivedType
Derived types.
Definition:DebugInfoMetadata.h:997
llvm::DIDerivedType::Tag
unsigned Tag
Definition:DebugInfoMetadata.h:1091
llvm::DIDerivedType::BaseType
unsigned StringRef DIFile unsigned DIScope DIType * BaseType
Definition:DebugInfoMetadata.h:1092
llvm::DIDerivedType::ExtraData
unsigned StringRef DIFile unsigned DIScope DIType uint64_t uint32_t uint64_t std::optional< unsigned > std::optional< PtrAuthData > DIFlags Metadata * ExtraData
Definition:DebugInfoMetadata.h:1096
llvm::DIDerivedType::SizeInBits
unsigned StringRef DIFile unsigned DIScope DIType uint64_t SizeInBits
Definition:DebugInfoMetadata.h:1092
llvm::DIDerivedType::getExtraData
Metadata * getExtraData() const
Get extra data associated with this derived type.
Definition:DebugInfoMetadata.h:1124
llvm::DIDerivedType::File
unsigned StringRef DIFile * File
Definition:DebugInfoMetadata.h:1091
llvm::DIDerivedType::OffsetInBits
unsigned StringRef DIFile unsigned DIScope DIType uint64_t uint32_t uint64_t OffsetInBits
Definition:DebugInfoMetadata.h:1093
llvm::DIDerivedType::AlignInBits
unsigned StringRef DIFile unsigned DIScope DIType uint64_t uint32_t AlignInBits
Definition:DebugInfoMetadata.h:1093
llvm::DIDerivedType::Scope
unsigned StringRef DIFile unsigned DIScope * Scope
Definition:DebugInfoMetadata.h:1092
llvm::DIDerivedType::getClassType
DIType * getClassType() const
Get casted version of extra data.
Definition:DebugInfoMetadata.cpp:707
llvm::DIDerivedType::getConstant
Constant * getConstant() const
Definition:DebugInfoMetadata.cpp:725
llvm::DIDerivedType::getStorageOffsetInBits
Constant * getStorageOffsetInBits() const
Definition:DebugInfoMetadata.cpp:718
llvm::DIDerivedType::getDiscriminantValue
Constant * getDiscriminantValue() const
Definition:DebugInfoMetadata.cpp:733
llvm::DIDerivedType::Name
unsigned StringRef Name
Definition:DebugInfoMetadata.h:1091
llvm::DIDerivedType::getVBPtrOffset
uint32_t getVBPtrOffset() const
Definition:DebugInfoMetadata.cpp:711
llvm::DIDerivedType::Flags
unsigned StringRef DIFile unsigned DIScope DIType uint64_t uint32_t uint64_t std::optional< unsigned > std::optional< PtrAuthData > DIFlags Flags
Definition:DebugInfoMetadata.h:1095
llvm::DIDerivedType::Line
unsigned StringRef DIFile unsigned Line
Definition:DebugInfoMetadata.h:1091
llvm::DIEnumerator
Enumeration value.
Definition:DebugInfoMetadata.h:459
llvm::DIEnumerator::IsUnsigned
int64_t bool IsUnsigned
Definition:DebugInfoMetadata.h:491
llvm::DIEnumerator::Name
int64_t bool MDString * Name
Definition:DebugInfoMetadata.h:491
llvm::DIExpression::ExprOperand::getSize
unsigned getSize() const
Return the size of the operand.
Definition:DebugInfoMetadata.cpp:1402
llvm::DIExpression::ExprOperand::getOp
uint64_t getOp() const
Get the operand code.
Definition:DebugInfoMetadata.h:2830
llvm::DIExpression::expr_op_iterator
An iterator for expression operands.
Definition:DebugInfoMetadata.h:2851
llvm::DIExpression
DWARF expression.
Definition:DebugInfoMetadata.h:2763
llvm::DIExpression::elements_end
element_iterator elements_end() const
Definition:DebugInfoMetadata.h:2814
llvm::DIExpression::isEntryValue
bool isEntryValue() const
Check if the expression consists of exactly one entry value operand.
Definition:DebugInfoMetadata.cpp:1375
llvm::DIExpression::expr_ops
iterator_range< expr_op_iterator > expr_ops() const
Definition:DebugInfoMetadata.h:2910
llvm::DIExpression::append
static DIExpression * append(const DIExpression *Expr, ArrayRef< uint64_t > Ops)
Append the opcodes Ops to DIExpr.
Definition:DebugInfoMetadata.cpp:1948
llvm::DIExpression::ExtOps
std::array< uint64_t, 6 > ExtOps
Definition:DebugInfoMetadata.h:3161
llvm::DIExpression::getNumElements
unsigned getNumElements() const
Definition:DebugInfoMetadata.h:2789
llvm::DIExpression::getExtOps
static ExtOps getExtOps(unsigned FromSize, unsigned ToSize, bool Signed)
Returns the ops for a zero- or sign-extension in a DIExpression.
Definition:DebugInfoMetadata.cpp:2243
llvm::DIExpression::expr_op_begin
expr_op_iterator expr_op_begin() const
Visit the elements via ExprOperand wrappers.
Definition:DebugInfoMetadata.h:2904
llvm::DIExpression::extractIfOffset
bool extractIfOffset(int64_t &Offset) const
If this is a constant offset, extract it.
Definition:DebugInfoMetadata.cpp:1736
llvm::DIExpression::appendOffset
static void appendOffset(SmallVectorImpl< uint64_t > &Ops, int64_t Offset)
Append Ops with operations to apply the Offset.
Definition:DebugInfoMetadata.cpp:1721
llvm::DIExpression::startsWithDeref
bool startsWithDeref() const
Return whether the first element a DW_OP_deref.
Definition:DebugInfoMetadata.cpp:1382
llvm::DIExpression::isEqualExpression
static bool isEqualExpression(const DIExpression *FirstExpr, bool FirstIndirect, const DIExpression *SecondExpr, bool SecondIndirect)
Determines whether two debug values should produce equivalent DWARF expressions, using their DIExpres...
Definition:DebugInfoMetadata.cpp:1664
llvm::DIExpression::expr_op_end
expr_op_iterator expr_op_end() const
Definition:DebugInfoMetadata.h:2907
llvm::DIExpression::isImplicit
bool isImplicit() const
Return whether this is an implicit location description.
Definition:DebugInfoMetadata.cpp:1521
llvm::DIExpression::calculateFragmentIntersect
static bool calculateFragmentIntersect(const DataLayout &DL, const Value *SliceStart, uint64_t SliceOffsetInBits, uint64_t SliceSizeInBits, const Value *DbgPtr, int64_t DbgPtrOffsetInBits, int64_t DbgExtractOffsetInBits, DIExpression::FragmentInfo VarFrag, std::optional< DIExpression::FragmentInfo > &Result, int64_t &OffsetFromLocationInBits)
Computes a fragment, bit-extract operation if needed, and new constant offset to describe a part of a...
Definition:DebugInfoMetadata.cpp:2099
llvm::DIExpression::SignedConstant
@ SignedConstant
Definition:DebugInfoMetadata.h:2796
llvm::DIExpression::UnsignedConstant
@ UnsignedConstant
Definition:DebugInfoMetadata.h:2796
llvm::DIExpression::elements_begin
element_iterator elements_begin() const
Definition:DebugInfoMetadata.h:2813
llvm::DIExpression::hasAllLocationOps
bool hasAllLocationOps(unsigned N) const
Returns true iff this DIExpression contains at least one instance of DW_OP_LLVM_arg,...
Definition:DebugInfoMetadata.cpp:1806
llvm::DIExpression::getFragmentInfo
std::optional< FragmentInfo > getFragmentInfo() const
Retrieve the details of this fragment expression.
Definition:DebugInfoMetadata.h:2940
llvm::DIExpression::appendOpsToArg
static DIExpression * appendOpsToArg(const DIExpression *Expr, ArrayRef< uint64_t > Ops, unsigned ArgNo, bool StackValue=false)
Create a copy of Expr by appending the given list of Ops to each instance of the operand DW_OP_LLVM_a...
Definition:DebugInfoMetadata.cpp:1858
llvm::DIExpression::DerefBefore
@ DerefBefore
Definition:DebugInfoMetadata.h:3045
llvm::DIExpression::EntryValue
@ EntryValue
Definition:DebugInfoMetadata.h:3048
llvm::DIExpression::DerefAfter
@ DerefAfter
Definition:DebugInfoMetadata.h:3046
llvm::DIExpression::StackValue
@ StackValue
Definition:DebugInfoMetadata.h:3047
llvm::DIExpression::isComplex
bool isComplex() const
Return whether the location is computed on the expression stack, meaning it cannot be a simple regist...
Definition:DebugInfoMetadata.cpp:1540
llvm::DIExpression::getFragmentInfo
static std::optional< FragmentInfo > getFragmentInfo(expr_op_iterator Start, expr_op_iterator End)
Retrieve the details of this fragment expression.
Definition:DebugInfoMetadata.cpp:1677
llvm::DIExpression::convertToNonVariadicExpression
static std::optional< const DIExpression * > convertToNonVariadicExpression(const DIExpression *Expr)
If Expr is a valid single-location expression, i.e.
Definition:DebugInfoMetadata.cpp:1624
llvm::DIExpression::constantFold
std::pair< DIExpression *, const ConstantInt * > constantFold(const ConstantInt *CI)
Try to shorten an expression with an initial constant operand.
Definition:DebugInfoMetadata.cpp:2168
llvm::DIExpression::isDeref
bool isDeref() const
Return whether there is exactly one operator and it is a DW_OP_deref;.
Definition:DebugInfoMetadata.cpp:1388
llvm::DIExpression::convertToVariadicExpression
static const DIExpression * convertToVariadicExpression(const DIExpression *Expr)
If Expr is a non-variadic expression (i.e.
Definition:DebugInfoMetadata.cpp:1611
llvm::DIExpression::getNumLocationOperands
uint64_t getNumLocationOperands() const
Return the number of unique location operands referred to (via DW_OP_LLVM_arg) in this expression; th...
Definition:DebugInfoMetadata.cpp:2206
llvm::DIExpression::getElements
ArrayRef< uint64_t > getElements() const
Definition:DebugInfoMetadata.h:2787
llvm::DIExpression::replaceArg
static DIExpression * replaceArg(const DIExpression *Expr, uint64_t OldArg, uint64_t NewArg)
Create a copy of Expr with each instance of DW_OP_LLVM_arg, \p OldArg replaced with DW_OP_LLVM_arg,...
Definition:DebugInfoMetadata.cpp:1893
llvm::DIExpression::getActiveBits
std::optional< uint64_t > getActiveBits(DIVariable *Var)
Return the number of bits that have an active value, i.e.
Definition:DebugInfoMetadata.cpp:1686
llvm::DIExpression::canonicalizeExpressionOps
static void canonicalizeExpressionOps(SmallVectorImpl< uint64_t > &Ops, const DIExpression *Expr, bool IsIndirect)
Inserts the elements of Expr into Ops modified to a canonical form, which uses DW_OP_LLVM_arg (i....
Definition:DebugInfoMetadata.cpp:1634
llvm::DIExpression::getElement
uint64_t getElement(unsigned I) const
Definition:DebugInfoMetadata.h:2791
llvm::DIExpression::createFragmentExpression
static std::optional< DIExpression * > createFragmentExpression(const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits)
Create a DIExpression to describe one part of an aggregate variable that is fragmented across multipl...
Definition:DebugInfoMetadata.cpp:2006
llvm::DIExpression::convertToUndefExpression
static const DIExpression * convertToUndefExpression(const DIExpression *Expr)
Removes all elements from Expr that do not apply to an undef debug value, which includes every operat...
Definition:DebugInfoMetadata.cpp:1601
llvm::DIExpression::prepend
static DIExpression * prepend(const DIExpression *Expr, uint8_t Flags, int64_t Offset=0)
Prepend DIExpr with a deref and offset operation and optionally turn it into a stack value or/and an ...
Definition:DebugInfoMetadata.cpp:1842
llvm::DIExpression::appendToStack
static DIExpression * appendToStack(const DIExpression *Expr, ArrayRef< uint64_t > Ops)
Convert DIExpr into a stack value if it isn't one already by appending DW_OP_deref if needed,...
Definition:DebugInfoMetadata.cpp:1972
llvm::DIExpression::appendExt
static DIExpression * appendExt(const DIExpression *Expr, unsigned FromSize, unsigned ToSize, bool Signed)
Append a zero- or sign-extension to Expr.
Definition:DebugInfoMetadata.cpp:2251
llvm::DIExpression::getSingleLocationExpressionElements
std::optional< ArrayRef< uint64_t > > getSingleLocationExpressionElements() const
Returns a reference to the elements contained in this expression, skipping past the leading DW_OP_LLV...
Definition:DebugInfoMetadata.cpp:1584
llvm::DIExpression::isSingleLocationExpression
bool isSingleLocationExpression() const
Return whether the evaluated expression makes use of a single location at the start of the expression...
Definition:DebugInfoMetadata.cpp:1563
llvm::DIExpression::extractLeadingOffset
bool extractLeadingOffset(int64_t &OffsetInBytes, SmallVectorImpl< uint64_t > &RemainingOps) const
Assuming that the expression operates on an address, extract a constant offset and the successive ops...
Definition:DebugInfoMetadata.cpp:1767
llvm::DIExpression::isConstant
std::optional< SignedOrUnsignedConstant > isConstant() const
Determine whether this represents a constant value, if so.
Definition:DebugInfoMetadata.cpp:2217
llvm::DIExpression::isValid
bool isValid() const
Definition:DebugInfoMetadata.cpp:1429
llvm::DIExpression::extractAddressClass
static const DIExpression * extractAddressClass(const DIExpression *Expr, unsigned &AddrClass)
Checks if the last 4 elements of the expression are DW_OP_constu <DWARF Address Space> DW_OP_swap DW_...
Definition:DebugInfoMetadata.cpp:1817
llvm::DIExpression::prependOpcodes
static DIExpression * prependOpcodes(const DIExpression *Expr, SmallVectorImpl< uint64_t > &Ops, bool StackValue=false, bool EntryValue=false)
Prepend DIExpr with the given opcodes and optionally turn it into a stack value.
Definition:DebugInfoMetadata.cpp:1915
llvm::DIFile
File.
Definition:DebugInfoMetadata.h:573
llvm::DIFile::Directory
MDString MDString * Directory
Definition:DebugInfoMetadata.h:650
llvm::DIFile::Filename
MDString * Filename
Definition:DebugInfoMetadata.h:650
llvm::DIFile::getChecksumKind
static std::optional< ChecksumKind > getChecksumKind(StringRef CSKindStr)
Definition:DebugInfoMetadata.cpp:909
llvm::DIFile::CSK_SHA1
@ CSK_SHA1
Definition:DebugInfoMetadata.h:588
llvm::DIFile::CSK_MD5
@ CSK_MD5
Definition:DebugInfoMetadata.h:587
llvm::DIFile::CSK_SHA256
@ CSK_SHA256
Definition:DebugInfoMetadata.h:589
llvm::DIFile::CSK_Last
@ CSK_Last
Definition:DebugInfoMetadata.h:590
llvm::DIFile::CS
MDString MDString std::optional< ChecksumInfo< MDString * > > CS
Definition:DebugInfoMetadata.h:651
llvm::DIGenericSubrange
Definition:DebugInfoMetadata.h:411
llvm::DIGenericSubrange::getRawLowerBound
Metadata * getRawLowerBound() const
Definition:DebugInfoMetadata.h:439
llvm::DIGenericSubrange::getRawCountNode
Metadata * getRawCountNode() const
Definition:DebugInfoMetadata.h:438
llvm::DIGenericSubrange::getRawStride
Metadata * getRawStride() const
Definition:DebugInfoMetadata.h:441
llvm::DIGenericSubrange::getLowerBound
BoundType getLowerBound() const
Definition:DebugInfoMetadata.cpp:596
llvm::DIGenericSubrange::getRawUpperBound
Metadata * getRawUpperBound() const
Definition:DebugInfoMetadata.h:440
llvm::DIGenericSubrange::getCount
BoundType getCount() const
Definition:DebugInfoMetadata.cpp:579
llvm::DIGenericSubrange::getUpperBound
BoundType getUpperBound() const
Definition:DebugInfoMetadata.cpp:613
llvm::DIGenericSubrange::BoundType
PointerUnion< DIVariable *, DIExpression * > BoundType
Definition:DebugInfoMetadata.h:443
llvm::DIGenericSubrange::getStride
BoundType getStride() const
Definition:DebugInfoMetadata.cpp:630
llvm::DIGlobalVariableExpression
A pair of DIGlobalVariable and DIExpression.
Definition:DebugInfoMetadata.h:3761
llvm::DIGlobalVariable
Global variables.
Definition:DebugInfoMetadata.h:3315
llvm::DIGlobalVariable::TemplateParams
Metadata MDString MDString Metadata unsigned Metadata bool bool Metadata Metadata * TemplateParams
Definition:DebugInfoMetadata.h:3371
llvm::DIGlobalVariable::Line
Metadata MDString MDString Metadata unsigned Line
Definition:DebugInfoMetadata.h:3370
llvm::DIGlobalVariable::Type
Metadata MDString MDString Metadata unsigned Metadata * Type
Definition:DebugInfoMetadata.h:3370
llvm::DIGlobalVariable::Name
Metadata MDString * Name
Definition:DebugInfoMetadata.h:3369
llvm::DIGlobalVariable::StaticDataMemberDeclaration
Metadata MDString MDString Metadata unsigned Metadata bool bool Metadata * StaticDataMemberDeclaration
Definition:DebugInfoMetadata.h:3371
llvm::DIGlobalVariable::LinkageName
Metadata MDString MDString * LinkageName
Definition:DebugInfoMetadata.h:3369
llvm::DIGlobalVariable::File
Metadata MDString MDString Metadata * File
Definition:DebugInfoMetadata.h:3369
llvm::DIGlobalVariable::AlignInBits
Metadata MDString MDString Metadata unsigned Metadata bool bool Metadata Metadata uint32_t AlignInBits
Definition:DebugInfoMetadata.h:3372
llvm::DIGlobalVariable::Scope
Metadata * Scope
Definition:DebugInfoMetadata.h:3369
llvm::DIImportedEntity
An imported module (C++ using directive or similar).
Definition:DebugInfoMetadata.h:3696
llvm::DIImportedEntity::Entity
unsigned Metadata Metadata * Entity
Definition:DebugInfoMetadata.h:3733
llvm::DIImportedEntity::Line
unsigned Metadata Metadata Metadata unsigned Line
Definition:DebugInfoMetadata.h:3734
llvm::DIImportedEntity::Name
unsigned Metadata Metadata Metadata unsigned MDString * Name
Definition:DebugInfoMetadata.h:3734
llvm::DIImportedEntity::Tag
unsigned Tag
Definition:DebugInfoMetadata.h:3733
llvm::DIImportedEntity::File
unsigned Metadata Metadata Metadata * File
Definition:DebugInfoMetadata.h:3734
llvm::DIImportedEntity::Scope
unsigned Metadata * Scope
Definition:DebugInfoMetadata.h:3733
llvm::DILabel
Label.
Definition:DebugInfoMetadata.h:3551
llvm::DILabel::Line
Metadata MDString Metadata unsigned Line
Definition:DebugInfoMetadata.h:3581
llvm::DILabel::Name
Metadata MDString * Name
Definition:DebugInfoMetadata.h:3580
llvm::DILabel::Scope
Metadata * Scope
Definition:DebugInfoMetadata.h:3580
llvm::DILabel::File
Metadata MDString Metadata * File
Definition:DebugInfoMetadata.h:3580
llvm::DILexicalBlockBase::DILexicalBlockBase
DILexicalBlockBase(LLVMContext &C, unsigned ID, StorageType Storage, ArrayRef< Metadata * > Ops)
Definition:DebugInfoMetadata.cpp:1173
llvm::DILexicalBlockFile
Definition:DebugInfoMetadata.h:2336
llvm::DILexicalBlockFile::Discriminator
Metadata Metadata unsigned Discriminator
Definition:DebugInfoMetadata.h:2372
llvm::DILexicalBlockFile::Scope
Metadata * Scope
Definition:DebugInfoMetadata.h:2372
llvm::DILexicalBlockFile::File
Metadata Metadata * File
Definition:DebugInfoMetadata.h:2372
llvm::DILexicalBlock
Debug lexical block.
Definition:DebugInfoMetadata.h:2283
llvm::DILexicalBlock::Scope
Metadata * Scope
Definition:DebugInfoMetadata.h:2322
llvm::DILexicalBlock::Line
Metadata Metadata unsigned Line
Definition:DebugInfoMetadata.h:2322
llvm::DILexicalBlock::File
Metadata Metadata * File
Definition:DebugInfoMetadata.h:2322
llvm::DILocalScope
A scope for locals.
Definition:DebugInfoMetadata.h:1675
llvm::DILocalScope::getSubprogram
DISubprogram * getSubprogram() const
Get the subprogram for this scope.
Definition:DebugInfoMetadata.cpp:1051
llvm::DILocalScope::getNonLexicalBlockFileScope
DILocalScope * getNonLexicalBlockFileScope() const
Get the first non DILexicalBlockFile scope of this scope.
Definition:DebugInfoMetadata.cpp:1057
llvm::DILocalScope::cloneScopeForSubprogram
static DILocalScope * cloneScopeForSubprogram(DILocalScope &RootScope, DISubprogram &NewSP, LLVMContext &Ctx, DenseMap< const MDNode *, MDNode * > &Cache)
Traverses the scope chain rooted at RootScope until it hits a Subprogram, recreating the chain with "...
Definition:DebugInfoMetadata.cpp:1063
llvm::DILocalVariable
Local variable.
Definition:DebugInfoMetadata.h:3460
llvm::DILocalVariable::Type
Metadata MDString Metadata unsigned Metadata * Type
Definition:DebugInfoMetadata.h:3508
llvm::DILocalVariable::File
Metadata MDString Metadata * File
Definition:DebugInfoMetadata.h:3507
llvm::DILocalVariable::Name
Metadata MDString * Name
Definition:DebugInfoMetadata.h:3507
llvm::DILocalVariable::Line
Metadata MDString Metadata unsigned Line
Definition:DebugInfoMetadata.h:3508
llvm::DILocalVariable::AlignInBits
Metadata MDString Metadata unsigned Metadata unsigned DIFlags uint32_t AlignInBits
Definition:DebugInfoMetadata.h:3509
llvm::DILocalVariable::Scope
Metadata * Scope
Definition:DebugInfoMetadata.h:3507
llvm::DILocation
Debug location.
Definition:DebugInfoMetadata.h:1988
llvm::DILocation::Scope
unsigned unsigned DILocalScope * Scope
Definition:DebugInfoMetadata.h:2025
llvm::DILocation::getMergedLocations
static DILocation * getMergedLocations(ArrayRef< DILocation * > Locs)
Try to combine the vector of locations passed as input in a single one.
Definition:DebugInfoMetadata.cpp:107
llvm::DILocation::encodeDiscriminator
static std::optional< unsigned > encodeDiscriminator(unsigned BD, unsigned DF, unsigned CI)
Raw encoding of the discriminator.
Definition:DebugInfoMetadata.cpp:248
llvm::DILocation::ImplicitCode
unsigned unsigned DILocalScope DILocation bool ImplicitCode
Definition:DebugInfoMetadata.h:2027
llvm::DILocation::decodeDiscriminator
static void decodeDiscriminator(unsigned D, unsigned &BD, unsigned &DF, unsigned &CI)
Raw decoder for values in an encoded discriminator D.
Definition:DebugInfoMetadata.cpp:281
llvm::DILocation::Line
unsigned Line
Definition:DebugInfoMetadata.h:2025
llvm::DILocation::getMergedLocation
static DILocation * getMergedLocation(DILocation *LocA, DILocation *LocB)
When two instructions are combined into a single instruction we also need to combine the original loc...
Definition:DebugInfoMetadata.cpp:121
llvm::DILocation::Column
unsigned unsigned Column
Definition:DebugInfoMetadata.h:2025
llvm::DILocation::InlinedAt
unsigned unsigned DILocalScope DILocation * InlinedAt
Definition:DebugInfoMetadata.h:2026
llvm::DIMacroFile
Macro file.
Definition:DebugInfoMetadata.h:3910
llvm::DIMacroFile::File
unsigned unsigned Metadata * File
Definition:DebugInfoMetadata.h:3944
llvm::DIMacroFile::Line
unsigned unsigned Line
Definition:DebugInfoMetadata.h:3944
llvm::DIMacroFile::MIType
unsigned MIType
Definition:DebugInfoMetadata.h:3944
llvm::DIMacroFile::Elements
unsigned unsigned Metadata Metadata * Elements
Definition:DebugInfoMetadata.h:3945
llvm::DIMacro
Macro.
Definition:DebugInfoMetadata.h:3856
llvm::DIMacro::MIType
unsigned MIType
Definition:DebugInfoMetadata.h:3888
llvm::DIMacro::Name
unsigned unsigned MDString * Name
Definition:DebugInfoMetadata.h:3888
llvm::DIMacro::Line
unsigned unsigned Line
Definition:DebugInfoMetadata.h:3888
llvm::DIModule
Represents a module in the programming language, for example, a Clang module, or a Fortran module.
Definition:DebugInfoMetadata.h:2511
llvm::DIModule::Scope
Metadata Metadata * Scope
Definition:DebugInfoMetadata.h:2551
llvm::DIModule::Name
Metadata Metadata MDString * Name
Definition:DebugInfoMetadata.h:2551
llvm::DIModule::APINotesFile
Metadata Metadata MDString MDString MDString MDString * APINotesFile
Definition:DebugInfoMetadata.h:2553
llvm::DIModule::File
Metadata * File
Definition:DebugInfoMetadata.h:2551
llvm::DIModule::IncludePath
Metadata Metadata MDString MDString MDString * IncludePath
Definition:DebugInfoMetadata.h:2552
llvm::DIModule::ConfigurationMacros
Metadata Metadata MDString MDString * ConfigurationMacros
Definition:DebugInfoMetadata.h:2552
llvm::DIModule::LineNo
Metadata Metadata MDString MDString MDString MDString unsigned LineNo
Definition:DebugInfoMetadata.h:2553
llvm::DINamespace
Debug lexical block.
Definition:DebugInfoMetadata.h:2462
llvm::DINamespace::ExportSymbols
Metadata MDString bool ExportSymbols
Definition:DebugInfoMetadata.h:2490
llvm::DINamespace::Name
Metadata MDString * Name
Definition:DebugInfoMetadata.h:2490
llvm::DINamespace::Scope
Metadata * Scope
Definition:DebugInfoMetadata.h:2490
llvm::DINode
Tagged DWARF-like metadata node.
Definition:DebugInfoMetadata.h:135
llvm::DINode::getTag
dwarf::Tag getTag() const
Definition:DebugInfoMetadata.cpp:288
llvm::DINode::getFlag
static DIFlags getFlag(StringRef Flag)
Definition:DebugInfoMetadata.cpp:290
llvm::DINode::splitFlags
static DIFlags splitFlags(DIFlags Flags, SmallVectorImpl< DIFlags > &SplitFlags)
Split up a flags bitfield.
Definition:DebugInfoMetadata.cpp:307
llvm::DINode::getFlagString
static StringRef getFlagString(DIFlags Flag)
Definition:DebugInfoMetadata.cpp:297
llvm::DINode::DIFlags
DIFlags
Debug info flags.
Definition:DebugInfoMetadata.h:174
llvm::DINode::FlagPtrToMemberRep
@ FlagPtrToMemberRep
Definition:DebugInfoMetadata.h:179
llvm::DINode::FlagAccessibility
@ FlagAccessibility
Definition:DebugInfoMetadata.h:178
llvm::DIObjCProperty
Definition:DebugInfoMetadata.h:3614
llvm::DIObjCProperty::File
MDString Metadata * File
Definition:DebugInfoMetadata.h:3654
llvm::DIObjCProperty::Name
MDString * Name
Definition:DebugInfoMetadata.h:3654
llvm::DIObjCProperty::GetterName
MDString Metadata unsigned MDString * GetterName
Definition:DebugInfoMetadata.h:3655
llvm::DIObjCProperty::SetterName
MDString Metadata unsigned MDString MDString * SetterName
Definition:DebugInfoMetadata.h:3655
llvm::DIScope
Base class for scope-like contexts.
Definition:DebugInfoMetadata.h:519
llvm::DIScope::getName
StringRef getName() const
Definition:DebugInfoMetadata.cpp:368
llvm::DIScope::getScope
DIScope * getScope() const
Definition:DebugInfoMetadata.cpp:344
llvm::DIStringType
String type, Fortran CHARACTER(n)
Definition:DebugInfoMetadata.h:905
llvm::DIStringType::Name
unsigned MDString * Name
Definition:DebugInfoMetadata.h:950
llvm::DIStringType::SizeInBits
unsigned MDString Metadata Metadata Metadata uint64_t SizeInBits
Definition:DebugInfoMetadata.h:952
llvm::DIStringType::AlignInBits
unsigned MDString Metadata Metadata Metadata uint64_t uint32_t AlignInBits
Definition:DebugInfoMetadata.h:952
llvm::DIStringType::StringLocationExp
unsigned MDString Metadata Metadata Metadata * StringLocationExp
Definition:DebugInfoMetadata.h:951
llvm::DIStringType::Tag
unsigned Tag
Definition:DebugInfoMetadata.h:950
llvm::DIStringType::StringLengthExp
unsigned MDString Metadata Metadata * StringLengthExp
Definition:DebugInfoMetadata.h:951
llvm::DIStringType::StringLength
unsigned MDString Metadata * StringLength
Definition:DebugInfoMetadata.h:950
llvm::DISubprogram
Subprogram description.
Definition:DebugInfoMetadata.h:1710
llvm::DISubprogram::Unit
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags Metadata * Unit
Definition:DebugInfoMetadata.h:1817
llvm::DISubprogram::Annotations
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags Metadata Metadata Metadata Metadata Metadata Metadata * Annotations
Definition:DebugInfoMetadata.h:1820
llvm::DISubprogram::Scope
Metadata * Scope
Definition:DebugInfoMetadata.h:1814
llvm::DISubprogram::ContainingType
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata * ContainingType
Definition:DebugInfoMetadata.h:1816
llvm::DISubprogram::TemplateParams
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags Metadata Metadata * TemplateParams
Definition:DebugInfoMetadata.h:1818
llvm::DISubprogram::Declaration
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags Metadata Metadata Metadata * Declaration
Definition:DebugInfoMetadata.h:1818
llvm::DISubprogram::TargetFuncName
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags Metadata Metadata Metadata Metadata Metadata Metadata MDString * TargetFuncName
Definition:DebugInfoMetadata.h:1820
llvm::DISubprogram::toSPFlags
static DISPFlags toSPFlags(bool IsLocalToUnit, bool IsDefinition, bool IsOptimized, unsigned Virtuality=SPFlagNonvirtual, bool IsMainSubprogram=false)
Definition:DebugInfoMetadata.cpp:1036
llvm::DISubprogram::Name
Metadata MDString * Name
Definition:DebugInfoMetadata.h:1814
llvm::DISubprogram::ThrownTypes
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags Metadata Metadata Metadata Metadata Metadata * ThrownTypes
Definition:DebugInfoMetadata.h:1819
llvm::DISubprogram::getFlag
static DISPFlags getFlag(StringRef Flag)
Definition:DebugInfoMetadata.cpp:1092
llvm::DISubprogram::File
Metadata MDString MDString Metadata * File
Definition:DebugInfoMetadata.h:1814
llvm::DISubprogram::splitFlags
static DISPFlags splitFlags(DISPFlags Flags, SmallVectorImpl< DISPFlags > &SplitFlags)
Split up a flags bitfield for easier printing.
Definition:DebugInfoMetadata.cpp:1113
llvm::DISubprogram::LinkageName
Metadata MDString MDString * LinkageName
Definition:DebugInfoMetadata.h:1814
llvm::DISubprogram::getFlagString
static StringRef getFlagString(DISPFlags Flag)
Definition:DebugInfoMetadata.cpp:1099
llvm::DISubprogram::Type
Metadata MDString MDString Metadata unsigned Metadata * Type
Definition:DebugInfoMetadata.h:1815
llvm::DISubprogram::RetainedNodes
Metadata MDString MDString Metadata unsigned Metadata unsigned Metadata unsigned int DIFlags DISPFlags Metadata Metadata Metadata Metadata * RetainedNodes
Definition:DebugInfoMetadata.h:1819
llvm::DISubprogram::DISPFlags
DISPFlags
Debug info subprogram flags.
Definition:DebugInfoMetadata.h:1725
llvm::DISubprogram::SPFlagVirtuality
@ SPFlagVirtuality
Definition:DebugInfoMetadata.h:1730
llvm::DISubrange
Array subrange.
Definition:DebugInfoMetadata.h:348
llvm::DISubrange::getUpperBound
BoundType getUpperBound() const
Definition:DebugInfoMetadata.cpp:523
llvm::DISubrange::getStride
BoundType getStride() const
Definition:DebugInfoMetadata.cpp:544
llvm::DISubrange::getLowerBound
BoundType getLowerBound() const
Definition:DebugInfoMetadata.cpp:502
llvm::DISubrange::CountNode
Metadata * CountNode
Definition:DebugInfoMetadata.h:378
llvm::DISubrange::getCount
BoundType getCount() const
Definition:DebugInfoMetadata.cpp:481
llvm::DISubroutineType
Type array for a subprogram.
Definition:DebugInfoMetadata.h:1412
llvm::DISubroutineType::Flags
DIFlags Flags
Definition:DebugInfoMetadata.h:1444
llvm::DISubroutineType::TypeArray
DIFlags uint8_t Metadata * TypeArray
Definition:DebugInfoMetadata.h:1444
llvm::DITemplateParameter
Base class for template parameters.
Definition:DebugInfoMetadata.h:2584
llvm::DITemplateParameter::isDefault
bool isDefault() const
Definition:DebugInfoMetadata.h:2599
llvm::DITemplateTypeParameter
Definition:DebugInfoMetadata.h:2607
llvm::DITemplateTypeParameter::Name
MDString * Name
Definition:DebugInfoMetadata.h:2636
llvm::DITemplateValueParameter
Definition:DebugInfoMetadata.h:2646
llvm::DITemplateValueParameter::Type
unsigned MDString Metadata * Type
Definition:DebugInfoMetadata.h:2682
llvm::DITemplateValueParameter::Tag
unsigned Tag
Definition:DebugInfoMetadata.h:2682
llvm::DITemplateValueParameter::Name
unsigned MDString * Name
Definition:DebugInfoMetadata.h:2682
llvm::DIType
Base class for types.
Definition:DebugInfoMetadata.h:710
llvm::DIType::isBitField
bool isBitField() const
Definition:DebugInfoMetadata.h:793
llvm::DIType::isStaticMember
bool isStaticMember() const
Definition:DebugInfoMetadata.h:794
llvm::DIType::getAlignInBits
uint32_t getAlignInBits() const
Definition:DebugInfoMetadata.cpp:37
llvm::DIVariable
Base class for variables.
Definition:DebugInfoMetadata.h:2698
llvm::DIVariable::getSignedness
std::optional< DIBasicType::Signedness > getSignedness() const
Return the signedness of this variable's type, or std::nullopt if this type is neither signed nor uns...
Definition:DebugInfoMetadata.h:2719
llvm::DIVariable::getSizeInBits
std::optional< uint64_t > getSizeInBits() const
Determines the size of the variable's type.
Definition:DebugInfoMetadata.cpp:1331
llvm::DIVariable::getRawType
Metadata * getRawType() const
Definition:DebugInfoMetadata.h:2746
llvm::DIVariable::DIVariable
DIVariable(LLVMContext &C, unsigned ID, StorageType Storage, signed Line, ArrayRef< Metadata * > Ops, uint32_t AlignInBits=0)
Definition:DebugInfoMetadata.cpp:1325
llvm::DWARFExpression::Operation
This class represents an Operation in the Expression.
Definition:DWARFExpression.h:32
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition:DataLayout.h:63
llvm::DbgVariableIntrinsic
This is the common base class for debug info intrinsics for variables.
Definition:IntrinsicInst.h:308
llvm::DbgVariableRecord
Record of a variable value-assignment, aka a non instruction representation of the dbg....
Definition:DebugProgramInstruction.h:270
llvm::DebugVariableAggregate::DebugVariableAggregate
DebugVariableAggregate(const DbgVariableIntrinsic *DVI)
Definition:DebugInfoMetadata.cpp:54
llvm::DebugVariable
Identifies a unique instance of a variable.
Definition:DebugInfoMetadata.h:4024
llvm::DebugVariable::DebugVariable
DebugVariable(const DbgVariableIntrinsic *DII)
Definition:DebugInfoMetadata.cpp:44
llvm::DenseMapBase::find
iterator find(const_arg_type_t< KeyT > Val)
Definition:DenseMap.h:156
llvm::DenseMapBase::try_emplace
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
Definition:DenseMap.h:226
llvm::DenseMapBase::end
iterator end()
Definition:DenseMap.h:84
llvm::DenseMap
Definition:DenseMap.h:727
llvm::Expression
Class representing an expression and its matching format.
Definition:FileCheckImpl.h:189
llvm::Function
Definition:Function.h:63
llvm::GenericDINode
Generic tagged DWARF-like metadata node.
Definition:DebugInfoMetadata.h:236
llvm::GenericDINode::Tag
unsigned Tag
Definition:DebugInfoMetadata.h:275
llvm::GenericDINode::getTag
dwarf::Tag getTag() const
Definition:DebugInfoMetadata.cpp:391
llvm::GenericDINode::Header
unsigned MDString * Header
Definition:DebugInfoMetadata.h:275
llvm::GenericDINode::DwarfOps
unsigned MDString ArrayRef< Metadata * > DwarfOps
Definition:DebugInfoMetadata.h:276
llvm::LLVMContextImpl::DIArgLists
DenseSet< DIArgList *, DIArgListInfo > DIArgLists
Definition:LLVMContextImpl.h:1537
llvm::LLVMContextImpl::DITypeMap
std::optional< DenseMap< const MDString *, DICompositeType * > > DITypeMap
Definition:LLVMContextImpl.h:1544
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition:LLVMContext.h:67
llvm::LLVMContext::isODRUniquingDebugTypes
bool isODRUniquingDebugTypes() const
Whether there is a string map for uniquing debug info identifiers across the context.
Definition:LLVMContext.cpp:334
llvm::LLVMContext::pImpl
LLVMContextImpl *const pImpl
Definition:LLVMContext.h:69
llvm::MDNode
Metadata node.
Definition:Metadata.h:1073
llvm::MDNode::DIAssignID
friend class DIAssignID
Definition:Metadata.h:1076
llvm::MDNode::getDistinct
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition:Metadata.h:1557
llvm::MDNode::get
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition:Metadata.h:1549
llvm::MDNode::clone
TempMDNode clone() const
Create a (temporary) clone of this.
Definition:Metadata.cpp:667
llvm::MDNode::storeImpl
static T * storeImpl(T *N, StorageType Storage, StoreT &Store)
Definition:MetadataImpl.h:42
llvm::MDNode::getContext
LLVMContext & getContext() const
Definition:Metadata.h:1237
llvm::MDNode::replaceWithUniqued
static std::enable_if_t< std::is_base_of< MDNode, T >::value, T * > replaceWithUniqued(std::unique_ptr< T, TempMDNodeDeleter > N)
Replace a temporary node with a uniqued one.
Definition:Metadata.h:1305
llvm::MDString
A single uniqued string.
Definition:Metadata.h:724
llvm::MDString::getString
StringRef getString() const
Definition:Metadata.cpp:616
llvm::MetadataTracking::untrack
static void untrack(Metadata *&MD)
Stop tracking a reference to metadata.
Definition:Metadata.h:353
llvm::MetadataTracking::track
static bool track(Metadata *&MD)
Track the reference to metadata.
Definition:Metadata.h:319
llvm::Metadata
Root of the metadata hierarchy.
Definition:Metadata.h:62
llvm::Metadata::StorageType
StorageType
Active type of storage.
Definition:Metadata.h:70
llvm::Metadata::Uniqued
@ Uniqued
Definition:Metadata.h:70
llvm::Metadata::SubclassData16
unsigned short SubclassData16
Definition:Metadata.h:76
llvm::Metadata::SubclassData32
unsigned SubclassData32
Definition:Metadata.h:77
llvm::Metadata::Storage
unsigned char Storage
Storage flag for non-uniqued, otherwise unowned, metadata.
Definition:Metadata.h:73
llvm::Metadata::SubclassData1
unsigned char SubclassData1
Definition:Metadata.h:75
llvm::PointerUnion
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
Definition:PointerUnion.h:118
llvm::PoisonValue::get
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Definition:Constants.cpp:1878
llvm::ReplaceableMetadataImpl::replaceAllUsesWith
void replaceAllUsesWith(Metadata *MD)
Replace all uses of this with MD.
Definition:Metadata.cpp:367
llvm::ReplaceableMetadataImpl::getContext
LLVMContext & getContext() const
Definition:Metadata.h:404
llvm::ReplaceableMetadataImpl::resolveAllUses
void resolveAllUses(bool ResolveUsers=true)
Resolve all uses of this.
Definition:Metadata.cpp:420
llvm::SmallDenseMap
Definition:DenseMap.h:883
llvm::SmallDenseSet
Implements a dense probed hash-table based set with some number of buckets stored inline.
Definition:DenseSet.h:298
llvm::SmallPtrSet
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition:SmallPtrSet.h:519
llvm::SmallVectorBase::empty
bool empty() const
Definition:SmallVector.h:81
llvm::SmallVectorBase::size
size_t size() const
Definition:SmallVector.h:78
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition:SmallVector.h:573
llvm::SmallVectorImpl::reserve
void reserve(size_type N)
Definition:SmallVector.h:663
llvm::SmallVectorImpl::append
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
Definition:SmallVector.h:683
llvm::SmallVectorImpl::insert
iterator insert(iterator I, T &&Elt)
Definition:SmallVector.h:805
llvm::SmallVectorImpl::clear
void clear()
Definition:SmallVector.h:610
llvm::SmallVectorTemplateBase::pop_back
void pop_back()
Definition:SmallVector.h:425
llvm::SmallVectorTemplateBase::push_back
void push_back(const T &Elt)
Definition:SmallVector.h:413
llvm::SmallVectorTemplateCommon::end
iterator end()
Definition:SmallVector.h:269
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition:SmallVector.h:1196
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:StringRef.h:51
llvm::StringRef::empty
constexpr bool empty() const
empty - Check if the string is empty.
Definition:StringRef.h:147
llvm::StringSwitch
A switch()-like statement whose cases are string literals.
Definition:StringSwitch.h:44
llvm::StringSwitch::Case
StringSwitch & Case(StringLiteral S, T Value)
Definition:StringSwitch.h:69
llvm::StringSwitch::Default
R Default(T Value)
Definition:StringSwitch.h:182
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition:Type.h:45
llvm::Type::getInt64Ty
static IntegerType * getInt64Ty(LLVMContext &C)
llvm::ValueAsMetadata
Value wrapper in the Metadata hierarchy.
Definition:Metadata.h:454
llvm::ValueAsMetadata::get
static ValueAsMetadata * get(Value *V)
Definition:Metadata.cpp:501
llvm::Value
LLVM Value Representation.
Definition:Value.h:74
llvm::Value::getPointerOffsetFrom
std::optional< int64_t > getPointerOffsetFrom(const Value *Other, const DataLayout &DL) const
If this ptr is provably equal to Other plus a constant offset, return that offset in bytes.
Definition:Value.cpp:1028
llvm::cl::opt
Definition:CommandLine.h:1423
llvm::detail::DenseSetImpl::insert
std::pair< iterator, bool > insert(const ValueT &V)
Definition:DenseSet.h:213
llvm::detail::DenseSetImpl::contains
bool contains(const_arg_type_t< ValueT > V) const
Check if the set contains the given element.
Definition:DenseSet.h:193
uint32_t
uint64_t
uint8_t
unsigned
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition:AMDGPUMetadata.h:395
llvm::CallingConv::C
@ C
The default llvm calling convention, compatible with C.
Definition:CallingConv.h:34
llvm::Sched::Source
@ Source
Definition:TargetLowering.h:102
llvm::cl::Hidden
@ Hidden
Definition:CommandLine.h:137
llvm::dwarf::TypeKind
TypeKind
Definition:Dwarf.h:157
llvm::dwarf::DW_OP_LLVM_entry_value
@ DW_OP_LLVM_entry_value
Only used in LLVM metadata.
Definition:Dwarf.h:145
llvm::dwarf::DW_OP_LLVM_implicit_pointer
@ DW_OP_LLVM_implicit_pointer
Only used in LLVM metadata.
Definition:Dwarf.h:146
llvm::dwarf::DW_OP_LLVM_extract_bits_zext
@ DW_OP_LLVM_extract_bits_zext
Only used in LLVM metadata.
Definition:Dwarf.h:149
llvm::dwarf::DW_OP_LLVM_tag_offset
@ DW_OP_LLVM_tag_offset
Only used in LLVM metadata.
Definition:Dwarf.h:144
llvm::dwarf::DW_OP_LLVM_fragment
@ DW_OP_LLVM_fragment
Only used in LLVM metadata.
Definition:Dwarf.h:142
llvm::dwarf::DW_OP_LLVM_arg
@ DW_OP_LLVM_arg
Only used in LLVM metadata.
Definition:Dwarf.h:147
llvm::dwarf::DW_OP_LLVM_convert
@ DW_OP_LLVM_convert
Only used in LLVM metadata.
Definition:Dwarf.h:143
llvm::dwarf::DW_OP_LLVM_extract_bits_sext
@ DW_OP_LLVM_extract_bits_sext
Only used in LLVM metadata.
Definition:Dwarf.h:148
llvm::dwarf::DW_VIRTUALITY_max
@ DW_VIRTUALITY_max
Definition:Dwarf.h:198
llvm::dwarf::Tag
Tag
Definition:Dwarf.h:103
llvm::lltok::NameTableKind
@ NameTableKind
Definition:LLToken.h:493
llvm::lltok::EmissionKind
@ EmissionKind
Definition:LLToken.h:492
llvm::logicalview::LVPrintKind::Elements
@ Elements
llvm::logicalview::LVSortMode::Line
@ Line
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::drop_begin
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
Definition:STLExtras.h:329
llvm::Offset
@ Offset
Definition:DWP.cpp:480
llvm::PseudoProbeType::Block
@ Block
llvm::getUniqued
static T * getUniqued(DenseSet< T *, InfoT > &Store, const typename InfoT::KeyTy &Key)
Definition:MetadataImpl.h:22
llvm::EnableFSDiscriminator
cl::opt< bool > EnableFSDiscriminator
Definition:TargetPassConfig.cpp:392
llvm::any_of
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition:STLExtras.h:1746
llvm::reverse
auto reverse(ContainerTy &&C)
Definition:STLExtras.h:420
llvm::none_of
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
Definition:STLExtras.h:1753
llvm::PackElem::Lo
@ Lo
llvm::ModRefInfo::Ref
@ Ref
The access may reference the value stored in memory.
llvm::IRMemLocation::First
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
llvm::DINameKind::LinkageName
@ LinkageName
llvm::HighlightColor::Tag
@ Tag
std
Implement std::hash so that hash_code can be used in STL containers.
Definition:BitVector.h:858
N
#define N
llvm::DIArgListKeyInfo
Definition:LLVMContextImpl.h:1339
llvm::DIFile::ChecksumInfo
A single checksum, represented by a Kind and a Value (a string).
Definition:DebugInfoMetadata.h:594
llvm::DbgVariableFragmentInfo
Definition:DbgVariableFragmentInfo.h:18
llvm::DbgVariableFragmentInfo::OffsetInBits
uint64_t OffsetInBits
Definition:DbgVariableFragmentInfo.h:23
llvm::DbgVariableFragmentInfo::intersect
static DbgVariableFragmentInfo intersect(DbgVariableFragmentInfo A, DbgVariableFragmentInfo B)
Returns a zero-sized fragment if A and B don't intersect.
Definition:DbgVariableFragmentInfo.h:31
llvm::DbgVariableFragmentInfo::SizeInBits
uint64_t SizeInBits
Definition:DbgVariableFragmentInfo.h:22
llvm::cl::desc
Definition:CommandLine.h:409

Generated on Sun Jul 20 2025 09:39:49 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp