authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-04-30 19:51:35-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-05-08 19:37:29-07:00
log200e06b2399d605c8d183e55649e39ba2c6b56f6
tree9bdd2acf67740b9de522545abb8684e602181d22
parent927f24a6ff4af55f79df54c392b906413eae1459

update maxIntAlignment for x86 to 16

LLVMABIAlignmentOfType(i128) reports 16 on this target, however the C ABI uses align(4). Clang in LLVM 17 does this: %struct.foo = type { i32, i128 } Clang in LLVM 18 does this: %struct.foo = type <{ i32, i128 }> Clang is working around the 16-byte alignment to use align(4) for the C ABI by making the LLVM struct packed.

2 files changed, 2 insertions(+), 43 deletions(-)

src/type.zig+1-5
......@@ -1572,11 +1572,6 @@ pub const Type = struct {
15721572 .wasm64,
15731573 => 8,
15741574
1575 .x86 => if (target.ofmt == .c) 16 else return switch (target.os.tag) {
1576 .windows, .uefi => 8,
1577 else => 4,
1578 },
1579
15801575 // For these, LLVMABIAlignmentOfType(i128) reports 8. Note that 16
15811576 // is a relevant number in three cases:
15821577 // 1. Different machine code instruction when loading into SIMD register.
......@@ -1599,6 +1594,7 @@ pub const Type = struct {
15991594 },
16001595
16011596 // Even LLVMABIAlignmentOfType(i128) agrees on these targets.
1597 .x86,
16021598 .aarch64,
16031599 .aarch64_be,
16041600 .aarch64_32,
test/behavior/align.zig+1-38
......@@ -114,44 +114,6 @@ test "alignment and size of structs with 128-bit fields" {
114114 .u129_size = 24,
115115 },
116116
117 .x86 => if (builtin.object_format == .c) .{
118 .a_align = 16,
119 .a_size = 16,
120
121 .b_align = 16,
122 .b_size = 32,
123
124 .u128_align = 16,
125 .u128_size = 16,
126 .u129_align = 16,
127 .u129_size = 32,
128 } else switch (builtin.os.tag) {
129 .windows => .{
130 .a_align = 8,
131 .a_size = 16,
132
133 .b_align = 16,
134 .b_size = 32,
135
136 .u128_align = 8,
137 .u128_size = 16,
138 .u129_align = 8,
139 .u129_size = 24,
140 },
141 else => .{
142 .a_align = 4,
143 .a_size = 16,
144
145 .b_align = 16,
146 .b_size = 32,
147
148 .u128_align = 4,
149 .u128_size = 16,
150 .u129_align = 4,
151 .u129_size = 20,
152 },
153 },
154
155117 .mips64,
156118 .mips64el,
157119 .powerpc64,
......@@ -211,6 +173,7 @@ test "alignment and size of structs with 128-bit fields" {
211173 },
212174 },
213175
176 .x86,
214177 .aarch64,
215178 .aarch64_be,
216179 .aarch64_32,