| author | |
| committer | |
| log | 200e06b2399d605c8d183e55649e39ba2c6b56f6 |
| tree | 9bdd2acf67740b9de522545abb8684e602181d22 |
| parent | 927f24a6ff4af55f79df54c392b906413eae1459 |
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 { | ... | @@ -1572,11 +1572,6 @@ pub const Type = struct { |
| 1572 | .wasm64, | 1572 | .wasm64, |
| 1573 | => 8, | 1573 | => 8, |
| 1574 | 1574 | ||
| 1575 | .x86 => if (target.ofmt == .c) 16 else return switch (target.os.tag) { | ||
| 1576 | .windows, .uefi => 8, | ||
| 1577 | else => 4, | ||
| 1578 | }, | ||
| 1579 | |||
| 1580 | // For these, LLVMABIAlignmentOfType(i128) reports 8. Note that 16 | 1575 | // For these, LLVMABIAlignmentOfType(i128) reports 8. Note that 16 |
| 1581 | // is a relevant number in three cases: | 1576 | // is a relevant number in three cases: |
| 1582 | // 1. Different machine code instruction when loading into SIMD register. | 1577 | // 1. Different machine code instruction when loading into SIMD register. |
| ... | @@ -1599,6 +1594,7 @@ pub const Type = struct { | ... | @@ -1599,6 +1594,7 @@ pub const Type = struct { |
| 1599 | }, | 1594 | }, |
| 1600 | 1595 | ||
| 1601 | // Even LLVMABIAlignmentOfType(i128) agrees on these targets. | 1596 | // Even LLVMABIAlignmentOfType(i128) agrees on these targets. |
| 1597 | .x86, | ||
| 1602 | .aarch64, | 1598 | .aarch64, |
| 1603 | .aarch64_be, | 1599 | .aarch64_be, |
| 1604 | .aarch64_32, | 1600 | .aarch64_32, |
test/behavior/align.zig+1-38| ... | @@ -114,44 +114,6 @@ test "alignment and size of structs with 128-bit fields" { | ... | @@ -114,44 +114,6 @@ test "alignment and size of structs with 128-bit fields" { |
| 114 | .u129_size = 24, | 114 | .u129_size = 24, |
| 115 | }, | 115 | }, |
| 116 | 116 | ||
| 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 | |||
| 155 | .mips64, | 117 | .mips64, |
| 156 | .mips64el, | 118 | .mips64el, |
| 157 | .powerpc64, | 119 | .powerpc64, |
| ... | @@ -211,6 +173,7 @@ test "alignment and size of structs with 128-bit fields" { | ... | @@ -211,6 +173,7 @@ test "alignment and size of structs with 128-bit fields" { |
| 211 | }, | 173 | }, |
| 212 | }, | 174 | }, |
| 213 | 175 | ||
| 176 | .x86, | ||
| 214 | .aarch64, | 177 | .aarch64, |
| 215 | .aarch64_be, | 178 | .aarch64_be, |
| 216 | .aarch64_32, | 179 | .aarch64_32, |