This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Help with getting started with adding IPA-related attribute


Hi,

On Sat, Apr 29, 2017 at 06:28:31AM -0500, Daniel Santos wrote:
> Brievity is not my forte, so let me start with the questions.  Can somebody
> please point me to the pass and/or function where gcc
> 
> 1.) decides rather or not to inline a function,

There are two inlining passes.  Early-inliner that works in
topological order and inlines (almost) only when the result is
expected to be smaller than uninlined code.  Then there is a full IPA
inlining pass, which can take advantage of LTO and heuristics that
allows code to grow.

To understand both, you really need to read most of ipa-inline*.[ch]
files.  The exact places where the decisions are made are:
  - early_inline_small_functions() and want_early_inline_function_p()
    in ipa-inline.c for early inlining, and
  - the IPA inliner has a few phases and sub-phases itself, see the
    helper functions in ipa_inline() and especially in
    inline_small_functions().  Alternatively, you want to check out
    all functions which call inline_call().

> 2.) decides rather or not to make a .constprop version of a
> function,

Check out the places that call create_specialized_node() in ipa-cp.c,
namely templated decide_about_value() and the end of
decide_whether_version_node(), which however just checks the flag
do_clone_for_all_contexts set earlier in estimate_local_effects().

> 3.) a good pass (when all constant propagation is done) to search for fn
> parameters and variables (marked with an attribute) that were not
> constproped away, and finally

The attributes must be accepted by the front-end.  For example in C
and C++ this is done in gcc/c-family/c-attribs.c.  Afterwards any pass
or any code in the compiler can use lookup_attribute on the
PARM_DECL tree representing the parameter.

> 4.) what mechanism should I use for that search?  (iterate through the tree
> to find them and then see if they have rtl?  I haven't worked in this area
> yet.

No, I do not think you want to operate on the RTL level (though I have
only very briefly skimmed through the rest of your email).  Use the
gimple/tree representation as I wrote above.  Look at for example
ipa_populate_param_decls() in ipa-prop.c to see how to iterate over
all PARM_DECLs of a function.


Hope this helps,

Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]