From: Javed Absar Date: Wed, 7 Jun 2017 10:02:02 +0000 (+0000) Subject: [ARM] Fix Neon vector type alignment to 64-bit X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1f8a87749fa3809736ee58d9904112aeed0e4702;p=clang [ARM] Fix Neon vector type alignment to 64-bit This is restricted version of patch - https://reviews.llvm.org/D33205 that I reverted as it was leading to ABI breaks on darwin etc. This patch restricts the fix to AAPCS (Android remains 128-bit). Reviewed by: Renato Golin, Stephen Hines Differential Revision: https://reviews.llvm.org/D33786 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@304889 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index f939bfb339..a304a78354 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -5385,6 +5385,10 @@ public: // ARM has atomics up to 8 bytes setAtomic(); + // Maximum alignment for ARM NEON data types should be 64-bits (AAPCS) + if (IsAAPCS && (Triple.getEnvironment() != llvm::Triple::Android)) + MaxVectorAlign = 64; + // Do force alignment of members that follow zero length bitfields. If // the alignment of the zero-length bitfield is greater than the member // that follows it, `bar', `bar' will be aligned as the type of the diff --git a/test/CodeGen/neon-aapcs-align.c b/test/CodeGen/neon-aapcs-align.c new file mode 100644 index 0000000000..4b7e5ff4d3 --- /dev/null +++ b/test/CodeGen/neon-aapcs-align.c @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -triple armv7a-none-eabi -target-feature +neon -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=AAPCS +// RUN: %clang_cc1 -triple armv7a-none-gnueabi -target-feature +neon -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=AAPCS +// RUN: %clang_cc1 -triple armv7a-none-freebsd -target-feature +neon -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=AAPCS + +// RUN: %clang_cc1 -triple armv7a-apple-ios -target-feature +neon -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=DEFAULT +// RUN: %clang_cc1 -triple armv7a-none-android -target-feature +neon -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=DEFAULT +// RUN: %clang_cc1 -triple armv7a-none-androideabi -target-feature +neon -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=DEFAULT + +#include +// Neon types have 64-bit alignment +int32x4_t gl_b; +void t3(int32x4_t *src) { +// CHECK: @t3 + gl_b = *src; +// AAPCS: store <4 x i32> {{%.*}}, <4 x i32>* @gl_b, align 8 +// DEFAULT: store <4 x i32> {{%.*}}, <4 x i32>* @gl_b, align 16 +}