Michael137 wrote:
Yea the problem with checking the size reported by the AST layout vs. the LLVM
type layout is that in DWARF we get following representation:
```
// main.cpp
struct A {
long c, d;
};
struct B {
[[no_unique_address]] Empty x;
};
struct C {
[[no_unique_address]] Empty x;
};
struct Foo : B, C, A {};
// dwarfdump
DW_TAG_structure_type
DW_AT_name ("Foo")
DW_AT_byte_size (0x10)
DW_TAG_inheritance
DW_AT_type (0x0000000000000085 "B")
DW_AT_data_member_location (0x00)
DW_TAG_inheritance
DW_AT_type (0x00000000000000b9 "C")
DW_AT_data_member_location (0x01)
DW_TAG_inheritance
DW_AT_type (0x0000000000000047 "A")
DW_AT_data_member_location (0x00)
```
Which is a perfectly valid layout, and shows how `B` and `C` don't contribute
any size to `Foo`.
However, the LLDB's AST gets lowered to:
```
Layout: <CGRecordLayout
LLVMType:%struct.Foo = type { %struct.B, %struct.C, %struct.E,
[18446744073709551615 x i8], [14 x i8], i64 }
NonVirtualBaseLLVMType:%struct.Foo = type { %struct.B, %struct.C, %struct.E,
[18446744073709551615 x i8], [14 x i8], i64 }
IsZeroInitializable:1
BitFields:[
]>
```
(side-note, the `18446744073709551615` here happens because using the offsets
from DWARF results in negative padding during lowering, but
`getTypeAllocSizeInBits` ends up wrapping the value around in the calculations
without issues it seems).
This won't pass the `AST layout size == LLVM type size` check. So it doesn't
seem like anything unexpected is going on here, the lack of `no_unique_address`
causes the lowering to get confused. Though I don't think we would want to
fixup the size passed to `RecordLayout`, because that's the one that we get
from Clang via DWARF, and should be the correct one to use. Don't have a good
idea on how we would get around the lack of `no_unique_address` here (without
relaxing the assertion for external sources, or encoding it in DWARF in some
way).
https://github.com/llvm/llvm-project/pull/93809
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits