[DebugInfo] run clang-format on some unformatted files

This trivial patch runs clang-format on some unformatted files before
doing logic changes and prevent hard to review diffs.

Differential Revision: https://reviews.llvm.org/D113572
This commit is contained in:
Luís Ferreira 2021-11-11 13:39:50 -08:00 committed by Paul Robinson
parent 87687b4ff7
commit 665b4138d9
5 changed files with 351 additions and 351 deletions

View File

@ -256,11 +256,13 @@ class GenericDINode : public DINode {
public: public:
unsigned getHash() const { return SubclassData32; } unsigned getHash() const { return SubclassData32; }
DEFINE_MDNODE_GET(GenericDINode, (unsigned Tag, StringRef Header, DEFINE_MDNODE_GET(GenericDINode,
ArrayRef<Metadata *> DwarfOps), (unsigned Tag, StringRef Header,
ArrayRef<Metadata *> DwarfOps),
(Tag, Header, DwarfOps)) (Tag, Header, DwarfOps))
DEFINE_MDNODE_GET(GenericDINode, (unsigned Tag, MDString *Header, DEFINE_MDNODE_GET(GenericDINode,
ArrayRef<Metadata *> DwarfOps), (unsigned Tag, MDString *Header,
ArrayRef<Metadata *> DwarfOps),
(Tag, Header, DwarfOps)) (Tag, Header, DwarfOps))
/// Return a (temporary) clone of this. /// Return a (temporary) clone of this.
@ -324,7 +326,7 @@ public:
DEFINE_MDNODE_GET(DISubrange, (int64_t Count, int64_t LowerBound = 0), DEFINE_MDNODE_GET(DISubrange, (int64_t Count, int64_t LowerBound = 0),
(Count, LowerBound)) (Count, LowerBound))
DEFINE_MDNODE_GET(DISubrange, (Metadata *CountNode, int64_t LowerBound = 0), DEFINE_MDNODE_GET(DISubrange, (Metadata * CountNode, int64_t LowerBound = 0),
(CountNode, LowerBound)) (CountNode, LowerBound))
DEFINE_MDNODE_GET(DISubrange, DEFINE_MDNODE_GET(DISubrange,
@ -334,9 +336,7 @@ public:
TempDISubrange clone() const { return cloneImpl(); } TempDISubrange clone() const { return cloneImpl(); }
Metadata *getRawCountNode() const { Metadata *getRawCountNode() const { return getOperand(0).get(); }
return getOperand(0).get();
}
Metadata *getRawLowerBound() const { return getOperand(1).get(); } Metadata *getRawLowerBound() const { return getOperand(1).get(); }
@ -548,14 +548,13 @@ public:
}; };
/// A single checksum, represented by a \a Kind and a \a Value (a string). /// A single checksum, represented by a \a Kind and a \a Value (a string).
template <typename T> template <typename T> struct ChecksumInfo {
struct ChecksumInfo {
/// The kind of checksum which \a Value encodes. /// The kind of checksum which \a Value encodes.
ChecksumKind Kind; ChecksumKind Kind;
/// The string value of the checksum. /// The string value of the checksum.
T Value; T Value;
ChecksumInfo(ChecksumKind Kind, T Value) : Kind(Kind), Value(Value) { } ChecksumInfo(ChecksumKind Kind, T Value) : Kind(Kind), Value(Value) {}
~ChecksumInfo() = default; ~ChecksumInfo() = default;
bool operator==(const ChecksumInfo<T> &X) const { bool operator==(const ChecksumInfo<T> &X) const {
return Kind == X.Kind && Value == X.Value; return Kind == X.Kind && Value == X.Value;
@ -578,15 +577,17 @@ private:
static DIFile *getImpl(LLVMContext &Context, StringRef Filename, static DIFile *getImpl(LLVMContext &Context, StringRef Filename,
StringRef Directory, StringRef Directory,
Optional<ChecksumInfo<StringRef>> CS, Optional<ChecksumInfo<StringRef>> CS,
Optional<StringRef> Source, Optional<StringRef> Source, StorageType Storage,
StorageType Storage, bool ShouldCreate = true) { bool ShouldCreate = true) {
Optional<ChecksumInfo<MDString *>> MDChecksum; Optional<ChecksumInfo<MDString *>> MDChecksum;
if (CS) if (CS)
MDChecksum.emplace(CS->Kind, getCanonicalMDString(Context, CS->Value)); MDChecksum.emplace(CS->Kind, getCanonicalMDString(Context, CS->Value));
return getImpl(Context, getCanonicalMDString(Context, Filename), return getImpl(
getCanonicalMDString(Context, Directory), MDChecksum, Context, getCanonicalMDString(Context, Filename),
Source ? Optional<MDString *>(getCanonicalMDString(Context, *Source)) : None, getCanonicalMDString(Context, Directory), MDChecksum,
Storage, ShouldCreate); Source ? Optional<MDString *>(getCanonicalMDString(Context, *Source))
: None,
Storage, ShouldCreate);
} }
static DIFile *getImpl(LLVMContext &Context, MDString *Filename, static DIFile *getImpl(LLVMContext &Context, MDString *Filename,
MDString *Directory, MDString *Directory,
@ -600,13 +601,15 @@ private:
} }
public: public:
DEFINE_MDNODE_GET(DIFile, (StringRef Filename, StringRef Directory, DEFINE_MDNODE_GET(DIFile,
Optional<ChecksumInfo<StringRef>> CS = None, (StringRef Filename, StringRef Directory,
Optional<StringRef> Source = None), Optional<ChecksumInfo<StringRef>> CS = None,
Optional<StringRef> Source = None),
(Filename, Directory, CS, Source)) (Filename, Directory, CS, Source))
DEFINE_MDNODE_GET(DIFile, (MDString * Filename, MDString *Directory, DEFINE_MDNODE_GET(DIFile,
Optional<ChecksumInfo<MDString *>> CS = None, (MDString * Filename, MDString *Directory,
Optional<MDString *> Source = None), Optional<ChecksumInfo<MDString *>> CS = None,
Optional<MDString *> Source = None),
(Filename, Directory, CS, Source)) (Filename, Directory, CS, Source))
TempDIFile clone() const { return cloneImpl(); } TempDIFile clone() const { return cloneImpl(); }
@ -707,7 +710,6 @@ public:
DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); } DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
StringRef getName() const { return getStringOperand(2); } StringRef getName() const { return getStringOperand(2); }
Metadata *getRawScope() const { return getOperand(1); } Metadata *getRawScope() const { return getOperand(1); }
MDString *getRawName() const { return getOperandAs<MDString>(2); } MDString *getRawName() const { return getOperandAs<MDString>(2); }
@ -959,17 +961,15 @@ class DIDerivedType : public DIType {
} }
public: public:
DEFINE_MDNODE_GET(DIDerivedType, DEFINE_MDNODE_GET(
(unsigned Tag, MDString *Name, Metadata *File, DIDerivedType,
unsigned Line, Metadata *Scope, Metadata *BaseType, (unsigned Tag, MDString *Name, Metadata *File, unsigned Line,
uint64_t SizeInBits, uint32_t AlignInBits, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
uint64_t OffsetInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
Optional<unsigned> DWARFAddressSpace, DIFlags Flags, Optional<unsigned> DWARFAddressSpace, DIFlags Flags,
Metadata *ExtraData = nullptr, Metadata *ExtraData = nullptr, Metadata *Annotations = nullptr),
Metadata *Annotations = nullptr), (Tag, Name, File, Line, Scope, BaseType, SizeInBits, AlignInBits,
(Tag, Name, File, Line, Scope, BaseType, SizeInBits, OffsetInBits, DWARFAddressSpace, Flags, ExtraData, Annotations))
AlignInBits, OffsetInBits, DWARFAddressSpace, Flags,
ExtraData, Annotations))
DEFINE_MDNODE_GET(DIDerivedType, DEFINE_MDNODE_GET(DIDerivedType,
(unsigned Tag, StringRef Name, DIFile *File, unsigned Line, (unsigned Tag, StringRef Name, DIFile *File, unsigned Line,
DIScope *Scope, DIType *BaseType, uint64_t SizeInBits, DIScope *Scope, DIType *BaseType, uint64_t SizeInBits,
@ -1074,8 +1074,8 @@ class DICompositeType : public DIType {
/// Change fields in place. /// Change fields in place.
void mutate(unsigned Tag, unsigned Line, unsigned RuntimeLang, void mutate(unsigned Tag, unsigned Line, unsigned RuntimeLang,
uint64_t SizeInBits, uint32_t AlignInBits, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
uint64_t OffsetInBits, DIFlags Flags) { DIFlags Flags) {
assert(isDistinct() && "Only distinct nodes can mutate"); assert(isDistinct() && "Only distinct nodes can mutate");
assert(getRawIdentifier() && "Only ODR-uniqued nodes should mutate"); assert(getRawIdentifier() && "Only ODR-uniqued nodes should mutate");
this->RuntimeLang = RuntimeLang; this->RuntimeLang = RuntimeLang;
@ -1209,7 +1209,9 @@ public:
Metadata *getRawTemplateParams() const { return getOperand(6); } Metadata *getRawTemplateParams() const { return getOperand(6); }
MDString *getRawIdentifier() const { return getOperandAs<MDString>(7); } MDString *getRawIdentifier() const { return getOperandAs<MDString>(7); }
Metadata *getRawDiscriminator() const { return getOperand(8); } Metadata *getRawDiscriminator() const { return getOperand(8); }
DIDerivedType *getDiscriminator() const { return getOperandAs<DIDerivedType>(8); } DIDerivedType *getDiscriminator() const {
return getOperandAs<DIDerivedType>(8);
}
Metadata *getRawDataLocation() const { return getOperand(9); } Metadata *getRawDataLocation() const { return getOperand(9); }
DIVariable *getDataLocation() const { DIVariable *getDataLocation() const {
return dyn_cast_or_null<DIVariable>(getRawDataLocation()); return dyn_cast_or_null<DIVariable>(getRawDataLocation());
@ -1525,9 +1527,7 @@ public:
void replaceEnumTypes(DICompositeTypeArray N) { void replaceEnumTypes(DICompositeTypeArray N) {
replaceOperandWith(4, N.get()); replaceOperandWith(4, N.get());
} }
void replaceRetainedTypes(DITypeArray N) { void replaceRetainedTypes(DITypeArray N) { replaceOperandWith(5, N.get()); }
replaceOperandWith(5, N.get());
}
void replaceGlobalVariables(DIGlobalVariableExpressionArray N) { void replaceGlobalVariables(DIGlobalVariableExpressionArray N) {
replaceOperandWith(6, N.get()); replaceOperandWith(6, N.get());
} }
@ -1709,7 +1709,8 @@ public:
/// base discriminator is set in the new DILocation, the other encoded values /// base discriminator is set in the new DILocation, the other encoded values
/// are elided. /// are elided.
/// If the discriminator cannot be encoded, the function returns None. /// If the discriminator cannot be encoded, the function returns None.
inline Optional<const DILocation *> cloneWithBaseDiscriminator(unsigned BD) const; inline Optional<const DILocation *>
cloneWithBaseDiscriminator(unsigned BD) const;
/// Returns the duplication factor stored in the discriminator, or 1 if no /// Returns the duplication factor stored in the discriminator, or 1 if no
/// duplication factor (or 0) is encoded. /// duplication factor (or 0) is encoded.
@ -1725,7 +1726,8 @@ public:
/// duplication factor encoded in the discriminator. The current duplication /// duplication factor encoded in the discriminator. The current duplication
/// factor is as defined by getDuplicationFactor(). /// factor is as defined by getDuplicationFactor().
/// Returns None if encoding failed. /// Returns None if encoding failed.
inline Optional<const DILocation *> cloneByMultiplyingDuplicationFactor(unsigned DF) const; inline Optional<const DILocation *>
cloneByMultiplyingDuplicationFactor(unsigned DF) const;
/// When two instructions are combined into a single instruction we also /// When two instructions are combined into a single instruction we also
/// need to combine the original locations into a single location. /// need to combine the original locations into a single location.
@ -1748,8 +1750,8 @@ public:
/// This function applies getMergedLocation() repeatedly left-to-right. /// This function applies getMergedLocation() repeatedly left-to-right.
/// ///
/// \p Locs: The locations to be merged. /// \p Locs: The locations to be merged.
static static const DILocation *
const DILocation *getMergedLocations(ArrayRef<const DILocation *> Locs); getMergedLocations(ArrayRef<const DILocation *> Locs);
/// Return the masked discriminator value for an input discrimnator value D /// Return the masked discriminator value for an input discrimnator value D
/// (i.e. zero out the (B+1)-th and above bits for D (B is 0-base). /// (i.e. zero out the (B+1)-th and above bits for D (B is 0-base).
@ -1773,13 +1775,18 @@ public:
/// Raw encoding of the discriminator. APIs such as cloneWithDuplicationFactor /// Raw encoding of the discriminator. APIs such as cloneWithDuplicationFactor
/// have certain special case behavior (e.g. treating empty duplication factor /// have certain special case behavior (e.g. treating empty duplication factor
/// as the value '1'). /// as the value '1').
/// This API, in conjunction with cloneWithDiscriminator, may be used to encode /// This API, in conjunction with cloneWithDiscriminator, may be used to
/// the raw values provided. \p BD: base discriminator \p DF: duplication factor /// encode the raw values provided.
///
/// \p BD: base discriminator
/// \p DF: duplication factor
/// \p CI: copy index /// \p CI: copy index
///
/// The return is None if the values cannot be encoded in 32 bits - for /// The return is None if the values cannot be encoded in 32 bits - for
/// example, values for BD or DF larger than 12 bits. Otherwise, the return /// example, values for BD or DF larger than 12 bits. Otherwise, the return is
/// is the encoded value. /// the encoded value.
static Optional<unsigned> encodeDiscriminator(unsigned BD, unsigned DF, unsigned CI); static Optional<unsigned> encodeDiscriminator(unsigned BD, unsigned DF,
unsigned CI);
/// Raw decoder for values in an encoded discriminator D. /// Raw decoder for values in an encoded discriminator D.
static void decodeDiscriminator(unsigned D, unsigned &BD, unsigned &DF, static void decodeDiscriminator(unsigned D, unsigned &BD, unsigned &DF,
@ -1799,11 +1806,10 @@ public:
/// Returns the copy identifier for a given encoded discriminator \p D. /// Returns the copy identifier for a given encoded discriminator \p D.
static unsigned getCopyIdentifierFromDiscriminator(unsigned D) { static unsigned getCopyIdentifierFromDiscriminator(unsigned D) {
return getUnsignedFromPrefixEncoding(getNextComponentInDiscriminator( return getUnsignedFromPrefixEncoding(
getNextComponentInDiscriminator(D))); getNextComponentInDiscriminator(getNextComponentInDiscriminator(D)));
} }
Metadata *getRawScope() const { return getOperand(0); } Metadata *getRawScope() const { return getOperand(0); }
Metadata *getRawInlinedAt() const { Metadata *getRawInlinedAt() const {
if (getNumOperands() == 2) if (getNumOperands() == 2)
@ -1857,10 +1863,10 @@ public:
unsigned Virtuality = SPFlagNonvirtual, unsigned Virtuality = SPFlagNonvirtual,
bool IsMainSubprogram = false) { bool IsMainSubprogram = false) {
// We're assuming virtuality is the low-order field. // We're assuming virtuality is the low-order field.
static_assert( static_assert(int(SPFlagVirtual) == int(dwarf::DW_VIRTUALITY_virtual) &&
int(SPFlagVirtual) == int(dwarf::DW_VIRTUALITY_virtual) && int(SPFlagPureVirtual) ==
int(SPFlagPureVirtual) == int(dwarf::DW_VIRTUALITY_pure_virtual), int(dwarf::DW_VIRTUALITY_pure_virtual),
"Virtuality constant mismatch"); "Virtuality constant mismatch");
return static_cast<DISPFlags>( return static_cast<DISPFlags>(
(Virtuality & SPFlagVirtuality) | (Virtuality & SPFlagVirtuality) |
(IsLocalToUnit ? SPFlagLocalToUnit : SPFlagZero) | (IsLocalToUnit ? SPFlagLocalToUnit : SPFlagZero) |
@ -1901,16 +1907,14 @@ private:
RetainedNodes.get(), ThrownTypes.get(), Annotations.get(), RetainedNodes.get(), ThrownTypes.get(), Annotations.get(),
Storage, ShouldCreate); Storage, ShouldCreate);
} }
static DISubprogram *getImpl(LLVMContext &Context, Metadata *Scope, static DISubprogram *
MDString *Name, MDString *LinkageName, getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
Metadata *File, unsigned Line, Metadata *Type, MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
unsigned ScopeLine, Metadata *ContainingType, unsigned ScopeLine, Metadata *ContainingType, unsigned VirtualIndex,
unsigned VirtualIndex, int ThisAdjustment, int ThisAdjustment, DIFlags Flags, DISPFlags SPFlags, Metadata *Unit,
DIFlags Flags, DISPFlags SPFlags, Metadata *Unit, Metadata *TemplateParams, Metadata *Declaration,
Metadata *TemplateParams, Metadata *Declaration, Metadata *RetainedNodes, Metadata *ThrownTypes, Metadata *Annotations,
Metadata *RetainedNodes, Metadata *ThrownTypes, StorageType Storage, bool ShouldCreate = true);
Metadata *Annotations, StorageType Storage,
bool ShouldCreate = true);
TempDISubprogram cloneImpl() const { TempDISubprogram cloneImpl() const {
return getTemporary(getContext(), getScope(), getName(), getLinkageName(), return getTemporary(getContext(), getScope(), getName(), getLinkageName(),
@ -1963,7 +1967,10 @@ public:
unsigned getVirtualIndex() const { return VirtualIndex; } unsigned getVirtualIndex() const { return VirtualIndex; }
int getThisAdjustment() const { return ThisAdjustment; } int getThisAdjustment() const { return ThisAdjustment; }
unsigned getScopeLine() const { return ScopeLine; } unsigned getScopeLine() const { return ScopeLine; }
void setScopeLine(unsigned L) { assert(isDistinct()); ScopeLine = L; } void setScopeLine(unsigned L) {
assert(isDistinct());
ScopeLine = L;
}
DIFlags getFlags() const { return Flags; } DIFlags getFlags() const { return Flags; }
DISPFlags getSPFlags() const { return SPFlags; } DISPFlags getSPFlags() const { return SPFlags; }
bool isLocalToUnit() const { return getSPFlags() & SPFlagLocalToUnit; } bool isLocalToUnit() const { return getSPFlags() & SPFlagLocalToUnit; }
@ -2139,11 +2146,13 @@ class DILexicalBlock : public DILexicalBlockBase {
} }
public: public:
DEFINE_MDNODE_GET(DILexicalBlock, (DILocalScope * Scope, DIFile *File, DEFINE_MDNODE_GET(DILexicalBlock,
unsigned Line, unsigned Column), (DILocalScope * Scope, DIFile *File, unsigned Line,
unsigned Column),
(Scope, File, Line, Column)) (Scope, File, Line, Column))
DEFINE_MDNODE_GET(DILexicalBlock, (Metadata * Scope, Metadata *File, DEFINE_MDNODE_GET(DILexicalBlock,
unsigned Line, unsigned Column), (Metadata * Scope, Metadata *File, unsigned Line,
unsigned Column),
(Scope, File, Line, Column)) (Scope, File, Line, Column))
TempDILexicalBlock clone() const { return cloneImpl(); } TempDILexicalBlock clone() const { return cloneImpl(); }
@ -2188,8 +2197,9 @@ class DILexicalBlockFile : public DILexicalBlockBase {
} }
public: public:
DEFINE_MDNODE_GET(DILexicalBlockFile, (DILocalScope * Scope, DIFile *File, DEFINE_MDNODE_GET(DILexicalBlockFile,
unsigned Discriminator), (DILocalScope * Scope, DIFile *File,
unsigned Discriminator),
(Scope, File, Discriminator)) (Scope, File, Discriminator))
DEFINE_MDNODE_GET(DILexicalBlockFile, DEFINE_MDNODE_GET(DILexicalBlockFile,
(Metadata * Scope, Metadata *File, unsigned Discriminator), (Metadata * Scope, Metadata *File, unsigned Discriminator),
@ -2303,10 +2313,10 @@ class DINamespace : public DIScope {
public: public:
DEFINE_MDNODE_GET(DINamespace, DEFINE_MDNODE_GET(DINamespace,
(DIScope *Scope, StringRef Name, bool ExportSymbols), (DIScope * Scope, StringRef Name, bool ExportSymbols),
(Scope, Name, ExportSymbols)) (Scope, Name, ExportSymbols))
DEFINE_MDNODE_GET(DINamespace, DEFINE_MDNODE_GET(DINamespace,
(Metadata *Scope, MDString *Name, bool ExportSymbols), (Metadata * Scope, MDString *Name, bool ExportSymbols),
(Scope, Name, ExportSymbols)) (Scope, Name, ExportSymbols))
TempDINamespace clone() const { return cloneImpl(); } TempDINamespace clone() const { return cloneImpl(); }
@ -2455,7 +2465,7 @@ public:
(StringRef Name, DIType *Type, bool IsDefault), (StringRef Name, DIType *Type, bool IsDefault),
(Name, Type, IsDefault)) (Name, Type, IsDefault))
DEFINE_MDNODE_GET(DITemplateTypeParameter, DEFINE_MDNODE_GET(DITemplateTypeParameter,
(MDString *Name, Metadata *Type, bool IsDefault), (MDString * Name, Metadata *Type, bool IsDefault),
(Name, Type, IsDefault)) (Name, Type, IsDefault))
TempDITemplateTypeParameter clone() const { return cloneImpl(); } TempDITemplateTypeParameter clone() const { return cloneImpl(); }
@ -2848,7 +2858,8 @@ public:
/// \param OffsetInBits Offset of the piece in bits. /// \param OffsetInBits Offset of the piece in bits.
/// \param SizeInBits Size of the piece in bits. /// \param SizeInBits Size of the piece in bits.
/// \return Creating a fragment expression may fail if \c Expr /// \return Creating a fragment expression may fail if \c Expr
/// contains arithmetic operations that would be truncated. /// contains arithmetic operations that would be
/// truncated.
static Optional<DIExpression *> static Optional<DIExpression *>
createFragmentExpression(const DIExpression *Expr, unsigned OffsetInBits, createFragmentExpression(const DIExpression *Expr, unsigned OffsetInBits,
unsigned SizeInBits); unsigned SizeInBits);
@ -2987,26 +2998,22 @@ class DIGlobalVariable : public DIVariable {
} }
public: public:
DEFINE_MDNODE_GET(DIGlobalVariable, DEFINE_MDNODE_GET(
(DIScope * Scope, StringRef Name, StringRef LinkageName, DIGlobalVariable,
DIFile *File, unsigned Line, DIType *Type, (DIScope * Scope, StringRef Name, StringRef LinkageName, DIFile *File,
bool IsLocalToUnit, bool IsDefinition, unsigned Line, DIType *Type, bool IsLocalToUnit, bool IsDefinition,
DIDerivedType *StaticDataMemberDeclaration, DIDerivedType *StaticDataMemberDeclaration, MDTuple *TemplateParams,
MDTuple *TemplateParams, uint32_t AlignInBits, uint32_t AlignInBits, DINodeArray Annotations),
DINodeArray Annotations), (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
(Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, StaticDataMemberDeclaration, TemplateParams, AlignInBits, Annotations))
IsDefinition, StaticDataMemberDeclaration, TemplateParams, DEFINE_MDNODE_GET(
AlignInBits, Annotations)) DIGlobalVariable,
DEFINE_MDNODE_GET(DIGlobalVariable, (Metadata * Scope, MDString *Name, MDString *LinkageName, Metadata *File,
(Metadata * Scope, MDString *Name, MDString *LinkageName, unsigned Line, Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
Metadata *File, unsigned Line, Metadata *Type, Metadata *StaticDataMemberDeclaration, Metadata *TemplateParams,
bool IsLocalToUnit, bool IsDefinition, uint32_t AlignInBits, Metadata *Annotations),
Metadata *StaticDataMemberDeclaration, (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
Metadata *TemplateParams, uint32_t AlignInBits, StaticDataMemberDeclaration, TemplateParams, AlignInBits, Annotations))
Metadata *Annotations),
(Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
IsDefinition, StaticDataMemberDeclaration, TemplateParams,
AlignInBits, Annotations))
TempDIGlobalVariable clone() const { return cloneImpl(); } TempDIGlobalVariable clone() const { return cloneImpl(); }
@ -3041,20 +3048,20 @@ class DICommonBlock : public DIScope {
DICommonBlock(LLVMContext &Context, StorageType Storage, unsigned LineNo, DICommonBlock(LLVMContext &Context, StorageType Storage, unsigned LineNo,
ArrayRef<Metadata *> Ops) ArrayRef<Metadata *> Ops)
: DIScope(Context, DICommonBlockKind, Storage, dwarf::DW_TAG_common_block, : DIScope(Context, DICommonBlockKind, Storage, dwarf::DW_TAG_common_block,
Ops), LineNo(LineNo) {} Ops),
LineNo(LineNo) {}
static DICommonBlock *getImpl(LLVMContext &Context, DIScope *Scope, static DICommonBlock *getImpl(LLVMContext &Context, DIScope *Scope,
DIGlobalVariable *Decl, StringRef Name, DIGlobalVariable *Decl, StringRef Name,
DIFile *File, unsigned LineNo, DIFile *File, unsigned LineNo,
StorageType Storage, StorageType Storage, bool ShouldCreate = true) {
bool ShouldCreate = true) {
return getImpl(Context, Scope, Decl, getCanonicalMDString(Context, Name), return getImpl(Context, Scope, Decl, getCanonicalMDString(Context, Name),
File, LineNo, Storage, ShouldCreate); File, LineNo, Storage, ShouldCreate);
} }
static DICommonBlock *getImpl(LLVMContext &Context, Metadata *Scope, static DICommonBlock *getImpl(LLVMContext &Context, Metadata *Scope,
Metadata *Decl, MDString *Name, Metadata *File, Metadata *Decl, MDString *Name, Metadata *File,
unsigned LineNo, unsigned LineNo, StorageType Storage,
StorageType Storage, bool ShouldCreate = true); bool ShouldCreate = true);
TempDICommonBlock cloneImpl() const { TempDICommonBlock cloneImpl() const {
return getTemporary(getContext(), getScope(), getDecl(), getName(), return getTemporary(getContext(), getScope(), getDecl(), getName(),
@ -3063,11 +3070,11 @@ class DICommonBlock : public DIScope {
public: public:
DEFINE_MDNODE_GET(DICommonBlock, DEFINE_MDNODE_GET(DICommonBlock,
(DIScope *Scope, DIGlobalVariable *Decl, StringRef Name, (DIScope * Scope, DIGlobalVariable *Decl, StringRef Name,
DIFile *File, unsigned LineNo), DIFile *File, unsigned LineNo),
(Scope, Decl, Name, File, LineNo)) (Scope, Decl, Name, File, LineNo))
DEFINE_MDNODE_GET(DICommonBlock, DEFINE_MDNODE_GET(DICommonBlock,
(Metadata *Scope, Metadata *Decl, MDString *Name, (Metadata * Scope, Metadata *Decl, MDString *Name,
Metadata *File, unsigned LineNo), Metadata *File, unsigned LineNo),
(Scope, Decl, Name, File, LineNo)) (Scope, Decl, Name, File, LineNo))
@ -3114,16 +3121,18 @@ class DILocalVariable : public DIVariable {
StringRef Name, DIFile *File, unsigned Line, StringRef Name, DIFile *File, unsigned Line,
DIType *Type, unsigned Arg, DIFlags Flags, DIType *Type, unsigned Arg, DIFlags Flags,
uint32_t AlignInBits, DINodeArray Annotations, uint32_t AlignInBits, DINodeArray Annotations,
StorageType Storage, bool ShouldCreate = true) { StorageType Storage,
bool ShouldCreate = true) {
return getImpl(Context, Scope, getCanonicalMDString(Context, Name), File, return getImpl(Context, Scope, getCanonicalMDString(Context, Name), File,
Line, Type, Arg, Flags, AlignInBits, Annotations.get(), Storage, Line, Type, Arg, Flags, AlignInBits, Annotations.get(),
ShouldCreate); Storage, ShouldCreate);
} }
static DILocalVariable *getImpl(LLVMContext &Context, Metadata *Scope, static DILocalVariable *getImpl(LLVMContext &Context, Metadata *Scope,
MDString *Name, Metadata *File, unsigned Line, MDString *Name, Metadata *File, unsigned Line,
Metadata *Type, unsigned Arg, DIFlags Flags, Metadata *Type, unsigned Arg, DIFlags Flags,
uint32_t AlignInBits, Metadata *Annotations, uint32_t AlignInBits, Metadata *Annotations,
StorageType Storage, bool ShouldCreate = true); StorageType Storage,
bool ShouldCreate = true);
TempDILocalVariable cloneImpl() const { TempDILocalVariable cloneImpl() const {
return getTemporary(getContext(), getScope(), getName(), getFile(), return getTemporary(getContext(), getScope(), getName(), getFile(),
@ -3140,8 +3149,8 @@ public:
Annotations)) Annotations))
DEFINE_MDNODE_GET(DILocalVariable, DEFINE_MDNODE_GET(DILocalVariable,
(Metadata * Scope, MDString *Name, Metadata *File, (Metadata * Scope, MDString *Name, Metadata *File,
unsigned Line, Metadata *Type, unsigned Arg, unsigned Line, Metadata *Type, unsigned Arg, DIFlags Flags,
DIFlags Flags, uint32_t AlignInBits, Metadata *Annotations), uint32_t AlignInBits, Metadata *Annotations),
(Scope, Name, File, Line, Type, Arg, Flags, AlignInBits, (Scope, Name, File, Line, Type, Arg, Flags, AlignInBits,
Annotations)) Annotations))
@ -3193,16 +3202,14 @@ class DILabel : public DINode {
: DINode(C, DILabelKind, Storage, dwarf::DW_TAG_label, Ops), Line(Line) {} : DINode(C, DILabelKind, Storage, dwarf::DW_TAG_label, Ops), Line(Line) {}
~DILabel() = default; ~DILabel() = default;
static DILabel *getImpl(LLVMContext &Context, DIScope *Scope, static DILabel *getImpl(LLVMContext &Context, DIScope *Scope, StringRef Name,
StringRef Name, DIFile *File, unsigned Line, DIFile *File, unsigned Line, StorageType Storage,
StorageType Storage,
bool ShouldCreate = true) { bool ShouldCreate = true) {
return getImpl(Context, Scope, getCanonicalMDString(Context, Name), File, return getImpl(Context, Scope, getCanonicalMDString(Context, Name), File,
Line, Storage, ShouldCreate); Line, Storage, ShouldCreate);
} }
static DILabel *getImpl(LLVMContext &Context, Metadata *Scope, static DILabel *getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
MDString *Name, Metadata *File, unsigned Line, Metadata *File, unsigned Line, StorageType Storage,
StorageType Storage,
bool ShouldCreate = true); bool ShouldCreate = true);
TempDILabel cloneImpl() const { TempDILabel cloneImpl() const {
@ -3515,11 +3522,13 @@ class DIMacro : public DIMacroNode {
} }
public: public:
DEFINE_MDNODE_GET(DIMacro, (unsigned MIType, unsigned Line, StringRef Name, DEFINE_MDNODE_GET(DIMacro,
StringRef Value = ""), (unsigned MIType, unsigned Line, StringRef Name,
StringRef Value = ""),
(MIType, Line, Name, Value)) (MIType, Line, Name, Value))
DEFINE_MDNODE_GET(DIMacro, (unsigned MIType, unsigned Line, MDString *Name, DEFINE_MDNODE_GET(DIMacro,
MDString *Value), (unsigned MIType, unsigned Line, MDString *Name,
MDString *Value),
(MIType, Line, Name, Value)) (MIType, Line, Name, Value))
TempDIMacro clone() const { return cloneImpl(); } TempDIMacro clone() const { return cloneImpl(); }
@ -3566,11 +3575,13 @@ class DIMacroFile : public DIMacroNode {
} }
public: public:
DEFINE_MDNODE_GET(DIMacroFile, (unsigned MIType, unsigned Line, DIFile *File, DEFINE_MDNODE_GET(DIMacroFile,
DIMacroNodeArray Elements), (unsigned MIType, unsigned Line, DIFile *File,
DIMacroNodeArray Elements),
(MIType, Line, File, Elements)) (MIType, Line, File, Elements))
DEFINE_MDNODE_GET(DIMacroFile, (unsigned MIType, unsigned Line, DEFINE_MDNODE_GET(DIMacroFile,
Metadata *File, Metadata *Elements), (unsigned MIType, unsigned Line, Metadata *File,
Metadata *Elements),
(MIType, Line, File, Elements)) (MIType, Line, File, Elements))
TempDIMacroFile clone() const { return cloneImpl(); } TempDIMacroFile clone() const { return cloneImpl(); }

View File

@ -362,7 +362,8 @@ class PlaceholderQueue {
public: public:
~PlaceholderQueue() { ~PlaceholderQueue() {
assert(empty() && "PlaceholderQueue hasn't been flushed before being destroyed"); assert(empty() &&
"PlaceholderQueue hasn't been flushed before being destroyed");
} }
bool empty() const { return PHs.empty(); } bool empty() const { return PHs.empty(); }
DistinctMDOperandPlaceholder &getPlaceholderOp(unsigned ID); DistinctMDOperandPlaceholder &getPlaceholderOp(unsigned ID);
@ -603,7 +604,7 @@ class MetadataLoader::MetadataLoaderImpl {
// If the expression is malformed, make sure we don't // If the expression is malformed, make sure we don't
// copy more elements than we should. // copy more elements than we should.
HistoricSize = std::min(SubExpr.size(), HistoricSize); HistoricSize = std::min(SubExpr.size(), HistoricSize);
ArrayRef<uint64_t> Args = SubExpr.slice(1, HistoricSize-1); ArrayRef<uint64_t> Args = SubExpr.slice(1, HistoricSize - 1);
switch (SubExpr.front()) { switch (SubExpr.front()) {
case dwarf::DW_OP_plus: case dwarf::DW_OP_plus:
@ -1408,8 +1409,9 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
return error("Invalid record"); return error("Invalid record");
IsDistinct = Record[0]; IsDistinct = Record[0];
DINode::DIFlags Flags = (Record.size() > 6) ? DINode::DIFlags Flags = (Record.size() > 6)
static_cast<DINode::DIFlags>(Record[6]) : DINode::FlagZero; ? static_cast<DINode::DIFlags>(Record[6])
: DINode::FlagZero;
MetadataList.assignValue( MetadataList.assignValue(
GET_OR_DISTINCT(DIBasicType, GET_OR_DISTINCT(DIBasicType,
@ -1670,9 +1672,9 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
SPFlags |= DISubprogram::SPFlagMainSubprogram; SPFlags |= DISubprogram::SPFlagMainSubprogram;
else if (!HasSPFlags) else if (!HasSPFlags)
SPFlags = DISubprogram::toSPFlags( SPFlags = DISubprogram::toSPFlags(
/*IsLocalToUnit=*/Record[7], /*IsDefinition=*/Record[8], /*IsLocalToUnit=*/Record[7], /*IsDefinition=*/Record[8],
/*IsOptimized=*/Record[14], /*Virtuality=*/Record[11], /*IsOptimized=*/Record[14], /*Virtuality=*/Record[11],
/*DIFlagMainSubprogram*/HasOldMainSubprogramFlag); /*DIFlagMainSubprogram=*/HasOldMainSubprogramFlag);
// All definitions should be distinct. // All definitions should be distinct.
IsDistinct = (Record[0] & 1) || (SPFlags & DISubprogram::SPFlagDefinition); IsDistinct = (Record[0] & 1) || (SPFlags & DISubprogram::SPFlagDefinition);
@ -1709,26 +1711,26 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
DISubprogram *SP = GET_OR_DISTINCT( DISubprogram *SP = GET_OR_DISTINCT(
DISubprogram, DISubprogram,
(Context, (Context,
getDITypeRefOrNull(Record[1]), // scope getDITypeRefOrNull(Record[1]), // scope
getMDString(Record[2]), // name getMDString(Record[2]), // name
getMDString(Record[3]), // linkageName getMDString(Record[3]), // linkageName
getMDOrNull(Record[4]), // file getMDOrNull(Record[4]), // file
Record[5], // line Record[5], // line
getMDOrNull(Record[6]), // type getMDOrNull(Record[6]), // type
Record[7 + OffsetA], // scopeLine Record[7 + OffsetA], // scopeLine
getDITypeRefOrNull(Record[8 + OffsetA]), // containingType getDITypeRefOrNull(Record[8 + OffsetA]), // containingType
Record[10 + OffsetA], // virtualIndex Record[10 + OffsetA], // virtualIndex
HasThisAdj ? Record[16 + OffsetB] : 0, // thisAdjustment HasThisAdj ? Record[16 + OffsetB] : 0, // thisAdjustment
Flags, // flags Flags, // flags
SPFlags, // SPFlags SPFlags, // SPFlags
HasUnit ? CUorFn : nullptr, // unit HasUnit ? CUorFn : nullptr, // unit
getMDOrNull(Record[13 + OffsetB]), // templateParams getMDOrNull(Record[13 + OffsetB]), // templateParams
getMDOrNull(Record[14 + OffsetB]), // declaration getMDOrNull(Record[14 + OffsetB]), // declaration
getMDOrNull(Record[15 + OffsetB]), // retainedNodes getMDOrNull(Record[15 + OffsetB]), // retainedNodes
HasThrownTypes ? getMDOrNull(Record[17 + OffsetB]) HasThrownTypes ? getMDOrNull(Record[17 + OffsetB])
: nullptr, // thrownTypes : nullptr, // thrownTypes
HasAnnotations ? getMDOrNull(Record[18 + OffsetB]) HasAnnotations ? getMDOrNull(Record[18 + OffsetB])
: nullptr // annotations : nullptr // annotations
)); ));
MetadataList.assignValue(SP, NextMetadataNo); MetadataList.assignValue(SP, NextMetadataNo);
NextMetadataNo++; NextMetadataNo++;
@ -1875,13 +1877,13 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
Annotations = getMDOrNull(Record[12]); Annotations = getMDOrNull(Record[12]);
MetadataList.assignValue( MetadataList.assignValue(
GET_OR_DISTINCT( GET_OR_DISTINCT(DIGlobalVariable,
DIGlobalVariable, (Context, getMDOrNull(Record[1]),
(Context, getMDOrNull(Record[1]), getMDString(Record[2]), getMDString(Record[2]), getMDString(Record[3]),
getMDString(Record[3]), getMDOrNull(Record[4]), Record[5], getMDOrNull(Record[4]), Record[5],
getDITypeRefOrNull(Record[6]), Record[7], Record[8], getDITypeRefOrNull(Record[6]), Record[7], Record[8],
getMDOrNull(Record[9]), getMDOrNull(Record[10]), Record[11], getMDOrNull(Record[9]), getMDOrNull(Record[10]),
Annotations)), Record[11], Annotations)),
NextMetadataNo); NextMetadataNo);
NextMetadataNo++; NextMetadataNo++;
@ -1889,13 +1891,12 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
// No upgrade necessary. A null field will be introduced to indicate // No upgrade necessary. A null field will be introduced to indicate
// that no parameter information is available. // that no parameter information is available.
MetadataList.assignValue( MetadataList.assignValue(
GET_OR_DISTINCT(DIGlobalVariable, GET_OR_DISTINCT(
(Context, getMDOrNull(Record[1]), DIGlobalVariable,
getMDString(Record[2]), getMDString(Record[3]), (Context, getMDOrNull(Record[1]), getMDString(Record[2]),
getMDOrNull(Record[4]), Record[5], getMDString(Record[3]), getMDOrNull(Record[4]), Record[5],
getDITypeRefOrNull(Record[6]), Record[7], Record[8], getDITypeRefOrNull(Record[6]), Record[7], Record[8],
getMDOrNull(Record[10]), nullptr, Record[11], getMDOrNull(Record[10]), nullptr, Record[11], nullptr)),
nullptr)),
NextMetadataNo); NextMetadataNo);
NextMetadataNo++; NextMetadataNo++;
@ -1973,8 +1974,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
getMDString(Record[2 + HasTag]), getMDString(Record[2 + HasTag]),
getMDOrNull(Record[3 + HasTag]), Record[4 + HasTag], getMDOrNull(Record[3 + HasTag]), Record[4 + HasTag],
getDITypeRefOrNull(Record[5 + HasTag]), getDITypeRefOrNull(Record[5 + HasTag]),
Record[6 + HasTag], Flags, AlignInBits, Record[6 + HasTag], Flags, AlignInBits, Annotations)),
Annotations)),
NextMetadataNo); NextMetadataNo);
NextMetadataNo++; NextMetadataNo++;
break; break;
@ -1985,10 +1985,9 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
IsDistinct = Record[0] & 1; IsDistinct = Record[0] & 1;
MetadataList.assignValue( MetadataList.assignValue(
GET_OR_DISTINCT(DILabel, GET_OR_DISTINCT(DILabel, (Context, getMDOrNull(Record[1]),
(Context, getMDOrNull(Record[1]), getMDString(Record[2]),
getMDString(Record[2]), getMDOrNull(Record[3]), Record[4])),
getMDOrNull(Record[3]), Record[4])),
NextMetadataNo); NextMetadataNo);
NextMetadataNo++; NextMetadataNo++;
break; break;
@ -2005,8 +2004,8 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
if (Error Err = upgradeDIExpression(Version, Elts, Buffer)) if (Error Err = upgradeDIExpression(Version, Elts, Buffer))
return Err; return Err;
MetadataList.assignValue( MetadataList.assignValue(GET_OR_DISTINCT(DIExpression, (Context, Elts)),
GET_OR_DISTINCT(DIExpression, (Context, Elts)), NextMetadataNo); NextMetadataNo);
NextMetadataNo++; NextMetadataNo++;
break; break;
} }

View File

@ -32,8 +32,8 @@ static cl::opt<bool>
cl::init(false), cl::Hidden); cl::init(false), cl::Hidden);
DIBuilder::DIBuilder(Module &m, bool AllowUnresolvedNodes, DICompileUnit *CU) DIBuilder::DIBuilder(Module &m, bool AllowUnresolvedNodes, DICompileUnit *CU)
: M(m), VMContext(M.getContext()), CUNode(CU), : M(m), VMContext(M.getContext()), CUNode(CU), DeclareFn(nullptr),
DeclareFn(nullptr), ValueFn(nullptr), LabelFn(nullptr), ValueFn(nullptr), LabelFn(nullptr),
AllowUnresolvedNodes(AllowUnresolvedNodes) {} AllowUnresolvedNodes(AllowUnresolvedNodes) {}
void DIBuilder::trackIfUnresolved(MDNode *N) { void DIBuilder::trackIfUnresolved(MDNode *N) {
@ -309,11 +309,10 @@ DIDerivedType *DIBuilder::createMemberPointerType(DIType *PointeeTy,
AlignInBits, 0, None, Flags, Base); AlignInBits, 0, None, Flags, Base);
} }
DIDerivedType *DIBuilder::createReferenceType( DIDerivedType *
unsigned Tag, DIType *RTy, DIBuilder::createReferenceType(unsigned Tag, DIType *RTy, uint64_t SizeInBits,
uint64_t SizeInBits, uint32_t AlignInBits,
uint32_t AlignInBits, Optional<unsigned> DWARFAddressSpace) {
Optional<unsigned> DWARFAddressSpace) {
assert(RTy && "Unable to create reference type"); assert(RTy && "Unable to create reference type");
return DIDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr, RTy, return DIDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr, RTy,
SizeInBits, AlignInBits, 0, DWARFAddressSpace, SizeInBits, AlignInBits, 0, DWARFAddressSpace,
@ -322,8 +321,7 @@ DIDerivedType *DIBuilder::createReferenceType(
DIDerivedType *DIBuilder::createTypedef(DIType *Ty, StringRef Name, DIDerivedType *DIBuilder::createTypedef(DIType *Ty, StringRef Name,
DIFile *File, unsigned LineNo, DIFile *File, unsigned LineNo,
DIScope *Context, DIScope *Context, uint32_t AlignInBits,
uint32_t AlignInBits,
DINodeArray Annotations) { DINodeArray Annotations) {
return DIDerivedType::get(VMContext, dwarf::DW_TAG_typedef, Name, File, return DIDerivedType::get(VMContext, dwarf::DW_TAG_typedef, Name, File,
LineNo, getNonCompileUnitScope(Context), Ty, 0, LineNo, getNonCompileUnitScope(Context), Ty, 0,
@ -346,8 +344,8 @@ DIDerivedType *DIBuilder::createInheritance(DIType *Ty, DIType *BaseTy,
Metadata *ExtraData = ConstantAsMetadata::get( Metadata *ExtraData = ConstantAsMetadata::get(
ConstantInt::get(IntegerType::get(VMContext, 32), VBPtrOffset)); ConstantInt::get(IntegerType::get(VMContext, 32), VBPtrOffset));
return DIDerivedType::get(VMContext, dwarf::DW_TAG_inheritance, "", nullptr, return DIDerivedType::get(VMContext, dwarf::DW_TAG_inheritance, "", nullptr,
0, Ty, BaseTy, 0, 0, BaseOffset, None, 0, Ty, BaseTy, 0, 0, BaseOffset, None, Flags,
Flags, ExtraData); ExtraData);
} }
DIDerivedType *DIBuilder::createMemberType( DIDerivedType *DIBuilder::createMemberType(
@ -383,7 +381,7 @@ DIDerivedType *DIBuilder::createBitFieldMemberType(
Flags |= DINode::FlagBitField; Flags |= DINode::FlagBitField;
return DIDerivedType::get( return DIDerivedType::get(
VMContext, dwarf::DW_TAG_member, Name, File, LineNumber, VMContext, dwarf::DW_TAG_member, Name, File, LineNumber,
getNonCompileUnitScope(Scope), Ty, SizeInBits, /* AlignInBits */ 0, getNonCompileUnitScope(Scope), Ty, SizeInBits, /*AlignInBits=*/0,
OffsetInBits, None, Flags, OffsetInBits, None, Flags,
ConstantAsMetadata::get(ConstantInt::get(IntegerType::get(VMContext, 64), ConstantAsMetadata::get(ConstantInt::get(IntegerType::get(VMContext, 64),
StorageOffsetInBits)), StorageOffsetInBits)),
@ -503,10 +501,12 @@ DICompositeType *DIBuilder::createUnionType(
return R; return R;
} }
DICompositeType *DIBuilder::createVariantPart( DICompositeType *
DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber, DIBuilder::createVariantPart(DIScope *Scope, StringRef Name, DIFile *File,
uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags, unsigned LineNumber, uint64_t SizeInBits,
DIDerivedType *Discriminator, DINodeArray Elements, StringRef UniqueIdentifier) { uint32_t AlignInBits, DINode::DIFlags Flags,
DIDerivedType *Discriminator, DINodeArray Elements,
StringRef UniqueIdentifier) {
auto *R = DICompositeType::get( auto *R = DICompositeType::get(
VMContext, dwarf::DW_TAG_variant_part, Name, File, LineNumber, VMContext, dwarf::DW_TAG_variant_part, Name, File, LineNumber,
getNonCompileUnitScope(Scope), nullptr, SizeInBits, AlignInBits, 0, Flags, getNonCompileUnitScope(Scope), nullptr, SizeInBits, AlignInBits, 0, Flags,
@ -547,16 +547,17 @@ DIDerivedType *DIBuilder::createSetType(DIScope *Scope, StringRef Name,
return R; return R;
} }
DICompositeType *DIBuilder::createArrayType( DICompositeType *
uint64_t Size, uint32_t AlignInBits, DIType *Ty, DINodeArray Subscripts, DIBuilder::createArrayType(uint64_t Size, uint32_t AlignInBits, DIType *Ty,
PointerUnion<DIExpression *, DIVariable *> DL, DINodeArray Subscripts,
PointerUnion<DIExpression *, DIVariable *> AS, PointerUnion<DIExpression *, DIVariable *> DL,
PointerUnion<DIExpression *, DIVariable *> AL, PointerUnion<DIExpression *, DIVariable *> AS,
PointerUnion<DIExpression *, DIVariable *> RK) { PointerUnion<DIExpression *, DIVariable *> AL,
PointerUnion<DIExpression *, DIVariable *> RK) {
auto *R = DICompositeType::get( auto *R = DICompositeType::get(
VMContext, dwarf::DW_TAG_array_type, "", nullptr, 0, VMContext, dwarf::DW_TAG_array_type, "", nullptr, 0, nullptr, Ty, Size,
nullptr, Ty, Size, AlignInBits, 0, DINode::FlagZero, AlignInBits, 0, DINode::FlagZero, Subscripts, 0, nullptr, nullptr, "",
Subscripts, 0, nullptr, nullptr, "", nullptr, nullptr,
DL.is<DIExpression *>() ? (Metadata *)DL.get<DIExpression *>() DL.is<DIExpression *>() ? (Metadata *)DL.get<DIExpression *>()
: (Metadata *)DL.get<DIVariable *>(), : (Metadata *)DL.get<DIVariable *>(),
AS.is<DIExpression *>() ? (Metadata *)AS.get<DIExpression *>() AS.is<DIExpression *>() ? (Metadata *)AS.get<DIExpression *>()
@ -639,8 +640,8 @@ DICompositeType *DIBuilder::createReplaceableCompositeType(
DICompositeType::getTemporary( DICompositeType::getTemporary(
VMContext, Tag, Name, F, Line, getNonCompileUnitScope(Scope), nullptr, VMContext, Tag, Name, F, Line, getNonCompileUnitScope(Scope), nullptr,
SizeInBits, AlignInBits, 0, Flags, nullptr, RuntimeLang, nullptr, SizeInBits, AlignInBits, 0, Flags, nullptr, RuntimeLang, nullptr,
nullptr, UniqueIdentifier, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, UniqueIdentifier, nullptr, nullptr, nullptr, nullptr,
Annotations) nullptr, Annotations)
.release(); .release();
trackIfUnresolved(RetTy); trackIfUnresolved(RetTy);
return RetTy; return RetTy;
@ -708,16 +709,16 @@ static void checkGlobalVariableScope(DIScope *Context) {
DIGlobalVariableExpression *DIBuilder::createGlobalVariableExpression( DIGlobalVariableExpression *DIBuilder::createGlobalVariableExpression(
DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *F, DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *F,
unsigned LineNumber, DIType *Ty, bool IsLocalToUnit, unsigned LineNumber, DIType *Ty, bool IsLocalToUnit, bool isDefined,
bool isDefined, DIExpression *Expr, DIExpression *Expr, MDNode *Decl, MDTuple *TemplateParams,
MDNode *Decl, MDTuple *TemplateParams, uint32_t AlignInBits, uint32_t AlignInBits, DINodeArray Annotations) {
DINodeArray Annotations) {
checkGlobalVariableScope(Context); checkGlobalVariableScope(Context);
auto *GV = DIGlobalVariable::getDistinct( auto *GV = DIGlobalVariable::getDistinct(
VMContext, cast_or_null<DIScope>(Context), Name, LinkageName, F, VMContext, cast_or_null<DIScope>(Context), Name, LinkageName, F,
LineNumber, Ty, IsLocalToUnit, isDefined, cast_or_null<DIDerivedType>(Decl), LineNumber, Ty, IsLocalToUnit, isDefined,
TemplateParams, AlignInBits, Annotations); cast_or_null<DIDerivedType>(Decl), TemplateParams, AlignInBits,
Annotations);
if (!Expr) if (!Expr)
Expr = createExpression(); Expr = createExpression();
auto *N = DIGlobalVariableExpression::get(VMContext, GV, Expr); auto *N = DIGlobalVariableExpression::get(VMContext, GV, Expr);
@ -751,10 +752,9 @@ static DILocalVariable *createLocalVariable(
// the only valid scopes)? // the only valid scopes)?
DIScope *Context = getNonCompileUnitScope(Scope); DIScope *Context = getNonCompileUnitScope(Scope);
auto *Node = auto *Node = DILocalVariable::get(
DILocalVariable::get(VMContext, cast_or_null<DILocalScope>(Context), Name, VMContext, cast_or_null<DILocalScope>(Context), Name, File, LineNo, Ty,
File, LineNo, Ty, ArgNo, Flags, AlignInBits, ArgNo, Flags, AlignInBits, Annotations);
Annotations);
if (AlwaysPreserve) { if (AlwaysPreserve) {
// The optimizer may remove local variables. If there is an interest // The optimizer may remove local variables. If there is an interest
// to preserve variable info in such situation then stash it in a // to preserve variable info in such situation then stash it in a
@ -783,17 +783,15 @@ DILocalVariable *DIBuilder::createParameterVariable(
assert(ArgNo && "Expected non-zero argument number for parameter"); assert(ArgNo && "Expected non-zero argument number for parameter");
return createLocalVariable(VMContext, PreservedVariables, Scope, Name, ArgNo, return createLocalVariable(VMContext, PreservedVariables, Scope, Name, ArgNo,
File, LineNo, Ty, AlwaysPreserve, Flags, File, LineNo, Ty, AlwaysPreserve, Flags,
/* AlignInBits */0, Annotations); /*AlignInBits=*/0, Annotations);
} }
DILabel *DIBuilder::createLabel( DILabel *DIBuilder::createLabel(DIScope *Scope, StringRef Name, DIFile *File,
DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo, bool AlwaysPreserve) {
unsigned LineNo, bool AlwaysPreserve) {
DIScope *Context = getNonCompileUnitScope(Scope); DIScope *Context = getNonCompileUnitScope(Scope);
auto *Node = auto *Node = DILabel::get(VMContext, cast_or_null<DILocalScope>(Context),
DILabel::get(VMContext, cast_or_null<DILocalScope>(Context), Name, Name, File, LineNo);
File, LineNo);
if (AlwaysPreserve) { if (AlwaysPreserve) {
/// The optimizer may remove labels. If there is an interest /// The optimizer may remove labels. If there is an interest
@ -817,7 +815,7 @@ DIExpression *DIBuilder::createExpression(ArrayRef<int64_t> Signed) {
} }
template <class... Ts> template <class... Ts>
static DISubprogram *getSubprogram(bool IsDistinct, Ts &&... Args) { static DISubprogram *getSubprogram(bool IsDistinct, Ts &&...Args) {
if (IsDistinct) if (IsDistinct)
return DISubprogram::getDistinct(std::forward<Ts>(Args)...); return DISubprogram::getDistinct(std::forward<Ts>(Args)...);
return DISubprogram::get(std::forward<Ts>(Args)...); return DISubprogram::get(std::forward<Ts>(Args)...);
@ -881,11 +879,11 @@ DISubprogram *DIBuilder::createMethod(
return SP; return SP;
} }
DICommonBlock *DIBuilder::createCommonBlock( DICommonBlock *DIBuilder::createCommonBlock(DIScope *Scope,
DIScope *Scope, DIGlobalVariable *Decl, StringRef Name, DIFile *File, DIGlobalVariable *Decl,
unsigned LineNo) { StringRef Name, DIFile *File,
return DICommonBlock::get( unsigned LineNo) {
VMContext, Scope, Decl, Name, File, LineNo); return DICommonBlock::get(VMContext, Scope, Decl, Name, File, LineNo);
} }
DINamespace *DIBuilder::createNameSpace(DIScope *Scope, StringRef Name, DINamespace *DIBuilder::createNameSpace(DIScope *Scope, StringRef Name,
@ -941,9 +939,9 @@ Instruction *DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
Instruction *DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL, Instruction *DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
Instruction *InsertBefore) { Instruction *InsertBefore) {
return insertLabel( return insertLabel(LabelInfo, DL,
LabelInfo, DL, InsertBefore ? InsertBefore->getParent() : nullptr, InsertBefore ? InsertBefore->getParent() : nullptr,
InsertBefore); InsertBefore);
} }
Instruction *DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL, Instruction *DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
@ -992,7 +990,8 @@ static Function *getDeclareIntrin(Module &M) {
Instruction *DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo, Instruction *DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
DIExpression *Expr, const DILocation *DL, DIExpression *Expr, const DILocation *DL,
BasicBlock *InsertBB, Instruction *InsertBefore) { BasicBlock *InsertBB,
Instruction *InsertBefore) {
assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.declare"); assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.declare");
assert(DL && "Expected debug loc"); assert(DL && "Expected debug loc");
assert(DL->getScope()->getSubprogram() == assert(DL->getScope()->getSubprogram() ==
@ -1035,9 +1034,9 @@ Instruction *DIBuilder::insertDbgValueIntrinsic(
return B.CreateCall(ValueFn, Args); return B.CreateCall(ValueFn, Args);
} }
Instruction *DIBuilder::insertLabel( Instruction *DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
DILabel *LabelInfo, const DILocation *DL, BasicBlock *InsertBB,
BasicBlock *InsertBB, Instruction *InsertBefore) { Instruction *InsertBefore) {
assert(LabelInfo && "empty or invalid DILabel* passed to dbg.label"); assert(LabelInfo && "empty or invalid DILabel* passed to dbg.label");
assert(DL && "Expected debug loc"); assert(DL && "Expected debug loc");
assert(DL->getScope()->getSubprogram() == assert(DL->getScope()->getSubprogram() ==
@ -1054,8 +1053,7 @@ Instruction *DIBuilder::insertLabel(
return B.CreateCall(LabelFn, Args); return B.CreateCall(LabelFn, Args);
} }
void DIBuilder::replaceVTableHolder(DICompositeType *&T, void DIBuilder::replaceVTableHolder(DICompositeType *&T, DIType *VTableHolder) {
DIType *VTableHolder) {
{ {
TypedTrackingMDRef<DICompositeType> N(T); TypedTrackingMDRef<DICompositeType> N(T);
N->replaceVTableHolder(VTableHolder); N->replaceVTableHolder(VTableHolder);

View File

@ -82,8 +82,8 @@ DILocation *DILocation::getImpl(LLVMContext &Context, unsigned Line,
Storage, Context.pImpl->DILocations); Storage, Context.pImpl->DILocations);
} }
const const DILocation *
DILocation *DILocation::getMergedLocations(ArrayRef<const DILocation *> Locs) { DILocation::getMergedLocations(ArrayRef<const DILocation *> Locs) {
if (Locs.empty()) if (Locs.empty())
return nullptr; return nullptr;
if (Locs.size() == 1) if (Locs.size() == 1)
@ -139,7 +139,8 @@ const DILocation *DILocation::getMergedLocation(const DILocation *LocA,
return DILocation::get(Result->getContext(), 0, 0, S, L); return DILocation::get(Result->getContext(), 0, 0, S, L);
} }
Optional<unsigned> DILocation::encodeDiscriminator(unsigned BD, unsigned DF, unsigned CI) { Optional<unsigned> DILocation::encodeDiscriminator(unsigned BD, unsigned DF,
unsigned CI) {
std::array<unsigned, 3> Components = {BD, DF, CI}; std::array<unsigned, 3> Components = {BD, DF, CI};
uint64_t RemainingWork = 0U; uint64_t RemainingWork = 0U;
// We use RemainingWork to figure out if we have no remaining components to // We use RemainingWork to figure out if we have no remaining components to
@ -147,7 +148,8 @@ Optional<unsigned> DILocation::encodeDiscriminator(unsigned BD, unsigned DF, uns
// encode anything for the latter 2. // encode anything for the latter 2.
// Since any of the input components is at most 32 bits, their sum will be // Since any of the input components is at most 32 bits, their sum will be
// less than 34 bits, and thus RemainingWork won't overflow. // less than 34 bits, and thus RemainingWork won't overflow.
RemainingWork = std::accumulate(Components.begin(), Components.end(), RemainingWork); RemainingWork =
std::accumulate(Components.begin(), Components.end(), RemainingWork);
int I = 0; int I = 0;
unsigned Ret = 0; unsigned Ret = 0;
@ -179,7 +181,6 @@ void DILocation::decodeDiscriminator(unsigned D, unsigned &BD, unsigned &DF,
getNextComponentInDiscriminator(getNextComponentInDiscriminator(D))); getNextComponentInDiscriminator(getNextComponentInDiscriminator(D)));
} }
DINode::DIFlags DINode::getFlag(StringRef Flag) { DINode::DIFlags DINode::getFlag(StringRef Flag) {
return StringSwitch<DIFlags>(Flag) return StringSwitch<DIFlags>(Flag)
#define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME) #define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME)
@ -546,8 +547,8 @@ DIBasicType *DIBasicType::getImpl(LLVMContext &Context, unsigned Tag,
DEFINE_GETIMPL_LOOKUP(DIBasicType, DEFINE_GETIMPL_LOOKUP(DIBasicType,
(Tag, Name, SizeInBits, AlignInBits, Encoding, Flags)); (Tag, Name, SizeInBits, AlignInBits, Encoding, Flags));
Metadata *Ops[] = {nullptr, nullptr, Name}; Metadata *Ops[] = {nullptr, nullptr, Name};
DEFINE_GETIMPL_STORE(DIBasicType, (Tag, SizeInBits, AlignInBits, Encoding, DEFINE_GETIMPL_STORE(DIBasicType,
Flags), Ops); (Tag, SizeInBits, AlignInBits, Encoding, Flags), Ops);
} }
Optional<DIBasicType::Signedness> DIBasicType::getSignedness() const { Optional<DIBasicType::Signedness> DIBasicType::getSignedness() const {
@ -589,9 +590,10 @@ DIDerivedType *DIDerivedType::getImpl(
AlignInBits, OffsetInBits, DWARFAddressSpace, Flags, AlignInBits, OffsetInBits, DWARFAddressSpace, Flags,
ExtraData, Annotations)); ExtraData, Annotations));
Metadata *Ops[] = {File, Scope, Name, BaseType, ExtraData, Annotations}; Metadata *Ops[] = {File, Scope, Name, BaseType, ExtraData, Annotations};
DEFINE_GETIMPL_STORE( DEFINE_GETIMPL_STORE(DIDerivedType,
DIDerivedType, (Tag, Line, SizeInBits, AlignInBits, OffsetInBits, (Tag, Line, SizeInBits, AlignInBits, OffsetInBits,
DWARFAddressSpace, Flags), Ops); DWARFAddressSpace, Flags),
Ops);
} }
DICompositeType *DICompositeType::getImpl( DICompositeType *DICompositeType::getImpl(
@ -616,9 +618,10 @@ DICompositeType *DICompositeType::getImpl(
Elements, VTableHolder, TemplateParams, Identifier, Elements, VTableHolder, TemplateParams, Identifier,
Discriminator, DataLocation, Associated, Allocated, Discriminator, DataLocation, Associated, Allocated,
Rank, Annotations}; Rank, Annotations};
DEFINE_GETIMPL_STORE(DICompositeType, (Tag, Line, RuntimeLang, SizeInBits, DEFINE_GETIMPL_STORE(
AlignInBits, OffsetInBits, Flags), DICompositeType,
Ops); (Tag, Line, RuntimeLang, SizeInBits, AlignInBits, OffsetInBits, Flags),
Ops);
} }
DICompositeType *DICompositeType::buildODRType( DICompositeType *DICompositeType::buildODRType(
@ -798,10 +801,14 @@ DICompileUnit::getNameTableKind(StringRef Str) {
const char *DICompileUnit::emissionKindString(DebugEmissionKind EK) { const char *DICompileUnit::emissionKindString(DebugEmissionKind EK) {
switch (EK) { switch (EK) {
case NoDebug: return "NoDebug"; case NoDebug:
case FullDebug: return "FullDebug"; return "NoDebug";
case LineTablesOnly: return "LineTablesOnly"; case FullDebug:
case DebugDirectivesOnly: return "DebugDirectivesOnly"; return "FullDebug";
case LineTablesOnly:
return "LineTablesOnly";
case DebugDirectivesOnly:
return "DebugDirectivesOnly";
} }
return nullptr; return nullptr;
} }
@ -881,9 +888,9 @@ DISubprogram *DISubprogram::getImpl(
SPFlags, Unit, TemplateParams, Declaration, SPFlags, Unit, TemplateParams, Declaration,
RetainedNodes, ThrownTypes, Annotations)); RetainedNodes, ThrownTypes, Annotations));
SmallVector<Metadata *, 12> Ops = { SmallVector<Metadata *, 12> Ops = {
File, Scope, Name, LinkageName, Type, Unit, File, Scope, Name, LinkageName,
Declaration, RetainedNodes, ContainingType, TemplateParams, ThrownTypes, Type, Unit, Declaration, RetainedNodes,
Annotations}; ContainingType, TemplateParams, ThrownTypes, Annotations};
if (!Annotations) { if (!Annotations) {
Ops.pop_back(); Ops.pop_back();
if (!ThrownTypes) { if (!ThrownTypes) {
@ -995,11 +1002,10 @@ DIGlobalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
bool ShouldCreate) { bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString"); assert(isCanonical(Name) && "Expected canonical MDString");
assert(isCanonical(LinkageName) && "Expected canonical MDString"); assert(isCanonical(LinkageName) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(DIGlobalVariable, (Scope, Name, LinkageName, File, Line, DEFINE_GETIMPL_LOOKUP(
Type, IsLocalToUnit, IsDefinition, DIGlobalVariable,
StaticDataMemberDeclaration, (Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
TemplateParams, AlignInBits, StaticDataMemberDeclaration, TemplateParams, AlignInBits, Annotations));
Annotations));
Metadata *Ops[] = {Scope, Metadata *Ops[] = {Scope,
Name, Name,
File, File,
@ -1013,22 +1019,19 @@ DIGlobalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
(Line, IsLocalToUnit, IsDefinition, AlignInBits), Ops); (Line, IsLocalToUnit, IsDefinition, AlignInBits), Ops);
} }
DILocalVariable *DILocalVariable::getImpl(LLVMContext &Context, Metadata *Scope, DILocalVariable *
MDString *Name, Metadata *File, DILocalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
unsigned Line, Metadata *Type, Metadata *File, unsigned Line, Metadata *Type,
unsigned Arg, DIFlags Flags, unsigned Arg, DIFlags Flags, uint32_t AlignInBits,
uint32_t AlignInBits, Metadata *Annotations, StorageType Storage,
Metadata *Annotations, bool ShouldCreate) {
StorageType Storage,
bool ShouldCreate) {
// 64K ought to be enough for any frontend. // 64K ought to be enough for any frontend.
assert(Arg <= UINT16_MAX && "Expected argument number to fit in 16-bits"); assert(Arg <= UINT16_MAX && "Expected argument number to fit in 16-bits");
assert(Scope && "Expected scope"); assert(Scope && "Expected scope");
assert(isCanonical(Name) && "Expected canonical MDString"); assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(DILocalVariable, DEFINE_GETIMPL_LOOKUP(DILocalVariable, (Scope, Name, File, Line, Type, Arg,
(Scope, Name, File, Line, Type, Arg, Flags, Flags, AlignInBits, Annotations));
AlignInBits, Annotations));
Metadata *Ops[] = {Scope, Name, File, Type, Annotations}; Metadata *Ops[] = {Scope, Name, File, Type, Annotations};
DEFINE_GETIMPL_STORE(DILocalVariable, (Line, Arg, Flags, AlignInBits), Ops); DEFINE_GETIMPL_STORE(DILocalVariable, (Line, Arg, Flags, AlignInBits), Ops);
} }
@ -1056,14 +1059,12 @@ Optional<uint64_t> DIVariable::getSizeInBits() const {
return None; return None;
} }
DILabel *DILabel::getImpl(LLVMContext &Context, Metadata *Scope, DILabel *DILabel::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
MDString *Name, Metadata *File, unsigned Line, Metadata *File, unsigned Line, StorageType Storage,
StorageType Storage,
bool ShouldCreate) { bool ShouldCreate) {
assert(Scope && "Expected scope"); assert(Scope && "Expected scope");
assert(isCanonical(Name) && "Expected canonical MDString"); assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(DILabel, DEFINE_GETIMPL_LOOKUP(DILabel, (Scope, Name, File, Line));
(Scope, Name, File, Line));
Metadata *Ops[] = {Scope, Name, File}; Metadata *Ops[] = {Scope, Name, File};
DEFINE_GETIMPL_STORE(DILabel, (Line), Ops); DEFINE_GETIMPL_STORE(DILabel, (Line), Ops);
} }
@ -1212,10 +1213,11 @@ bool DIExpression::isComplex() const {
// kind of complex computation occurs. // kind of complex computation occurs.
for (const auto &It : expr_ops()) { for (const auto &It : expr_ops()) {
switch (It.getOp()) { switch (It.getOp()) {
case dwarf::DW_OP_LLVM_tag_offset: case dwarf::DW_OP_LLVM_tag_offset:
case dwarf::DW_OP_LLVM_fragment: case dwarf::DW_OP_LLVM_fragment:
continue; continue;
default: return true; default:
return true;
} }
} }
@ -1364,8 +1366,7 @@ DIExpression *DIExpression::replaceArg(const DIExpression *Expr,
DIExpression *DIExpression::prependOpcodes(const DIExpression *Expr, DIExpression *DIExpression::prependOpcodes(const DIExpression *Expr,
SmallVectorImpl<uint64_t> &Ops, SmallVectorImpl<uint64_t> &Ops,
bool StackValue, bool StackValue, bool EntryValue) {
bool EntryValue) {
assert(Expr && "Can't prepend ops to this expression"); assert(Expr && "Can't prepend ops to this expression");
if (EntryValue) { if (EntryValue) {
@ -1460,7 +1461,8 @@ Optional<DIExpression *> DIExpression::createFragmentExpression(
if (Expr) { if (Expr) {
for (auto Op : Expr->expr_ops()) { for (auto Op : Expr->expr_ops()) {
switch (Op.getOp()) { switch (Op.getOp()) {
default: break; default:
break;
case dwarf::DW_OP_shr: case dwarf::DW_OP_shr:
case dwarf::DW_OP_shra: case dwarf::DW_OP_shra:
case dwarf::DW_OP_shl: case dwarf::DW_OP_shl:
@ -1619,12 +1621,12 @@ DIImportedEntity *DIImportedEntity::getImpl(LLVMContext &Context, unsigned Tag,
DEFINE_GETIMPL_STORE(DIImportedEntity, (Tag, Line), Ops); DEFINE_GETIMPL_STORE(DIImportedEntity, (Tag, Line), Ops);
} }
DIMacro *DIMacro::getImpl(LLVMContext &Context, unsigned MIType, DIMacro *DIMacro::getImpl(LLVMContext &Context, unsigned MIType, unsigned Line,
unsigned Line, MDString *Name, MDString *Value, MDString *Name, MDString *Value, StorageType Storage,
StorageType Storage, bool ShouldCreate) { bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString"); assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(DIMacro, (MIType, Line, Name, Value)); DEFINE_GETIMPL_LOOKUP(DIMacro, (MIType, Line, Name, Value));
Metadata *Ops[] = { Name, Value }; Metadata *Ops[] = {Name, Value};
DEFINE_GETIMPL_STORE(DIMacro, (MIType, Line), Ops); DEFINE_GETIMPL_STORE(DIMacro, (MIType, Line), Ops);
} }
@ -1632,9 +1634,8 @@ DIMacroFile *DIMacroFile::getImpl(LLVMContext &Context, unsigned MIType,
unsigned Line, Metadata *File, unsigned Line, Metadata *File,
Metadata *Elements, StorageType Storage, Metadata *Elements, StorageType Storage,
bool ShouldCreate) { bool ShouldCreate) {
DEFINE_GETIMPL_LOOKUP(DIMacroFile, DEFINE_GETIMPL_LOOKUP(DIMacroFile, (MIType, Line, File, Elements));
(MIType, Line, File, Elements)); Metadata *Ops[] = {File, Elements};
Metadata *Ops[] = { File, Elements };
DEFINE_GETIMPL_STORE(DIMacroFile, (MIType, Line), Ops); DEFINE_GETIMPL_STORE(DIMacroFile, (MIType, Line), Ops);
} }

View File

@ -61,7 +61,9 @@ using DenseMapAPIntKeyInfo = DenseMapInfo<APInt>;
struct DenseMapAPFloatKeyInfo { struct DenseMapAPFloatKeyInfo {
static inline APFloat getEmptyKey() { return APFloat(APFloat::Bogus(), 1); } static inline APFloat getEmptyKey() { return APFloat(APFloat::Bogus(), 1); }
static inline APFloat getTombstoneKey() { return APFloat(APFloat::Bogus(), 2); } static inline APFloat getTombstoneKey() {
return APFloat(APFloat::Bogus(), 2);
}
static unsigned getHashValue(const APFloat &Key) { static unsigned getHashValue(const APFloat &Key) {
return static_cast<unsigned>(hash_value(Key)); return static_cast<unsigned>(hash_value(Key));
@ -74,46 +76,42 @@ struct DenseMapAPFloatKeyInfo {
struct AnonStructTypeKeyInfo { struct AnonStructTypeKeyInfo {
struct KeyTy { struct KeyTy {
ArrayRef<Type*> ETypes; ArrayRef<Type *> ETypes;
bool isPacked; bool isPacked;
KeyTy(const ArrayRef<Type*>& E, bool P) : KeyTy(const ArrayRef<Type *> &E, bool P) : ETypes(E), isPacked(P) {}
ETypes(E), isPacked(P) {}
KeyTy(const StructType *ST) KeyTy(const StructType *ST)
: ETypes(ST->elements()), isPacked(ST->isPacked()) {} : ETypes(ST->elements()), isPacked(ST->isPacked()) {}
bool operator==(const KeyTy& that) const { bool operator==(const KeyTy &that) const {
if (isPacked != that.isPacked) if (isPacked != that.isPacked)
return false; return false;
if (ETypes != that.ETypes) if (ETypes != that.ETypes)
return false; return false;
return true; return true;
} }
bool operator!=(const KeyTy& that) const { bool operator!=(const KeyTy &that) const { return !this->operator==(that); }
return !this->operator==(that);
}
}; };
static inline StructType* getEmptyKey() { static inline StructType *getEmptyKey() {
return DenseMapInfo<StructType*>::getEmptyKey(); return DenseMapInfo<StructType *>::getEmptyKey();
} }
static inline StructType* getTombstoneKey() { static inline StructType *getTombstoneKey() {
return DenseMapInfo<StructType*>::getTombstoneKey(); return DenseMapInfo<StructType *>::getTombstoneKey();
} }
static unsigned getHashValue(const KeyTy& Key) { static unsigned getHashValue(const KeyTy &Key) {
return hash_combine(hash_combine_range(Key.ETypes.begin(), return hash_combine(
Key.ETypes.end()), hash_combine_range(Key.ETypes.begin(), Key.ETypes.end()), Key.isPacked);
Key.isPacked);
} }
static unsigned getHashValue(const StructType *ST) { static unsigned getHashValue(const StructType *ST) {
return getHashValue(KeyTy(ST)); return getHashValue(KeyTy(ST));
} }
static bool isEqual(const KeyTy& LHS, const StructType *RHS) { static bool isEqual(const KeyTy &LHS, const StructType *RHS) {
if (RHS == getEmptyKey() || RHS == getTombstoneKey()) if (RHS == getEmptyKey() || RHS == getTombstoneKey())
return false; return false;
return LHS == KeyTy(RHS); return LHS == KeyTy(RHS);
@ -127,16 +125,16 @@ struct AnonStructTypeKeyInfo {
struct FunctionTypeKeyInfo { struct FunctionTypeKeyInfo {
struct KeyTy { struct KeyTy {
const Type *ReturnType; const Type *ReturnType;
ArrayRef<Type*> Params; ArrayRef<Type *> Params;
bool isVarArg; bool isVarArg;
KeyTy(const Type* R, const ArrayRef<Type*>& P, bool V) : KeyTy(const Type *R, const ArrayRef<Type *> &P, bool V)
ReturnType(R), Params(P), isVarArg(V) {} : ReturnType(R), Params(P), isVarArg(V) {}
KeyTy(const FunctionType *FT) KeyTy(const FunctionType *FT)
: ReturnType(FT->getReturnType()), Params(FT->params()), : ReturnType(FT->getReturnType()), Params(FT->params()),
isVarArg(FT->isVarArg()) {} isVarArg(FT->isVarArg()) {}
bool operator==(const KeyTy& that) const { bool operator==(const KeyTy &that) const {
if (ReturnType != that.ReturnType) if (ReturnType != that.ReturnType)
return false; return false;
if (isVarArg != that.isVarArg) if (isVarArg != that.isVarArg)
@ -145,31 +143,28 @@ struct FunctionTypeKeyInfo {
return false; return false;
return true; return true;
} }
bool operator!=(const KeyTy& that) const { bool operator!=(const KeyTy &that) const { return !this->operator==(that); }
return !this->operator==(that);
}
}; };
static inline FunctionType* getEmptyKey() { static inline FunctionType *getEmptyKey() {
return DenseMapInfo<FunctionType*>::getEmptyKey(); return DenseMapInfo<FunctionType *>::getEmptyKey();
} }
static inline FunctionType* getTombstoneKey() { static inline FunctionType *getTombstoneKey() {
return DenseMapInfo<FunctionType*>::getTombstoneKey(); return DenseMapInfo<FunctionType *>::getTombstoneKey();
} }
static unsigned getHashValue(const KeyTy& Key) { static unsigned getHashValue(const KeyTy &Key) {
return hash_combine(Key.ReturnType, return hash_combine(
hash_combine_range(Key.Params.begin(), Key.ReturnType,
Key.Params.end()), hash_combine_range(Key.Params.begin(), Key.Params.end()), Key.isVarArg);
Key.isVarArg);
} }
static unsigned getHashValue(const FunctionType *FT) { static unsigned getHashValue(const FunctionType *FT) {
return getHashValue(KeyTy(FT)); return getHashValue(KeyTy(FT));
} }
static bool isEqual(const KeyTy& LHS, const FunctionType *RHS) { static bool isEqual(const KeyTy &LHS, const FunctionType *RHS) {
if (RHS == getEmptyKey() || RHS == getTombstoneKey()) if (RHS == getEmptyKey() || RHS == getTombstoneKey())
return false; return false;
return LHS == KeyTy(RHS); return LHS == KeyTy(RHS);
@ -412,14 +407,14 @@ template <> struct MDNodeKeyImpl<DIBasicType> {
Encoding(Encoding), Flags(Flags) {} Encoding(Encoding), Flags(Flags) {}
MDNodeKeyImpl(const DIBasicType *N) MDNodeKeyImpl(const DIBasicType *N)
: Tag(N->getTag()), Name(N->getRawName()), SizeInBits(N->getSizeInBits()), : Tag(N->getTag()), Name(N->getRawName()), SizeInBits(N->getSizeInBits()),
AlignInBits(N->getAlignInBits()), Encoding(N->getEncoding()), Flags(N->getFlags()) {} AlignInBits(N->getAlignInBits()), Encoding(N->getEncoding()),
Flags(N->getFlags()) {}
bool isKeyOf(const DIBasicType *RHS) const { bool isKeyOf(const DIBasicType *RHS) const {
return Tag == RHS->getTag() && Name == RHS->getRawName() && return Tag == RHS->getTag() && Name == RHS->getRawName() &&
SizeInBits == RHS->getSizeInBits() && SizeInBits == RHS->getSizeInBits() &&
AlignInBits == RHS->getAlignInBits() && AlignInBits == RHS->getAlignInBits() &&
Encoding == RHS->getEncoding() && Encoding == RHS->getEncoding() && Flags == RHS->getFlags();
Flags == RHS->getFlags();
} }
unsigned getHashValue() const { unsigned getHashValue() const {
@ -526,7 +521,8 @@ template <> struct MDNodeSubsetEqualImpl<DIDerivedType> {
return isODRMember(LHS.Tag, LHS.Scope, LHS.Name, RHS); return isODRMember(LHS.Tag, LHS.Scope, LHS.Name, RHS);
} }
static bool isSubsetEqual(const DIDerivedType *LHS, const DIDerivedType *RHS) { static bool isSubsetEqual(const DIDerivedType *LHS,
const DIDerivedType *RHS) {
return isODRMember(LHS->getTag(), LHS->getRawScope(), LHS->getRawName(), return isODRMember(LHS->getTag(), LHS->getRawScope(), LHS->getRawName(),
RHS); RHS);
} }
@ -667,14 +663,13 @@ template <> struct MDNodeKeyImpl<DIFile> {
bool isKeyOf(const DIFile *RHS) const { bool isKeyOf(const DIFile *RHS) const {
return Filename == RHS->getRawFilename() && return Filename == RHS->getRawFilename() &&
Directory == RHS->getRawDirectory() && Directory == RHS->getRawDirectory() &&
Checksum == RHS->getRawChecksum() && Checksum == RHS->getRawChecksum() && Source == RHS->getRawSource();
Source == RHS->getRawSource();
} }
unsigned getHashValue() const { unsigned getHashValue() const {
return hash_combine( return hash_combine(Filename, Directory, Checksum ? Checksum->Kind : 0,
Filename, Directory, Checksum ? Checksum->Kind : 0, Checksum ? Checksum->Value : nullptr,
Checksum ? Checksum->Value : nullptr, Source.getValueOr(nullptr)); Source.getValueOr(nullptr));
} }
}; };
@ -723,8 +718,8 @@ template <> struct MDNodeKeyImpl<DISubprogram> {
TemplateParams(N->getRawTemplateParams()), TemplateParams(N->getRawTemplateParams()),
Declaration(N->getRawDeclaration()), Declaration(N->getRawDeclaration()),
RetainedNodes(N->getRawRetainedNodes()), RetainedNodes(N->getRawRetainedNodes()),
ThrownTypes(N->getRawThrownTypes()), Annotations(N->getRawAnnotations()) ThrownTypes(N->getRawThrownTypes()),
{} Annotations(N->getRawAnnotations()) {}
bool isKeyOf(const DISubprogram *RHS) const { bool isKeyOf(const DISubprogram *RHS) const {
return Scope == RHS->getRawScope() && Name == RHS->getRawName() && return Scope == RHS->getRawScope() && Name == RHS->getRawName() &&
@ -861,9 +856,7 @@ template <> struct MDNodeKeyImpl<DINamespace> {
ExportSymbols == RHS->getExportSymbols(); ExportSymbols == RHS->getExportSymbols();
} }
unsigned getHashValue() const { unsigned getHashValue() const { return hash_combine(Scope, Name); }
return hash_combine(Scope, Name);
}
}; };
template <> struct MDNodeKeyImpl<DICommonBlock> { template <> struct MDNodeKeyImpl<DICommonBlock> {
@ -873,8 +866,8 @@ template <> struct MDNodeKeyImpl<DICommonBlock> {
Metadata *File; Metadata *File;
unsigned LineNo; unsigned LineNo;
MDNodeKeyImpl(Metadata *Scope, Metadata *Decl, MDString *Name, MDNodeKeyImpl(Metadata *Scope, Metadata *Decl, MDString *Name, Metadata *File,
Metadata *File, unsigned LineNo) unsigned LineNo)
: Scope(Scope), Decl(Decl), Name(Name), File(File), LineNo(LineNo) {} : Scope(Scope), Decl(Decl), Name(Name), File(File), LineNo(LineNo) {}
MDNodeKeyImpl(const DICommonBlock *N) MDNodeKeyImpl(const DICommonBlock *N)
: Scope(N->getRawScope()), Decl(N->getRawDecl()), Name(N->getRawName()), : Scope(N->getRawScope()), Decl(N->getRawDecl()), Name(N->getRawName()),
@ -882,8 +875,8 @@ template <> struct MDNodeKeyImpl<DICommonBlock> {
bool isKeyOf(const DICommonBlock *RHS) const { bool isKeyOf(const DICommonBlock *RHS) const {
return Scope == RHS->getRawScope() && Decl == RHS->getRawDecl() && return Scope == RHS->getRawScope() && Decl == RHS->getRawDecl() &&
Name == RHS->getRawName() && File == RHS->getRawFile() && Name == RHS->getRawName() && File == RHS->getRawFile() &&
LineNo == RHS->getLineNo(); LineNo == RHS->getLineNo();
} }
unsigned getHashValue() const { unsigned getHashValue() const {
@ -1093,9 +1086,7 @@ template <> struct MDNodeKeyImpl<DILabel> {
} }
/// Using name and line to get hash value. It should already be mostly unique. /// Using name and line to get hash value. It should already be mostly unique.
unsigned getHashValue() const { unsigned getHashValue() const { return hash_combine(Scope, Name, Line); }
return hash_combine(Scope, Name, Line);
}
}; };
template <> struct MDNodeKeyImpl<DIExpression> { template <> struct MDNodeKeyImpl<DIExpression> {
@ -1342,7 +1333,7 @@ class LLVMContextImpl {
public: public:
/// OwnedModules - The set of modules instantiated in this context, and which /// OwnedModules - The set of modules instantiated in this context, and which
/// will be automatically deleted if this context is deleted. /// will be automatically deleted if this context is deleted.
SmallPtrSet<Module*, 4> OwnedModules; SmallPtrSet<Module *, 4> OwnedModules;
/// The main remark streamer used by all the other streamers (e.g. IR, MIR, /// The main remark streamer used by all the other streamers (e.g. IR, MIR,
/// frontends, etc.). This should only be used by the specific streamers, and /// frontends, etc.). This should only be used by the specific streamers, and
@ -1394,7 +1385,7 @@ public:
DenseMap<Value *, ValueAsMetadata *> ValuesAsMetadata; DenseMap<Value *, ValueAsMetadata *> ValuesAsMetadata;
DenseMap<Metadata *, MetadataAsValue *> MetadataAsValues; DenseMap<Metadata *, MetadataAsValue *> MetadataAsValues;
DenseMap<const Value*, ValueName*> ValueNames; DenseMap<const Value *, ValueName *> ValueNames;
#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \ #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
DenseSet<CLASS *, CLASS##Info> CLASS##s; DenseSet<CLASS *, CLASS##Info> CLASS##s;
@ -1429,7 +1420,7 @@ public:
StringMap<std::unique_ptr<ConstantDataSequential>> CDSConstants; StringMap<std::unique_ptr<ConstantDataSequential>> CDSConstants;
DenseMap<std::pair<const Function *, const BasicBlock *>, BlockAddress *> DenseMap<std::pair<const Function *, const BasicBlock *>, BlockAddress *>
BlockAddresses; BlockAddresses;
DenseMap<const GlobalValue *, DSOLocalEquivalent *> DSOLocalEquivalents; DenseMap<const GlobalValue *, DSOLocalEquivalent *> DSOLocalEquivalents;
@ -1451,19 +1442,19 @@ public:
BumpPtrAllocator Alloc; BumpPtrAllocator Alloc;
UniqueStringSaver Saver{Alloc}; UniqueStringSaver Saver{Alloc};
DenseMap<unsigned, IntegerType*> IntegerTypes; DenseMap<unsigned, IntegerType *> IntegerTypes;
using FunctionTypeSet = DenseSet<FunctionType *, FunctionTypeKeyInfo>; using FunctionTypeSet = DenseSet<FunctionType *, FunctionTypeKeyInfo>;
FunctionTypeSet FunctionTypes; FunctionTypeSet FunctionTypes;
using StructTypeSet = DenseSet<StructType *, AnonStructTypeKeyInfo>; using StructTypeSet = DenseSet<StructType *, AnonStructTypeKeyInfo>;
StructTypeSet AnonStructTypes; StructTypeSet AnonStructTypes;
StringMap<StructType*> NamedStructTypes; StringMap<StructType *> NamedStructTypes;
unsigned NamedStructTypesUniqueID = 0; unsigned NamedStructTypesUniqueID = 0;
DenseMap<std::pair<Type *, uint64_t>, ArrayType*> ArrayTypes; DenseMap<std::pair<Type *, uint64_t>, ArrayType *> ArrayTypes;
DenseMap<std::pair<Type *, ElementCount>, VectorType *> VectorTypes; DenseMap<std::pair<Type *, ElementCount>, VectorType *> VectorTypes;
DenseMap<Type*, PointerType*> PointerTypes; // Pointers in AddrSpace = 0 DenseMap<Type *, PointerType *> PointerTypes; // Pointers in AddrSpace = 0
DenseMap<std::pair<Type*, unsigned>, PointerType*> ASPointerTypes; DenseMap<std::pair<Type *, unsigned>, PointerType *> ASPointerTypes;
/// ValueHandles - This map keeps track of all of the value handles that are /// ValueHandles - This map keeps track of all of the value handles that are
/// watching a Value*. The Value::HasValueHandle bit is used to know /// watching a Value*. The Value::HasValueHandle bit is used to know
@ -1517,7 +1508,7 @@ public:
/// This saves allocating an additional word in Function for programs which /// This saves allocating an additional word in Function for programs which
/// do not use GC (i.e., most programs) at the cost of increased overhead for /// do not use GC (i.e., most programs) at the cost of increased overhead for
/// clients which do use GC. /// clients which do use GC.
DenseMap<const Function*, std::string> GCNames; DenseMap<const Function *, std::string> GCNames;
/// Flag to indicate if Value (other than GlobalValue) retains their name or /// Flag to indicate if Value (other than GlobalValue) retains their name or
/// not. /// not.
@ -1540,7 +1531,7 @@ public:
/// ///
/// The lifetime of the object must be guaranteed to extend as long as the /// The lifetime of the object must be guaranteed to extend as long as the
/// LLVMContext is used by compilation. /// LLVMContext is used by compilation.
void setOptPassGate(OptPassGate&); void setOptPassGate(OptPassGate &);
// TODO: clean up the following after we no longer support non-opaque pointer // TODO: clean up the following after we no longer support non-opaque pointer
// types. // types.