arm64: Fix alignment of structs with only zero sized fields#22445
arm64: Fix alignment of structs with only zero sized fields#22445thewilsonator merged 1 commit intodlang:masterfrom
Conversation
f46338a to
8b23ea6
Compare
|
Thanks for your pull request, @ibuclaw! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#22445" |
8b23ea6 to
55750d9
Compare
| { | ||
| // sufficient for DMD's currently supported architectures | ||
| return !bfd.isAnonymous(); | ||
| return !bfd.isAnonymous() || target.isAArch64; |
There was a problem hiding this comment.
According to LDC, Apple diverges (no arm64 special case).
There was a problem hiding this comment.
Confirmed in https://cpp.godbolt.org/z/44GcTKnvY.
There was a problem hiding this comment.
@kinke I expect LDC to have a smarter way to detect this.
There was a problem hiding this comment.
GDC queries its backend to see if targetm.align_anon_bitfield is true.
There was a problem hiding this comment.
I doubt LLVM has a similar logic, this is C stuff, so most likely in clang. - In LDC, we use this (which caused the test failures): https://github.com/ldc-developers/ldc/blob/d20bda5334a742e043fe6a2c945e1edc7c6f8564/gen/target.cpp#L433-L459
| static assert(D7.sizeof == 3 && D7.alignof == 4); | ||
| static assert(D8.sizeof == 4 && D8.alignof == 8); |
There was a problem hiding this comment.
WTF are these 2? sizeof not a multiple of alignof?!
There was a problem hiding this comment.
sizeof should be 0, as for the x86_64 case: https://cpp.godbolt.org/z/jq8jKfWhK
Edit: Oh well, for extern(C), where the tests are already correct. I guess these were just typos, should be 4/8 for extern(D). - Preparing a PR.
There was a problem hiding this comment.
You mistyped the -target option (https://cpp.godbolt.org/z/7TYn8b8dP)
Yes, looks like a typo for the sizeof of D7/D8. There were a lot of tests and configuration combos to sift through in my defence. :-)
|
=> #23068 |
ARM is one of the few targets where anonymous fields contribute to the aggregate alignment.
Did check a few with
-os=windowsand-os=windows -arm, but didn't write any tests for them.