public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gcc-patches@gcc.gnu.org
Cc: Andrew Burgess <andrew.burgess@embecosm.com>
Subject: [PATCH 1/2] gcc: Remove unneeded global flag.
Date: Fri, 10 Jun 2016 16:56:00 -0000	[thread overview]
Message-ID: <a3ed605cdecc22d1c5ff91d90b4856574fea2139.1465577682.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <cover.1465577682.git.andrew.burgess@embecosm.com>
In-Reply-To: <cover.1465577682.git.andrew.burgess@embecosm.com>

The global flag `user_defined_section_attribute' is set while parsing C
code when the section attribute is encountered.  The flag is set when
anything has the section attribute applied to it, functions or data.

The only place this global was used was within the gate function for
partitioning blocks (pass_partition_blocks::gate), however, the
partitioning is done during compilation, while the flag is set earlier,
during the parsing.  The flag is then cleared again during the final
compilation pass.

The result is that if any function or data has a section attribute then
the flag will be set to true during the file parse pass.  The first
compiled function will then skip the partition-blocks pass, and the flag
will be set back to false during the final-pass on the first function.
After then, the flag is never set to true again.

The guarding of the partition-blocks pass does not appear to be
necessary, given that applying a section attribute correctly
overrides the hot/cold section partitioning (this is taken care if in
varasm.c).

gcc/ChangeLog:

	* gcc/bb-reorder.c: Remove 'toplev.h' include.
	(pass_partition_blocks::gate): No longer check
	user_defined_section_attribute.
	* gcc/c-family/c-common.c (handle_section_attribute): No longer
	set user_defined_section_attribute.
	* gcc/final.c (rest_of_handle_final): Likewise.
	* gcc/toplev.c: Remove definition of user_defined_section_attribute.
	* gcc/toplev.h: Remove declaration of
	user_defined_section_attribute.
---
 gcc/ChangeLog           | 12 ++++++++++++
 gcc/bb-reorder.c        |  4 +---
 gcc/c-family/c-common.c |  2 --
 gcc/final.c             |  2 --
 gcc/toplev.c            |  5 -----
 gcc/toplev.h            |  5 -----
 6 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c
index 5fb60bd..04874da 100644
--- a/gcc/bb-reorder.c
+++ b/gcc/bb-reorder.c
@@ -106,7 +106,6 @@
 #include "output.h"
 #include "expr.h"
 #include "params.h"
-#include "toplev.h" /* user_defined_section_attribute */
 #include "tree-pass.h"
 #include "cfgrtl.h"
 #include "cfganal.h"
@@ -2889,8 +2888,7 @@ pass_partition_blocks::gate (function *fun)
 	  /* See gate_handle_reorder_blocks.  We should not partition if
 	     we are going to omit the reordering.  */
 	  && optimize_function_for_speed_p (fun)
-	  && !DECL_COMDAT_GROUP (current_function_decl)
-	  && !user_defined_section_attribute);
+	  && !DECL_COMDAT_GROUP (current_function_decl));
 }
 
 unsigned
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 94005ff..66add18 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -7617,8 +7617,6 @@ handle_section_attribute (tree *node, tree ARG_UNUSED (name), tree args,
       goto fail;
     }
 
-  user_defined_section_attribute = true;
-
   if (!VAR_OR_FUNCTION_DECL_P (decl))
     {
       error ("section attribute not allowed for %q+D", *node);
diff --git a/gcc/final.c b/gcc/final.c
index 5b04311..256ce34 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -4454,8 +4454,6 @@ rest_of_handle_final (void)
 
   assemble_end_function (current_function_decl, fnname);
 
-  user_defined_section_attribute = false;
-
   /* Free up reg info memory.  */
   free_reg_info ();
 
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 543b8a3..868eecf 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -148,11 +148,6 @@ HOST_WIDE_INT random_seed;
    the support provided depends on the backend.  */
 rtx stack_limit_rtx;
 
-/* True if the user has tagged the function with the 'section'
-   attribute.  */
-
-bool user_defined_section_attribute = false;
-
 struct target_flag_state default_target_flag_state;
 #if SWITCHABLE_TARGET
 struct target_flag_state *this_target_flag_state = &default_target_flag_state;
diff --git a/gcc/toplev.h b/gcc/toplev.h
index 06923cf..f62a172 100644
--- a/gcc/toplev.h
+++ b/gcc/toplev.h
@@ -74,11 +74,6 @@ extern void target_reinit (void);
 /* A unique local time stamp, might be zero if none is available.  */
 extern unsigned local_tick;
 
-/* True if the user has tagged the function with the 'section'
-   attribute.  */
-
-extern bool user_defined_section_attribute;
-
 /* See toplev.c.  */
 extern int flag_rerun_cse_after_global_opts;
 
-- 
2.6.4

  reply	other threads:[~2016-06-10 16:56 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-10 16:56 [PATCH 0/2] Remove user_defined_section_attribute global Andrew Burgess
2016-06-10 16:56 ` Andrew Burgess [this message]
2016-06-22  2:55   ` [PATCH 1/2] gcc: Remove unneeded global flag Jeff Law
2016-06-22  6:02     ` Jakub Jelinek
2016-06-29 19:33     ` Andrew Burgess
2016-09-14 13:05       ` Ping: " Andrew Burgess
2016-09-14 13:08         ` Jakub Jelinek
2016-09-15 14:30           ` Andrew Burgess
2016-10-28 15:58             ` Jeff Law
2016-10-28 16:15               ` Andrew Burgess
2016-11-03 12:01         ` Bernd Schmidt
2016-11-16 20:09           ` Andrew Burgess
2016-11-16 21:00             ` Mike Stump
2016-11-16 22:12               ` Andrew Burgess
2016-11-17 17:59                 ` Jeff Law
2016-11-18 12:22                 ` Christophe Lyon
2016-11-19 21:59                   ` Andrew Burgess
2016-11-20 17:27                     ` Mike Stump
2016-11-21 12:47                       ` Christophe Lyon
2016-11-24 21:40                         ` Andrew Burgess
2016-11-28 22:09                           ` Jeff Law
2016-11-29 14:03                             ` Andrew Burgess
2016-11-29 17:36                               ` Jeff Law
2016-11-30 11:40                                 ` Andrew Burgess
2016-06-10 16:57 ` [PATCH 2/2] gcc: Update comment in bb-reorder.c Andrew Burgess
2016-06-22  2:59   ` 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=a3ed605cdecc22d1c5ff91d90b4856574fea2139.1465577682.git.andrew.burgess@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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).