Retro68/gcc/gcc/ipa-inline.h

135 lines
4.2 KiB
C
Raw Normal View History

2012-03-27 23:13:14 +00:00
/* Inlining decision heuristics.
Copyright (C) 2003-2022 Free Software Foundation, Inc.
2012-03-27 23:13:14 +00:00
Contributed by Jan Hubicka
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
2015-08-28 15:33:40 +00:00
#ifndef GCC_IPA_INLINE_H
#define GCC_IPA_INLINE_H
2018-12-28 15:30:48 +00:00
/* Data we cache about callgraph edges during inlining to avoid expensive
re-computations during the greedy algorithm. */
class edge_growth_cache_entry
2012-03-27 23:13:14 +00:00
{
public:
2018-12-28 15:30:48 +00:00
sreal time, nonspec_time;
2012-03-27 23:13:14 +00:00
int size;
2018-12-28 15:30:48 +00:00
ipa_hints hints;
2012-03-27 23:13:14 +00:00
2018-12-28 15:30:48 +00:00
edge_growth_cache_entry()
: size (0), hints (0) {}
2012-03-27 23:13:14 +00:00
2018-12-28 15:30:48 +00:00
edge_growth_cache_entry(int64_t time, int64_t nonspec_time,
int size, ipa_hints hints)
: time (time), nonspec_time (nonspec_time), size (size),
hints (hints) {}
2014-09-21 17:33:12 +00:00
};
2012-03-27 23:13:14 +00:00
extern fast_call_summary<edge_growth_cache_entry *, va_heap> *edge_growth_cache;
2012-03-27 23:13:14 +00:00
/* In ipa-inline-analysis.cc */
2012-03-27 23:13:14 +00:00
int estimate_size_after_inlining (struct cgraph_node *, struct cgraph_edge *);
2015-08-28 15:33:40 +00:00
int estimate_growth (struct cgraph_node *);
bool growth_positive_p (struct cgraph_node *, struct cgraph_edge *, int);
2014-09-21 17:33:12 +00:00
int do_estimate_edge_size (struct cgraph_edge *edge);
sreal do_estimate_edge_time (struct cgraph_edge *edge, sreal *nonspec_time = NULL);
2018-12-28 15:30:48 +00:00
ipa_hints do_estimate_edge_hints (struct cgraph_edge *edge);
void reset_node_cache (struct cgraph_node *node);
void initialize_growth_caches ();
2012-03-27 23:13:14 +00:00
void free_growth_caches (void);
2018-12-28 15:30:48 +00:00
/* In ipa-inline.cc */
2015-08-28 15:33:40 +00:00
unsigned int early_inliner (function *fun);
bool inline_account_function_p (struct cgraph_node *node);
2012-03-27 23:13:14 +00:00
/* In ipa-inline-transform.cc */
2015-08-28 15:33:40 +00:00
bool inline_call (struct cgraph_edge *, bool, vec<cgraph_edge *> *, int *, bool,
2014-09-21 17:33:12 +00:00
bool *callee_removed = NULL);
2012-03-27 23:13:14 +00:00
unsigned int inline_transform (struct cgraph_node *);
2018-12-28 15:30:48 +00:00
void clone_inlined_nodes (struct cgraph_edge *e, bool, bool, int *);
2012-03-27 23:13:14 +00:00
extern int ncalls_inlined;
extern int nfunctions_inlined;
extern function_summary <tree *> *ipa_saved_clone_sources;
2012-03-27 23:13:14 +00:00
2014-09-21 17:33:12 +00:00
/* Return estimated size of the inline sequence of EDGE. */
2012-03-27 23:13:14 +00:00
static inline int
2014-09-21 17:33:12 +00:00
estimate_edge_size (struct cgraph_edge *edge)
2012-03-27 23:13:14 +00:00
{
2019-06-02 15:48:37 +00:00
edge_growth_cache_entry *entry;
if (edge_growth_cache == NULL
|| (entry = edge_growth_cache->get (edge)) == NULL
|| entry->size == 0)
2014-09-21 17:33:12 +00:00
return do_estimate_edge_size (edge);
2019-06-02 15:48:37 +00:00
return entry->size - (entry->size > 0);
2012-03-27 23:13:14 +00:00
}
/* Return lower bound on estimated callee growth after inlining EDGE. */
static inline int
estimate_min_edge_growth (struct cgraph_edge *edge)
{
ipa_call_summary *s = ipa_call_summaries->get (edge);
struct cgraph_node *callee = edge->callee->ultimate_alias_target ();
return (ipa_fn_summaries->get (callee)->min_size - s->call_stmt_size);
}
2014-09-21 17:33:12 +00:00
/* Return estimated callee growth after inlining EDGE. */
static inline int
estimate_edge_growth (struct cgraph_edge *edge)
{
2019-06-02 15:48:37 +00:00
ipa_call_summary *s = ipa_call_summaries->get (edge);
gcc_checking_assert (s->call_stmt_size || !edge->callee->analyzed);
return (estimate_edge_size (edge) - s->call_stmt_size);
2014-09-21 17:33:12 +00:00
}
2012-03-27 23:13:14 +00:00
/* Return estimated callee runtime increase after inlining
2012-03-27 23:13:14 +00:00
EDGE. */
2018-12-28 15:30:48 +00:00
static inline sreal
estimate_edge_time (struct cgraph_edge *edge, sreal *nonspec_time = NULL)
2012-03-27 23:13:14 +00:00
{
2019-06-02 15:48:37 +00:00
edge_growth_cache_entry *entry;
if (edge_growth_cache == NULL
|| (entry = edge_growth_cache->get (edge)) == NULL
|| entry->time == 0)
return do_estimate_edge_time (edge, nonspec_time);
2018-12-28 15:30:48 +00:00
if (nonspec_time)
2019-06-02 15:48:37 +00:00
*nonspec_time = edge_growth_cache->get (edge)->nonspec_time;
return entry->time;
2012-03-27 23:13:14 +00:00
}
/* Return estimated callee runtime increase after inlining
2014-09-21 17:33:12 +00:00
EDGE. */
2018-12-28 15:30:48 +00:00
static inline ipa_hints
2014-09-21 17:33:12 +00:00
estimate_edge_hints (struct cgraph_edge *edge)
{
2019-06-02 15:48:37 +00:00
edge_growth_cache_entry *entry;
if (edge_growth_cache == NULL
|| (entry = edge_growth_cache->get (edge)) == NULL
|| entry->hints == 0)
2014-09-21 17:33:12 +00:00
return do_estimate_edge_hints (edge);
2019-06-02 15:48:37 +00:00
return entry->hints - 1;
2012-03-27 23:13:14 +00:00
}
2015-08-28 15:33:40 +00:00
#endif /* GCC_IPA_INLINE_H */