This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH ARM]: PR67745: Fix function alignment after __attribute__ 2/2
- From: Christian Bruel <christian dot bruel at st dot com>
- To: <law at redhat dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>, <Ramana dot Radhakrishnan at arm dot com>, <kyrylo dot tkachov at arm dot com>, <richard dot earnshaw at arm dot com>
- Date: Wed, 7 Oct 2015 09:04:50 +0200
- Subject: Re: [PATCH ARM]: PR67745: Fix function alignment after __attribute__ 2/2
- Authentication-results: sourceware.org; auth=none
- References: <560A90F2 dot 5010708 at st dot com> <560C31CD dot 7060009 at redhat dot com> <560CDCD7 dot 9080108 at st dot com> <560D5B36 dot 2020600 at st dot com>
The ARM target can switch different alignment requirements between the
thumb or arm, thanks to the attribute ((target)). Using
FUNCTION_BOUNDARY that now depends on the switchable target_flag.
The previous attempt to fix this was to use the set_current_function
hook to reset DECL_ALIGN. On a second thought I found this not
satisfactory because this hook is called multiple time between passes,
whereas the setting only needs to be done once.
Instead, this patch resets the function's DECL_ALIGN in
allocate_struct_function, when not enforced by the user or the language,
after the attributes are processed.
Tested for arm-none-eabi (with the 1/2 part
https://gcc.gnu.org/ml/gcc-patches/2015-09/msg02198.html)
Bootstraped for x86_64-unknown-linux-gnu and tested (c+,c++,fortran)
Comments ? OK for trunk ?
thanks
Christian
2015-10-07 Christian Bruel <christian.bruel@st.com>
PR target/67745
* function.c (allocate_struct_function): Relayout function's alignment.
Index: gcc/function.c
===================================================================
--- gcc/function.c (revision 228515)
+++ gcc/function.c (working copy)
@@ -4840,6 +4840,12 @@ allocate_struct_function (tree fndecl, b
for (tree parm = DECL_ARGUMENTS (fndecl); parm;
parm = DECL_CHAIN (parm))
relayout_decl (parm);
+
+ /* Similarly, relayout function's alignment if not forced. */
+ if (!DECL_USER_ALIGN (fndecl)
+ && (TREE_CODE (fntype) != METHOD_TYPE
+ || TARGET_PTRMEMFUNC_VBIT_LOCATION != ptrmemfunc_vbit_in_pfn))
+ DECL_ALIGN (fndecl) = FUNCTION_BOUNDARY;
}
if (!abstract_p && aggregate_value_p (result, fndecl))