public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Christian Bruel <christian.bruel@st.com>
To: Bernd Schmidt <bschmidt@redhat.com>, "law@redhat.com" <law@redhat.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	       "Ramana.Radhakrishnan@arm.com"
	<Ramana.Radhakrishnan@arm.com>,
	       "kyrylo.tkachov@arm.com" <kyrylo.tkachov@arm.com>,
	       "richard.earnshaw@arm.com"	<richard.earnshaw@arm.com>
Subject: Re: [PATCH ARM]: PR67745: Fix function alignment after __attribute__ 2/2
Date: Thu, 08 Oct 2015 14:01:00 -0000	[thread overview]
Message-ID: <56167745.1080409@st.com> (raw)
In-Reply-To: <56155841.6000404@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1784 bytes --]



On 10/07/2015 07:37 PM, Bernd Schmidt wrote:
> 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.
>

OK, Similar pattern occurs at many other places, that changed also in 
the attached proposal.
Not fully tested (in particular the java part) and no ChangeLog. Just to 
make sure that we agree on the interface first.

Thanks

Christian

>
> Bernd
>

[-- Attachment #2: align5.patch --]
[-- Type: text/x-patch, Size: 3010 bytes --]

Index: gcc/builtins.c
===================================================================
304a305,306
>       tree fntype = exp ? TREE_TYPE (exp) : NULL_TREE;
> 
309,310c311,312
<       if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn)
< 	align = 2 * BITS_PER_UNIT;
---
>       align = MAX (minimum_function_boundary (exp), align);
> 
Index: gcc/cp/decl.c
===================================================================
7855,7858c7855
<   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;
---
>   DECL_ALIGN (decl) = MAX (minimum_function_boundary (decl), DECL_ALIGN (decl));
Index: gcc/cp/lambda.c
===================================================================
1010,1012c1010,1011
<   if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn
<       && DECL_ALIGN (fn) < 2 * BITS_PER_UNIT)
<     DECL_ALIGN (fn) = 2 * BITS_PER_UNIT;
---
>   extern int need_vptr_align (void);
>   DECL_ALIGN (fn) = MAX (minimum_function_boundary (fn), DECL_ALIGN (fn));
1045,1047c1044
<   if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn
<       && DECL_ALIGN (fn) < 2 * BITS_PER_UNIT)
<     DECL_ALIGN (fn) = 2 * BITS_PER_UNIT;
---
>   DECL_ALIGN (fn) = MAX (minimum_function_boundary (fn), DECL_ALIGN (fn));
Index: gcc/cp/method.c
===================================================================
1852c1852
<   
---
> 
1856,1858c1856
<   if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn
<       && DECL_ALIGN (fn) < 2 * BITS_PER_UNIT)
<     DECL_ALIGN (fn) = 2 * BITS_PER_UNIT;
---
>   DECL_ALIGN (fn) = MAX (minimum_function_boundary (fn), DECL_ALIGN (fn));
Index: gcc/function.c
===================================================================
4791a4792,4806
> unsigned int
> minimum_function_boundary (tree fndecl)
> {
>   gcc_assert (fndecl);
> 
>   tree fntype = TREE_TYPE (fndecl);
> 
>   if (TREE_CODE (fntype) == METHOD_TYPE
>       && TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn
>       && FUNCTION_BOUNDARY < 2 * BITS_PER_UNIT)
>       return 2 * BITS_PER_UNIT;
> 
>   return FUNCTION_BOUNDARY;
> }
> 
4842a4858,4861
> 
> 	  /* Similarly, relayout function's alignment if not forced.  */
> 	  if (!DECL_USER_ALIGN (fndecl))
> 	    DECL_ALIGN (fndecl) = minimum_function_boundary (fndecl);
Index: gcc/function.h
===================================================================
601c601
< 
---
> extern unsigned int minimum_function_boundary (tree);
Index: gcc/java/class.c
===================================================================
785,788c785,786
<   if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn
<       && !(access_flags & ACC_STATIC)
<       && DECL_ALIGN (fndecl) < 2 * BITS_PER_UNIT)
<     DECL_ALIGN (fndecl) = 2 * BITS_PER_UNIT;
---
>   if !(access_flags & ACC_STATIC)
>     DECL_ALIGN (fndecl) = MAX (minimum_function_boundary (decl), DECL_ALIGN (fndecl));

  parent reply	other threads:[~2015-10-08 14:01 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-29 13:44 Christian Bruel
2015-09-29 13:59 ` Christian Bruel
2015-09-30 19:30 ` Jeff Law
2015-10-01  7:12   ` Christian Bruel
2015-10-01 16:11     ` Christian Bruel
2015-10-07  7:05       ` Christian Bruel
2015-10-07 10:18         ` Bernd Schmidt
2015-10-07 10:45           ` Christian Bruel
2015-10-07 17:37             ` Bernd Schmidt
2015-10-07 17:50               ` Bernd Schmidt
2015-10-08 13:14                 ` Christian Bruel
2015-10-08 13:20                   ` Bernd Schmidt
2015-10-08 13:51                     ` Christian Bruel
2015-10-08 14:30                       ` Bernd Schmidt
2015-10-12 10:56                         ` Christian Bruel
2015-10-12 11:19                           ` Bernd Schmidt
2015-10-12 11:26                             ` Christian Bruel
2015-10-16  8:03                             ` refactoring TARGET_PTRMEMFUNC_VBIT_LOCATION checks Christian Bruel
2015-10-16  9:47                               ` Bernd Schmidt
2015-10-16 10:50                                 ` Christian Bruel
2015-10-16 10:56                                   ` Christian Bruel
2015-10-16 10:56                                   ` Bernd Schmidt
2015-10-13  8:03                           ` [PATCH ARM]: PR67745: Fix function alignment after __attribute__ 2/2 Ramana Radhakrishnan
2015-10-13 10:18                             ` Christian Bruel
2015-10-16 14:18                             ` Christian Bruel
2015-10-08 14:01               ` Christian Bruel [this message]
2015-10-08 14:05                 ` Bernd Schmidt
2015-10-07 17:40         ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56167745.1080409@st.com \
    --to=christian.bruel@st.com \
    --cc=Ramana.Radhakrishnan@arm.com \
    --cc=bschmidt@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=kyrylo.tkachov@arm.com \
    --cc=law@redhat.com \
    --cc=richard.earnshaw@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).