22 DILocation::DILocation(
LLVMContext &
C, StorageType Storage,
unsigned Line,
24 :
MDNode(C, DILocationKind, Storage, MDs) {
26 "Expected a scope and optional inlined-at");
29 assert(Column < (1u << 16) &&
"Expected 16-bit column");
31 SubclassData32 = Line;
32 SubclassData16 = Column;
37 if (Column >= (1u << 16))
43 Metadata *InlinedAt, StorageType Storage,
51 DILocationInfo::KeyTy(Line, Column, Scope, InlinedAt)))
56 assert(ShouldCreate &&
"Expected non-uniqued nodes to always be created");
64 DILocation(Context, Storage, Line, Column, Ops),
71 #include "llvm/IR/DebugInfoFlags.def"
72 .Default(DINode::FlagZero);
77 #define HANDLE_DI_FLAG(ID, NAME) \
79 return "DIFlag" #NAME;
80 #include "llvm/IR/DebugInfoFlags.def"
93 else if (
A == FlagProtected)
100 if (R == FlagSingleInheritance)
101 SplitFlags.
push_back(FlagSingleInheritance);
102 else if (R == FlagMultipleInheritance)
103 SplitFlags.
push_back(FlagMultipleInheritance);
105 SplitFlags.
push_back(FlagVirtualInheritance);
108 if ((Flags & FlagIndirectVirtualBase) == FlagIndirectVirtualBase) {
109 Flags &= ~FlagIndirectVirtualBase;
110 SplitFlags.
push_back(FlagIndirectVirtualBase);
113 #define HANDLE_DI_FLAG(ID, NAME) \
114 if (DIFlags Bit = Flags & Flag##NAME) { \
115 SplitFlags.push_back(Bit); \
118 #include "llvm/IR/DebugInfoFlags.def"
123 if (
auto *
T = dyn_cast<DIType>(
this))
124 return T->getScope();
126 if (
auto *SP = dyn_cast<DISubprogram>(
this))
127 return SP->getScope();
129 if (
auto *LB = dyn_cast<DILexicalBlockBase>(
this))
130 return LB->getScope();
132 if (
auto *NS = dyn_cast<DINamespace>(
this))
133 return NS->getScope();
135 if (
auto *M = dyn_cast<DIModule>(
this))
136 return M->getScope();
138 assert((isa<DIFile>(
this) || isa<DICompileUnit>(
this)) &&
139 "Unhandled type of scope.");
144 if (
auto *
T = dyn_cast<DIType>(
this))
146 if (
auto *SP = dyn_cast<DISubprogram>(
this))
147 return SP->getName();
148 if (
auto *NS = dyn_cast<DINamespace>(
this))
149 return NS->getName();
150 if (
auto *M = dyn_cast<DIModule>(
this))
152 assert((isa<DILexicalBlockBase>(
this) || isa<DIFile>(
this) ||
153 isa<DICompileUnit>(
this)) &&
154 "Unhandled type of scope.");
167 StorageType Storage,
bool ShouldCreate) {
170 GenericDINodeInfo::KeyTy Key(Tag, Header, DwarfOps);
175 Hash = Key.getHash();
177 assert(ShouldCreate &&
"Expected non-uniqued nodes to always be created");
184 Context, Storage, Hash, Tag, PreOps, DwarfOps),
188 void GenericDINode::recalculateHash() {
189 setHash(GenericDINodeInfo::KeyTy::calculateHash(
this));
192 #define UNWRAP_ARGS_IMPL(...) __VA_ARGS__
193 #define UNWRAP_ARGS(ARGS) UNWRAP_ARGS_IMPL ARGS
194 #define DEFINE_GETIMPL_LOOKUP(CLASS, ARGS) \
196 if (Storage == Uniqued) { \
197 if (auto *N = getUniqued(Context.pImpl->CLASS##s, \
198 CLASS##Info::KeyTy(UNWRAP_ARGS(ARGS)))) \
203 assert(ShouldCreate && \
204 "Expected non-uniqued nodes to always be created"); \
207 #define DEFINE_GETIMPL_STORE(CLASS, ARGS, OPS) \
208 return storeImpl(new (array_lengthof(OPS)) \
209 CLASS(Context, Storage, UNWRAP_ARGS(ARGS), OPS), \
210 Storage, Context.pImpl->CLASS##s)
211 #define DEFINE_GETIMPL_STORE_NO_OPS(CLASS, ARGS) \
212 return storeImpl(new (0u) CLASS(Context, Storage, UNWRAP_ARGS(ARGS)), \
213 Storage, Context.pImpl->CLASS##s)
214 #define DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(CLASS, OPS) \
215 return storeImpl(new (array_lengthof(OPS)) CLASS(Context, Storage, OPS), \
216 Storage, Context.pImpl->CLASS##s)
219 StorageType Storage,
bool ShouldCreate) {
234 MDString *Name, uint64_t SizeInBits,
235 uint32_t AlignInBits,
unsigned Encoding,
236 StorageType Storage,
bool ShouldCreate) {
239 (Tag, Name, SizeInBits, AlignInBits, Encoding));
240 Metadata *Ops[] = {
nullptr,
nullptr, Name};
249 Metadata *ExtraData, StorageType Storage,
bool ShouldCreate) {
252 (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
253 AlignInBits, OffsetInBits, Flags, ExtraData));
256 DIDerivedType, (Tag, Line, SizeInBits, AlignInBits, OffsetInBits, Flags),
263 uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags,
272 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
273 VTableHolder, TemplateParams, Identifier));
277 AlignInBits, OffsetInBits, Flags),
284 uint64_t SizeInBits,
uint32_t AlignInBits, uint64_t OffsetInBits,
293 Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
294 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
295 VTableHolder, TemplateParams, &Identifier);
298 assert(CT->getRawIdentifier() == &Identifier &&
"Wrong ODR identifier?");
299 if (!CT->isForwardDecl() || (Flags & DINode::FlagFwdDecl))
303 CT->mutate(Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits,
308 "Mismatched number of operands");
309 for (
unsigned I = 0,
E = CT->getNumOperands();
I !=
E; ++
I)
310 if (Ops[
I] != CT->getOperand(
I))
311 CT->setOperand(
I, Ops[
I]);
318 uint64_t SizeInBits,
uint32_t AlignInBits, uint64_t OffsetInBits,
319 DIFlags Flags,
Metadata *Elements,
unsigned RuntimeLang,
327 Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
328 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang, VTableHolder,
329 TemplateParams, &Identifier);
346 Metadata *Ops[] = {
nullptr,
nullptr,
nullptr, TypeArray};
363 StringRef DIFile::getChecksumKindAsString()
const {
370 MDString *Checksum, StorageType Storage,
383 unsigned RuntimeVersion,
MDString *SplitDebugFilename,
386 uint64_t DWOId,
bool SplitDebugInlining, StorageType Storage,
399 IsOptimized, RuntimeVersion, EmissionKind,
400 DWOId, SplitDebugInlining, Ops),
415 case NoDebug:
return "NoDebug";
423 if (
auto *Block = dyn_cast<DILexicalBlockBase>(
this))
424 return Block->getScope()->getSubprogram();
425 return const_cast<DISubprogram *
>(cast<DISubprogram>(
this));
429 if (
auto *File = dyn_cast<DILexicalBlockFile>(
this))
430 return File->getScope()->getNonLexicalBlockFileScope();
437 bool IsLocalToUnit,
bool IsDefinition,
unsigned ScopeLine,
438 Metadata *ContainingType,
unsigned Virtuality,
unsigned VirtualIndex,
439 int ThisAdjustment, DIFlags Flags,
bool IsOptimized,
Metadata *
Unit,
441 StorageType Storage,
bool ShouldCreate) {
446 (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
447 ScopeLine, ContainingType, Virtuality, VirtualIndex, ThisAdjustment,
448 Flags, IsOptimized, Unit, TemplateParams, Declaration, Variables));
453 ThisAdjustment, Flags, IsLocalToUnit,
454 IsDefinition, IsOptimized),
458 bool DISubprogram::describes(
const Function *
F)
const {
459 assert(F &&
"Invalid function");
470 unsigned Column, StorageType Storage,
475 assert(Scope &&
"Expected scope");
483 unsigned Discriminator,
486 assert(Scope &&
"Expected scope");
494 bool ExportSymbols, StorageType Storage,
505 StorageType Storage,
bool ShouldCreate) {
508 DIModule, (Scope, Name, ConfigurationMacros, IncludePath, ISysRoot));
526 Metadata *Value, StorageType Storage,
bool ShouldCreate) {
536 Metadata *Type,
bool IsLocalToUnit,
bool IsDefinition,
537 Metadata *StaticDataMemberDeclaration,
538 uint32_t AlignInBits, StorageType Storage,
543 (Scope, Name, LinkageName, File, Line, Type,
544 IsLocalToUnit, IsDefinition,
545 StaticDataMemberDeclaration, AlignInBits));
549 (Line, IsLocalToUnit, IsDefinition, AlignInBits),
556 unsigned Arg, DIFlags Flags,
561 assert(Arg <= UINT16_MAX &&
"Expected argument number to fit in 16-bits");
563 assert(Scope &&
"Expected scope");
566 (Scope, Name, File, Line, Type, Arg, Flags,
574 StorageType Storage,
bool ShouldCreate) {
583 case dwarf::DW_OP_constu:
584 case dwarf::DW_OP_plus:
585 case dwarf::DW_OP_minus:
595 if (
I->get() +
I->getSize() >
E->get())
599 switch (
I->getOp()) {
604 return I->get() +
I->getSize() ==
E->get();
605 case dwarf::DW_OP_stack_value: {
607 if (
I->get() +
I->getSize() ==
E->get())
614 case dwarf::DW_OP_constu:
615 case dwarf::DW_OP_plus:
616 case dwarf::DW_OP_minus:
617 case dwarf::DW_OP_deref:
626 for (
auto I = Start;
I !=
End; ++
I)
651 Metadata *Ops[] = {Variable, Expression};
663 SetterName, Attributes, Type));
675 Metadata *Ops[] = {Scope, Entity, Name};
693 (MIType, Line, File, Elements));
void push_back(const T &Elt)
Metadata MDString MDString * ConfigurationMacros
const_iterator end(StringRef path)
Get end iterator over path.
MDString MDString * Directory
static DICompositeType * getODRTypeIfExists(LLVMContext &Context, MDString &Identifier)
unsigned MDString Metadata unsigned Metadata Metadata * BaseType
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
uint64_t getElement(unsigned I) const
const_iterator begin(StringRef path)
Get begin iterator over path.
static T * storeImpl(T *N, StorageType Storage, StoreT &Store)
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned Metadata Metadata * TemplateParams
unsigned Metadata MDString bool MDString * Flags
unsigned MDString Metadata * Type
Metadata MDString MDString Metadata unsigned Metadata * Type
DebugEmissionKind getEmissionKind() const
StringRef getName() const
Return a constant reference to the value's name.
bool isODRUniquingDebugTypes() const
Whether there is a string map for uniquing debug info identifiers across the context.
DILocalScope * getNonLexicalBlockFileScope() const
Get the first non DILexicalBlockFile scope of this scope.
struct fuzzer::@269 Flags
unsigned Metadata MDString * Producer
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
LLVM_ATTRIBUTE_ALWAYS_INLINE R Default(const T &Value) const
unsigned Metadata MDString bool MDString unsigned MDString * SplitDebugFilename
static const char * EmissionKindString(DebugEmissionKind EK)
Only used in LLVM metadata.
unsigned Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata * GlobalVariables
Holds a subclass of DINode.
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Case(const char(&S)[N], const T &Value)
unsigned StringRef DIFile unsigned DIScopeRef DITypeRef BaseType
Holds the characteristics of one fragment of a larger variable.
unsigned StringRef DIFile * File
expr_op_iterator expr_op_begin() const
Visit the elements via ExprOperand wrappers.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
DIScopeRef getScope() const
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata * Elements
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
Flag
These should be considered private to the implementation of the MCInstrDesc class.
static ChecksumKind getChecksumKind(StringRef CSKindStr)
static StringRef getFlagString(DIFlags Flag)
Metadata MDString MDString Metadata unsigned Metadata bool bool unsigned Metadata unsigned unsigned int DIFlags bool Metadata Metadata * TemplateParams
Metadata MDString MDString Metadata * File
A switch()-like statement whose cases are string literals.
static T * getUniqued(DenseSet< T *, InfoT > &Store, const typename InfoT::KeyTy &Key)
unsigned getNumElements() const
StringRef getName() const
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
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, DIFlags Flags, Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder, Metadata *TemplateParams)
Build a DICompositeType with the given ODR identifier.
unsigned getSize() const
Return the size of the operand.
unsigned StringRef DIFile unsigned DIScopeRef Scope
A pair of DIGlobalVariable and DIExpression.
static const unsigned End
Metadata MDString MDString * LinkageName
unsigned Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata * RetainedTypes
LLVMContextImpl *const pImpl
Metadata MDString MDString Metadata unsigned Metadata bool bool unsigned Metadata unsigned unsigned int DIFlags bool Metadata Metadata Metadata * Declaration
An imported module (C++ using directive or similar).
StringRef getString() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Metadata MDString MDString * LinkageName
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
static DIFlags splitFlags(DIFlags Flags, SmallVectorImpl< DIFlags > &SplitFlags)
Split up a flags bitfield.
Optional< FragmentInfo > getFragmentInfo() const
Retrieve the details of this fragment expression.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
Metadata MDString MDString Metadata unsigned Metadata bool bool unsigned Metadata * ContainingType
static DIFlags getFlag(StringRef Flag)
A (clang) module that has been imported by the compile unit.
DISubprogram * getSubprogram() const
Get the attached subprogram.
Metadata MDString MDString Metadata unsigned Metadata bool bool unsigned Metadata unsigned unsigned int DIFlags bool Metadata * Unit
unsigned Metadata MDString bool MDString unsigned MDString unsigned Metadata * EnumTypes
Generic tagged DWARF-like metadata node.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Metadata MDString Metadata * File
Type array for a subprogram.
Metadata MDString MDString Metadata * File
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
Metadata MDString MDString MDString * IncludePath
unsigned MDString Metadata unsigned Metadata * Scope
bool isConstant() const
Determine whether this represents a standalone constant value.
std::vector< uint8_t > Unit
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint32_t uint64_t DIFlags Metadata unsigned Metadata * VTableHolder
LLVM Value Representation.
unsigned Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata Metadata * ImportedEntities
Metadata MDString MDString Metadata unsigned Metadata * Type
An iterator for expression operands.
uint64_t getOp() const
Get the operand code.
std::string Hash(const Unit &U)
StringRef - Represent a constant reference to a string, i.e.
DISubprogram * getSubprogram() const
Get the subprogram for this scope.
expr_op_iterator expr_op_end() const
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
Optional< DenseMap< const MDString *, DICompositeType * > > DITypeMap
unsigned MDString Metadata * File
Basic type, like 'int' or 'float'.