diff mbox

[GOOGLE] Fix the bug where implicit section names prevents function splitting

Message ID CADvRseaf+z02WcFFPWE_W5D2JyfDpp43BYEFOZyPMkojsBb1_Q@mail.gmail.com
State New
Headers show

Commit Message

Yi Yang Aug. 14, 2014, 4:03 a.m. UTC
This bug is caused by my last patch, which did not differentiate
between explicit section names (via attributes) and implicit section
names (via -ffunction-section).

This patch fixes that.

--

--

Comments

Teresa Johnson Aug. 14, 2014, 6:25 p.m. UTC | #1
On Wed, Aug 13, 2014 at 9:03 PM, Yi Yang <ahyangyi@google.com> wrote:
> This bug is caused by my last patch, which did not differentiate
> between explicit section names (via attributes) and implicit section
> names (via -ffunction-section).
>
> This patch fixes that.
>
> --
>
> diff --git gcc/bb-reorder.c gcc/bb-reorder.c
> index 8f8c420..2115b01 100644
> --- gcc/bb-reorder.c
> +++ gcc/bb-reorder.c
> @@ -2505,7 +2505,7 @@ gate_handle_partition_blocks (void)
>              we are going to omit the reordering.  */
>           && optimize_function_for_speed_p (cfun)
>           && !DECL_ONE_ONLY (current_function_decl)
> -         && !DECL_SECTION_NAME (current_function_decl));
> +         && !DECL_HAS_EXPLICIT_SECTION_NAME_P(current_function_decl));
>  }
>
>  /* This function is the main 'entrance' for the optimization that
> diff --git gcc/tree.h gcc/tree.h
> index 817507f..738675a 100644
> --- gcc/tree.h
> +++ gcc/tree.h
> @@ -3201,6 +3201,11 @@ struct GTY(()) tree_parm_decl {
>  #define DECL_HAS_IMPLICIT_SECTION_NAME_P(NODE) \
>    (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.implicit_section_name_p)
>
> +/* Speficy whether the section name was explicitly set with decl_attributes. */
> +#define DECL_HAS_EXPLICIT_SECTION_NAME_P(NODE) \
> +  (DECL_HAS_IMPLICIT_SECTION_NAME_P(NODE)? false: \
> +   !!DECL_SECTION_NAME(NODE))

Personally, I think it is clearer to simply write this as:

#define DECL_HAS_EXPLICIT_SECTION_NAME_P(NODE) \
    (DECL_SECTION_NAME(NODE) != NULL_TREE \
     && !DECL_HAS_IMPLICIT_SECTION_NAME_P(NODE))

Teresa

> +
>  struct GTY(()) tree_decl_with_vis {
>   struct tree_decl_with_rtl common;
>   tree assembler_name;
> --
diff mbox

Patch

diff --git gcc/bb-reorder.c gcc/bb-reorder.c
index 8f8c420..2115b01 100644
--- gcc/bb-reorder.c
+++ gcc/bb-reorder.c
@@ -2505,7 +2505,7 @@  gate_handle_partition_blocks (void)
             we are going to omit the reordering.  */
          && optimize_function_for_speed_p (cfun)
          && !DECL_ONE_ONLY (current_function_decl)
-         && !DECL_SECTION_NAME (current_function_decl));
+         && !DECL_HAS_EXPLICIT_SECTION_NAME_P(current_function_decl));
 }

 /* This function is the main 'entrance' for the optimization that
diff --git gcc/tree.h gcc/tree.h
index 817507f..738675a 100644
--- gcc/tree.h
+++ gcc/tree.h
@@ -3201,6 +3201,11 @@  struct GTY(()) tree_parm_decl {
 #define DECL_HAS_IMPLICIT_SECTION_NAME_P(NODE) \
   (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.implicit_section_name_p)

+/* Speficy whether the section name was explicitly set with decl_attributes. */
+#define DECL_HAS_EXPLICIT_SECTION_NAME_P(NODE) \
+  (DECL_HAS_IMPLICIT_SECTION_NAME_P(NODE)? false: \
+   !!DECL_SECTION_NAME(NODE))
+
 struct GTY(()) tree_decl_with_vis {
  struct tree_decl_with_rtl common;
  tree assembler_name;