public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/siemens/heads/gcc-10-lto-fixes)] middle-end: Disable section anchors for VAR_DECLs if -fdata-sections
@ 2021-11-11 16:18 Joseph Myers
  0 siblings, 0 replies; only message in thread
From: Joseph Myers @ 2021-11-11 16:18 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:4f7fd8abb9a423e7f21924fa898ab7033637067e

commit 4f7fd8abb9a423e7f21924fa898ab7033637067e
Author: David Edelsohn <dje.gcc@gmail.com>
Date:   Thu Apr 29 14:44:01 2021 -0400

    middle-end: Disable section anchors for VAR_DECLs if -fdata-sections
    
    -fdata-sections places data symbols into their own, unique, named sections.
    -fsection-anchors create an anchor to access neighboring symbols
    within a section.
    
    When both are enabled, a separate section anchor is created for each
    symbol, which provides no benefit.
    
    This patch updates the common gating function use_blocks_for_decl_p() to
    return false if -fdata-sections is enabled.
    
    gcc/ChangeLog:
    
            * varasm.c (use_blocks_for_decl_p): Don't use section anchors
            for VAR_DECLs if -fdata-sections enabled.
    
    (cherry picked from commit dc4202bd24fcc13dab80c4520cb53a2302c49929)

Diff:
---
 gcc/varasm.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gcc/varasm.c b/gcc/varasm.c
index 814d29a02de..72de5ca211a 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -1278,6 +1278,12 @@ use_blocks_for_decl_p (tree decl)
 {
   struct symtab_node *snode;
 
+  /* Don't create object blocks if each DECL is placed into a separate
+     section because that will uselessly create a section anchor for
+     each DECL.  */
+  if (flag_data_sections)
+    return false;
+
   /* Only data DECLs can be placed into object blocks.  */
   if (!VAR_P (decl) && TREE_CODE (decl) != CONST_DECL)
     return false;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-11 16:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-11 16:18 [gcc(refs/vendors/siemens/heads/gcc-10-lto-fixes)] middle-end: Disable section anchors for VAR_DECLs if -fdata-sections Joseph Myers

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