Hi,

On Mon, Feb 17 2020, Richard Biener wrote:
> On Mon, Feb 17, 2020 at 1:16 PM Martin Liška <mli...@suse.cz> wrote:
>>
>> Hello.
>>
>> As mentioned in the PR, we end up with a void function
>> call that has set MALLOC attribute. That causes problems in RTL
>> expansion.
>>
>> I believe a proper fix is to drop the attribute when a callgraph
>> clone with void type is created.
>>
>> I would like to see Martin's comment about the hunk in propagate_malloc
>> which is maybe suboptimal and one can find a better way?
>>
>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>> It fixes LTO bootstrap on ppc64le.
>
> Is the ipa-pure-const.c hunk really necessary? malloc_candidate_p shouldn't
> see any such function as candidate.  If so it should be fixed there?

malloc_candidate_p runs at summary building phase (LTO compile time) and
IPA-SRA WPA phase, which actually removes the return value, runs between
that and ipa-pure-const WPA phase. So without the hunk, the pass could
now happily re-introduce the flag.

I have not analyzed the original bug report but I actually believe that
the ipa-pure-const hunk is actually the one fixing the core issue there.
Otherwise, removal of the attribute in tree-inline.c would have been
enough.

If we don't like adding another look at the trees in a WPA phase of an
IPA pass, ipa-pure const could alternatively test:

  if (node->param_adjustments && node->param_adjustments->m_skip_return)
    continue;

Martin


>
> Thanks,
> Richard.
>
>> Thanks,
>> Martin
>>
>> gcc/ChangeLog:
>>
>> 2020-02-17  Martin Liska  <mli...@suse.cz>
>>
>>         PR ipa/93583
>>         * cgraph.c (cgraph_node::verify_node): Verify MALLOC attribute
>>         and return type of functions.
>>         * ipa-param-manipulation.c (ipa_param_adjustments::adjust_decl):
>>         Drop MALLOC attribute for void functions.
>>         * ipa-pure-const.c (propagate_malloc): Do not set malloc flag
>>         for void functions.
>>
>> gcc/testsuite/ChangeLog:
>>
>> 2020-02-17  Martin Liska  <mli...@suse.cz>
>>
>>         PR ipa/93583
>>         * gcc.dg/ipa/pr93583.c: New test.
>> ---
>>   gcc/cgraph.c                       |  6 ++++++
>>   gcc/ipa-param-manipulation.c       |  4 ++++
>>   gcc/ipa-pure-const.c               |  9 ++++++---
>>   gcc/testsuite/gcc.dg/ipa/pr93583.c | 15 +++++++++++++++
>>   4 files changed, 31 insertions(+), 3 deletions(-)
>>   create mode 100644 gcc/testsuite/gcc.dg/ipa/pr93583.c
>>
>>

Reply via email to