This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH ARM]: PR67745: Fix function alignment after __attribute__ 2/2


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))

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]