This fixes two issues where Clang was both over- and under-aligning
variables:
1) We were applying the x86_64 Sys V psABI "large array" alignment increase
(default when inheriting from X86_64TargetInfo), but MSVC doesn't follow
that ABI.
2) MSVC implements a similar scheme though, where it increases the
alignment of large objects. This is documented for ARM64 [1] and was
implemented in Clang b7c6d95af5, but it
also applies to x86_64. ([2] says "MSVC does size (total size, not
element size) based alignment for global symbols on ARM64 *which is
copied from AMD64*").
This patch stops doing 1) and implements 2) for x86_64-windows-msvc.
[1]
https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#alignment
[2] https://github.com/llvm/llvm-project/issues/40851
Fixes https://github.com/llvm/llvm-project/issues/196071
Fixes https://github.com/llvm/llvm-project/issues/171855
28 lines
996 B
C++
28 lines
996 B
C++
// RUN: %clang_cc1 -triple aarch64-windows-msvc -emit-llvm -o - %s | FileCheck %s
|
|
// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -o - %s | FileCheck %s
|
|
|
|
struct size1 { char str[1]; };
|
|
struct size2 { char str[2]; };
|
|
struct size7 { char str[7]; };
|
|
struct size8 { char str[8]; };
|
|
struct size63 { char str[63]; };
|
|
struct size64 { char str[64]; };
|
|
|
|
struct size1 s1;
|
|
// CHECK: @"?s1@@3Usize1@@A" = dso_local global %struct.size1 zeroinitializer, align 1
|
|
|
|
struct size2 s2;
|
|
// CHECK: @"?s2@@3Usize2@@A" = dso_local global %struct.size2 zeroinitializer, align 4
|
|
|
|
struct size7 s7;
|
|
// CHECK: @"?s7@@3Usize7@@A" = dso_local global %struct.size7 zeroinitializer, align 4
|
|
|
|
struct size8 s8;
|
|
// CHECK: @"?s8@@3Usize8@@A" = dso_local global %struct.size8 zeroinitializer, align 8
|
|
|
|
struct size63 s63;
|
|
// CHECK: @"?s63@@3Usize63@@A" = dso_local global %struct.size63 zeroinitializer, align 8
|
|
|
|
struct size64 s64;
|
|
// CHECK: @"?s64@@3Usize64@@A" = dso_local global %struct.size64 zeroinitializer, align 16
|