From: David Edelsohn Date: Thu, 29 Apr 2021 18:44:01 +0000 (-0400) Subject: middle-end: Disable section anchors for VAR_DECLs if -fdata-sections X-Git-Tag: basepoints/gcc-13~7987 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc4202bd24fcc13dab80c4520cb53a2302c49929;p=thirdparty%2Fgcc.git 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. --- diff --git a/gcc/varasm.c b/gcc/varasm.c index 3ecf9e039bb9..ac256ef65e5c 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -1340,6 +1340,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;