diff mbox

Don't use section anchors for declarations that don't fit in a single anchor range

Message ID AM4PR0802MB22740240D3C6DAED27731737FF130@AM4PR0802MB2274.eurprd08.prod.outlook.com
State New
Headers show

Commit Message

Tamar Christina Aug. 16, 2016, 2:01 p.m. UTC
Hi All,

This patch turns off the usage of section anchors for
declarations that do not fit in a single anchor range.
A large enough object will use the full anchor range
and also force the use of another anchor pointer.

By not using an anchor for large objects more globals
can share the same anchor.

The patch has been benchmarked using Spec2000 and
the impact on performance is negligible, however some files
using large arrays showed a appreciable reduction in amount of
instructions in the assembly file.

Regression tests were run on aarch64-none-elf and no regressions.

Ok for trunk?

2016-08-16  Tamar Christina  <tamar.christina@arm.com>
        Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>

    * gcc/varasm.c
    (default_use_anchors_for_symbol_p): Reject too large decls.

Thanks,
Tamar

Comments

Jeff Law Aug. 16, 2016, 4:06 p.m. UTC | #1
On 08/16/2016 08:01 AM, Tamar Christina wrote:
>
> Hi All,
>
> This patch turns off the usage of section anchors for
> declarations that do not fit in a single anchor range.
> A large enough object will use the full anchor range
> and also force the use of another anchor pointer.
>
> By not using an anchor for large objects more globals
> can share the same anchor.
>
> The patch has been benchmarked using Spec2000 and
> the impact on performance is negligible, however some files
> using large arrays showed a appreciable reduction in amount of
> instructions in the assembly file.
>
> Regression tests were run on aarch64-none-elf and no regressions.
>
> Ok for trunk?
>
> 2016-08-16  Tamar Christina  <tamar.christina@arm.com>
>         Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
>
>     * gcc/varasm.c
>     (default_use_anchors_for_symbol_p): Reject too large decls.
Do you have to worry about DECL_SIZE being non-constant here or are 
those filtered out earlier?

jeff
Richard Biener Aug. 17, 2016, 8:23 a.m. UTC | #2
On Tue, Aug 16, 2016 at 6:06 PM, Jeff Law <law@redhat.com> wrote:
> On 08/16/2016 08:01 AM, Tamar Christina wrote:
>>
>>
>> Hi All,
>>
>> This patch turns off the usage of section anchors for
>> declarations that do not fit in a single anchor range.
>> A large enough object will use the full anchor range
>> and also force the use of another anchor pointer.
>>
>> By not using an anchor for large objects more globals
>> can share the same anchor.
>>
>> The patch has been benchmarked using Spec2000 and
>> the impact on performance is negligible, however some files
>> using large arrays showed a appreciable reduction in amount of
>> instructions in the assembly file.
>>
>> Regression tests were run on aarch64-none-elf and no regressions.
>>
>> Ok for trunk?
>>
>> 2016-08-16  Tamar Christina  <tamar.christina@arm.com>
>>         Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
>>
>>     * gcc/varasm.c
>>     (default_use_anchors_for_symbol_p): Reject too large decls.
>
> Do you have to worry about DECL_SIZE being non-constant here or are those
> filtered out earlier?

Globals can't have variable size.

Richard.

> jeff
Richard Earnshaw (lists) Aug. 17, 2016, 10:13 a.m. UTC | #3
On 17/08/16 09:23, Richard Biener wrote:
> On Tue, Aug 16, 2016 at 6:06 PM, Jeff Law <law@redhat.com> wrote:
>> On 08/16/2016 08:01 AM, Tamar Christina wrote:
>>>
>>>
>>> Hi All,
>>>
>>> This patch turns off the usage of section anchors for
>>> declarations that do not fit in a single anchor range.
>>> A large enough object will use the full anchor range
>>> and also force the use of another anchor pointer.
>>>
>>> By not using an anchor for large objects more globals
>>> can share the same anchor.
>>>
>>> The patch has been benchmarked using Spec2000 and
>>> the impact on performance is negligible, however some files
>>> using large arrays showed a appreciable reduction in amount of
>>> instructions in the assembly file.
>>>
>>> Regression tests were run on aarch64-none-elf and no regressions.
>>>
>>> Ok for trunk?
>>>
>>> 2016-08-16  Tamar Christina  <tamar.christina@arm.com>
>>>         Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
>>>
>>>     * gcc/varasm.c
>>>     (default_use_anchors_for_symbol_p): Reject too large decls.
>>
>> Do you have to worry about DECL_SIZE being non-constant here or are those
>> filtered out earlier?
> 
> Globals can't have variable size.
> 

And Common variables (which may change size at link time) can't go in
anchor groups.  Nor, for that matter, can anything that's preemtible at
link time.

R.


> Richard.
> 
>> jeff
>
Jeff Law Aug. 18, 2016, 3:09 a.m. UTC | #4
On 08/17/2016 02:23 AM, Richard Biener wrote:
> On Tue, Aug 16, 2016 at 6:06 PM, Jeff Law <law@redhat.com> wrote:
>> On 08/16/2016 08:01 AM, Tamar Christina wrote:
>>>
>>>
>>> Hi All,
>>>
>>> This patch turns off the usage of section anchors for
>>> declarations that do not fit in a single anchor range.
>>> A large enough object will use the full anchor range
>>> and also force the use of another anchor pointer.
>>>
>>> By not using an anchor for large objects more globals
>>> can share the same anchor.
>>>
>>> The patch has been benchmarked using Spec2000 and
>>> the impact on performance is negligible, however some files
>>> using large arrays showed a appreciable reduction in amount of
>>> instructions in the assembly file.
>>>
>>> Regression tests were run on aarch64-none-elf and no regressions.
>>>
>>> Ok for trunk?
>>>
>>> 2016-08-16  Tamar Christina  <tamar.christina@arm.com>
>>>         Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
>>>
>>>     * gcc/varasm.c
>>>     (default_use_anchors_for_symbol_p): Reject too large decls.
>>
>> Do you have to worry about DECL_SIZE being non-constant here or are those
>> filtered out earlier?
>
> Globals can't have variable size.
Duh.  You're obviously correct.

Patch is OK for the trunk.

jeff
James Greenhalgh Aug. 18, 2016, 8:47 a.m. UTC | #5
On Wed, Aug 17, 2016 at 09:09:07PM -0600, Jeff Law wrote:
> On 08/17/2016 02:23 AM, Richard Biener wrote:
> >On Tue, Aug 16, 2016 at 6:06 PM, Jeff Law <law@redhat.com> wrote:
> >>On 08/16/2016 08:01 AM, Tamar Christina wrote:
> >>>
> >>>
> >>>Hi All,
> >>>
> >>>This patch turns off the usage of section anchors for
> >>>declarations that do not fit in a single anchor range.
> >>>A large enough object will use the full anchor range
> >>>and also force the use of another anchor pointer.
> >>>
> >>>By not using an anchor for large objects more globals
> >>>can share the same anchor.
> >>>
> >>>The patch has been benchmarked using Spec2000 and
> >>>the impact on performance is negligible, however some files
> >>>using large arrays showed a appreciable reduction in amount of
> >>>instructions in the assembly file.
> >>>
> >>>Regression tests were run on aarch64-none-elf and no regressions.
> >>>
> >>>Ok for trunk?
> >>>
> >>>2016-08-16  Tamar Christina  <tamar.christina@arm.com>
> >>>        Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
> >>>
> >>>    * gcc/varasm.c
> >>>    (default_use_anchors_for_symbol_p): Reject too large decls.
> >>
> >>Do you have to worry about DECL_SIZE being non-constant here or are those
> >>filtered out earlier?
> >
> >Globals can't have variable size.
> Duh.  You're obviously correct.
> 
> Patch is OK for the trunk.

Tamar's not yet got commit rights, so I've committed this on his behalf as
r239561.

Thanks for the review!

James
diff mbox

Patch

:100644 100644 e747d2c... 00a9b30... M	gcc/varasm.c

diff --git a/gcc/varasm.c b/gcc/varasm.c
index e747d2c..00a9b30 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -6793,6 +6793,15 @@  default_use_anchors_for_symbol_p (const_rtx symbol)
 	 sections that should be marked as small in the section directive.  */
       if (targetm.in_small_data_p (decl))
 	return false;
+
+      /* Don't use section anchors for decls that won't fit inside a single
+	 anchor range to reduce the amount of instructions require to refer
+	 to the entire declaration.  */
+      if (decl && DECL_SIZE (decl)
+	 && tree_to_shwi (DECL_SIZE (decl))
+	    >= (targetm.max_anchor_offset * BITS_PER_UNIT))
+	return false;
+
     }
   return true;
 }