diff options
author | Tom Tromey <tromey@adacore.com> | 2025-03-25 18:14:07 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-25 17:14:07 -0700 |
commit | f89129af8adfda5d9071210b771787e36ae8cd96 (patch) | |
tree | 7f80c7db5c90b5da0f8a88d5d7b7fad510e99ba8 /llvm/lib/IR/DIBuilder.cpp | |
parent | 584b24cd6de5fd8bcfefa0b4a57ddbbf58c14af1 (diff) | |
download | llvm-f89129af8adfda5d9071210b771787e36ae8cd96.zip llvm-f89129af8adfda5d9071210b771787e36ae8cd96.tar.gz llvm-f89129af8adfda5d9071210b771787e36ae8cd96.tar.bz2 |
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.
Diffstat (limited to 'llvm/lib/IR/DIBuilder.cpp')
-rw-r--r-- | llvm/lib/IR/DIBuilder.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp index f127ca8..9e7aea8 100644 --- a/llvm/lib/IR/DIBuilder.cpp +++ b/llvm/lib/IR/DIBuilder.cpp @@ -611,7 +611,7 @@ DICompositeType *DIBuilder::createArrayType( PointerUnion<DIExpression *, DIVariable *> DL, PointerUnion<DIExpression *, DIVariable *> AS, PointerUnion<DIExpression *, DIVariable *> AL, - PointerUnion<DIExpression *, DIVariable *> RK) { + PointerUnion<DIExpression *, DIVariable *> RK, Metadata *BitStride) { auto *R = DICompositeType::get( VMContext, dwarf::DW_TAG_array_type, Name, File, LineNumber, getNonCompileUnitScope(Scope), Ty, Size, AlignInBits, 0, DINode::FlagZero, @@ -623,7 +623,8 @@ DICompositeType *DIBuilder::createArrayType( isa<DIExpression *>(AL) ? (Metadata *)cast<DIExpression *>(AL) : (Metadata *)cast<DIVariable *>(AL), isa<DIExpression *>(RK) ? (Metadata *)cast<DIExpression *>(RK) - : (Metadata *)cast<DIVariable *>(RK)); + : (Metadata *)cast<DIVariable *>(RK), + nullptr, nullptr, 0, BitStride); trackIfUnresolved(R); return R; } |