Hi, On Mon, Feb 17 2020, Martin Liška 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. >
It looks sensible to me. I did not quite took into consideration that ipa-pure-const can add the attribute and only dropped in tree-inline's tree_function_versioning. Just the hunk in ipa_param_adjustments::adjust_decl could be simplified a tiny bit... > 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 > [...] > diff --git a/gcc/ipa-param-manipulation.c b/gcc/ipa-param-manipulation.c > index 19ec87358fa..5f6f0575b06 100644 > --- a/gcc/ipa-param-manipulation.c > +++ b/gcc/ipa-param-manipulation.c > @@ -410,6 +410,10 @@ ipa_param_adjustments::adjust_decl (tree orig_decl) > DECL_VIRTUAL_P (new_decl) = 0; > DECL_LANG_SPECIFIC (new_decl) = NULL; > > + /* Drop MALLOC attribute for a void function. */ > + if (VOID_TYPE_P (TREE_TYPE (TREE_TYPE (new_decl)))) > + DECL_IS_MALLOC (new_decl) = 0; by just testing m_skip_return here (but it is no big deal). Thanks! Martin