]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/ipa-inline.h
[Ada] Define the -fdump-scos option in lang.opt
[thirdparty/gcc.git] / gcc / ipa-inline.h
CommitLineData
99c67f24 1/* Inlining decision heuristics.
fbd26352 2 Copyright (C) 2003-2019 Free Software Foundation, Inc.
99c67f24 3 Contributed by Jan Hubicka
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 3, or (at your option) any later
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
ce6bb0f3 21#ifndef GCC_IPA_INLINE_H
22#define GCC_IPA_INLINE_H
23
e062e35c 24/* Data we cache about callgraph edges during inlining to avoid expensive
25 re-computations during the greedy algorithm. */
251317e4 26class edge_growth_cache_entry
a41f2a28 27{
251317e4 28public:
e062e35c 29 sreal time, nonspec_time;
2e211986 30 int size;
1297cbcd 31 ipa_hints hints;
195ae82f 32
33 edge_growth_cache_entry()
34 : size (0), hints (0) {}
35
36 edge_growth_cache_entry(int64_t time, int64_t nonspec_time,
37 int size, ipa_hints hints)
38 : time (time), nonspec_time (nonspec_time), size (size),
39 hints (hints) {}
b3e7c666 40};
a41f2a28 41
bc4e1286 42extern call_summary<edge_growth_cache_entry *> *edge_growth_cache;
c7b2cc59 43
8cbc43ff 44/* In ipa-inline-analysis.c */
99c67f24 45int estimate_size_after_inlining (struct cgraph_node *, struct cgraph_edge *);
bc42c20c 46int estimate_growth (struct cgraph_node *);
db197f90 47bool growth_likely_positive (struct cgraph_node *, int);
6c2c7775 48int do_estimate_edge_size (struct cgraph_edge *edge);
2e211986 49sreal do_estimate_edge_time (struct cgraph_edge *edge);
1297cbcd 50ipa_hints do_estimate_edge_hints (struct cgraph_edge *edge);
a41f2a28 51void free_growth_caches (void);
b9a58fc5 52
53/* In ipa-inline.c */
94bed7c3 54unsigned int early_inliner (function *fun);
a6d60179 55bool inline_account_function_p (struct cgraph_node *node);
56
99c67f24 57
8cbc43ff 58/* In ipa-inline-transform.c */
415d1b9a 59bool inline_call (struct cgraph_edge *, bool, vec<cgraph_edge *> *, int *, bool,
7c5c01f1 60 bool *callee_removed = NULL);
8cbc43ff 61unsigned int inline_transform (struct cgraph_node *);
151b9ff5 62void clone_inlined_nodes (struct cgraph_edge *e, bool, bool, int *);
8cbc43ff 63
64extern int ncalls_inlined;
65extern int nfunctions_inlined;
66
6c2c7775 67/* Return estimated size of the inline sequence of EDGE. */
99c67f24 68
69static inline int
6c2c7775 70estimate_edge_size (struct cgraph_edge *edge)
99c67f24 71{
bc4e1286 72 edge_growth_cache_entry *entry;
73 if (edge_growth_cache == NULL
74 || (entry = edge_growth_cache->get (edge)) == NULL
75 || entry->size == 0)
6c2c7775 76 return do_estimate_edge_size (edge);
bc4e1286 77 return entry->size - (entry->size > 0);
a41f2a28 78}
79
6c2c7775 80/* Return estimated callee growth after inlining EDGE. */
81
82static inline int
83estimate_edge_growth (struct cgraph_edge *edge)
84{
f445cfda 85 ipa_call_summary *s = ipa_call_summaries->get (edge);
fbc9c62d 86 gcc_checking_assert (s->call_stmt_size || !edge->callee->analyzed);
87 return (estimate_edge_size (edge) - s->call_stmt_size);
6c2c7775 88}
a41f2a28 89
2fbe7a32 90/* Return estimated callee runtime increase after inlining
a41f2a28 91 EDGE. */
92
2e211986 93static inline sreal
e062e35c 94estimate_edge_time (struct cgraph_edge *edge, sreal *nonspec_time = NULL)
a41f2a28 95{
bc4e1286 96 edge_growth_cache_entry *entry;
97 if (edge_growth_cache == NULL
98 || (entry = edge_growth_cache->get (edge)) == NULL
99 || entry->time == 0)
a41f2a28 100 return do_estimate_edge_time (edge);
e062e35c 101 if (nonspec_time)
bc4e1286 102 *nonspec_time = edge_growth_cache->get (edge)->nonspec_time;
103 return entry->time;
a41f2a28 104}
105
106
2fbe7a32 107/* Return estimated callee runtime increase after inlining
eb7c606e 108 EDGE. */
109
1297cbcd 110static inline ipa_hints
eb7c606e 111estimate_edge_hints (struct cgraph_edge *edge)
112{
bc4e1286 113 edge_growth_cache_entry *entry;
114 if (edge_growth_cache == NULL
115 || (entry = edge_growth_cache->get (edge)) == NULL
116 || entry->hints == 0)
6e300957 117 return do_estimate_edge_hints (edge);
bc4e1286 118 return entry->hints - 1;
99c67f24 119}
ce6bb0f3 120
121#endif /* GCC_IPA_INLINE_H */