[PATCH] Remove unreachable nodes before IPA profile pass (PR ipa/87706).

Martin Liška mliska@suse.cz
Mon Nov 12 09:19:00 GMT 2018


On 11/8/18 12:46 PM, Jan Hubicka wrote:
>> On Thu, Nov 8, 2018 at 12:39 PM Martin Liška <mliska@suse.cz> wrote:
>>>
>>> On 11/8/18 12:19 PM, Jan Hubicka wrote:
>>>>> Hi.
>>>>>
>>>>> In order to fix the warnings mentioned in the PR, we need
>>>>> to run remove_unreachable_nodes after early tree passes. That's
>>>>> however possible only within a IPA pass. Thus I'm calling that
>>>>> before the profile PASS.
>>>>>
>>>>> Patch survives regression tests on ppc64le-linux-gnu and majority
>>>>> of warnings are gone in profiledbootstrap.
>>>>>
>>>>> Ready for trunk?
>>>>
>>>> I think we want to do that even with no -fprofile-generate because the
>>>> unreachable code otherwise goes into all other IPA passes for no good
>>>> reason.  So perhaps adding it as todo after the early optimization
>>>> metapass?
>>>
>>> That fails due to gcc_assert.
>>> So one needs:
>>>
>>> diff --git a/gcc/passes.c b/gcc/passes.c
>>> index d838d909941..be92a2f3be3 100644
>>> --- a/gcc/passes.c
>>> +++ b/gcc/passes.c
>>> @@ -485,7 +485,7 @@ const pass_data pass_data_all_early_optimizations =
>>>    0, /* properties_provided */
>>>    0, /* properties_destroyed */
>>>    0, /* todo_flags_start */
>>> -  0, /* todo_flags_finish */
>>> +  TODO_remove_functions | TODO_rebuild_cgraph_edges, /* todo_flags_finish */
>>>  };
>>>
>>>  class pass_all_early_optimizations : public gimple_opt_pass
>>> @@ -1989,7 +1989,8 @@ execute_todo (unsigned int flags)
>>>       of IPA pass queue.  */
>>>    if (flags & TODO_remove_functions)
>>>      {
>>> -      gcc_assert (!cfun);
>>> +      gcc_assert (!cfun
>>> +                 || strcmp (current_pass->name, "early_optimizations") == 0);
>>>        symtab->remove_unreachable_nodes (dump_file);
>>>      }
>>>
>>>
>>> Or do you prefer to a new pass_remove_functions pass that will be added after
>>> pass_local_optimization_passes ?
>>
>> Can you make it todo_flags_start of pass_ipa_tree_profile instead?
> 
> It fails because all_early_optimizations are now gimple pass, so it
> should be TODO after pass_local_optimization_passes?

Unfortunately it does not work. Following file can't be compiled:

./xgcc -B. /home/marxin/Programming/gcc/gcc/testsuite/gcc.dg/torture/inline-2.c  -O0 
/usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/bin/ld: /tmp/ccCVFrPv.o: in function `bar1':
inline-2.c:(.text+0x5): undefined reference to `foo2'
/usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/bin/ld: /tmp/ccCVFrPv.o: in function `bar2':
inline-2.c:(.text+0x11): undefined reference to `foo1'
collect2: error: ld returned 1 exit status

So it's some interference with einline. Honza?

Thus I'm suggesting to add a new IPA pass.

That survives regression tests on x86_64-linux-gnu and bootstrap works.
Martin

> 
> Honza
>>
>>> Martin
>>>
>>>>
>>>> Honza
>>>>> Thanks,
>>>>> Martin
>>>>>
>>>>> gcc/ChangeLog:
>>>>>
>>>>> 2018-11-08  Martin Liska  <mliska@suse.cz>
>>>>>
>>>>>      * tree-profile.c: Run TODO_remove_functions before "profile"
>>>>>      pass in order to remove dead functions that will trigger
>>>>>      -Wmissing-profile.
>>>>> ---
>>>>>  gcc/tree-profile.c | 2 +-
>>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>
>>>>>
>>>>
>>>>> diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c
>>>>> index d8f2a3b1ba4..c14ebc556a6 100644
>>>>> --- a/gcc/tree-profile.c
>>>>> +++ b/gcc/tree-profile.c
>>>>> @@ -776,7 +776,7 @@ const pass_data pass_data_ipa_tree_profile =
>>>>>    0, /* properties_required */
>>>>>    0, /* properties_provided */
>>>>>    0, /* properties_destroyed */
>>>>> -  0, /* todo_flags_start */
>>>>> +  TODO_remove_functions, /* todo_flags_start */
>>>>>    TODO_dump_symtab, /* todo_flags_finish */
>>>>>  };
>>>>>
>>>>>
>>>>
>>>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Remove-unreachable-nodes-before-IPA-profile-pass-PR-.patch
Type: text/x-patch
Size: 3126 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20181112/7b0d630c/attachment.bin>


More information about the Gcc-patches mailing list