From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 104302 invoked by alias); 29 Sep 2015 13:16:11 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 104291 invoked by uid 89); 29 Sep 2015 13:16:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL,BAYES_00,KAM_ASCII_DIVIDERS,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: mx07-00178001.pphosted.com Received: from mx07-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (62.209.51.94) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 29 Sep 2015 13:16:08 +0000 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.14.5/8.14.5) with SMTP id t8TDEMhp017133; Tue, 29 Sep 2015 15:16:03 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 1x6pr3rkby-1 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 29 Sep 2015 15:16:02 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 4A16534; Tue, 29 Sep 2015 13:15:44 +0000 (GMT) Received: from Webmail-eu.st.com (safex1hubcas4.st.com [10.75.90.69]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 9F16C26B9; Tue, 29 Sep 2015 13:16:00 +0000 (GMT) Received: from [164.129.122.197] (164.129.122.197) by webmail-eu.st.com (10.75.90.13) with Microsoft SMTP Server (TLS) id 8.3.342.0; Tue, 29 Sep 2015 15:15:59 +0200 From: Christian Bruel Subject: [PATCH ARM]: PR67745: Fix function alignment after __attribute__ 1/2 To: , CC: X-Enigmail-Draft-Status: N1110 X-No-Archive: yes Message-ID: <560A8F0F.7090704@st.com> Date: Tue, 29 Sep 2015 13:39:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------000001040209010908010702" X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.14.151,1.0.33,0.0.0000 definitions=2015-09-29_09:2015-09-29,2015-09-29,1970-01-01 signatures=0 X-IsSubscribed: yes X-SW-Source: 2015-09/txt/msg02202.txt.bz2 --------------000001040209010908010702 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Content-length: 458 This patch is the ARM part to make the function's alignment more sensible to current function attributes that depends on both opts->target_flags and opts->x_optimize_size. - Does not change FUNCTION_BOUNDARY's value between functions for a given ABI (arm or thumb). Setting done per function with override_options. - Implements the TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE hook to track aligns between functions. No regressions for arm-none-eabi. Christian --------------000001040209010908010702 Content-Type: text/x-patch; name="align.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="align.patch" Content-length: 5672 2015-09-29 Christian Bruel PR target/67745 * config/arm/arm.h (FUNCTION_BOUNDARY): Move optimize_size condition to: * config/arm/arm.c (arm_option_override_internal): Call arm_override_options_after_change_1. (arm_override_options_after_change): New function. (arm_override_options_after_change_1): Likewise. (TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE): Define hook. 2015-09-29 Christian Bruel PR target/67745 * gcc.target/arm/attr-align1.c: New test. * gcc.target/arm/attr-align2.c: New test. * gcc.target/arm/attr-align3.c: New test. Index: gcc/config/arm/arm.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/config/arm/arm.c (revision 228229) +++ gcc/config/arm/arm.c (working copy) @@ -246,6 +246,7 @@ static tree arm_build_builtin_va_list (v static void arm_expand_builtin_va_start (tree, rtx); static tree arm_gimplify_va_arg_expr (tree, tree, gimple_seq *, gimple_seq= *); static void arm_option_override (void); +static void arm_override_options_after_change (void); static void arm_option_print (FILE *, int, struct cl_target_option *); static void arm_set_current_function (tree); static bool arm_can_inline_p (tree, tree); @@ -407,6 +408,9 @@ static const struct attribute_spec arm_a #undef TARGET_OPTION_OVERRIDE #define TARGET_OPTION_OVERRIDE arm_option_override =20 +#undef TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE +#define TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE arm_override_options_after_ch= ange + #undef TARGET_OPTION_PRINT #define TARGET_OPTION_PRINT arm_option_print =20 @@ -2810,11 +2814,29 @@ static GTY(()) bool thumb_flipper; /* Options after initial target override. */ static GTY(()) tree init_optimize; =20 +static void +arm_override_options_after_change_1 (struct gcc_options *opts) +{ + if (opts->x_align_functions <=3D 0) + opts->x_align_functions =3D TARGET_THUMB_P (opts->x_target_flags) + && opts->x_optimize_size ? 2 : 4; +} + +/* Implement targetm.override_options_after_change. */ + +static void +arm_override_options_after_change (void) +{ + arm_override_options_after_change_1 (&global_options); +} + /* Reset options between modes that the user has specified. */ static void arm_option_override_internal (struct gcc_options *opts, struct gcc_options *opts_set) { + arm_override_options_after_change_1 (opts); + if (TARGET_THUMB_P (opts->x_target_flags) && !(ARM_FSET_HAS_CPU1 (insn_flags, FL_THUMB))) { Index: gcc/config/arm/arm.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/config/arm/arm.h (revision 228229) +++ gcc/config/arm/arm.h (working copy) @@ -565,7 +565,7 @@ extern int arm_arch_crc; #define PREFERRED_STACK_BOUNDARY \ (arm_abi =3D=3D ARM_ABI_ATPCS ? 64 : STACK_BOUNDARY) =20 -#define FUNCTION_BOUNDARY ((TARGET_THUMB && optimize_size) ? 16 : 32) +#define FUNCTION_BOUNDARY (TARGET_THUMB ? 16 : 32) =20 /* The lowest bit is used to indicate Thumb-mode functions, so the vbit must go into the delta field of pointers to member Index: gcc/testsuite/gcc.target/arm/attr-align1.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/testsuite/gcc.target/arm/attr-align1.c (revision 0) +++ gcc/testsuite/gcc.target/arm/attr-align1.c (working copy) @@ -0,0 +1,13 @@ +/* PR target/67745 + Verify alignment when attribute target is used with -falign-functions. = */ +/* { dg-do compile } */ +/* { dg-options "-falign-functions=3D2" } */ + +/* Check that arm code is always 4 bytes aligned. */ +void __attribute__ ((target ("arm"))) +c(void) +{ +} + + +/* { dg-final { scan-assembler-not ".align\[ \t]*1" } } */ Index: gcc/testsuite/gcc.target/arm/attr-align2.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/testsuite/gcc.target/arm/attr-align2.c (revision 0) +++ gcc/testsuite/gcc.target/arm/attr-align2.c (working copy) @@ -0,0 +1,15 @@ +/* PR target/67745 + Verify alignment when attribute optimize is used. */ +/* { dg-do compile } */ +/* { dg-skip-if "" { ! { arm_thumb1_ok || arm_thumb2_ok } } } */ +/* { dg-options "-O2 -mthumb" } */ + +/* Check that thumb code is always 2 bytes aligned for -Os. */ + +void +__attribute__ ((optimize("Os"))) +foo() +{ +} + +/* { dg-final { scan-assembler ".align\[ \t]*1" } } */ Index: gcc/testsuite/gcc.target/arm/attr-align3.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/testsuite/gcc.target/arm/attr-align3.c (revision 0) +++ gcc/testsuite/gcc.target/arm/attr-align3.c (working copy) @@ -0,0 +1,13 @@ +/* PR target/67745 + Verify alignment when attribute target is used. */ +/* { dg-do compile } */ +/* { dg-skip-if "" { ! { arm_thumb1_ok || arm_thumb2_ok } } } */ +/* { dg-options "-Os -mthumb" } */ + +/* Check that thumb code is always 4 bytes aligned. */ +void __attribute__ ((target ("arm"))) +c(void) +{ +} + +/* { dg-final { scan-assembler-not ".align\[ \t]*1" } } */ --------------000001040209010908010702--