diff mbox

[GOOGLE] recalculate dominance before update_ssa in AutoFDO pass

Message ID CAO2gOZVffcvf5HitLrfX+cmb4EZWDfEJRcYCFvrSiBhNn_nsgw@mail.gmail.com
State New
Headers show

Commit Message

Dehao Chen Oct. 15, 2014, 11 p.m. UTC
It's destroyed by gimple_value_profile_transformations.

Patch updated to move the update_ssa early.


Dehao

On Wed, Oct 15, 2014 at 10:50 AM, Xinliang David Li <davidxl@google.com> wrote:
> Is it destroyed by value profile transformations? Can you move the
> dominance recomputing code closer to where it gets invalidated?
>
> David
>
> On Wed, Oct 15, 2014 at 10:37 AM, Dehao Chen <dehao@google.com> wrote:
>> This patch recalculates dominance info before update_ssa call in
>> AutoFDO. This fixes bug when dominance info is out-of-date and causes
>> segfaults during update_ssa.
>>
>> Bootstrapped and regression test on-going.
>>
>> OK for google-4_9 branch?
>>
>> Thanks,
>> Dehao
>>
>> Index: gcc/auto-profile.c
>> ===================================================================
>> --- gcc/auto-profile.c (revision 216278)
>> +++ gcc/auto-profile.c (working copy)
>> @@ -1756,6 +1756,11 @@ auto_profile (void)
>>        early_inline ();
>>        autofdo::afdo_annotate_cfg (promoted_stmts);
>>        compute_function_frequency ();
>> +
>> +      free_dominance_info (CDI_DOMINATORS);
>> +      free_dominance_info (CDI_POST_DOMINATORS);
>> +      calculate_dominance_info (CDI_POST_DOMINATORS);
>> +      calculate_dominance_info (CDI_DOMINATORS);
>>        update_ssa (TODO_update_ssa);
>>
>>        /* Local pure-const may imply need to fixup the cfg.  */

Comments

Xinliang David Li Oct. 15, 2014, 11:03 p.m. UTC | #1
ok.

David

On Wed, Oct 15, 2014 at 4:00 PM, Dehao Chen <dehao@google.com> wrote:
> It's destroyed by gimple_value_profile_transformations.
>
> Patch updated to move the update_ssa early.
>
> Index: gcc/auto-profile.c
> ===================================================================
> --- gcc/auto-profile.c (revision 216278)
> +++ gcc/auto-profile.c (working copy)
> @@ -1674,7 +1674,14 @@ afdo_annotate_cfg (const stmt_set &promoted_stmts)
>        counts_to_freqs ();
>      }
>    if (flag_value_profile_transformations)
> -    gimple_value_profile_transformations ();
> +    {
> +      gimple_value_profile_transformations ();
> +      free_dominance_info (CDI_DOMINATORS);
> +      free_dominance_info (CDI_POST_DOMINATORS);
> +      calculate_dominance_info (CDI_POST_DOMINATORS);
> +      calculate_dominance_info (CDI_DOMINATORS);
> +      update_ssa (TODO_update_ssa);
> +    }
>  }
>
>  /* Wrapper function to invoke early inliner.  */
> @@ -1756,7 +1763,6 @@ auto_profile (void)
>        early_inline ();
>        autofdo::afdo_annotate_cfg (promoted_stmts);
>        compute_function_frequency ();
> -      update_ssa (TODO_update_ssa);
>
>        /* Local pure-const may imply need to fixup the cfg.  */
>        if (execute_fixup_cfg () & TODO_cleanup_cfg)
>
> Dehao
>
> On Wed, Oct 15, 2014 at 10:50 AM, Xinliang David Li <davidxl@google.com> wrote:
>> Is it destroyed by value profile transformations? Can you move the
>> dominance recomputing code closer to where it gets invalidated?
>>
>> David
>>
>> On Wed, Oct 15, 2014 at 10:37 AM, Dehao Chen <dehao@google.com> wrote:
>>> This patch recalculates dominance info before update_ssa call in
>>> AutoFDO. This fixes bug when dominance info is out-of-date and causes
>>> segfaults during update_ssa.
>>>
>>> Bootstrapped and regression test on-going.
>>>
>>> OK for google-4_9 branch?
>>>
>>> Thanks,
>>> Dehao
>>>
>>> Index: gcc/auto-profile.c
>>> ===================================================================
>>> --- gcc/auto-profile.c (revision 216278)
>>> +++ gcc/auto-profile.c (working copy)
>>> @@ -1756,6 +1756,11 @@ auto_profile (void)
>>>        early_inline ();
>>>        autofdo::afdo_annotate_cfg (promoted_stmts);
>>>        compute_function_frequency ();
>>> +
>>> +      free_dominance_info (CDI_DOMINATORS);
>>> +      free_dominance_info (CDI_POST_DOMINATORS);
>>> +      calculate_dominance_info (CDI_POST_DOMINATORS);
>>> +      calculate_dominance_info (CDI_DOMINATORS);
>>>        update_ssa (TODO_update_ssa);
>>>
>>>        /* Local pure-const may imply need to fixup the cfg.  */
diff mbox

Patch

Index: gcc/auto-profile.c
===================================================================
--- gcc/auto-profile.c (revision 216278)
+++ gcc/auto-profile.c (working copy)
@@ -1674,7 +1674,14 @@  afdo_annotate_cfg (const stmt_set &promoted_stmts)
       counts_to_freqs ();
     }
   if (flag_value_profile_transformations)
-    gimple_value_profile_transformations ();
+    {
+      gimple_value_profile_transformations ();
+      free_dominance_info (CDI_DOMINATORS);
+      free_dominance_info (CDI_POST_DOMINATORS);
+      calculate_dominance_info (CDI_POST_DOMINATORS);
+      calculate_dominance_info (CDI_DOMINATORS);
+      update_ssa (TODO_update_ssa);
+    }
 }

 /* Wrapper function to invoke early inliner.  */
@@ -1756,7 +1763,6 @@  auto_profile (void)
       early_inline ();
       autofdo::afdo_annotate_cfg (promoted_stmts);
       compute_function_frequency ();
-      update_ssa (TODO_update_ssa);

       /* Local pure-const may imply need to fixup the cfg.  */
       if (execute_fixup_cfg () & TODO_cleanup_cfg)