[DebugInfo] Add dataSize to DIBasicType to add DW_AT_bit_size to _BitInt types (#164372)
DW_TAG_base_type DIEs are permitted to have both byte_size and bit_size attributes "If the value of an object of the given type does not fully occupy the storage described by a byte size attribute" * Add DataSizeInBits to DIBasicType (`DIBasicType(... dataSize: n ...)` in IR). * Change Clang to add DataSizeInBits to _BitInt type metadata. * Change LLVM to add DW_AT_bit_size to base_type DIEs that have non-zero DataSizeInBits. TODO: Do we need to emit DW_AT_data_bit_offset for big endian targets? See discussion on the PR. Fixes [#61952](https://github.com/llvm/llvm-project/issues/61952) --------- Co-authored-by: David Stenberg <david.stenberg@ericsson.com>
This commit is contained in:
parent
9b513ad505
commit
aa5fe56db4
@ -1174,14 +1174,13 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
|
||||
}
|
||||
|
||||
llvm::DIType *CGDebugInfo::CreateType(const BitIntType *Ty) {
|
||||
|
||||
StringRef Name = Ty->isUnsigned() ? "unsigned _BitInt" : "_BitInt";
|
||||
llvm::dwarf::TypeKind Encoding = Ty->isUnsigned()
|
||||
? llvm::dwarf::DW_ATE_unsigned
|
||||
: llvm::dwarf::DW_ATE_signed;
|
||||
|
||||
return DBuilder.createBasicType(Name, CGM.getContext().getTypeSize(Ty),
|
||||
Encoding);
|
||||
Encoding, llvm::DINode::FlagZero, 0,
|
||||
Ty->getNumBits());
|
||||
}
|
||||
|
||||
llvm::DIType *CGDebugInfo::CreateType(const ComplexType *Ty) {
|
||||
|
||||
8
clang/test/DebugInfo/Generic/bit-int.c
Normal file
8
clang/test/DebugInfo/Generic/bit-int.c
Normal file
@ -0,0 +1,8 @@
|
||||
// RUN: %clang_cc1 -x c++ %s -debug-info-kind=standalone -gno-column-info -emit-llvm -o - | FileCheck %s
|
||||
// RUN: %clang_cc1 -x c %s -debug-info-kind=standalone -gno-column-info -emit-llvm -o - | FileCheck %s
|
||||
|
||||
unsigned _BitInt(17) a;
|
||||
_BitInt(2) b;
|
||||
|
||||
// CHECK: !DIBasicType(name: "_BitInt", size: 8, dataSize: 2, encoding: DW_ATE_signed)
|
||||
// CHECK: !DIBasicType(name: "unsigned _BitInt", size: 32, dataSize: 17, encoding: DW_ATE_unsigned)
|
||||
@ -209,10 +209,15 @@ namespace llvm {
|
||||
/// \param NumExtraInhabitants The number of extra inhabitants of the type.
|
||||
/// An extra inhabitant is a bit pattern that does not represent a valid
|
||||
/// value for instances of a given type. This is used by the Swift language.
|
||||
/// \param DataSizeInBits Optionally describes the number of bits used by
|
||||
/// the value of the object when this is less than the storage size of
|
||||
/// SizeInBits. Default value of zero indicates the object value and storage
|
||||
/// sizes are equal.
|
||||
LLVM_ABI DIBasicType *
|
||||
createBasicType(StringRef Name, uint64_t SizeInBits, unsigned Encoding,
|
||||
DINode::DIFlags Flags = DINode::FlagZero,
|
||||
uint32_t NumExtraInhabitants = 0);
|
||||
uint32_t NumExtraInhabitants = 0,
|
||||
uint32_t DataSizeInBits = 0);
|
||||
|
||||
/// Create debugging information entry for a binary fixed-point type.
|
||||
/// \param Name Type name.
|
||||
|
||||
@ -891,96 +891,114 @@ class DIBasicType : public DIType {
|
||||
friend class MDNode;
|
||||
|
||||
unsigned Encoding;
|
||||
/// Describes the number of bits used by the value of the object. Non-zero
|
||||
/// when the value of an object does not fully occupy the storage size
|
||||
/// specified by SizeInBits.
|
||||
uint32_t DataSizeInBits;
|
||||
|
||||
protected:
|
||||
DIBasicType(LLVMContext &C, StorageType Storage, unsigned Tag,
|
||||
uint32_t AlignInBits, unsigned Encoding,
|
||||
uint32_t NumExtraInhabitants, DIFlags Flags,
|
||||
ArrayRef<Metadata *> Ops)
|
||||
uint32_t NumExtraInhabitants, uint32_t DataSizeInBits,
|
||||
DIFlags Flags, ArrayRef<Metadata *> Ops)
|
||||
: DIType(C, DIBasicTypeKind, Storage, Tag, 0, AlignInBits,
|
||||
NumExtraInhabitants, Flags, Ops),
|
||||
Encoding(Encoding) {}
|
||||
Encoding(Encoding), DataSizeInBits(DataSizeInBits) {}
|
||||
DIBasicType(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
|
||||
uint32_t AlignInBits, unsigned Encoding,
|
||||
uint32_t NumExtraInhabitants, DIFlags Flags,
|
||||
ArrayRef<Metadata *> Ops)
|
||||
uint32_t NumExtraInhabitants, uint32_t DataSizeInBits,
|
||||
DIFlags Flags, ArrayRef<Metadata *> Ops)
|
||||
: DIType(C, ID, Storage, Tag, 0, AlignInBits, NumExtraInhabitants, Flags,
|
||||
Ops),
|
||||
Encoding(Encoding) {}
|
||||
Encoding(Encoding), DataSizeInBits(DataSizeInBits) {}
|
||||
~DIBasicType() = default;
|
||||
|
||||
static DIBasicType *getImpl(LLVMContext &Context, unsigned Tag,
|
||||
StringRef Name, uint64_t SizeInBits,
|
||||
uint32_t AlignInBits, unsigned Encoding,
|
||||
uint32_t NumExtraInhabitants, DIFlags Flags,
|
||||
uint32_t NumExtraInhabitants,
|
||||
uint32_t DataSizeInBits, DIFlags Flags,
|
||||
StorageType Storage, bool ShouldCreate = true) {
|
||||
return getImpl(Context, Tag, getCanonicalMDString(Context, Name),
|
||||
SizeInBits, AlignInBits, Encoding, NumExtraInhabitants,
|
||||
Flags, Storage, ShouldCreate);
|
||||
DataSizeInBits, Flags, Storage, ShouldCreate);
|
||||
}
|
||||
static DIBasicType *getImpl(LLVMContext &Context, unsigned Tag,
|
||||
MDString *Name, uint64_t SizeInBits,
|
||||
uint32_t AlignInBits, unsigned Encoding,
|
||||
uint32_t NumExtraInhabitants, DIFlags Flags,
|
||||
uint32_t NumExtraInhabitants,
|
||||
uint32_t DataSizeInBits, DIFlags Flags,
|
||||
StorageType Storage, bool ShouldCreate = true) {
|
||||
auto *SizeInBitsNode = ConstantAsMetadata::get(
|
||||
ConstantInt::get(Type::getInt64Ty(Context), SizeInBits));
|
||||
return getImpl(Context, Tag, Name, SizeInBitsNode, AlignInBits, Encoding,
|
||||
NumExtraInhabitants, Flags, Storage, ShouldCreate);
|
||||
NumExtraInhabitants, DataSizeInBits, Flags, Storage,
|
||||
ShouldCreate);
|
||||
}
|
||||
LLVM_ABI static DIBasicType *getImpl(LLVMContext &Context, unsigned Tag,
|
||||
MDString *Name, Metadata *SizeInBits,
|
||||
uint32_t AlignInBits, unsigned Encoding,
|
||||
uint32_t NumExtraInhabitants,
|
||||
DIFlags Flags, StorageType Storage,
|
||||
bool ShouldCreate = true);
|
||||
LLVM_ABI static DIBasicType *
|
||||
getImpl(LLVMContext &Context, unsigned Tag, MDString *Name,
|
||||
Metadata *SizeInBits, uint32_t AlignInBits, unsigned Encoding,
|
||||
uint32_t NumExtraInhabitants, uint32_t DataSizeInBits, DIFlags Flags,
|
||||
StorageType Storage, bool ShouldCreate = true);
|
||||
|
||||
TempDIBasicType cloneImpl() const {
|
||||
return getTemporary(getContext(), getTag(), getRawName(),
|
||||
getRawSizeInBits(), getAlignInBits(), getEncoding(),
|
||||
getNumExtraInhabitants(), getFlags());
|
||||
getNumExtraInhabitants(), getDataSizeInBits(),
|
||||
getFlags());
|
||||
}
|
||||
|
||||
public:
|
||||
DEFINE_MDNODE_GET(DIBasicType, (unsigned Tag, StringRef Name),
|
||||
(Tag, Name, 0, 0, 0, 0, FlagZero))
|
||||
(Tag, Name, 0, 0, 0, 0, 0, FlagZero))
|
||||
DEFINE_MDNODE_GET(DIBasicType,
|
||||
(unsigned Tag, StringRef Name, uint64_t SizeInBits),
|
||||
(Tag, Name, SizeInBits, 0, 0, 0, FlagZero))
|
||||
(Tag, Name, SizeInBits, 0, 0, 0, 0, FlagZero))
|
||||
DEFINE_MDNODE_GET(DIBasicType,
|
||||
(unsigned Tag, MDString *Name, uint64_t SizeInBits),
|
||||
(Tag, Name, SizeInBits, 0, 0, 0, FlagZero))
|
||||
(Tag, Name, SizeInBits, 0, 0, 0, 0, FlagZero))
|
||||
DEFINE_MDNODE_GET(DIBasicType,
|
||||
(unsigned Tag, StringRef Name, uint64_t SizeInBits,
|
||||
uint32_t AlignInBits, unsigned Encoding, DIFlags Flags),
|
||||
(Tag, Name, SizeInBits, AlignInBits, Encoding, 0, Flags))
|
||||
(Tag, Name, SizeInBits, AlignInBits, Encoding, 0, 0, Flags))
|
||||
DEFINE_MDNODE_GET(DIBasicType,
|
||||
(unsigned Tag, MDString *Name, uint64_t SizeInBits,
|
||||
uint32_t AlignInBits, unsigned Encoding, DIFlags Flags),
|
||||
(Tag, Name, SizeInBits, AlignInBits, Encoding, 0, Flags))
|
||||
(Tag, Name, SizeInBits, AlignInBits, Encoding, 0, 0, Flags))
|
||||
DEFINE_MDNODE_GET(DIBasicType,
|
||||
(unsigned Tag, StringRef Name, uint64_t SizeInBits,
|
||||
uint32_t AlignInBits, unsigned Encoding,
|
||||
uint32_t NumExtraInhabitants, DIFlags Flags),
|
||||
(Tag, Name, SizeInBits, AlignInBits, Encoding,
|
||||
NumExtraInhabitants, Flags))
|
||||
NumExtraInhabitants, 0, Flags))
|
||||
DEFINE_MDNODE_GET(DIBasicType,
|
||||
(unsigned Tag, StringRef Name, uint64_t SizeInBits,
|
||||
uint32_t AlignInBits, unsigned Encoding,
|
||||
uint32_t NumExtraInhabitants, uint32_t DataSizeInBits,
|
||||
DIFlags Flags),
|
||||
(Tag, Name, SizeInBits, AlignInBits, Encoding,
|
||||
NumExtraInhabitants, DataSizeInBits, Flags))
|
||||
DEFINE_MDNODE_GET(DIBasicType,
|
||||
(unsigned Tag, MDString *Name, uint64_t SizeInBits,
|
||||
uint32_t AlignInBits, unsigned Encoding,
|
||||
uint32_t NumExtraInhabitants, DIFlags Flags),
|
||||
uint32_t NumExtraInhabitants, uint32_t DataSizeInBits,
|
||||
DIFlags Flags),
|
||||
(Tag, Name, SizeInBits, AlignInBits, Encoding,
|
||||
NumExtraInhabitants, Flags))
|
||||
NumExtraInhabitants, DataSizeInBits, Flags))
|
||||
DEFINE_MDNODE_GET(DIBasicType,
|
||||
(unsigned Tag, MDString *Name, Metadata *SizeInBits,
|
||||
uint32_t AlignInBits, unsigned Encoding,
|
||||
uint32_t NumExtraInhabitants, DIFlags Flags),
|
||||
uint32_t NumExtraInhabitants, uint32_t DataSizeInBits,
|
||||
DIFlags Flags),
|
||||
(Tag, Name, SizeInBits, AlignInBits, Encoding,
|
||||
NumExtraInhabitants, Flags))
|
||||
NumExtraInhabitants, DataSizeInBits, Flags))
|
||||
|
||||
TempDIBasicType clone() const { return cloneImpl(); }
|
||||
|
||||
unsigned getEncoding() const { return Encoding; }
|
||||
|
||||
uint32_t getDataSizeInBits() const { return DataSizeInBits; }
|
||||
|
||||
enum class Signedness { Signed, Unsigned };
|
||||
|
||||
/// Return the signedness of this type, or std::nullopt if this type is
|
||||
@ -1010,7 +1028,7 @@ class DIFixedPointType : public DIBasicType {
|
||||
uint32_t AlignInBits, unsigned Encoding, DIFlags Flags,
|
||||
unsigned Kind, int Factor, ArrayRef<Metadata *> Ops)
|
||||
: DIBasicType(C, DIFixedPointTypeKind, Storage, Tag, AlignInBits,
|
||||
Encoding, 0, Flags, Ops),
|
||||
Encoding, 0, 0, Flags, Ops),
|
||||
Kind(Kind), Factor(Factor) {
|
||||
assert(Kind == FixedPointBinary || Kind == FixedPointDecimal);
|
||||
}
|
||||
@ -1019,7 +1037,7 @@ class DIFixedPointType : public DIBasicType {
|
||||
unsigned Kind, APInt Numerator, APInt Denominator,
|
||||
ArrayRef<Metadata *> Ops)
|
||||
: DIBasicType(C, DIFixedPointTypeKind, Storage, Tag, AlignInBits,
|
||||
Encoding, 0, Flags, Ops),
|
||||
Encoding, 0, 0, Flags, Ops),
|
||||
Kind(Kind), Factor(0), Numerator(Numerator), Denominator(Denominator) {
|
||||
assert(Kind == FixedPointRational);
|
||||
}
|
||||
@ -1028,7 +1046,7 @@ class DIFixedPointType : public DIBasicType {
|
||||
unsigned Kind, int Factor, APInt Numerator,
|
||||
APInt Denominator, ArrayRef<Metadata *> Ops)
|
||||
: DIBasicType(C, DIFixedPointTypeKind, Storage, Tag, AlignInBits,
|
||||
Encoding, 0, Flags, Ops),
|
||||
Encoding, 0, 0, Flags, Ops),
|
||||
Kind(Kind), Factor(Factor), Numerator(Numerator),
|
||||
Denominator(Denominator) {}
|
||||
~DIFixedPointType() = default;
|
||||
|
||||
@ -5642,16 +5642,17 @@ bool LLParser::parseDIBasicType(MDNode *&Result, bool IsDistinct) {
|
||||
OPTIONAL(name, MDStringField, ); \
|
||||
OPTIONAL(size, MDUnsignedOrMDField, (0, UINT64_MAX)); \
|
||||
OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX)); \
|
||||
OPTIONAL(dataSize, MDUnsignedField, (0, UINT32_MAX)); \
|
||||
OPTIONAL(encoding, DwarfAttEncodingField, ); \
|
||||
OPTIONAL(num_extra_inhabitants, MDUnsignedField, (0, UINT32_MAX)); \
|
||||
OPTIONAL(flags, DIFlagField, );
|
||||
PARSE_MD_FIELDS();
|
||||
#undef VISIT_MD_FIELDS
|
||||
|
||||
Result = GET_OR_DISTINCT(DIBasicType, (Context, tag.Val, name.Val,
|
||||
size.getValueAsMetadata(Context),
|
||||
align.Val, encoding.Val,
|
||||
num_extra_inhabitants.Val, flags.Val));
|
||||
Result = GET_OR_DISTINCT(
|
||||
DIBasicType,
|
||||
(Context, tag.Val, name.Val, size.getValueAsMetadata(Context), align.Val,
|
||||
encoding.Val, num_extra_inhabitants.Val, dataSize.Val, flags.Val));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -1531,7 +1531,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
|
||||
break;
|
||||
}
|
||||
case bitc::METADATA_BASIC_TYPE: {
|
||||
if (Record.size() < 6 || Record.size() > 8)
|
||||
if (Record.size() < 6 || Record.size() > 9)
|
||||
return error("Invalid record");
|
||||
|
||||
IsDistinct = Record[0] & 1;
|
||||
@ -1540,13 +1540,13 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
|
||||
? static_cast<DINode::DIFlags>(Record[6])
|
||||
: DINode::FlagZero;
|
||||
uint32_t NumExtraInhabitants = (Record.size() > 7) ? Record[7] : 0;
|
||||
|
||||
uint32_t DataSizeInBits = (Record.size() > 8) ? Record[8] : 0;
|
||||
Metadata *SizeInBits = getMetadataOrConstant(SizeIsMetadata, Record[3]);
|
||||
|
||||
MetadataList.assignValue(
|
||||
GET_OR_DISTINCT(DIBasicType,
|
||||
(Context, Record[1], getMDString(Record[2]), SizeInBits,
|
||||
Record[4], Record[5], NumExtraInhabitants, Flags)),
|
||||
Record[4], Record[5], NumExtraInhabitants,
|
||||
DataSizeInBits, Flags)),
|
||||
NextMetadataNo);
|
||||
NextMetadataNo++;
|
||||
break;
|
||||
|
||||
@ -1925,6 +1925,7 @@ void ModuleBitcodeWriter::writeDIBasicType(const DIBasicType *N,
|
||||
Record.push_back(N->getEncoding());
|
||||
Record.push_back(N->getFlags());
|
||||
Record.push_back(N->getNumExtraInhabitants());
|
||||
Record.push_back(N->getDataSizeInBits());
|
||||
|
||||
Stream.EmitRecord(bitc::METADATA_BASIC_TYPE, Record, Abbrev);
|
||||
Record.clear();
|
||||
|
||||
@ -1793,9 +1793,13 @@ void DwarfCompileUnit::createBaseTypeDIEs() {
|
||||
"_" + Twine(Btr.BitSize)).toStringRef(Str));
|
||||
addUInt(Die, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Btr.Encoding);
|
||||
// Round up to smallest number of bytes that contains this number of bits.
|
||||
// ExprRefedBaseTypes is populated with types referenced by
|
||||
// DW_OP_LLVM_convert operations in location expressions. These are often
|
||||
// byte-sized, but one common counter-example is 1-bit sized conversions
|
||||
// from `i1` types. TODO: Should these use DW_AT_bit_size? See
|
||||
// DwarfUnit::constructTypeDIE.
|
||||
addUInt(Die, dwarf::DW_AT_byte_size, std::nullopt,
|
||||
divideCeil(Btr.BitSize, 8));
|
||||
|
||||
Btr.Die = &Die;
|
||||
}
|
||||
}
|
||||
|
||||
@ -766,8 +766,19 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DIBasicType *BTy) {
|
||||
addUInt(Buffer, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
|
||||
BTy->getEncoding());
|
||||
|
||||
uint64_t Size = BTy->getSizeInBits() >> 3;
|
||||
addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt, Size);
|
||||
uint64_t SizeInBytes = divideCeil(BTy->getSizeInBits(), 8);
|
||||
addUInt(Buffer, dwarf::DW_AT_byte_size, std::nullopt, SizeInBytes);
|
||||
if (BTy->getTag() == dwarf::Tag::DW_TAG_base_type) {
|
||||
// DW_TAG_base_type:
|
||||
// If the value of an object of the given type does not fully occupy the
|
||||
// storage described by a byte size attribute, the base type entry may also
|
||||
// have a DW_AT_bit_size [...] attribute.
|
||||
// TODO: Do big endian targets need DW_AT_data_bit_offset? See discussion in
|
||||
// pull request #164372.
|
||||
if (uint64_t DataSizeInBits = BTy->getDataSizeInBits();
|
||||
DataSizeInBits && DataSizeInBits != SizeInBytes * 8)
|
||||
addUInt(Buffer, dwarf::DW_AT_bit_size, std::nullopt, DataSizeInBits);
|
||||
}
|
||||
|
||||
if (BTy->isBigEndian())
|
||||
addUInt(Buffer, dwarf::DW_AT_endianity, std::nullopt, dwarf::DW_END_big);
|
||||
|
||||
@ -2199,6 +2199,7 @@ static void writeDIBasicType(raw_ostream &Out, const DIBasicType *N,
|
||||
Printer.printString("name", N->getName());
|
||||
Printer.printMetadataOrInt("size", N->getRawSizeInBits(), true);
|
||||
Printer.printInt("align", N->getAlignInBits());
|
||||
Printer.printInt("dataSize", N->getDataSizeInBits());
|
||||
Printer.printDwarfEnum("encoding", N->getEncoding(),
|
||||
dwarf::AttributeEncodingString);
|
||||
Printer.printInt("num_extra_inhabitants", N->getNumExtraInhabitants());
|
||||
|
||||
@ -261,10 +261,12 @@ DIBasicType *DIBuilder::createNullPtrType() {
|
||||
DIBasicType *DIBuilder::createBasicType(StringRef Name, uint64_t SizeInBits,
|
||||
unsigned Encoding,
|
||||
DINode::DIFlags Flags,
|
||||
uint32_t NumExtraInhabitants) {
|
||||
uint32_t NumExtraInhabitants,
|
||||
uint32_t DataSizeInBits) {
|
||||
assert(!Name.empty() && "Unable to create type without name");
|
||||
return DIBasicType::get(VMContext, dwarf::DW_TAG_base_type, Name, SizeInBits,
|
||||
0, Encoding, NumExtraInhabitants, Flags);
|
||||
0, Encoding, NumExtraInhabitants, DataSizeInBits,
|
||||
Flags);
|
||||
}
|
||||
|
||||
DIFixedPointType *
|
||||
|
||||
@ -872,15 +872,18 @@ DIEnumerator *DIEnumerator::getImpl(LLVMContext &Context, const APInt &Value,
|
||||
DIBasicType *DIBasicType::getImpl(LLVMContext &Context, unsigned Tag,
|
||||
MDString *Name, Metadata *SizeInBits,
|
||||
uint32_t AlignInBits, unsigned Encoding,
|
||||
uint32_t NumExtraInhabitants, DIFlags Flags,
|
||||
uint32_t NumExtraInhabitants,
|
||||
uint32_t DataSizeInBits, DIFlags Flags,
|
||||
StorageType Storage, bool ShouldCreate) {
|
||||
assert(isCanonical(Name) && "Expected canonical MDString");
|
||||
DEFINE_GETIMPL_LOOKUP(DIBasicType, (Tag, Name, SizeInBits, AlignInBits,
|
||||
Encoding, NumExtraInhabitants, Flags));
|
||||
DEFINE_GETIMPL_LOOKUP(DIBasicType,
|
||||
(Tag, Name, SizeInBits, AlignInBits, Encoding,
|
||||
NumExtraInhabitants, DataSizeInBits, Flags));
|
||||
Metadata *Ops[] = {nullptr, nullptr, Name, SizeInBits, nullptr};
|
||||
DEFINE_GETIMPL_STORE(DIBasicType,
|
||||
(Tag, AlignInBits, Encoding, NumExtraInhabitants, Flags),
|
||||
Ops);
|
||||
DEFINE_GETIMPL_STORE(
|
||||
DIBasicType,
|
||||
(Tag, AlignInBits, Encoding, NumExtraInhabitants, DataSizeInBits, Flags),
|
||||
Ops);
|
||||
}
|
||||
|
||||
std::optional<DIBasicType::Signedness> DIBasicType::getSignedness() const {
|
||||
|
||||
@ -480,20 +480,22 @@ template <> struct MDNodeKeyImpl<DIBasicType> {
|
||||
uint32_t AlignInBits;
|
||||
unsigned Encoding;
|
||||
uint32_t NumExtraInhabitants;
|
||||
uint32_t DataSizeInBits;
|
||||
unsigned Flags;
|
||||
|
||||
MDNodeKeyImpl(unsigned Tag, MDString *Name, Metadata *SizeInBits,
|
||||
uint32_t AlignInBits, unsigned Encoding,
|
||||
uint32_t NumExtraInhabitants, unsigned Flags)
|
||||
uint32_t NumExtraInhabitants, uint32_t DataSizeInBits,
|
||||
unsigned Flags)
|
||||
: Tag(Tag), Name(Name), SizeInBits(SizeInBits), AlignInBits(AlignInBits),
|
||||
Encoding(Encoding), NumExtraInhabitants(NumExtraInhabitants),
|
||||
Flags(Flags) {}
|
||||
DataSizeInBits(DataSizeInBits), Flags(Flags) {}
|
||||
MDNodeKeyImpl(const DIBasicType *N)
|
||||
: Tag(N->getTag()), Name(N->getRawName()),
|
||||
SizeInBits(N->getRawSizeInBits()), AlignInBits(N->getAlignInBits()),
|
||||
Encoding(N->getEncoding()),
|
||||
NumExtraInhabitants(N->getNumExtraInhabitants()), Flags(N->getFlags()) {
|
||||
}
|
||||
NumExtraInhabitants(N->getNumExtraInhabitants()),
|
||||
DataSizeInBits(N->getDataSizeInBits()), Flags(N->getFlags()) {}
|
||||
|
||||
bool isKeyOf(const DIBasicType *RHS) const {
|
||||
return Tag == RHS->getTag() && Name == RHS->getRawName() &&
|
||||
@ -501,6 +503,7 @@ template <> struct MDNodeKeyImpl<DIBasicType> {
|
||||
AlignInBits == RHS->getAlignInBits() &&
|
||||
Encoding == RHS->getEncoding() &&
|
||||
NumExtraInhabitants == RHS->getNumExtraInhabitants() &&
|
||||
DataSizeInBits == RHS->getDataSizeInBits() &&
|
||||
Flags == RHS->getFlags();
|
||||
}
|
||||
|
||||
|
||||
19
llvm/test/Bitcode/dbg-data-size-roundtrip.ll
Normal file
19
llvm/test/Bitcode/dbg-data-size-roundtrip.ll
Normal file
@ -0,0 +1,19 @@
|
||||
; RUN: opt %s -o - -S | llvm-as - | llvm-dis - | FileCheck %s
|
||||
|
||||
; CHECK: !DIBasicType(name: "unsigned _BitInt", size: 32, dataSize: 17, encoding: DW_ATE_unsigned)
|
||||
|
||||
@a = global i8 0, align 1, !dbg !0
|
||||
|
||||
!llvm.dbg.cu = !{!2}
|
||||
!llvm.module.flags = !{!6, !7}
|
||||
!llvm.ident = !{!8}
|
||||
|
||||
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
|
||||
!1 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !3, line: 4, type: !5, isLocal: false, isDefinition: true)
|
||||
!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 22.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
|
||||
!3 = !DIFile(filename: "bit-int.c", directory: "/")
|
||||
!4 = !{!0}
|
||||
!5 = !DIBasicType(name: "unsigned _BitInt", size: 32, dataSize: 17, encoding: DW_ATE_unsigned)
|
||||
!6 = !{i32 2, !"Debug Info Version", i32 3}
|
||||
!7 = !{i32 1, !"wchar_size", i32 4}
|
||||
!8 = !{!"clang version 22.0.0git"}
|
||||
@ -11,7 +11,10 @@
|
||||
; CHECK: DW_TAG_base_type
|
||||
; CHECK-NEXT: DW_AT_name ("DW_ATE_unsigned_1")
|
||||
; CHECK-NEXT: DW_AT_encoding (DW_ATE_unsigned)
|
||||
;; TODO: Should this type use bit_size?
|
||||
; CHECK-NOT: DW_AT_bit_size
|
||||
; CHECK-NEXT: DW_AT_byte_size (0x01)
|
||||
; CHECK-NOT: DW_AT_bit_size
|
||||
|
||||
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
38
llvm/test/DebugInfo/bit-int-size.ll
Normal file
38
llvm/test/DebugInfo/bit-int-size.ll
Normal file
@ -0,0 +1,38 @@
|
||||
; RUN: %llc_dwarf %s -filetype=obj -o - | llvm-dwarfdump - | FileCheck %s
|
||||
; REQUIRES: object-emission
|
||||
|
||||
;; Check base types with bit-sizes that don't fit fully fit within a byte
|
||||
;; multiple get both a a byte_size and bit_size attribute.
|
||||
|
||||
; CHECK: DW_TAG_base_type
|
||||
; CHECK-NEXT: DW_AT_name ("unsigned _BitInt")
|
||||
; CHECK-NEXT: DW_AT_encoding (DW_ATE_unsigned)
|
||||
; CHECK-NEXT: DW_AT_byte_size (0x04)
|
||||
; CHECK-NEXT: DW_AT_bit_size (0x11)
|
||||
|
||||
; CHECK: DW_TAG_base_type
|
||||
; CHECK-NEXT: DW_AT_name ("_BitInt")
|
||||
; CHECK-NEXT: DW_AT_encoding (DW_ATE_signed)
|
||||
; CHECK-NEXT: DW_AT_byte_size (0x01)
|
||||
; CHECK-NEXT: DW_AT_bit_size (0x02)
|
||||
|
||||
@a = global i8 0, align 1, !dbg !0
|
||||
@b = global i8 0, align 1, !dbg !5
|
||||
|
||||
!llvm.dbg.cu = !{!2}
|
||||
!llvm.module.flags = !{!10, !11}
|
||||
!llvm.ident = !{!12}
|
||||
|
||||
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
|
||||
!1 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !7, line: 4, type: !9, isLocal: false, isDefinition: true)
|
||||
!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "clang version 22.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
|
||||
!3 = !DIFile(filename: "bit-int.c", directory: "/")
|
||||
!4 = !{!0, !5}
|
||||
!5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression())
|
||||
!6 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !7, line: 5, type: !8, isLocal: false, isDefinition: true)
|
||||
!7 = !DIFile(filename: "bit-int.c", directory: "/")
|
||||
!8 = !DIBasicType(name: "_BitInt", size: 8, dataSize: 2, encoding: DW_ATE_signed)
|
||||
!9 = !DIBasicType(name: "unsigned _BitInt", size: 32, dataSize: 17, encoding: DW_ATE_unsigned)
|
||||
!10 = !{i32 2, !"Debug Info Version", i32 3}
|
||||
!11 = !{i32 1, !"wchar_size", i32 4}
|
||||
!12 = !{!"clang version 22.0.0git"}
|
||||
Loading…
x
Reference in New Issue
Block a user