Replace checking user_defined_section_attribute with directly checking
DECL_SECTION_NAME. The former does not work in the presence of IPA.

See also: discussion on the same patch in Google branch:
https://gcc.gnu.org/ml/gcc-patches/2014-08/msg00749.html

--

2014-08-11  Yi Yang  <ahyan...@google.com>

gcc:
    * bb-reorder.c (pass_partition_blocks::gate): Replace check.
    * c-family/c-common.c (handle_section_attribute): Remove
user_defined_section_attribute
    * final.c (rest_of_handle_final): ditto
    * toplev.c (user_defined_section_attribute): ditto
    * toplev.h (user_defined_section_attribute): ditto

diff --git gcc/bb-reorder.c gcc/bb-reorder.c
index 96547c2..747831c 100644
--- gcc/bb-reorder.c
+++ gcc/bb-reorder.c
@@ -95,7 +95,6 @@
 #include "expr.h"
 #include "params.h"
 #include "diagnostic-core.h"
-#include "toplev.h" /* user_defined_section_attribute */
 #include "tree-pass.h"
 #include "df.h"
 #include "bb-reorder.h"
@@ -2671,11 +2670,9 @@ pass_partition_blocks::gate (function *fun)
      arises.  */
   return (flag_reorder_blocks_and_partition
   && optimize
-  /* 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);
+  && !DECL_SECTION_NAME (current_function_decl));
 }

 unsigned
diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c
index acc9a20..967ae2b 100644
--- gcc/c-family/c-common.c
+++ gcc/c-family/c-common.c
@@ -7395,8 +7395,6 @@ handle_section_attribute (tree *node, tree
ARG_UNUSED (name), tree args,

   if (targetm_common.have_named_sections)
     {
-      user_defined_section_attribute = true;
-
       if ((TREE_CODE (decl) == FUNCTION_DECL
    || TREE_CODE (decl) == VAR_DECL)
   && TREE_CODE (TREE_VALUE (args)) == STRING_CST)
diff --git gcc/final.c gcc/final.c
index 304ae2a..3fee226 100644
--- gcc/final.c
+++ gcc/final.c
@@ -4460,8 +4460,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 gcc/toplev.c gcc/toplev.c
index 88d48c2..07d5e05 100644
--- gcc/toplev.c
+++ gcc/toplev.c
@@ -152,11 +152,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 gcc/toplev.h gcc/toplev.h
index 1b54578..b0d0ca4 100644
--- gcc/toplev.h
+++ gcc/toplev.h
@@ -53,11 +53,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;

--

Reply via email to