[llvm] r339714 - [DebugInfoMetadata] Added DIFlags interface in DIBasicType.
Adrian Prantl via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 14 12:35:34 PDT 2018
Author: adrian
Date: Tue Aug 14 12:35:34 2018
New Revision: 339714
URL: http://llvm.org/viewvc/llvm-project?rev=339714&view=rev
Log:
[DebugInfoMetadata] Added DIFlags interface in DIBasicType.
Flags in DIBasicType will be used to pass attributes used in
DW_TAG_base_type, such as DW_AT_endianity.
Patch by Chirag Patel!
Differential Revision: https://reviews.llvm.org/D49610
Modified:
llvm/trunk/include/llvm/BinaryFormat/Dwarf.def
llvm/trunk/include/llvm/BinaryFormat/Dwarf.h
llvm/trunk/include/llvm/IR/DIBuilder.h
llvm/trunk/include/llvm/IR/DebugInfoFlags.def
llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
llvm/trunk/lib/AsmParser/LLParser.cpp
llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp
llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/trunk/lib/IR/AsmWriter.cpp
llvm/trunk/lib/IR/DIBuilder.cpp
llvm/trunk/lib/IR/DebugInfoMetadata.cpp
llvm/trunk/lib/IR/LLVMContextImpl.h
llvm/trunk/lib/IR/Verifier.cpp
llvm/trunk/test/Assembler/debug-info.ll
llvm/trunk/unittests/IR/MetadataTest.cpp
Modified: llvm/trunk/include/llvm/BinaryFormat/Dwarf.def
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BinaryFormat/Dwarf.def?rev=339714&r1=339713&r2=339714&view=diff
==============================================================================
--- llvm/trunk/include/llvm/BinaryFormat/Dwarf.def (original)
+++ llvm/trunk/include/llvm/BinaryFormat/Dwarf.def Tue Aug 14 12:35:34 2018
@@ -20,7 +20,8 @@
defined HANDLE_DW_LNCT || defined HANDLE_DW_MACRO || \
defined HANDLE_DW_RLE || defined HANDLE_DW_CFA || \
defined HANDLE_DW_APPLE_PROPERTY || defined HANDLE_DW_UT || \
- defined HANDLE_DWARF_SECTION || defined HANDLE_DW_IDX)
+ defined HANDLE_DWARF_SECTION || defined HANDLE_DW_IDX || \
+ defined HANDLE_DW_END)
#error "Missing macro definition of HANDLE_DW*"
#endif
@@ -100,6 +101,10 @@
#define HANDLE_DW_IDX(ID, NAME)
#endif
+#ifndef HANDLE_DW_END
+#define HANDLE_DW_END(ID, NAME)
+#endif
+
HANDLE_DW_TAG(0x0000, null, 2, DWARF)
HANDLE_DW_TAG(0x0001, array_type, 2, DWARF)
HANDLE_DW_TAG(0x0002, class_type, 2, DWARF)
@@ -690,6 +695,11 @@ HANDLE_DW_ATE(0x10, UTF, 4, DWARF)
HANDLE_DW_ATE(0x11, UCS, 5, DWARF)
HANDLE_DW_ATE(0x12, ASCII, 5, DWARF)
+// DWARF attribute endianity
+HANDLE_DW_END(0x00, default)
+HANDLE_DW_END(0x01, big)
+HANDLE_DW_END(0x02, little)
+
// DWARF virtuality codes.
HANDLE_DW_VIRTUALITY(0x00, none)
HANDLE_DW_VIRTUALITY(0x01, virtual)
@@ -909,3 +919,4 @@ HANDLE_DW_IDX(0x05, type_hash)
#undef HANDLE_DW_UT
#undef HANDLE_DWARF_SECTION
#undef HANDLE_DW_IDX
+#undef HANDLE_DW_END
Modified: llvm/trunk/include/llvm/BinaryFormat/Dwarf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BinaryFormat/Dwarf.h?rev=339714&r1=339713&r2=339714&view=diff
==============================================================================
--- llvm/trunk/include/llvm/BinaryFormat/Dwarf.h (original)
+++ llvm/trunk/include/llvm/BinaryFormat/Dwarf.h Tue Aug 14 12:35:34 2018
@@ -150,9 +150,8 @@ enum DecimalSignEncoding {
enum EndianityEncoding {
// Endianity attribute values
- DW_END_default = 0x00,
- DW_END_big = 0x01,
- DW_END_little = 0x02,
+#define HANDLE_DW_END(ID, NAME) DW_END_##NAME = ID,
+#include "llvm/BinaryFormat/Dwarf.def"
DW_END_lo_user = 0x40,
DW_END_hi_user = 0xff
};
Modified: llvm/trunk/include/llvm/IR/DIBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DIBuilder.h?rev=339714&r1=339713&r2=339714&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DIBuilder.h (original)
+++ llvm/trunk/include/llvm/IR/DIBuilder.h Tue Aug 14 12:35:34 2018
@@ -188,9 +188,11 @@ namespace llvm {
/// type.
/// \param Name Type name.
/// \param SizeInBits Size of the type.
- /// \param Encoding DWARF encoding code, e.g. dwarf::DW_ATE_float.
+ /// \param Encoding DWARF encoding code, e.g., dwarf::DW_ATE_float.
+ /// \param Flags Optional DWARF attributes, e.g., DW_AT_endianity.
DIBasicType *createBasicType(StringRef Name, uint64_t SizeInBits,
- unsigned Encoding);
+ unsigned Encoding,
+ DINode::DIFlags Flags = DINode::FlagZero);
/// Create debugging information entry for a qualified
/// type, e.g. 'const int'.
Modified: llvm/trunk/include/llvm/IR/DebugInfoFlags.def
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfoFlags.def?rev=339714&r1=339713&r2=339714&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfoFlags.def (original)
+++ llvm/trunk/include/llvm/IR/DebugInfoFlags.def Tue Aug 14 12:35:34 2018
@@ -48,6 +48,8 @@ HANDLE_DI_FLAG((1 << 23), TypePassByRefe
HANDLE_DI_FLAG((1 << 24), FixedEnum)
HANDLE_DI_FLAG((1 << 25), Thunk)
HANDLE_DI_FLAG((1 << 26), Trivial)
+HANDLE_DI_FLAG((1 << 27), BigEndian)
+HANDLE_DI_FLAG((1 << 28), LittleEndian)
// To avoid needing a dedicated value for IndirectVirtualBase, we use
// the bitwise or of Virtual and FwdDecl, which does not otherwise
@@ -57,7 +59,7 @@ HANDLE_DI_FLAG((1 << 2) | (1 << 5), Indi
#ifdef DI_FLAG_LARGEST_NEEDED
// intended to be used with ADT/BitmaskEnum.h
// NOTE: always must be equal to largest flag, check this when adding new flag
-HANDLE_DI_FLAG((1 << 26), Largest)
+HANDLE_DI_FLAG((1 << 28), Largest)
#undef DI_FLAG_LARGEST_NEEDED
#endif
Modified: llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfoMetadata.h?rev=339714&r1=339713&r2=339714&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfoMetadata.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfoMetadata.h Tue Aug 14 12:35:34 2018
@@ -713,6 +713,8 @@ public:
bool isTypePassByReference() const {
return getFlags() & FlagTypePassByReference;
}
+ bool isBigEndian() const { return getFlags() & FlagBigEndian; }
+ bool isLittleEndian() const { return getFlags() & FlagLittleEndian; }
static bool classof(const Metadata *MD) {
switch (MD->getMetadataID()) {
@@ -739,40 +741,43 @@ class DIBasicType : public DIType {
DIBasicType(LLVMContext &C, StorageType Storage, unsigned Tag,
uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding,
- ArrayRef<Metadata *> Ops)
+ DIFlags Flags, ArrayRef<Metadata *> Ops)
: DIType(C, DIBasicTypeKind, Storage, Tag, 0, SizeInBits, AlignInBits, 0,
- FlagZero, Ops),
+ Flags, Ops),
Encoding(Encoding) {}
~DIBasicType() = default;
static DIBasicType *getImpl(LLVMContext &Context, unsigned Tag,
StringRef Name, uint64_t SizeInBits,
uint32_t AlignInBits, unsigned Encoding,
- StorageType Storage, bool ShouldCreate = true) {
+ DIFlags Flags, StorageType Storage,
+ bool ShouldCreate = true) {
return getImpl(Context, Tag, getCanonicalMDString(Context, Name),
- SizeInBits, AlignInBits, Encoding, Storage, ShouldCreate);
+ SizeInBits, AlignInBits, Encoding, Flags, Storage,
+ ShouldCreate);
}
static DIBasicType *getImpl(LLVMContext &Context, unsigned Tag,
MDString *Name, uint64_t SizeInBits,
uint32_t AlignInBits, unsigned Encoding,
- StorageType Storage, bool ShouldCreate = true);
+ DIFlags Flags, StorageType Storage,
+ bool ShouldCreate = true);
TempDIBasicType cloneImpl() const {
return getTemporary(getContext(), getTag(), getName(), getSizeInBits(),
- getAlignInBits(), getEncoding());
+ getAlignInBits(), getEncoding(), getFlags());
}
public:
DEFINE_MDNODE_GET(DIBasicType, (unsigned Tag, StringRef Name),
- (Tag, Name, 0, 0, 0))
+ (Tag, Name, 0, 0, 0, FlagZero))
DEFINE_MDNODE_GET(DIBasicType,
(unsigned Tag, StringRef Name, uint64_t SizeInBits,
- uint32_t AlignInBits, unsigned Encoding),
- (Tag, Name, SizeInBits, AlignInBits, Encoding))
+ uint32_t AlignInBits, unsigned Encoding, DIFlags Flags),
+ (Tag, Name, SizeInBits, AlignInBits, Encoding, Flags))
DEFINE_MDNODE_GET(DIBasicType,
(unsigned Tag, MDString *Name, uint64_t SizeInBits,
- uint32_t AlignInBits, unsigned Encoding),
- (Tag, Name, SizeInBits, AlignInBits, Encoding))
+ uint32_t AlignInBits, unsigned Encoding, DIFlags Flags),
+ (Tag, Name, SizeInBits, AlignInBits, Encoding, Flags))
TempDIBasicType clone() const { return cloneImpl(); }
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=339714&r1=339713&r2=339714&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Tue Aug 14 12:35:34 2018
@@ -4281,19 +4281,21 @@ bool LLParser::ParseDIEnumerator(MDNode
}
/// ParseDIBasicType:
-/// ::= !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32)
+/// ::= !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32,
+/// encoding: DW_ATE_encoding, flags: 0)
bool LLParser::ParseDIBasicType(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
OPTIONAL(tag, DwarfTagField, (dwarf::DW_TAG_base_type)); \
OPTIONAL(name, MDStringField, ); \
OPTIONAL(size, MDUnsignedField, (0, UINT64_MAX)); \
OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX)); \
- OPTIONAL(encoding, DwarfAttEncodingField, );
+ OPTIONAL(encoding, DwarfAttEncodingField, ); \
+ OPTIONAL(flags, DIFlagField, );
PARSE_MD_FIELDS();
#undef VISIT_MD_FIELDS
Result = GET_OR_DISTINCT(DIBasicType, (Context, tag.Val, name.Val, size.Val,
- align.Val, encoding.Val));
+ align.Val, encoding.Val, flags.Val));
return false;
}
Modified: llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp?rev=339714&r1=339713&r2=339714&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp Tue Aug 14 12:35:34 2018
@@ -1211,14 +1211,17 @@ Error MetadataLoader::MetadataLoaderImpl
break;
}
case bitc::METADATA_BASIC_TYPE: {
- if (Record.size() != 6)
+ if (Record.size() < 6 || Record.size() > 7)
return error("Invalid record");
IsDistinct = Record[0];
+ DINode::DIFlags Flags = (Record.size() > 6) ?
+ static_cast<DINode::DIFlags>(Record[6]) : DINode::FlagZero;
+
MetadataList.assignValue(
GET_OR_DISTINCT(DIBasicType,
(Context, Record[1], getMDString(Record[2]), Record[3],
- Record[4], Record[5])),
+ Record[4], Record[5], Flags)),
NextMetadataNo);
NextMetadataNo++;
break;
Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=339714&r1=339713&r2=339714&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Tue Aug 14 12:35:34 2018
@@ -1486,6 +1486,7 @@ void ModuleBitcodeWriter::writeDIBasicTy
Record.push_back(N->getSizeInBits());
Record.push_back(N->getAlignInBits());
Record.push_back(N->getEncoding());
+ Record.push_back(N->getFlags());
Stream.EmitRecord(bitc::METADATA_BASIC_TYPE, Record, Abbrev);
Record.clear();
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=339714&r1=339713&r2=339714&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Tue Aug 14 12:35:34 2018
@@ -859,6 +859,11 @@ void DwarfUnit::constructTypeDIE(DIE &Bu
uint64_t Size = BTy->getSizeInBits() >> 3;
addUInt(Buffer, dwarf::DW_AT_byte_size, None, Size);
+
+ if (BTy->isBigEndian())
+ addUInt(Buffer, dwarf::DW_AT_endianity, None, dwarf::DW_END_big);
+ else if (BTy->isLittleEndian())
+ addUInt(Buffer, dwarf::DW_AT_endianity, None, dwarf::DW_END_little);
}
void DwarfUnit::constructTypeDIE(DIE &Buffer, const DIDerivedType *DTy) {
Modified: llvm/trunk/lib/IR/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=339714&r1=339713&r2=339714&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)
+++ llvm/trunk/lib/IR/AsmWriter.cpp Tue Aug 14 12:35:34 2018
@@ -1787,6 +1787,7 @@ static void writeDIBasicType(raw_ostream
Printer.printInt("align", N->getAlignInBits());
Printer.printDwarfEnum("encoding", N->getEncoding(),
dwarf::AttributeEncodingString);
+ Printer.printDIFlags("flags", N->getFlags());
Out << ")";
}
Modified: llvm/trunk/lib/IR/DIBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=339714&r1=339713&r2=339714&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DIBuilder.cpp (original)
+++ llvm/trunk/lib/IR/DIBuilder.cpp Tue Aug 14 12:35:34 2018
@@ -256,10 +256,11 @@ DIBasicType *DIBuilder::createNullPtrTyp
}
DIBasicType *DIBuilder::createBasicType(StringRef Name, uint64_t SizeInBits,
- unsigned Encoding) {
+ unsigned Encoding,
+ DINode::DIFlags Flags) {
assert(!Name.empty() && "Unable to create type without name");
return DIBasicType::get(VMContext, dwarf::DW_TAG_base_type, Name, SizeInBits,
- 0, Encoding);
+ 0, Encoding, Flags);
}
DIDerivedType *DIBuilder::createQualifiedType(unsigned Tag, DIType *FromTy) {
Modified: llvm/trunk/lib/IR/DebugInfoMetadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfoMetadata.cpp?rev=339714&r1=339713&r2=339714&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfoMetadata.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfoMetadata.cpp Tue Aug 14 12:35:34 2018
@@ -274,13 +274,14 @@ DIEnumerator *DIEnumerator::getImpl(LLVM
DIBasicType *DIBasicType::getImpl(LLVMContext &Context, unsigned Tag,
MDString *Name, uint64_t SizeInBits,
uint32_t AlignInBits, unsigned Encoding,
- StorageType Storage, bool ShouldCreate) {
+ DIFlags Flags, StorageType Storage,
+ bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(DIBasicType,
- (Tag, Name, SizeInBits, AlignInBits, Encoding));
+ (Tag, Name, SizeInBits, AlignInBits, Encoding, Flags));
Metadata *Ops[] = {nullptr, nullptr, Name};
- DEFINE_GETIMPL_STORE(DIBasicType, (Tag, SizeInBits, AlignInBits, Encoding),
- Ops);
+ DEFINE_GETIMPL_STORE(DIBasicType, (Tag, SizeInBits, AlignInBits, Encoding,
+ Flags), Ops);
}
Optional<DIBasicType::Signedness> DIBasicType::getSignedness() const {
Modified: llvm/trunk/lib/IR/LLVMContextImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LLVMContextImpl.h?rev=339714&r1=339713&r2=339714&view=diff
==============================================================================
--- llvm/trunk/lib/IR/LLVMContextImpl.h (original)
+++ llvm/trunk/lib/IR/LLVMContextImpl.h Tue Aug 14 12:35:34 2018
@@ -376,20 +376,22 @@ template <> struct MDNodeKeyImpl<DIBasic
uint64_t SizeInBits;
uint32_t AlignInBits;
unsigned Encoding;
+ unsigned Flags;
MDNodeKeyImpl(unsigned Tag, MDString *Name, uint64_t SizeInBits,
- uint32_t AlignInBits, unsigned Encoding)
+ uint32_t AlignInBits, unsigned Encoding, unsigned Flags)
: Tag(Tag), Name(Name), SizeInBits(SizeInBits), AlignInBits(AlignInBits),
- Encoding(Encoding) {}
+ Encoding(Encoding), Flags(Flags) {}
MDNodeKeyImpl(const DIBasicType *N)
: Tag(N->getTag()), Name(N->getRawName()), SizeInBits(N->getSizeInBits()),
- AlignInBits(N->getAlignInBits()), Encoding(N->getEncoding()) {}
+ AlignInBits(N->getAlignInBits()), Encoding(N->getEncoding()), Flags(N->getFlags()) {}
bool isKeyOf(const DIBasicType *RHS) const {
return Tag == RHS->getTag() && Name == RHS->getRawName() &&
SizeInBits == RHS->getSizeInBits() &&
AlignInBits == RHS->getAlignInBits() &&
- Encoding == RHS->getEncoding();
+ Encoding == RHS->getEncoding() &&
+ Flags == RHS->getFlags();
}
unsigned getHashValue() const {
Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=339714&r1=339713&r2=339714&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Tue Aug 14 12:35:34 2018
@@ -886,6 +886,8 @@ void Verifier::visitDIBasicType(const DI
AssertDI(N.getTag() == dwarf::DW_TAG_base_type ||
N.getTag() == dwarf::DW_TAG_unspecified_type,
"invalid tag", &N);
+ AssertDI(!(N.isBigEndian() && N.isLittleEndian()) ,
+ "has conflicting flags", &N);
}
void Verifier::visitDIDerivedType(const DIDerivedType &N) {
Modified: llvm/trunk/test/Assembler/debug-info.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/debug-info.ll?rev=339714&r1=339713&r2=339714&view=diff
==============================================================================
--- llvm/trunk/test/Assembler/debug-info.ll (original)
+++ llvm/trunk/test/Assembler/debug-info.ll Tue Aug 14 12:35:34 2018
@@ -1,8 +1,8 @@
; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
; RUN: verify-uselistorder %s
-; CHECK: !named = !{!0, !0, !1, !2, !3, !4, !5, !6, !7, !8, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !27, !28, !29, !30, !31, !32, !33, !34, !35, !36, !37}
-!named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !28, !29, !30, !31, !32, !33, !34, !35, !36, !37, !38, !39, !40}
+; CHECK: !named = !{!0, !0, !1, !2, !3, !4, !5, !6, !7, !8, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !27, !28, !29, !30, !31, !32, !33, !34, !35, !36, !37, !38, !39}
+!named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !28, !29, !30, !31, !32, !33, !34, !35, !36, !37, !38, !39, !40, !41, !42}
; CHECK: !0 = !DISubrange(count: 3)
; CHECK-NEXT: !1 = !DISubrange(count: 3, lowerBound: 4)
@@ -94,3 +94,8 @@
; CHECK-NEXT: !37 = !DIFile(filename: "file", directory: "dir", checksumkind: CSK_MD5, checksum: "3a420e2646916a475e68de8d48f779f5", source: "int source() { }\0A")
!39 = !DIFile(filename: "file", directory: "dir", source: "int source() { }\0A")
!40 = !DIFile(filename: "file", directory: "dir", checksumkind: CSK_MD5, checksum: "3a420e2646916a475e68de8d48f779f5", source: "int source() { }\0A")
+
+; CHECK-NEXT: !38 = !DIBasicType(name: "u64.be", size: 64, align: 1, encoding: DW_ATE_unsigned, flags: DIFlagBigEndian)
+; CHECK-NEXT: !39 = !DIBasicType(name: "u64.le", size: 64, align: 1, encoding: DW_ATE_unsigned, flags: DIFlagLittleEndian)
+!41 = !DIBasicType(name: "u64.be", size: 64, align: 1, encoding: DW_ATE_unsigned, flags: DIFlagBigEndian)
+!42 = !DIBasicType(name: "u64.le", size: 64, align: 1, encoding: DW_ATE_unsigned, flags: DIFlagLittleEndian)
Modified: llvm/trunk/unittests/IR/MetadataTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/MetadataTest.cpp?rev=339714&r1=339713&r2=339714&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/MetadataTest.cpp (original)
+++ llvm/trunk/unittests/IR/MetadataTest.cpp Tue Aug 14 12:35:34 2018
@@ -997,26 +997,33 @@ typedef MetadataTest DIBasicTypeTest;
TEST_F(DIBasicTypeTest, get) {
auto *N =
- DIBasicType::get(Context, dwarf::DW_TAG_base_type, "special", 33, 26, 7);
+ DIBasicType::get(Context, dwarf::DW_TAG_base_type, "special", 33, 26, 7,
+ DINode::FlagZero);
EXPECT_EQ(dwarf::DW_TAG_base_type, N->getTag());
EXPECT_EQ("special", N->getName());
EXPECT_EQ(33u, N->getSizeInBits());
EXPECT_EQ(26u, N->getAlignInBits());
EXPECT_EQ(7u, N->getEncoding());
EXPECT_EQ(0u, N->getLine());
+ EXPECT_EQ(DINode::FlagZero, N->getFlags());
EXPECT_EQ(N, DIBasicType::get(Context, dwarf::DW_TAG_base_type, "special", 33,
- 26, 7));
+ 26, 7, DINode::FlagZero));
EXPECT_NE(N, DIBasicType::get(Context, dwarf::DW_TAG_unspecified_type,
- "special", 33, 26, 7));
+ "special", 33, 26, 7, DINode::FlagZero));
EXPECT_NE(N,
- DIBasicType::get(Context, dwarf::DW_TAG_base_type, "s", 33, 26, 7));
+ DIBasicType::get(Context, dwarf::DW_TAG_base_type, "s", 33, 26, 7,
+ DINode::FlagZero));
EXPECT_NE(N, DIBasicType::get(Context, dwarf::DW_TAG_base_type, "special", 32,
- 26, 7));
+ 26, 7, DINode::FlagZero));
EXPECT_NE(N, DIBasicType::get(Context, dwarf::DW_TAG_base_type, "special", 33,
- 25, 7));
+ 25, 7, DINode::FlagZero));
EXPECT_NE(N, DIBasicType::get(Context, dwarf::DW_TAG_base_type, "special", 33,
- 26, 6));
+ 26, 6, DINode::FlagZero));
+ EXPECT_NE(N, DIBasicType::get(Context, dwarf::DW_TAG_base_type, "special", 33,
+ 26, 7, DINode::FlagBigEndian));
+ EXPECT_NE(N, DIBasicType::get(Context, dwarf::DW_TAG_base_type, "special", 33,
+ 26, 7, DINode::FlagLittleEndian));
TempDIBasicType Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
@@ -1024,7 +1031,7 @@ TEST_F(DIBasicTypeTest, get) {
TEST_F(DIBasicTypeTest, getWithLargeValues) {
auto *N = DIBasicType::get(Context, dwarf::DW_TAG_base_type, "special",
- UINT64_MAX, UINT32_MAX - 1, 7);
+ UINT64_MAX, UINT32_MAX - 1, 7, DINode::FlagZero);
EXPECT_EQ(UINT64_MAX, N->getSizeInBits());
EXPECT_EQ(UINT32_MAX - 1, N->getAlignInBits());
}
@@ -1038,6 +1045,7 @@ TEST_F(DIBasicTypeTest, getUnspecified)
EXPECT_EQ(0u, N->getAlignInBits());
EXPECT_EQ(0u, N->getEncoding());
EXPECT_EQ(0u, N->getLine());
+ EXPECT_EQ(DINode::FlagZero, N->getFlags());
}
typedef MetadataTest DITypeTest;
@@ -1045,7 +1053,7 @@ typedef MetadataTest DITypeTest;
TEST_F(DITypeTest, clone) {
// Check that DIType has a specialized clone that returns TempDIType.
DIType *N = DIBasicType::get(Context, dwarf::DW_TAG_base_type, "int", 32, 32,
- dwarf::DW_ATE_signed);
+ dwarf::DW_ATE_signed, DINode::FlagZero);
TempDIType Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
More information about the llvm-commits
mailing list