# LLVM: fix lowering of structs with underaligned fields · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/f550c29c4e76ccfbdbc8ec2159cf90474530a24c)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: f550c29c4e76ccfbdbc8ec2159cf90474530a24c

Requested commit: f550c29c4e76ccfbdbc8ec2159cf90474530a24c

Commit: f550c29c4e76ccfbdbc8ec2159cf90474530a24c

Tree: 66b810de7b303ce71bb7eb538cc8a2b497c11d72

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
LLVM: fix lowering of structs with underaligned fields

When lowering a struct type to an LLVM struct type, keep track of
whether there are any underaligned fields. If so, then make it a packed
llvm struct. This works because we already insert manual padding bytes
regardless.

We could unconditionally use an LLVM packed struct; the reason we bother
checking for underaligned fields is that it is a conservative choice, in
case LLVM handles packed structs less optimally. A future improvement
could simplify this code by unconditionally using packed LLVM structs
and then make sure measure perf is unaffected.

closes #12190

```

## Parents

- [460211431f407c9f707e3ac3bbff61610a487926](https://git.cafe/gitcafe/zig/commit/460211431f407c9f707e3ac3bbff61610a487926?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/f550c29c4e76ccfbdbc8ec2159cf90474530a24c?format=markdown)
