22 DILocation::DILocation(
LLVMContext &C, StorageType Storage,
unsigned Line,
24 :
MDNode(C, DILocationKind, Storage, MDs) {
25 assert((MDs.
size() == 1 || MDs.
size() == 2) &&
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,
48 assert(Scope &&
"Expected scope");
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),
82 std::pair<const char *, unsigned> Key(getFilename().data(), getLine());
89 #include "llvm/IR/DebugInfoFlags.def"
97 #define HANDLE_DI_FLAG(ID, NAME) \
99 return "DIFlag" #NAME;
100 #include "llvm/IR/DebugInfoFlags.def"
109 if (
A == FlagPrivate)
111 else if (
A == FlagProtected)
118 #define HANDLE_DI_FLAG(ID, NAME) \
119 if (unsigned Bit = Flags & ID) { \
120 SplitFlags.push_back(Bit); \
123 #include "llvm/IR/DebugInfoFlags.def"
129 if (
auto *
T = dyn_cast<DIType>(
this))
130 return T->getScope();
132 if (
auto *
SP = dyn_cast<DISubprogram>(
this))
133 return SP->getScope();
135 if (
auto *LB = dyn_cast<DILexicalBlockBase>(
this))
138 if (
auto *NS = dyn_cast<DINamespace>(
this))
141 if (
auto *M = dyn_cast<DIModule>(
this))
144 assert((isa<DIFile>(
this) || isa<DICompileUnit>(
this)) &&
145 "Unhandled type of scope.");
150 if (
auto *
T = dyn_cast<DIType>(
this))
152 if (
auto *
SP = dyn_cast<DISubprogram>(
this))
153 return SP->getName();
154 if (
auto *NS = dyn_cast<DINamespace>(
this))
155 return NS->getName();
156 if (
auto *M = dyn_cast<DIModule>(
this))
158 assert((isa<DILexicalBlockBase>(
this) || isa<DIFile>(
this) ||
159 isa<DICompileUnit>(
this)) &&
160 "Unhandled type of scope.");
179 StorageType Storage,
bool ShouldCreate) {
182 GenericDINodeInfo::KeyTy Key(Tag,
getString(Header), DwarfOps);
187 Hash = Key.getHash();
189 assert(ShouldCreate &&
"Expected non-uniqued nodes to always be created");
193 assert(
isCanonical(Header) &&
"Expected canonical MDString");
196 Context, Storage, Hash, Tag, PreOps, DwarfOps),
200 void GenericDINode::recalculateHash() {
201 setHash(GenericDINodeInfo::KeyTy::calculateHash(
this));
204 #define UNWRAP_ARGS_IMPL(...) __VA_ARGS__
205 #define UNWRAP_ARGS(ARGS) UNWRAP_ARGS_IMPL ARGS
206 #define DEFINE_GETIMPL_LOOKUP(CLASS, ARGS) \
208 if (Storage == Uniqued) { \
209 if (auto *N = getUniqued(Context.pImpl->CLASS##s, \
210 CLASS##Info::KeyTy(UNWRAP_ARGS(ARGS)))) \
215 assert(ShouldCreate && \
216 "Expected non-uniqued nodes to always be created"); \
219 #define DEFINE_GETIMPL_STORE(CLASS, ARGS, OPS) \
220 return storeImpl(new (ArrayRef<Metadata *>(OPS).size()) \
221 CLASS(Context, Storage, UNWRAP_ARGS(ARGS), OPS), \
222 Storage, Context.pImpl->CLASS##s)
223 #define DEFINE_GETIMPL_STORE_NO_OPS(CLASS, ARGS) \
224 return storeImpl(new (0u) CLASS(Context, Storage, UNWRAP_ARGS(ARGS)), \
225 Storage, Context.pImpl->CLASS##s)
226 #define DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(CLASS, OPS) \
227 return storeImpl(new (ArrayRef<Metadata *>(OPS).size()) \
228 CLASS(Context, Storage, OPS), \
229 Storage, Context.pImpl->CLASS##s)
232 StorageType Storage,
bool ShouldCreate) {
240 assert(
isCanonical(Name) &&
"Expected canonical MDString");
247 MDString *Name, uint64_t SizeInBits,
248 uint64_t AlignInBits,
unsigned Encoding,
249 StorageType Storage,
bool ShouldCreate) {
250 assert(
isCanonical(Name) &&
"Expected canonical MDString");
253 Metadata *Ops[] = {
nullptr,
nullptr, Name};
261 uint64_t AlignInBits, uint64_t OffsetInBits,
unsigned Flags,
262 Metadata *ExtraData, StorageType Storage,
bool ShouldCreate) {
263 assert(
isCanonical(Name) &&
"Expected canonical MDString");
265 BaseType, SizeInBits, AlignInBits,
266 OffsetInBits, Flags, ExtraData));
269 DIDerivedType, (Tag, Line, SizeInBits, AlignInBits, OffsetInBits, Flags),
276 uint64_t AlignInBits, uint64_t OffsetInBits,
unsigned Flags,
280 assert(
isCanonical(Name) &&
"Expected canonical MDString");
282 (Tag,
getString(Name), File, Line, Scope, BaseType,
283 SizeInBits, AlignInBits, OffsetInBits, Flags, Elements,
284 RuntimeLang, VTableHolder, TemplateParams,
289 AlignInBits, OffsetInBits, Flags),
294 unsigned Flags,
Metadata *TypeArray,
298 Metadata *Ops[] = {
nullptr,
nullptr,
nullptr,
nullptr,
304 MDString *Directory, StorageType Storage,
306 assert(
isCanonical(Filename) &&
"Expected canonical MDString");
307 assert(
isCanonical(Directory) &&
"Expected canonical MDString");
316 unsigned RuntimeVersion,
MDString *SplitDebugFilename,
319 Metadata *ImportedEntities, uint64_t DWOId,
320 StorageType Storage,
bool ShouldCreate) {
321 assert(
isCanonical(Producer) &&
"Expected canonical MDString");
322 assert(
isCanonical(Flags) &&
"Expected canonical MDString");
323 assert(
isCanonical(SplitDebugFilename) &&
"Expected canonical MDString");
327 RuntimeVersion,
getString(SplitDebugFilename), EmissionKind, EnumTypes,
328 RetainedTypes, Subprograms, GlobalVariables, ImportedEntities, DWOId));
334 (SourceLanguage, IsOptimized, RuntimeVersion, EmissionKind, DWOId), Ops);
338 if (
auto *
Block = dyn_cast<DILexicalBlockBase>(
this))
339 return Block->getScope()->getSubprogram();
340 return const_cast<DISubprogram *
>(cast<DISubprogram>(
this));
346 bool IsLocalToUnit,
bool IsDefinition,
unsigned ScopeLine,
347 Metadata *ContainingType,
unsigned Virtuality,
unsigned VirtualIndex,
350 StorageType Storage,
bool ShouldCreate) {
351 assert(
isCanonical(Name) &&
"Expected canonical MDString");
352 assert(
isCanonical(LinkageName) &&
"Expected canonical MDString");
355 Line, Type, IsLocalToUnit, IsDefinition, ScopeLine,
356 ContainingType, Virtuality, VirtualIndex, Flags,
357 IsOptimized, Function, TemplateParams, Declaration,
363 (Line, ScopeLine, Virtuality, VirtualIndex, Flags,
364 IsLocalToUnit, IsDefinition, IsOptimized),
368 Function *DISubprogram::getFunction()
const {
370 return dyn_cast_or_null<Function>(getFunctionConstant());
374 assert(F &&
"Invalid function");
375 if (F == getFunction())
385 : static_cast<ConstantAsMetadata *>(
nullptr));
390 unsigned Column, StorageType Storage,
392 assert(Scope &&
"Expected scope");
400 unsigned Discriminator,
403 assert(Scope &&
"Expected scope");
411 StorageType Storage,
bool ShouldCreate) {
412 assert(
isCanonical(Name) &&
"Expected canonical MDString");
421 StorageType Storage,
bool ShouldCreate) {
422 assert(
isCanonical(Name) &&
"Expected canonical MDString");
435 assert(
isCanonical(Name) &&
"Expected canonical MDString");
443 Metadata *Value, StorageType Storage,
bool ShouldCreate) {
444 assert(
isCanonical(Name) &&
"Expected canonical MDString");
454 Metadata *Type,
bool IsLocalToUnit,
bool IsDefinition,
456 Metadata *StaticDataMemberDeclaration,
457 StorageType Storage,
bool ShouldCreate) {
458 assert(
isCanonical(Name) &&
"Expected canonical MDString");
459 assert(
isCanonical(LinkageName) &&
"Expected canonical MDString");
462 Line, Type, IsLocalToUnit, IsDefinition, Variable,
463 StaticDataMemberDeclaration));
474 unsigned Flags, StorageType Storage,
477 assert(Arg <= UINT16_MAX &&
"Expected argument number to fit in 16-bits");
479 assert(Scope &&
"Expected scope");
480 assert(
isCanonical(Name) &&
"Expected canonical MDString");
482 Line, Type, Arg, Flags));
489 StorageType Storage,
bool ShouldCreate) {
496 case dwarf::DW_OP_bit_piece:
498 case dwarf::DW_OP_plus:
508 if (
I->get() +
I->getSize() > E->get())
512 switch (
I->getOp()) {
515 case dwarf::DW_OP_bit_piece:
517 return I->get() +
I->getSize() == E->get();
518 case dwarf::DW_OP_plus:
519 case dwarf::DW_OP_deref:
527 assert(
isValid() &&
"Expected valid expression");
530 return getElement(
N - 3) == dwarf::DW_OP_bit_piece;
548 assert(
isCanonical(Name) &&
"Expected canonical MDString");
549 assert(
isCanonical(GetterName) &&
"Expected canonical MDString");
550 assert(
isCanonical(SetterName) &&
"Expected canonical MDString");
553 getString(SetterName), Attributes, Type));
563 assert(
isCanonical(Name) &&
"Expected canonical MDString");
565 (Tag, Scope, Entity, Line,
getString(Name)));
566 Metadata *Ops[] = {Scope, Entity, Name};
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint64_t uint64_t unsigned Metadata unsigned Metadata * VTableHolder
bool describes(const Function *F) const
Check if this subprogram decribes the given function.
void push_back(const T &Elt)
Metadata MDString MDString * ConfigurationMacros
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint64_t uint64_t unsigned Metadata * Elements
unsigned MDString Metadata unsigned Metadata Metadata * BaseType
uint64_t getElement(unsigned I) const
void replaceFunction(Function *F)
Replace the function.
unsigned Metadata * Scope
static T * storeImpl(T *N, StorageType Storage, StoreT &Store)
unsigned Metadata MDString bool MDString * Flags
unsigned MDString Metadata * Type
Metadata MDString MDString Metadata unsigned Metadata * Type
StringRef getName() const
Return a constant reference to the value's name.
Metadata MDString MDString Metadata unsigned Metadata bool bool unsigned Metadata unsigned unsigned unsigned bool Metadata Metadata Metadata * Declaration
Metadata MDString MDString Metadata unsigned Metadata bool bool Metadata * Variable
unsigned Metadata MDString * Producer
unsigned Metadata MDString bool MDString unsigned MDString * SplitDebugFilename
Pointer union between a subclass of DINode and MDString.
Metadata MDString MDString Metadata unsigned Metadata bool bool unsigned Metadata unsigned unsigned unsigned bool Metadata Metadata * TemplateParams
unsigned StringRef DIFile unsigned DIScopeRef DITypeRef BaseType
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
size_t size() const
size - Get the array size.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
unsigned MDString Metadata unsigned Metadata Metadata uint64_t uint64_t uint64_t unsigned Metadata unsigned 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 computeNewDiscriminator() const
Compute new discriminator in the given context.
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.
unsigned getSize() const
Return the size of the operand.
unsigned StringRef DIFile unsigned DIScopeRef Scope
unsigned Metadata * TypeArray
Metadata MDString MDString * LinkageName
unsigned Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata * RetainedTypes
LLVMContextImpl *const pImpl
An imported module (C++ using directive or similar).
TypedDINodeRef< DIScope > DIScopeRef
StringRef getString() const
static const char * getFlagString(unsigned Flag)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Metadata MDString MDString * LinkageName
Metadata MDString MDString Metadata unsigned Metadata bool bool unsigned Metadata * ContainingType
A (clang) module that has been imported by the compile unit.
unsigned Metadata MDString bool MDString unsigned MDString unsigned Metadata * EnumTypes
Generic tagged DWARF-like metadata node.
Metadata MDString MDString Metadata unsigned Metadata bool bool unsigned Metadata unsigned unsigned unsigned bool Metadata * Function
static unsigned getFlag(StringRef Flag)
Type array for a subprogram.
static unsigned splitFlags(unsigned Flags, SmallVectorImpl< unsigned > &SplitFlags)
Split up a flags bitfield.
DenseMap< std::pair< const char *, unsigned >, unsigned > DiscriminatorTable
DiscriminatorTable - This table maps file:line locations to an integer representing the next DWARF pa...
Metadata MDString MDString Metadata * File
unsigned Metadata MDString Metadata * File
Metadata MDString MDString MDString * IncludePath
LLVMContext & getContext() const
unsigned MDString Metadata unsigned Metadata * Scope
bool isBitPiece() const
Return whether this is a piece of an aggregate variable.
LLVM Value Representation.
Metadata MDString MDString Metadata unsigned Metadata * Type
uint64_t getBitPieceSize() const
Return the size of this piece in bits.
unsigned Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata * Subprograms
uint64_t getBitPieceOffset() const
Return the offset of this piece in bits.
uint64_t getOp() const
Get the operand code.
unsigned Metadata MDString * Name
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
unsigned MDString Metadata * File
unsigned Metadata MDString bool MDString unsigned MDString unsigned Metadata Metadata Metadata Metadata * GlobalVariables
bool empty() const
empty - Check if the string is empty.
Basic type, like 'int' or 'float'.