diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-07-21 16:50:06 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-07-21 22:51:17 -0700 |
| commit | f550c29c4e76ccfbdbc8ec2159cf90474530a24c (patch) | |
| tree | 66b810de7b303ce71bb7eb538cc8a2b497c11d72 /lib/std | |
| parent | 460211431f407c9f707e3ac3bbff61610a487926 (diff) | |
| download | zig-f550c29c4e76ccfbdbc8ec2159cf90474530a24c.tar.gz zig-f550c29c4e76ccfbdbc8ec2159cf90474530a24c.zip | |
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
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/os/linux.zig | 5 | ||||
| -rw-r--r-- | lib/std/x/os/io.zig | 1 |
2 files changed, 4 insertions, 2 deletions
diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index ab421c4d32..1db3f862ed 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -3236,7 +3236,10 @@ pub const epoll_event = switch (builtin.zig_backend) { }, else => extern struct { events: u32, - data: epoll_data align(4), + data: epoll_data align(switch (native_arch) { + .x86_64 => 4, + else => @alignOf(epoll_data), + }), }, }; diff --git a/lib/std/x/os/io.zig b/lib/std/x/os/io.zig index e61d212e52..35e7c3e1ed 100644 --- a/lib/std/x/os/io.zig +++ b/lib/std/x/os/io.zig @@ -117,7 +117,6 @@ pub const Reactor = struct { }; test "reactor/linux: drive async tcp client/listener pair" { - if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; if (native_os.tag != .linux) return error.SkipZigTest; const ip = std.x.net.ip; |
