On Fri, 27 Oct 2017, Jan Hubicka wrote:

> > On 25 October 2017 at 20:44, Jan Hubicka <hubi...@ucw.cz> wrote:
> > >> On 24 October 2017 at 16:26, Jan Hubicka <hubi...@ucw.cz> wrote:
> > >> >> 2017-10-13  Prathamesh Kulkarni  <prathamesh.kulka...@linaro.org>
> > >> >>
> > >> >>       * cgraph.h (set_malloc_flag): Declare.
> > >> >>       * cgraph.c (set_malloc_flag_1): New function.
> > >> >>       (set_malloc_flag): Likewise.
> > >> >>       * ipa-fnsummary.h (ipa_call_summary): Add new field 
> > >> >> is_return_callee.
> > >> >>       * ipa-fnsummary.c (ipa_call_summary::reset): Set 
> > >> >> is_return_callee to
> > >> >>       false.
> > >> >>       (read_ipa_call_summary): Add support for reading 
> > >> >> is_return_callee.
> > >> >>       (write_ipa_call_summary): Stream is_return_callee.
> > >> >>       * ipa-inline.c (ipa_inline): Remove call to ipa_free_fn_summary.
> > >> >>       * ipa-pure-const.c: Add headers ssa.h, alloc-pool.h, 
> > >> >> symbol-summary.h,
> > >> >>       ipa-prop.h, ipa-fnsummary.h.
> > >> >>       (pure_const_names): Change to static.
> > >> >>       (malloc_state_e): Define.
> > >> >>       (malloc_state_names): Define.
> > >> >>       (funct_state_d): Add field malloc_state.
> > >> >>       (varying_state): Set malloc_state to STATE_MALLOC_BOTTOM.
> > >> >>       (check_retval_uses): New function.
> > >> >>       (malloc_candidate_p): Likewise.
> > >> >>       (analyze_function): Add support for malloc attribute.
> > >> >>       (pure_const_write_summary): Stream malloc_state.
> > >> >>       (pure_const_read_summary): Add support for reading malloc_state.
> > >> >>       (dump_malloc_lattice): New function.
> > >> >>       (propagate_malloc): New function.
> > >> >>       (ipa_pure_const::execute): Call propagate_malloc and
> > >> >>       ipa_free_fn_summary.
> > >> >>       (pass_local_pure_const::execute): Add support for malloc 
> > >> >> attribute.
> > >> >>       * ssa-iterators.h (RETURN_FROM_IMM_USE_STMT): New macro.
> > >> >>
> > >> >> testsuite/
> > >> >>       * gcc.dg/ipa/propmalloc-1.c: New test-case.
> > >> >>       * gcc.dg/ipa/propmalloc-2.c: Likewise.
> > >> >>       * gcc.dg/ipa/propmalloc-3.c: Likewise.
> > >> >
> > >> > OK.
> > >> > Perhaps we could also add -Wsuggest-sttribute=malloc and mention it in 
> > >> > changes.html?
> > >> Done in this version.
> > >> In warn_function_malloc(), I passed false for known_finite param to
> > >> suggest_attribute().
> > >> Does that look OK ?
> > >> Validation in progress. OK to commit if passes ?
> > >
> > > OK, thanks!
> > Thanks, committed as r254140 after following validation:
> > 1] Bootstrap+test with --enable-languages=all,ada,go on
> > x86_64-unknown-linux-gnu and ppc64le-linux-gnu.
> > 2] LTO bootstrap+test on x86_64-unknown-linux-gnu and ppc64le-linux-gnu
> > 3] Cross tested on arm*-*-* and aarch64*-*-*.
> > 
> > Would it be a good idea to extend ipa-pure-const to propagate
> > alloc_size/alloc_align and returns_nonnull attributes ?
> > Which other attributes would be useful to propagate in ipa-pure-const ?
> 
> Also one extension I was considering was TBAA mod-ref pass. I.e. propagate 
> what
> types are read/stored by the call, rather than having just pure/const (no 
> stores,
> no reads at all).
> 
> This will be bit fun to implement in IPA, but it may be useful.  If you would
> be interested in looking into this, we can discuss it (I wanted to implement 
> it
> this stage1 but I think I have way too many other plans).
> 
> LLVM also has nocapture that seems useful for PTA. Richi may have useful
> opinions on that ;)

I once tried to prototype "fn spec" attribute autodetection and
IPA propagation (also into IPA pure const).  Didn't get very far
though.  That tracks per function argument properties like whether
memory is written to through this pointer or whether a pointer
possibly escapes from the function (including through its returned
value).

Richard.

Reply via email to