23 DILocation::DILocation(
LLVMContext &
C, StorageType Storage,
unsigned Line,
25 :
MDNode(C, DILocationKind, Storage, MDs) {
27 "Expected a scope and optional inlined-at");
30 assert(Column < (1u << 16) &&
"Expected 16-bit column");
32 SubclassData32 = Line;
33 SubclassData16 = Column;
38 if (Column >= (1u << 16))
44 Metadata *InlinedAt, StorageType Storage,
52 DILocationInfo::KeyTy(Line, Column, Scope, InlinedAt)))
57 assert(ShouldCreate &&
"Expected non-uniqued nodes to always be created");
65 DILocation(Context, Storage, Line, Column, Ops),
72 #include "llvm/IR/DebugInfoFlags.def"
73 .Default(DINode::FlagZero);
78 #define HANDLE_DI_FLAG(ID, NAME) \
80 return "DIFlag" #NAME;
81 #include "llvm/IR/DebugInfoFlags.def"
94 else if (
A == FlagProtected)
101 if (R == FlagSingleInheritance)
102 SplitFlags.
push_back(FlagSingleInheritance);
103 else if (R == FlagMultipleInheritance)
104 SplitFlags.
push_back(FlagMultipleInheritance);
106 SplitFlags.
push_back(FlagVirtualInheritance);
109 if ((Flags & FlagIndirectVirtualBase) == FlagIndirectVirtualBase) {
110 Flags &= ~FlagIndirectVirtualBase;
111 SplitFlags.
push_back(FlagIndirectVirtualBase);
114 #define HANDLE_DI_FLAG(ID, NAME) \
115 if (DIFlags Bit = Flags & Flag##NAME) { \
116 SplitFlags.push_back(Bit); \
119 #include "llvm/IR/DebugInfoFlags.def"
124 if (
auto *
T = dyn_cast<DIType>(
this))
125 return T->getScope();
127 if (
auto *SP = dyn_cast<DISubprogram>(
this))
128 return SP->getScope();
130 if (
auto *LB = dyn_cast<DILexicalBlockBase>(
this))
131 return LB->getScope();
133 if (
auto *NS = dyn_cast<DINamespace>(
this))
134 return NS->getScope();
136 if (
auto *M = dyn_cast<DIModule>(
this))
137 return M->getScope();
139 assert((isa<DIFile>(
this) || isa<DICompileUnit>(
this)) &&
140 "Unhandled type of scope.");
145 if (
auto *
T = dyn_cast<DIType>(
this))
147 if (
auto *SP = dyn_cast<DISubprogram>(
this))
148 return SP->getName();
149 if (
auto *NS = dyn_cast<DINamespace>(
this))
150 return NS->getName();
151 if (
auto *M = dyn_cast<DIModule>(
this))
153 assert((isa<DILexicalBlockBase>(
this) || isa<DIFile>(
this) ||
154 isa<DICompileUnit>(
this)) &&
155 "Unhandled type of scope.");
168 StorageType Storage,
bool ShouldCreate) {
171 GenericDINodeInfo::KeyTy Key(Tag, Header, DwarfOps);
176 Hash = Key.getHash();
178 assert(ShouldCreate &&
"Expected non-uniqued nodes to always be created");
185 Context, Storage, Hash, Tag, PreOps, DwarfOps),
189 void GenericDINode::recalculateHash() {
190 setHash(GenericDINodeInfo::KeyTy::calculateHash(
this));
193 #define UNWRAP_ARGS_IMPL(...) __VA_ARGS__
194 #define UNWRAP_ARGS(ARGS) UNWRAP_ARGS_IMPL ARGS
195 #define DEFINE_GETIMPL_LOOKUP(CLASS, ARGS) \
197 if (Storage == Uniqued) { \
198 if (auto *N = getUniqued(Context.pImpl->CLASS##s, \
199 CLASS##Info::KeyTy(UNWRAP_ARGS(ARGS)))) \
204 assert(ShouldCreate && \
205 "Expected non-uniqued nodes to always be created"); \
208 #define DEFINE_GETIMPL_STORE(CLASS, ARGS, OPS) \
209 return storeImpl(new (array_lengthof(OPS)) \
210 CLASS(Context, Storage, UNWRAP_ARGS(ARGS), OPS), \
211 Storage, Context.pImpl->CLASS##s)
212 #define DEFINE_GETIMPL_STORE_NO_OPS(CLASS, ARGS) \
213 return storeImpl(new (0u) CLASS(Context, Storage, UNWRAP_ARGS(ARGS)), \
214 Storage, Context.pImpl->CLASS##s)
215 #define DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(CLASS, OPS) \
216 return storeImpl(new (array_lengthof(OPS)) CLASS(Context, Storage, OPS), \
217 Storage, Context.pImpl->CLASS##s)
218 #define DEFINE_GETIMPL_STORE_N(CLASS, ARGS, OPS, NUM_OPS) \
219 return storeImpl(new (NUM_OPS) \
220 CLASS(Context, Storage, UNWRAP_ARGS(ARGS), OPS), \
221 Storage, Context.pImpl->CLASS##s)
224 StorageType Storage,
bool ShouldCreate) {
239 MDString *Name, uint64_t SizeInBits,
240 uint32_t AlignInBits,
unsigned Encoding,
241 StorageType Storage,
bool ShouldCreate) {
244 (Tag, Name, SizeInBits, AlignInBits, Encoding));
245 Metadata *Ops[] = {
nullptr,
nullptr, Name};
253 uint32_t AlignInBits, uint64_t OffsetInBits,
255 StorageType Storage,
bool ShouldCreate) {
258 (Tag, Name, File, Line, Scope, BaseType, SizeInBits,
259 AlignInBits, OffsetInBits, DWARFAddressSpace, Flags,
263 DIDerivedType, (Tag, Line, SizeInBits, AlignInBits, OffsetInBits,
264 DWARFAddressSpace, Flags), Ops);
270 uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags,
279 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
280 VTableHolder, TemplateParams, Identifier));
284 AlignInBits, OffsetInBits, Flags),
291 uint64_t SizeInBits,
uint32_t AlignInBits, uint64_t OffsetInBits,
300 Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
301 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
302 VTableHolder, TemplateParams, &Identifier);
305 assert(CT->getRawIdentifier() == &Identifier &&
"Wrong ODR identifier?");
306 if (!CT->isForwardDecl() || (Flags & DINode::FlagFwdDecl))
310 CT->mutate(Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits,
315 "Mismatched number of operands");
316 for (
unsigned I = 0,
E = CT->getNumOperands();
I !=
E; ++
I)
317 if (Ops[
I] != CT->getOperand(
I))
318 CT->setOperand(
I, Ops[
I]);
325 uint64_t SizeInBits,
uint32_t AlignInBits, uint64_t OffsetInBits,
326 DIFlags Flags,
Metadata *Elements,
unsigned RuntimeLang,
334 Context, Tag, Name, File, Line, Scope, BaseType, SizeInBits,
335 AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang, VTableHolder,
336 TemplateParams, &Identifier);
353 Metadata *Ops[] = {
nullptr,
nullptr,
nullptr, TypeArray};
370 StringRef DIFile::getChecksumKindAsString()
const {
377 MDString *Checksum, StorageType Storage,
390 unsigned RuntimeVersion,
MDString *SplitDebugFilename,
393 uint64_t DWOId,
bool SplitDebugInlining,
bool DebugInfoForProfiling,
394 StorageType Storage,
bool ShouldCreate) {
406 IsOptimized, RuntimeVersion, EmissionKind,
407 DWOId, SplitDebugInlining,
408 DebugInfoForProfiling, Ops),
423 case NoDebug:
return "NoDebug";
431 if (
auto *Block = dyn_cast<DILexicalBlockBase>(
this))
432 return Block->getScope()->getSubprogram();
433 return const_cast<DISubprogram *
>(cast<DISubprogram>(
this));
437 if (
auto *File = dyn_cast<DILexicalBlockFile>(
this))
438 return File->getScope()->getNonLexicalBlockFileScope();
445 bool IsLocalToUnit,
bool IsDefinition,
unsigned ScopeLine,
446 Metadata *ContainingType,
unsigned Virtuality,
unsigned VirtualIndex,
447 int ThisAdjustment, DIFlags Flags,
bool IsOptimized,
Metadata *
Unit,
449 Metadata *ThrownTypes, StorageType Storage,
bool ShouldCreate) {
453 DISubprogram, (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
454 IsDefinition, ScopeLine, ContainingType, Virtuality,
455 VirtualIndex, ThisAdjustment, Flags, IsOptimized, Unit,
456 TemplateParams, Declaration, Variables, ThrownTypes));
462 if (!TemplateParams) {
469 (Line, ScopeLine, Virtuality, VirtualIndex,
470 ThisAdjustment, Flags, IsLocalToUnit, IsDefinition,
475 bool DISubprogram::describes(
const Function *
F)
const {
476 assert(F &&
"Invalid function");
487 unsigned Column, StorageType Storage,
492 assert(Scope &&
"Expected scope");
500 unsigned Discriminator,
503 assert(Scope &&
"Expected scope");
511 StorageType Storage,
bool ShouldCreate) {
522 StorageType Storage,
bool ShouldCreate) {
525 DIModule, (Scope, Name, ConfigurationMacros, IncludePath, ISysRoot));
543 Metadata *Value, StorageType Storage,
bool ShouldCreate) {
553 Metadata *Type,
bool IsLocalToUnit,
bool IsDefinition,
554 Metadata *StaticDataMemberDeclaration,
555 uint32_t AlignInBits, StorageType Storage,
560 (Scope, Name, LinkageName, File, Line, Type,
561 IsLocalToUnit, IsDefinition,
562 StaticDataMemberDeclaration, AlignInBits));
566 (Line, IsLocalToUnit, IsDefinition, AlignInBits),
573 unsigned Arg, DIFlags Flags,
578 assert(Arg <= UINT16_MAX &&
"Expected argument number to fit in 16-bits");
580 assert(Scope &&
"Expected scope");
583 (Scope, Name, File, Line, Type, Arg, Flags,
591 StorageType Storage,
bool ShouldCreate) {
600 case dwarf::DW_OP_constu:
601 case dwarf::DW_OP_plus_uconst:
611 if (
I->get() +
I->getSize() >
E->get())
615 switch (
I->getOp()) {
620 return I->get() +
I->getSize() ==
E->get();
621 case dwarf::DW_OP_stack_value: {
623 if (
I->get() +
I->getSize() ==
E->get())
630 case dwarf::DW_OP_swap: {
642 case dwarf::DW_OP_constu:
643 case dwarf::DW_OP_plus_uconst:
644 case dwarf::DW_OP_plus:
645 case dwarf::DW_OP_minus:
646 case dwarf::DW_OP_deref:
647 case dwarf::DW_OP_xderef:
656 for (
auto I = Start;
I !=
End; ++
I)
669 }
else if (Offset < 0) {
682 if (
getNumElements() == 2 && Elements[0] == dwarf::DW_OP_plus_uconst) {
683 Offset = Elements[1];
687 if (
getNumElements() == 3 && Elements[0] == dwarf::DW_OP_constu) {
688 if (Elements[2] == dwarf::DW_OP_plus) {
689 Offset = Elements[1];
692 if (Elements[2] == dwarf::DW_OP_minus) {
693 Offset = -Elements[1];
702 int64_t
Offset,
bool StackValue) {
711 if (
Op.getOp() == dwarf::DW_OP_stack_value)
719 for (
unsigned I = 0;
I <
Op.getNumArgs(); ++
I)
744 Metadata *Ops[] = {Variable, Expression};
756 SetterName, Attributes, Type));
768 (Tag, Scope, Entity, File, Line, Name));
787 (MIType, Line, File, Elements));
static void appendOffset(SmallVectorImpl< uint64_t > &Ops, int64_t Offset)
Append Ops with operations to apply the Offset.
void push_back(const T &Elt)
Metadata MDString MDString * ConfigurationMacros
const_iterator end(StringRef path)
Get end iterator over path.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin 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
bool extractIfOffset(int64_t &Offset) const
If this is a constant offset, extract it.
iterator_range< expr_op_iterator > expr_ops() const
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.
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.
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).
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
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.
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.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static std::vector< std::string > Flags
Metadata MDString MDString Metadata * File
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
Metadata MDString MDString MDString * IncludePath
LLVMContext & getContext() const
Metadata MDString MDString Metadata unsigned Metadata bool bool unsigned Metadata unsigned unsigned int DIFlags bool Metadata Metadata Metadata Metadata * Variables
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
static DIExpression * prepend(const DIExpression *DIExpr, bool Deref, int64_t Offset=0, bool StackValue=false)
Prepend DIExpr with a deref and offset operation and optionally turn it into a stack value...
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.
static LazyValueInfoImpl & getImpl(void *&PImpl, AssumptionCache *AC, const DataLayout *DL, DominatorTree *DT=nullptr)
This lazily constructs the LazyValueInfoImpl.
DISubprogram * getSubprogram() const
Get the subprogram for this scope.
expr_op_iterator expr_op_end() const
Optional< DenseMap< const MDString *, DICompositeType * > > DITypeMap
unsigned MDString Metadata * File
Basic type, like 'int' or 'float'.