From d909af3e2469aad87d5c3e79b93c778fd26c03a9 Mon Sep 17 00:00:00 2001 From: Andrew Hsieh Date: Wed, 15 May 2013 10:30:44 +0800 Subject: Fix ARM/GCC-4.7,4.8 generates insufficient alignment for NEON vst/vld GCC allocates memory buffer and passes it as the first hidden argument for function return large composite type (ie. > 4 bytes for all NDK toolchain). Problem is that GCC doesn't observe the aligement required by the type, and ARM EABI only requires stack to be aligned to 8-byte. Please see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57271 for external bug tracking this issue and testcase. This CL offers temp relief before formal one Change-Id: I8004bc4208487e539ba8b0c9686c44ac86c37d83 --- gcc-4.7/gcc/config/arm/arm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'gcc-4.7') diff --git a/gcc-4.7/gcc/config/arm/arm.c b/gcc-4.7/gcc/config/arm/arm.c index 8d36af8e5..a30960681 100644 --- a/gcc-4.7/gcc/config/arm/arm.c +++ b/gcc-4.7/gcc/config/arm/arm.c @@ -17719,9 +17719,13 @@ arm_print_operand (FILE *stream, rtx x, int code) memsize = MEM_SIZE (x); /* Only certain alignment specifiers are supported by the hardware. */ - if (memsize == 32 && (align % 32) == 0) + /* Note that ARM EABI only guarentees 8-byte stack alignment. While GCC + honors stricter alignment of composite type in user code, it doesn't + observe the alignment of memory passed as an extra argument for function + returning large composite type. See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57271 */ + if (memsize == 32 && (align % 32) == 0 && !TARGET_AAPCS_BASED) align_bits = 256; - else if ((memsize == 16 || memsize == 32) && (align % 16) == 0) + else if ((memsize == 16 || memsize == 32) && (align % 16) == 0 && !TARGET_AAPCS_BASED) align_bits = 128; else if (memsize >= 8 && (align % 8) == 0) align_bits = 64; -- cgit v1.2.3