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


On 10/07/2015 12:45 PM, Christian Bruel wrote:


On 10/07/2015 12:18 PM, Bernd Schmidt wrote:
On 10/07/2015 09:04 AM, Christian Bruel wrote:
+      /* 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;
       }

That's a very odd-looking condition. Why the vbit location test?

This is for member functions to make sure that the lsb address is
reserved for the virtual function bit.

see cp/decl.c:

   /* If pointers to member functions use the least significant bit to
      indicate whether a function is virtual, ensure a pointer
      to this function will have that bit clear.  */
   if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn
       && TREE_CODE (type) == METHOD_TYPE
       && DECL_ALIGN (decl) < 2 * BITS_PER_UNIT)
     DECL_ALIGN (decl) = 2 * BITS_PER_UNIT;

This happens for instance on i386 that aligns member functions on 2
bytes, bigger than the one byte required boundary. So we cannot
re-layout bellow that.

Hmm, at least that would need to be spelled out in a comment, but I think this would better be abstracted as

#define MINIMUM_FUNCTION_BOUNDARY(FN) \
 ....
in a header file, and used in both places.


Bernd


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