aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/include/llvm/IR/DebugInfoMetadata.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/llvm/include/llvm/IR/DebugInfoMetadata.h')
-rw-r--r--contrib/llvm-project/llvm/include/llvm/IR/DebugInfoMetadata.h238
1 files changed, 211 insertions, 27 deletions
diff --git a/contrib/llvm-project/llvm/include/llvm/IR/DebugInfoMetadata.h b/contrib/llvm-project/llvm/include/llvm/IR/DebugInfoMetadata.h
index 7d7cc4de7937..22dd5ee6efac 100644
--- a/contrib/llvm-project/llvm/include/llvm/IR/DebugInfoMetadata.h
+++ b/contrib/llvm-project/llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -182,6 +182,7 @@ public:
case DISubrangeKind:
case DIEnumeratorKind:
case DIBasicTypeKind:
+ case DIStringTypeKind:
case DIDerivedTypeKind:
case DICompositeTypeKind:
case DISubroutineTypeKind:
@@ -200,6 +201,7 @@ public:
case DIObjCPropertyKind:
case DIImportedEntityKind:
case DIModuleKind:
+ case DIGenericSubrangeKind:
return true;
}
}
@@ -238,9 +240,8 @@ class GenericDINode : public DINode {
StorageType Storage, bool ShouldCreate = true);
TempGenericDINode cloneImpl() const {
- return getTemporary(
- getContext(), getTag(), getHeader(),
- SmallVector<Metadata *, 4>(dwarf_op_begin(), dwarf_op_end()));
+ return getTemporary(getContext(), getTag(), getHeader(),
+ SmallVector<Metadata *, 4>(dwarf_operands()));
}
public:
@@ -350,6 +351,52 @@ public:
}
};
+class DIGenericSubrange : public DINode {
+ friend class LLVMContextImpl;
+ friend class MDNode;
+
+ DIGenericSubrange(LLVMContext &C, StorageType Storage,
+ ArrayRef<Metadata *> Ops)
+ : DINode(C, DIGenericSubrangeKind, Storage,
+ dwarf::DW_TAG_generic_subrange, Ops) {}
+
+ ~DIGenericSubrange() = default;
+
+ static DIGenericSubrange *getImpl(LLVMContext &Context, Metadata *CountNode,
+ Metadata *LowerBound, Metadata *UpperBound,
+ Metadata *Stride, StorageType Storage,
+ bool ShouldCreate = true);
+
+ TempDIGenericSubrange cloneImpl() const {
+ return getTemporary(getContext(), getRawCountNode(), getRawLowerBound(),
+ getRawUpperBound(), getRawStride());
+ }
+
+public:
+ DEFINE_MDNODE_GET(DIGenericSubrange,
+ (Metadata * CountNode, Metadata *LowerBound,
+ Metadata *UpperBound, Metadata *Stride),
+ (CountNode, LowerBound, UpperBound, Stride))
+
+ TempDIGenericSubrange clone() const { return cloneImpl(); }
+
+ Metadata *getRawCountNode() const { return getOperand(0).get(); }
+ Metadata *getRawLowerBound() const { return getOperand(1).get(); }
+ Metadata *getRawUpperBound() const { return getOperand(2).get(); }
+ Metadata *getRawStride() const { return getOperand(3).get(); }
+
+ using BoundType = PointerUnion<DIVariable *, DIExpression *>;
+
+ BoundType getCount() const;
+ BoundType getLowerBound() const;
+ BoundType getUpperBound() const;
+ BoundType getStride() const;
+
+ static bool classof(const Metadata *MD) {
+ return MD->getMetadataID() == DIGenericSubrangeKind;
+ }
+};
+
/// Enumeration value.
///
/// TODO: Add a pointer to the context (DW_TAG_enumeration_type) once that no
@@ -451,6 +498,7 @@ public:
default:
return false;
case DIBasicTypeKind:
+ case DIStringTypeKind:
case DIDerivedTypeKind:
case DICompositeTypeKind:
case DISubroutineTypeKind:
@@ -697,6 +745,7 @@ public:
default:
return false;
case DIBasicTypeKind:
+ case DIStringTypeKind:
case DIDerivedTypeKind:
case DICompositeTypeKind:
case DISubroutineTypeKind:
@@ -747,6 +796,12 @@ public:
DEFINE_MDNODE_GET(DIBasicType, (unsigned Tag, StringRef Name),
(Tag, Name, 0, 0, 0, FlagZero))
DEFINE_MDNODE_GET(DIBasicType,
+ (unsigned Tag, StringRef Name, uint64_t SizeInBits),
+ (Tag, Name, SizeInBits, 0, 0, FlagZero))
+ DEFINE_MDNODE_GET(DIBasicType,
+ (unsigned Tag, MDString *Name, uint64_t SizeInBits),
+ (Tag, Name, SizeInBits, 0, 0, FlagZero))
+ DEFINE_MDNODE_GET(DIBasicType,
(unsigned Tag, StringRef Name, uint64_t SizeInBits,
uint32_t AlignInBits, unsigned Encoding, DIFlags Flags),
(Tag, Name, SizeInBits, AlignInBits, Encoding, Flags))
@@ -770,6 +825,81 @@ public:
}
};
+/// String type, Fortran CHARACTER(n)
+class DIStringType : public DIType {
+ friend class LLVMContextImpl;
+ friend class MDNode;
+
+ unsigned Encoding;
+
+ DIStringType(LLVMContext &C, StorageType Storage, unsigned Tag,
+ uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding,
+ ArrayRef<Metadata *> Ops)
+ : DIType(C, DIStringTypeKind, Storage, Tag, 0, SizeInBits, AlignInBits, 0,
+ FlagZero, Ops),
+ Encoding(Encoding) {}
+ ~DIStringType() = default;
+
+ static DIStringType *getImpl(LLVMContext &Context, unsigned Tag,
+ StringRef Name, Metadata *StringLength,
+ Metadata *StrLenExp, uint64_t SizeInBits,
+ uint32_t AlignInBits, unsigned Encoding,
+ StorageType Storage, bool ShouldCreate = true) {
+ return getImpl(Context, Tag, getCanonicalMDString(Context, Name),
+ StringLength, StrLenExp, SizeInBits, AlignInBits, Encoding,
+ Storage, ShouldCreate);
+ }
+ static DIStringType *getImpl(LLVMContext &Context, unsigned Tag,
+ MDString *Name, Metadata *StringLength,
+ Metadata *StrLenExp, uint64_t SizeInBits,
+ uint32_t AlignInBits, unsigned Encoding,
+ StorageType Storage, bool ShouldCreate = true);
+
+ TempDIStringType cloneImpl() const {
+ return getTemporary(getContext(), getTag(), getRawName(),
+ getRawStringLength(), getRawStringLengthExp(),
+ getSizeInBits(), getAlignInBits(), getEncoding());
+ }
+
+public:
+ DEFINE_MDNODE_GET(DIStringType,
+ (unsigned Tag, StringRef Name, uint64_t SizeInBits,
+ uint32_t AlignInBits),
+ (Tag, Name, nullptr, nullptr, SizeInBits, AlignInBits, 0))
+ DEFINE_MDNODE_GET(DIStringType,
+ (unsigned Tag, MDString *Name, Metadata *StringLength,
+ Metadata *StringLengthExp, uint64_t SizeInBits,
+ uint32_t AlignInBits, unsigned Encoding),
+ (Tag, Name, StringLength, StringLengthExp, SizeInBits,
+ AlignInBits, Encoding))
+ DEFINE_MDNODE_GET(DIStringType,
+ (unsigned Tag, StringRef Name, Metadata *StringLength,
+ Metadata *StringLengthExp, uint64_t SizeInBits,
+ uint32_t AlignInBits, unsigned Encoding),
+ (Tag, Name, StringLength, StringLengthExp, SizeInBits,
+ AlignInBits, Encoding))
+
+ TempDIStringType clone() const { return cloneImpl(); }
+
+ static bool classof(const Metadata *MD) {
+ return MD->getMetadataID() == DIStringTypeKind;
+ }
+
+ DIVariable *getStringLength() const {
+ return cast_or_null<DIVariable>(getRawStringLength());
+ }
+
+ DIExpression *getStringLengthExp() const {
+ return cast_or_null<DIExpression>(getRawStringLengthExp());
+ }
+
+ unsigned getEncoding() const { return Encoding; }
+
+ Metadata *getRawStringLength() const { return getOperand(3); }
+
+ Metadata *getRawStringLengthExp() const { return getOperand(4); }
+};
+
/// Derived types.
///
/// This includes qualified types, pointers, references, friends, typedefs, and
@@ -942,13 +1072,14 @@ class DICompositeType : public DIType {
DINodeArray Elements, unsigned RuntimeLang, DIType *VTableHolder,
DITemplateParameterArray TemplateParams, StringRef Identifier,
DIDerivedType *Discriminator, Metadata *DataLocation,
+ Metadata *Associated, Metadata *Allocated, Metadata *Rank,
StorageType Storage, bool ShouldCreate = true) {
- return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
- Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits,
- Flags, Elements.get(), RuntimeLang, VTableHolder,
- TemplateParams.get(),
- getCanonicalMDString(Context, Identifier), Discriminator,
- DataLocation, Storage, ShouldCreate);
+ return getImpl(
+ Context, Tag, getCanonicalMDString(Context, Name), File, Line, Scope,
+ BaseType, SizeInBits, AlignInBits, OffsetInBits, Flags, Elements.get(),
+ RuntimeLang, VTableHolder, TemplateParams.get(),
+ getCanonicalMDString(Context, Identifier), Discriminator, DataLocation,
+ Associated, Allocated, Rank, Storage, ShouldCreate);
}
static DICompositeType *
getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
@@ -957,6 +1088,7 @@ class DICompositeType : public DIType {
DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
Metadata *VTableHolder, Metadata *TemplateParams,
MDString *Identifier, Metadata *Discriminator, Metadata *DataLocation,
+ Metadata *Associated, Metadata *Allocated, Metadata *Rank,
StorageType Storage, bool ShouldCreate = true);
TempDICompositeType cloneImpl() const {
@@ -965,7 +1097,8 @@ class DICompositeType : public DIType {
getAlignInBits(), getOffsetInBits(), getFlags(),
getElements(), getRuntimeLang(), getVTableHolder(),
getTemplateParams(), getIdentifier(),
- getDiscriminator(), getRawDataLocation());
+ getDiscriminator(), getRawDataLocation(),
+ getRawAssociated(), getRawAllocated(), getRawRank());
}
public:
@@ -977,10 +1110,11 @@ public:
DINodeArray Elements, unsigned RuntimeLang, DIType *VTableHolder,
DITemplateParameterArray TemplateParams = nullptr,
StringRef Identifier = "", DIDerivedType *Discriminator = nullptr,
- Metadata *DataLocation = nullptr),
+ Metadata *DataLocation = nullptr, Metadata *Associated = nullptr,
+ Metadata *Allocated = nullptr, Metadata *Rank = nullptr),
(Tag, Name, File, Line, Scope, BaseType, SizeInBits, AlignInBits,
OffsetInBits, Flags, Elements, RuntimeLang, VTableHolder, TemplateParams,
- Identifier, Discriminator, DataLocation))
+ Identifier, Discriminator, DataLocation, Associated, Allocated, Rank))
DEFINE_MDNODE_GET(
DICompositeType,
(unsigned Tag, MDString *Name, Metadata *File, unsigned Line,
@@ -988,10 +1122,12 @@ public:
uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags,
Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder,
Metadata *TemplateParams = nullptr, MDString *Identifier = nullptr,
- Metadata *Discriminator = nullptr, Metadata *DataLocation = nullptr),
+ Metadata *Discriminator = nullptr, Metadata *DataLocation = nullptr,
+ Metadata *Associated = nullptr, Metadata *Allocated = nullptr,
+ Metadata *Rank = nullptr),
(Tag, Name, File, Line, Scope, BaseType, SizeInBits, AlignInBits,
OffsetInBits, Flags, Elements, RuntimeLang, VTableHolder, TemplateParams,
- Identifier, Discriminator, DataLocation))
+ Identifier, Discriminator, DataLocation, Associated, Allocated, Rank))
TempDICompositeType clone() const { return cloneImpl(); }
@@ -1009,7 +1145,8 @@ public:
uint64_t OffsetInBits, DIFlags Flags, Metadata *Elements,
unsigned RuntimeLang, Metadata *VTableHolder,
Metadata *TemplateParams, Metadata *Discriminator,
- Metadata *DataLocation);
+ Metadata *DataLocation, Metadata *Associated, Metadata *Allocated,
+ Metadata *Rank);
static DICompositeType *getODRTypeIfExists(LLVMContext &Context,
MDString &Identifier);
@@ -1029,7 +1166,8 @@ public:
uint64_t OffsetInBits, DIFlags Flags, Metadata *Elements,
unsigned RuntimeLang, Metadata *VTableHolder,
Metadata *TemplateParams, Metadata *Discriminator,
- Metadata *DataLocation);
+ Metadata *DataLocation, Metadata *Associated,
+ Metadata *Allocated, Metadata *Rank);
DIType *getBaseType() const { return cast_or_null<DIType>(getRawBaseType()); }
DINodeArray getElements() const {
@@ -1058,6 +1196,29 @@ public:
DIExpression *getDataLocationExp() const {
return dyn_cast_or_null<DIExpression>(getRawDataLocation());
}
+ Metadata *getRawAssociated() const { return getOperand(10); }
+ DIVariable *getAssociated() const {
+ return dyn_cast_or_null<DIVariable>(getRawAssociated());
+ }
+ DIExpression *getAssociatedExp() const {
+ return dyn_cast_or_null<DIExpression>(getRawAssociated());
+ }
+ Metadata *getRawAllocated() const { return getOperand(11); }
+ DIVariable *getAllocated() const {
+ return dyn_cast_or_null<DIVariable>(getRawAllocated());
+ }
+ DIExpression *getAllocatedExp() const {
+ return dyn_cast_or_null<DIExpression>(getRawAllocated());
+ }
+ Metadata *getRawRank() const { return getOperand(12); }
+ ConstantInt *getRankConst() const {
+ if (auto *MD = dyn_cast_or_null<ConstantAsMetadata>(getRawRank()))
+ return dyn_cast_or_null<ConstantInt>(MD->getValue());
+ return nullptr;
+ }
+ DIExpression *getRankExp() const {
+ return dyn_cast_or_null<DIExpression>(getRawRank());
+ }
/// Replace operands.
///
@@ -1536,6 +1697,18 @@ public:
inline unsigned getDiscriminator() const;
+ // For the regular discriminator, it stands for all empty components if all
+ // the lowest 3 bits are non-zero and all higher 29 bits are unused(zero by
+ // default). Here we fully leverage the higher 29 bits for pseudo probe use.
+ // This is the format:
+ // [2:0] - 0x7
+ // [31:3] - pseudo probe fields guaranteed to be non-zero as a whole
+ // So if the lower 3 bits is non-zero and the others has at least one
+ // non-zero bit, it guarantees to be a pseudo probe discriminator
+ inline static bool isPseudoProbeDiscriminator(unsigned Discriminator) {
+ return ((Discriminator & 0x7) == 0x7) && (Discriminator & 0xFFFFFFF8);
+ }
+
/// Returns a new DILocation with updated \p Discriminator.
inline const DILocation *cloneWithDiscriminator(unsigned Discriminator) const;
@@ -1879,6 +2052,10 @@ public:
return getNumOperands() > 10 ? getOperandAs<Metadata>(10) : nullptr;
}
+ void replaceRawLinkageName(MDString *LinkageName) {
+ replaceOperandWith(3, LinkageName);
+ }
+
/// Check if this subprogram describes the given function.
///
/// FIXME: Should this be looking through bitcasts?
@@ -2123,49 +2300,52 @@ class DIModule : public DIScope {
friend class LLVMContextImpl;
friend class MDNode;
unsigned LineNo;
+ bool IsDecl;
DIModule(LLVMContext &Context, StorageType Storage, unsigned LineNo,
- ArrayRef<Metadata *> Ops)
+ bool IsDecl, ArrayRef<Metadata *> Ops)
: DIScope(Context, DIModuleKind, Storage, dwarf::DW_TAG_module, Ops),
- LineNo(LineNo) {}
+ LineNo(LineNo), IsDecl(IsDecl) {}
~DIModule() = default;
static DIModule *getImpl(LLVMContext &Context, DIFile *File, DIScope *Scope,
StringRef Name, StringRef ConfigurationMacros,
StringRef IncludePath, StringRef APINotesFile,
- unsigned LineNo, StorageType Storage,
+ unsigned LineNo, bool IsDecl, StorageType Storage,
bool ShouldCreate = true) {
return getImpl(Context, File, Scope, getCanonicalMDString(Context, Name),
getCanonicalMDString(Context, ConfigurationMacros),
getCanonicalMDString(Context, IncludePath),
- getCanonicalMDString(Context, APINotesFile), LineNo, Storage,
- ShouldCreate);
+ getCanonicalMDString(Context, APINotesFile), LineNo, IsDecl,
+ Storage, ShouldCreate);
}
static DIModule *getImpl(LLVMContext &Context, Metadata *File,
Metadata *Scope, MDString *Name,
MDString *ConfigurationMacros, MDString *IncludePath,
- MDString *APINotesFile, unsigned LineNo,
+ MDString *APINotesFile, unsigned LineNo, bool IsDecl,
StorageType Storage, bool ShouldCreate = true);
TempDIModule cloneImpl() const {
return getTemporary(getContext(), getFile(), getScope(), getName(),
getConfigurationMacros(), getIncludePath(),
- getAPINotesFile(), getLineNo());
+ getAPINotesFile(), getLineNo(), getIsDecl());
}
public:
DEFINE_MDNODE_GET(DIModule,
(DIFile * File, DIScope *Scope, StringRef Name,
StringRef ConfigurationMacros, StringRef IncludePath,
- StringRef APINotesFile, unsigned LineNo),
+ StringRef APINotesFile, unsigned LineNo,
+ bool IsDecl = false),
(File, Scope, Name, ConfigurationMacros, IncludePath,
- APINotesFile, LineNo))
+ APINotesFile, LineNo, IsDecl))
DEFINE_MDNODE_GET(DIModule,
(Metadata * File, Metadata *Scope, MDString *Name,
MDString *ConfigurationMacros, MDString *IncludePath,
- MDString *APINotesFile, unsigned LineNo),
+ MDString *APINotesFile, unsigned LineNo,
+ bool IsDecl = false),
(File, Scope, Name, ConfigurationMacros, IncludePath,
- APINotesFile, LineNo))
+ APINotesFile, LineNo, IsDecl))
TempDIModule clone() const { return cloneImpl(); }
@@ -2175,6 +2355,7 @@ public:
StringRef getIncludePath() const { return getStringOperand(4); }
StringRef getAPINotesFile() const { return getStringOperand(5); }
unsigned getLineNo() const { return LineNo; }
+ bool getIsDecl() const { return IsDecl; }
Metadata *getRawScope() const { return getOperand(1); }
MDString *getRawName() const { return getOperandAs<MDString>(2); }
@@ -2409,6 +2590,9 @@ public:
/// Determine whether this represents a standalone constant value.
bool isConstant() const;
+ /// Determine whether this represents a standalone signed constant value.
+ bool isSignedConstant() const;
+
using element_iterator = ArrayRef<uint64_t>::iterator;
element_iterator elements_begin() const { return getElements().begin(); }