From f89129af8adfda5d9071210b771787e36ae8cd96 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 25 Mar 2025 18:14:07 -0600 Subject: Add bit stride to DICompositeType (#131680) In Ada, an array can be packed and the elements can take less space than their natural object size. For example, for this type: type Packed_Array is array (4 .. 8) of Boolean; pragma pack (Packed_Array); ... each element of the array occupies a single bit, even though the "natural" size for a Boolean in memory is a byte. In DWARF, this is represented by putting a DW_AT_bit_stride onto the array type itself. This patch adds a bit stride to DICompositeType so that gnat-llvm can emit DWARF for these sorts of arrays. --- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp') diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 8f7482d16797..34ba25dccc36 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -1990,6 +1990,7 @@ void ModuleBitcodeWriter::writeDICompositeType( Record.push_back(VE.getMetadataOrNullID(N->getRawSpecification())); Record.push_back( N->getEnumKind().value_or(dwarf::DW_APPLE_ENUM_KIND_invalid)); + Record.push_back(VE.getMetadataOrNullID(N->getRawBitStride())); Stream.EmitRecord(bitc::METADATA_COMPOSITE_TYPE, Record, Abbrev); Record.clear(); -- cgit v1.2.3