Skip to content

Commit 200e06b

Browse files
committed
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.
1 parent 927f24a commit 200e06b

File tree

2 files changed

+2
-43
lines changed

2 files changed

+2
-43
lines changed

src/type.zig

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -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,

0 commit comments

Comments
 (0)