Skip to content

Commit 81c441f

Browse files
committed
remove incorrect assert regarding 128-bit integers
LLVM incorrectly reports 8 as the alignment of i128 on x86_64 but it correctly reports 16 as the alignment of i128 on aarch64. closes #3101
1 parent 3b5a885 commit 81c441f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/analyze.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6051,12 +6051,12 @@ ZigType *make_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits) {
60516051
entry->abi_size = LLVMABISizeOfType(g->target_data_ref, entry->llvm_type);
60526052
entry->abi_align = LLVMABIAlignmentOfType(g->target_data_ref, entry->llvm_type);
60536053

6054-
if (size_in_bits >= 128) {
6054+
if (size_in_bits >= 128 && entry->abi_align < 16) {
60556055
// Override the incorrect alignment reported by LLVM. Clang does this as well.
60566056
// On x86_64 there are some instructions like CMPXCHG16B which require this.
60576057
// On all targets, integers 128 bits and above have ABI alignment of 16.
6058+
// However for some targets, LLVM incorrectly reports this as 8.
60586059
// See: https://github.com/ziglang/zig/issues/2987
6059-
assert(entry->abi_align == 8); // if this trips we can remove the workaround
60606060
entry->abi_align = 16;
60616061
}
60626062
}

0 commit comments

Comments
 (0)