Patch v2.

Trunk no longer set SECTION_NAME for implicit section names, so this
probably does not apply to trunk. It's probably not necessary for
trunk either.

Tested for Google 4.8(albeit unnecessary) and 4.9 branch.

diff --git gcc/bb-reorder.c gcc/bb-reorder.c
index a1b3e65..b9a829e 100644
--- gcc/bb-reorder.c
+++ gcc/bb-reorder.c
@@ -2554,7 +2554,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 b656b7b..308eef8 100644
--- gcc/tree.h
+++ gcc/tree.h
@@ -2405,6 +2405,11 @@ extern void decl_value_expr_insert (tree, tree);
 #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_SECTION_NAME(NODE) != NULL_TREE \
+   && !DECL_HAS_IMPLICIT_SECTION_NAME_P(NODE))
+
 extern tree decl_debug_expr_lookup (tree);
 extern void decl_debug_expr_insert (tree, tree);

-- 

On Thu, Aug 14, 2014 at 11:25 AM, Teresa Johnson <tejohn...@google.com> wrote:
> On Wed, Aug 13, 2014 at 9:03 PM, Yi Yang <ahyan...@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;
>> --
>
>
>
> --
> Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413

Reply via email to