/// TODO: Split up flags.
class MDType : public MDScope {
unsigned Line;
- unsigned SizeInBits;
- unsigned AlignInBits;
- unsigned OffsetInBits;
unsigned Flags;
+ uint64_t SizeInBits;
+ uint64_t AlignInBits;
+ uint64_t OffsetInBits;
protected:
MDType(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
- unsigned Line, unsigned SizeInBits, unsigned AlignInBits,
- unsigned OffsetInBits, unsigned Flags, ArrayRef<Metadata *> Ops)
- : MDScope(C, ID, Storage, Tag, Ops), Line(Line), SizeInBits(SizeInBits),
- AlignInBits(AlignInBits), OffsetInBits(OffsetInBits), Flags(Flags) {}
+ unsigned Line, uint64_t SizeInBits, uint64_t AlignInBits,
+ uint64_t OffsetInBits, unsigned Flags, ArrayRef<Metadata *> Ops)
+ : MDScope(C, ID, Storage, Tag, Ops), Line(Line), Flags(Flags),
+ SizeInBits(SizeInBits), AlignInBits(AlignInBits),
+ OffsetInBits(OffsetInBits) {}
~MDType() {}
public:
unsigned getLine() const { return Line; }
- unsigned getSizeInBits() const { return SizeInBits; }
- unsigned getAlignInBits() const { return AlignInBits; }
- unsigned getOffsetInBits() const { return OffsetInBits; }
+ uint64_t getSizeInBits() const { return SizeInBits; }
+ uint64_t getAlignInBits() const { return AlignInBits; }
+ uint64_t getOffsetInBits() const { return OffsetInBits; }
unsigned getFlags() const { return Flags; }
Metadata *getScope() const { return getOperand(1); }
unsigned Encoding;
MDBasicType(LLVMContext &C, StorageType Storage, unsigned Tag,
- unsigned SizeInBits, unsigned AlignInBits, unsigned Encoding,
+ uint64_t SizeInBits, uint64_t AlignInBits, unsigned Encoding,
ArrayRef<Metadata *> Ops)
: MDType(C, MDBasicTypeKind, Storage, Tag, 0, SizeInBits, AlignInBits, 0,
0, Ops),
~MDBasicType() {}
static MDBasicType *getImpl(LLVMContext &Context, unsigned Tag,
- StringRef Name, unsigned SizeInBits,
- unsigned AlignInBits, unsigned Encoding,
+ StringRef Name, uint64_t SizeInBits,
+ uint64_t AlignInBits, unsigned Encoding,
StorageType Storage, bool ShouldCreate = true) {
return getImpl(Context, Tag, getCanonicalMDString(Context, Name),
SizeInBits, AlignInBits, Encoding, Storage, ShouldCreate);
}
static MDBasicType *getImpl(LLVMContext &Context, unsigned Tag,
- MDString *Name, unsigned SizeInBits,
- unsigned AlignInBits, unsigned Encoding,
+ MDString *Name, uint64_t SizeInBits,
+ uint64_t AlignInBits, unsigned Encoding,
StorageType Storage, bool ShouldCreate = true);
TempMDBasicType cloneImpl() const {
public:
DEFINE_MDNODE_GET(MDBasicType,
- (unsigned Tag, StringRef Name, unsigned SizeInBits,
- unsigned AlignInBits, unsigned Encoding),
+ (unsigned Tag, StringRef Name, uint64_t SizeInBits,
+ uint64_t AlignInBits, unsigned Encoding),
(Tag, Name, SizeInBits, AlignInBits, Encoding))
DEFINE_MDNODE_GET(MDBasicType,
- (unsigned Tag, MDString *Name, unsigned SizeInBits,
- unsigned AlignInBits, unsigned Encoding),
+ (unsigned Tag, MDString *Name, uint64_t SizeInBits,
+ uint64_t AlignInBits, unsigned Encoding),
(Tag, Name, SizeInBits, AlignInBits, Encoding))
TempMDBasicType clone() const { return cloneImpl(); }
class MDDerivedTypeBase : public MDType {
protected:
MDDerivedTypeBase(LLVMContext &C, unsigned ID, StorageType Storage,
- unsigned Tag, unsigned Line, unsigned SizeInBits,
- unsigned AlignInBits, unsigned OffsetInBits, unsigned Flags,
+ unsigned Tag, unsigned Line, uint64_t SizeInBits,
+ uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
ArrayRef<Metadata *> Ops)
: MDType(C, ID, Storage, Tag, Line, SizeInBits, AlignInBits, OffsetInBits,
Flags, Ops) {}
friend class MDNode;
MDDerivedType(LLVMContext &C, StorageType Storage, unsigned Tag,
- unsigned Line, unsigned SizeInBits, unsigned AlignInBits,
- unsigned OffsetInBits, unsigned Flags, ArrayRef<Metadata *> Ops)
+ unsigned Line, uint64_t SizeInBits, uint64_t AlignInBits,
+ uint64_t OffsetInBits, unsigned Flags, ArrayRef<Metadata *> Ops)
: MDDerivedTypeBase(C, MDDerivedTypeKind, Storage, Tag, Line, SizeInBits,
AlignInBits, OffsetInBits, Flags, Ops) {}
~MDDerivedType() {}
static MDDerivedType *getImpl(LLVMContext &Context, unsigned Tag,
StringRef Name, Metadata *File, unsigned Line,
Metadata *Scope, Metadata *BaseType,
- unsigned SizeInBits, unsigned AlignInBits,
- unsigned OffsetInBits, unsigned Flags,
+ uint64_t SizeInBits, uint64_t AlignInBits,
+ uint64_t OffsetInBits, unsigned Flags,
Metadata *ExtraData, StorageType Storage,
bool ShouldCreate = true) {
return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
static MDDerivedType *getImpl(LLVMContext &Context, unsigned Tag,
MDString *Name, Metadata *File, unsigned Line,
Metadata *Scope, Metadata *BaseType,
- unsigned SizeInBits, unsigned AlignInBits,
- unsigned OffsetInBits, unsigned Flags,
+ uint64_t SizeInBits, uint64_t AlignInBits,
+ uint64_t OffsetInBits, unsigned Flags,
Metadata *ExtraData, StorageType Storage,
bool ShouldCreate = true);
DEFINE_MDNODE_GET(MDDerivedType,
(unsigned Tag, MDString *Name, Metadata *File,
unsigned Line, Metadata *Scope, Metadata *BaseType,
- unsigned SizeInBits, unsigned AlignInBits,
- unsigned OffsetInBits, unsigned Flags,
+ uint64_t SizeInBits, uint64_t AlignInBits,
+ uint64_t OffsetInBits, unsigned Flags,
Metadata *ExtraData = nullptr),
(Tag, Name, File, Line, Scope, BaseType, SizeInBits,
AlignInBits, OffsetInBits, Flags, ExtraData))
DEFINE_MDNODE_GET(MDDerivedType,
(unsigned Tag, StringRef Name, Metadata *File,
unsigned Line, Metadata *Scope, Metadata *BaseType,
- unsigned SizeInBits, unsigned AlignInBits,
- unsigned OffsetInBits, unsigned Flags,
+ uint64_t SizeInBits, uint64_t AlignInBits,
+ uint64_t OffsetInBits, unsigned Flags,
Metadata *ExtraData = nullptr),
(Tag, Name, File, Line, Scope, BaseType, SizeInBits,
AlignInBits, OffsetInBits, Flags, ExtraData))
protected:
MDCompositeTypeBase(LLVMContext &C, unsigned ID, StorageType Storage,
unsigned Tag, unsigned Line, unsigned RuntimeLang,
- unsigned SizeInBits, unsigned AlignInBits,
- unsigned OffsetInBits, unsigned Flags,
+ uint64_t SizeInBits, uint64_t AlignInBits,
+ uint64_t OffsetInBits, unsigned Flags,
ArrayRef<Metadata *> Ops)
: MDDerivedTypeBase(C, ID, Storage, Tag, Line, SizeInBits, AlignInBits,
OffsetInBits, Flags, Ops),
friend class MDNode;
MDCompositeType(LLVMContext &C, StorageType Storage, unsigned Tag,
- unsigned Line, unsigned RuntimeLang, unsigned SizeInBits,
- unsigned AlignInBits, unsigned OffsetInBits, unsigned Flags,
+ unsigned Line, unsigned RuntimeLang, uint64_t SizeInBits,
+ uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
ArrayRef<Metadata *> Ops)
: MDCompositeTypeBase(C, MDCompositeTypeKind, Storage, Tag, Line,
RuntimeLang, SizeInBits, AlignInBits, OffsetInBits,
static MDCompositeType *
getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, Metadata *File,
unsigned Line, Metadata *Scope, Metadata *BaseType,
- unsigned SizeInBits, unsigned AlignInBits, unsigned OffsetInBits,
- unsigned Flags, Metadata *Elements, unsigned RuntimeLang,
+ uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits,
+ uint64_t Flags, Metadata *Elements, unsigned RuntimeLang,
Metadata *VTableHolder, Metadata *TemplateParams,
StringRef Identifier, StorageType Storage, bool ShouldCreate = true) {
return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
static MDCompositeType *
getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
unsigned Line, Metadata *Scope, Metadata *BaseType,
- unsigned SizeInBits, unsigned AlignInBits, unsigned OffsetInBits,
+ uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits,
unsigned Flags, Metadata *Elements, unsigned RuntimeLang,
Metadata *VTableHolder, Metadata *TemplateParams,
MDString *Identifier, StorageType Storage, bool ShouldCreate = true);
DEFINE_MDNODE_GET(MDCompositeType,
(unsigned Tag, StringRef Name, Metadata *File,
unsigned Line, Metadata *Scope, Metadata *BaseType,
- unsigned SizeInBits, unsigned AlignInBits,
- unsigned OffsetInBits, unsigned Flags, Metadata *Elements,
+ uint64_t SizeInBits, uint64_t AlignInBits,
+ uint64_t OffsetInBits, unsigned Flags, Metadata *Elements,
unsigned RuntimeLang, Metadata *VTableHolder,
Metadata *TemplateParams = nullptr,
StringRef Identifier = ""),
DEFINE_MDNODE_GET(MDCompositeType,
(unsigned Tag, MDString *Name, Metadata *File,
unsigned Line, Metadata *Scope, Metadata *BaseType,
- unsigned SizeInBits, unsigned AlignInBits,
- unsigned OffsetInBits, unsigned Flags, Metadata *Elements,
+ uint64_t SizeInBits, uint64_t AlignInBits,
+ uint64_t OffsetInBits, unsigned Flags, Metadata *Elements,
unsigned RuntimeLang, Metadata *VTableHolder,
Metadata *TemplateParams = nullptr,
MDString *Identifier = nullptr),
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
+TEST_F(MDBasicTypeTest, getWithLargeValues) {
+ auto *N = MDBasicType::get(Context, dwarf::DW_TAG_base_type, "special",
+ UINT64_MAX, UINT64_MAX - 1, 7);
+ EXPECT_EQ(UINT64_MAX, N->getSizeInBits());
+ EXPECT_EQ(UINT64_MAX - 1, N->getAlignInBits());
+}
+
typedef MetadataTest MDDerivedTypeTest;
TEST_F(MDDerivedTypeTest, get) {
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
+TEST_F(MDDerivedTypeTest, getWithLargeValues) {
+ Metadata *File = MDTuple::getDistinct(Context, None);
+ Metadata *Scope = MDTuple::getDistinct(Context, None);
+ Metadata *BaseType = MDTuple::getDistinct(Context, None);
+ Metadata *ExtraData = MDTuple::getDistinct(Context, None);
+
+ auto *N = MDDerivedType::get(Context, dwarf::DW_TAG_pointer_type, "something",
+ File, 1, Scope, BaseType, UINT64_MAX,
+ UINT64_MAX - 1, UINT64_MAX - 2, 5, ExtraData);
+ EXPECT_EQ(UINT64_MAX, N->getSizeInBits());
+ EXPECT_EQ(UINT64_MAX - 1, N->getAlignInBits());
+ EXPECT_EQ(UINT64_MAX - 2, N->getOffsetInBits());
+}
+
typedef MetadataTest MDCompositeTypeTest;
TEST_F(MDCompositeTypeTest, get) {
unsigned Line = 1;
Metadata *Scope = MDTuple::getDistinct(Context, None);
Metadata *BaseType = MDTuple::getDistinct(Context, None);
- unsigned SizeInBits = 2;
- unsigned AlignInBits = 3;
- unsigned OffsetInBits = 4;
+ uint64_t SizeInBits = 2;
+ uint64_t AlignInBits = 3;
+ uint64_t OffsetInBits = 4;
unsigned Flags = 5;
Metadata *Elements = MDTuple::getDistinct(Context, None);
unsigned RuntimeLang = 6;
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
}
+TEST_F(MDCompositeTypeTest, getWithLargeValues) {
+ unsigned Tag = dwarf::DW_TAG_structure_type;
+ StringRef Name = "some name";
+ Metadata *File = MDTuple::getDistinct(Context, None);
+ unsigned Line = 1;
+ Metadata *Scope = MDTuple::getDistinct(Context, None);
+ Metadata *BaseType = MDTuple::getDistinct(Context, None);
+ uint64_t SizeInBits = UINT64_MAX;
+ uint64_t AlignInBits = UINT64_MAX - 1;
+ uint64_t OffsetInBits = UINT64_MAX - 2;
+ unsigned Flags = 5;
+ Metadata *Elements = MDTuple::getDistinct(Context, None);
+ unsigned RuntimeLang = 6;
+ Metadata *VTableHolder = MDTuple::getDistinct(Context, None);
+ Metadata *TemplateParams = MDTuple::getDistinct(Context, None);
+ StringRef Identifier = "some id";
+
+ auto *N = MDCompositeType::get(Context, Tag, Name, File, Line, Scope,
+ BaseType, SizeInBits, AlignInBits,
+ OffsetInBits, Flags, Elements, RuntimeLang,
+ VTableHolder, TemplateParams, Identifier);
+ EXPECT_EQ(SizeInBits, N->getSizeInBits());
+ EXPECT_EQ(AlignInBits, N->getAlignInBits());
+ EXPECT_EQ(OffsetInBits, N->getOffsetInBits());
+}
+
TEST_F(MDCompositeTypeTest, replaceOperands) {
unsigned Tag = dwarf::DW_TAG_structure_type;
StringRef Name = "some name";
unsigned Line = 1;
Metadata *Scope = MDTuple::getDistinct(Context, None);
Metadata *BaseType = MDTuple::getDistinct(Context, None);
- unsigned SizeInBits = 2;
- unsigned AlignInBits = 3;
- unsigned OffsetInBits = 4;
+ uint64_t SizeInBits = 2;
+ uint64_t AlignInBits = 3;
+ uint64_t OffsetInBits = 4;
unsigned Flags = 5;
unsigned RuntimeLang = 6;
StringRef Identifier = "some id";