aboutsummaryrefslogtreecommitdiff
path: root/src/Cache.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-05-03 23:44:32 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-05-04 17:34:16 -0700
commit259f784241fb44e0a1b570daaf31ba2b9f164106 (patch)
treeff024852310df27dfad242c12af8d8a77a290988 /src/Cache.zig
parent080e870a717124204cbfa58a1f29061a701b0362 (diff)
downloadzig-259f784241fb44e0a1b570daaf31ba2b9f164106.tar.gz
zig-259f784241fb44e0a1b570daaf31ba2b9f164106.zip
stage2: improve `@sizeOf` and `@alignOf` integers
Prior to this commit, the logic for ABI size and ABI alignment for integers was naive and incorrect. This results in wasted hardware as well as undefined behavior in the LLVM backend when we memset an incorrect number of bytes to 0xaa due to disagreeing with LLVM about the ABI size of integers. This commit introduces a "max int align" value which is different per Target. This value is used to derive the ABI size and alignment of all integers. This commit makes an interesting change from stage1, which treats 128-bit integers as 16-bytes aligned for x86_64-linux. stage1 is incorrect. The maximum integer alignment on this system is only 8 bytes. This change breaks the behavior test called "128-bit cmpxchg" because on that target, 128-bit cmpxchg does require a 16-bytes aligned pointer to a 128 bit integer. However, this alignment property does not belong on *all* 128 bit integers - only on the pointer type in the `@cmpxchg` builtin function prototype. The user can then use an alignment override annotation on a 128-bit integer variable or struct field to obtain such a pointer.
Diffstat (limited to 'src/Cache.zig')
0 files changed, 0 insertions, 0 deletions