#
bed16824 |
| 16-Jul-2024 |
Michael Buch <michaelbuch12@gmail.com> |
[clang][test] zero-init-empty-virtual.cpp: remove redundant alignment check
Fixes a `clang-armv8-quick` buildbot failure. Where the alignment was `4` instead of `8`: ``` // CHECK: @{{.*}} = {{.*}}gl
[clang][test] zero-init-empty-virtual.cpp: remove redundant alignment check
Fixes a `clang-armv8-quick` buildbot failure. Where the alignment was `4` instead of `8`: ``` // CHECK: @{{.*}} = {{.*}}global %struct.Holder2 zeroinitializer, align 8 ^ <stdin>:66:178: note: scanning from here @g_holder1 = global %struct.Holder1 { %struct.polymorphic_base { ptr getelementptr inbounds inrange(-8, 12) ({ [5 x ptr] }, ptr @_ZTV16polymorphic_base, i32 0, i32 0, i32 2) } }, align 4 ^ <stdin>:68:8: note: possible intended match here @g_holder2 = global %struct.Holder2 zeroinitializer, align 4 ^ ```
This test isn't about checking alignment, so remove that from the FileCheck entry.
show more ...
|
#
4497ec29 |
| 16-Jul-2024 |
Michael Buch <michaelbuch12@gmail.com> |
[clang][CGRecordLayout] Remove dependency on isZeroSize (#96422)
This is a follow-up from the conversation starting at
https://github.com/llvm/llvm-project/pull/93809#issuecomment-2173729801
The
[clang][CGRecordLayout] Remove dependency on isZeroSize (#96422)
This is a follow-up from the conversation starting at
https://github.com/llvm/llvm-project/pull/93809#issuecomment-2173729801
The root problem that motivated the change are external AST sources that
compute `ASTRecordLayout`s themselves instead of letting Clang compute
them from the AST. One such example is LLDB using DWARF to get the
definitive offsets and sizes of C++ structures. Such layouts should be
considered correct (modulo buggy DWARF), but various assertions and
lowering logic around the `CGRecordLayoutBuilder` relies on the AST
having `[[no_unique_address]]` attached to them. This is a
layout-altering attribute which is not encoded in DWARF. This causes us
LLDB to trip over the various LLVM<->Clang layout consistency checks.
There has been precedent for avoiding such layout-altering attributes
from affecting lowering with externally-provided layouts (e.g., packed
structs).
This patch proposes to replace the `isZeroSize` checks in
`CGRecordLayoutBuilder` (which roughly means "empty field with
[[no_unique_address]]") with checks for
`CodeGen::isEmptyField`/`CodeGen::isEmptyRecord`.
**Details**
The main strategy here was to change the `isZeroSize` check in
`CGRecordLowering::accumulateFields` and
`CGRecordLowering::accumulateBases` to use the `isEmptyXXX` APIs
instead, preventing empty fields from being added to the `Members` and
`Bases` structures. The rest of the changes fall out from here, to
prevent lookups into these structures (for field numbers or base
indices) from failing.
Added `isEmptyRecordForLayout` and `isEmptyFieldForLayout` (open to
better naming suggestions). The main difference to the existing
`isEmptyRecord`/`isEmptyField` APIs, is that the `isEmptyXXXForLayout`
counterparts don't have special treatment for `unnamed bitfields`/arrays
and also treat fields of empty types as if they had
`[[no_unique_address]]` (i.e., just like the `AsIfNoUniqueAddr` in
`isEmptyField` does).
show more ...
|