]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/ipa-inline.h
Update copyright years.
[thirdparty/gcc.git] / gcc / ipa-inline.h
CommitLineData
03dfc36d 1/* Inlining decision heuristics.
85ec4feb 2 Copyright (C) 2003-2018 Free Software Foundation, Inc.
03dfc36d
JH
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
f1717f8d
KC
21#ifndef GCC_IPA_INLINE_H
22#define GCC_IPA_INLINE_H
23
4adaad64
JH
24/* Data we cache about callgraph edges during inlining to avoid expensive
25 re-computations during the greedy algorithm. */
84562394 26struct edge_growth_cache_entry
632b4f8e 27{
4adaad64 28 sreal time, nonspec_time;
ab38481c 29 int size;
0bceb671 30 ipa_hints hints;
c8fb20d8
YG
31
32 edge_growth_cache_entry()
33 : size (0), hints (0) {}
34
35 edge_growth_cache_entry(int64_t time, int64_t nonspec_time,
36 int size, ipa_hints hints)
37 : time (time), nonspec_time (nonspec_time), size (size),
38 hints (hints) {}
84562394 39};
632b4f8e 40
9771b263 41extern vec<edge_growth_cache_entry> edge_growth_cache;
10a5dd5d 42
fee8b6da 43/* In ipa-inline-analysis.c */
03dfc36d 44int estimate_size_after_inlining (struct cgraph_node *, struct cgraph_edge *);
0d92b555 45int estimate_growth (struct cgraph_node *);
4cd8957f 46bool growth_likely_positive (struct cgraph_node *, int);
ed901e4c 47int do_estimate_edge_size (struct cgraph_edge *edge);
ab38481c 48sreal do_estimate_edge_time (struct cgraph_edge *edge);
0bceb671 49ipa_hints do_estimate_edge_hints (struct cgraph_edge *edge);
632b4f8e
JH
50void initialize_growth_caches (void);
51void free_growth_caches (void);
27d020cf
JH
52
53/* In ipa-inline.c */
be3c16c4 54unsigned int early_inliner (function *fun);
bb1e543c
JH
55bool inline_account_function_p (struct cgraph_node *node);
56
03dfc36d 57
fee8b6da 58/* In ipa-inline-transform.c */
d52f5295 59bool inline_call (struct cgraph_edge *, bool, vec<cgraph_edge *> *, int *, bool,
1bbb87c4 60 bool *callee_removed = NULL);
fee8b6da 61unsigned int inline_transform (struct cgraph_node *);
1bad9c18 62void clone_inlined_nodes (struct cgraph_edge *e, bool, bool, int *);
fee8b6da
JH
63
64extern int ncalls_inlined;
65extern int nfunctions_inlined;
66
ed901e4c 67/* Return estimated size of the inline sequence of EDGE. */
03dfc36d
JH
68
69static inline int
ed901e4c 70estimate_edge_size (struct cgraph_edge *edge)
03dfc36d 71{
632b4f8e 72 int ret;
9771b263
DN
73 if ((int)edge_growth_cache.length () <= edge->uid
74 || !(ret = edge_growth_cache[edge->uid].size))
ed901e4c 75 return do_estimate_edge_size (edge);
632b4f8e
JH
76 return ret - (ret > 0);
77}
78
ed901e4c
JH
79/* Return estimated callee growth after inlining EDGE. */
80
81static inline int
82estimate_edge_growth (struct cgraph_edge *edge)
83{
263e19c7 84 gcc_checking_assert (ipa_call_summaries->get (edge)->call_stmt_size
9de6f6c3 85 || !edge->callee->analyzed);
ed901e4c 86 return (estimate_edge_size (edge)
263e19c7 87 - ipa_call_summaries->get (edge)->call_stmt_size);
ed901e4c 88}
632b4f8e 89
5764ee3c 90/* Return estimated callee runtime increase after inlining
632b4f8e
JH
91 EDGE. */
92
ab38481c 93static inline sreal
4adaad64 94estimate_edge_time (struct cgraph_edge *edge, sreal *nonspec_time = NULL)
632b4f8e 95{
ab38481c 96 sreal ret;
9771b263 97 if ((int)edge_growth_cache.length () <= edge->uid
ab38481c 98 || !edge_growth_cache[edge->uid].size)
632b4f8e 99 return do_estimate_edge_time (edge);
4adaad64
JH
100 if (nonspec_time)
101 *nonspec_time = edge_growth_cache[edge->uid].nonspec_time;
ab38481c 102 return edge_growth_cache[edge->uid].time;
632b4f8e
JH
103}
104
105
5764ee3c 106/* Return estimated callee runtime increase after inlining
37678631
JH
107 EDGE. */
108
0bceb671 109static inline ipa_hints
37678631
JH
110estimate_edge_hints (struct cgraph_edge *edge)
111{
0bceb671 112 ipa_hints ret;
9771b263
DN
113 if ((int)edge_growth_cache.length () <= edge->uid
114 || !(ret = edge_growth_cache[edge->uid].hints))
de99ac70 115 return do_estimate_edge_hints (edge);
37678631
JH
116 return ret - 1;
117}
118
632b4f8e
JH
119/* Reset cached value for EDGE. */
120
121static inline void
122reset_edge_growth_cache (struct cgraph_edge *edge)
123{
9771b263 124 if ((int)edge_growth_cache.length () > edge->uid)
632b4f8e 125 {
c8fb20d8 126 struct edge_growth_cache_entry zero (0, 0, 0, 0);
9771b263 127 edge_growth_cache[edge->uid] = zero;
632b4f8e 128 }
03dfc36d 129}
f1717f8d
KC
130
131#endif /* GCC_IPA_INLINE_H */