annotate gcc/ipa-inline.h @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Inlining decision heuristics.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 Copyright (C) 2003-2020 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
3 Contributed by Jan Hubicka
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 This file is part of GCC.
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify it under
kono
parents:
diff changeset
8 the terms of the GNU General Public License as published by the Free
kono
parents:
diff changeset
9 Software Foundation; either version 3, or (at your option) any later
kono
parents:
diff changeset
10 version.
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
kono
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kono
parents:
diff changeset
15 for more details.
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
18 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
19 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 #ifndef GCC_IPA_INLINE_H
kono
parents:
diff changeset
22 #define GCC_IPA_INLINE_H
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 /* Data we cache about callgraph edges during inlining to avoid expensive
kono
parents:
diff changeset
25 re-computations during the greedy algorithm. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
26 class edge_growth_cache_entry
111
kono
parents:
diff changeset
27 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
28 public:
111
kono
parents:
diff changeset
29 sreal time, nonspec_time;
kono
parents:
diff changeset
30 int size;
kono
parents:
diff changeset
31 ipa_hints hints;
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 edge_growth_cache_entry()
kono
parents:
diff changeset
34 : size (0), hints (0) {}
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 edge_growth_cache_entry(int64_t time, int64_t nonspec_time,
kono
parents:
diff changeset
37 int size, ipa_hints hints)
kono
parents:
diff changeset
38 : time (time), nonspec_time (nonspec_time), size (size),
kono
parents:
diff changeset
39 hints (hints) {}
kono
parents:
diff changeset
40 };
kono
parents:
diff changeset
41
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
42 extern fast_call_summary<edge_growth_cache_entry *, va_heap> *edge_growth_cache;
111
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 /* In ipa-inline-analysis.c */
kono
parents:
diff changeset
45 int estimate_size_after_inlining (struct cgraph_node *, struct cgraph_edge *);
kono
parents:
diff changeset
46 int estimate_growth (struct cgraph_node *);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
47 bool growth_positive_p (struct cgraph_node *, struct cgraph_edge *, int);
111
kono
parents:
diff changeset
48 int do_estimate_edge_size (struct cgraph_edge *edge);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
49 sreal do_estimate_edge_time (struct cgraph_edge *edge, sreal *nonspec_time = NULL);
111
kono
parents:
diff changeset
50 ipa_hints do_estimate_edge_hints (struct cgraph_edge *edge);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
51 void reset_node_cache (struct cgraph_node *node);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
52 void initialize_growth_caches ();
111
kono
parents:
diff changeset
53 void free_growth_caches (void);
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 /* In ipa-inline.c */
kono
parents:
diff changeset
56 unsigned int early_inliner (function *fun);
kono
parents:
diff changeset
57 bool inline_account_function_p (struct cgraph_node *node);
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 /* In ipa-inline-transform.c */
kono
parents:
diff changeset
61 bool inline_call (struct cgraph_edge *, bool, vec<cgraph_edge *> *, int *, bool,
kono
parents:
diff changeset
62 bool *callee_removed = NULL);
kono
parents:
diff changeset
63 unsigned int inline_transform (struct cgraph_node *);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
64 void clone_inlined_nodes (struct cgraph_edge *e, bool, bool, int *);
111
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 extern int ncalls_inlined;
kono
parents:
diff changeset
67 extern int nfunctions_inlined;
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 /* Return estimated size of the inline sequence of EDGE. */
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 static inline int
kono
parents:
diff changeset
72 estimate_edge_size (struct cgraph_edge *edge)
kono
parents:
diff changeset
73 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
74 edge_growth_cache_entry *entry;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
75 if (edge_growth_cache == NULL
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
76 || (entry = edge_growth_cache->get (edge)) == NULL
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
77 || entry->size == 0)
111
kono
parents:
diff changeset
78 return do_estimate_edge_size (edge);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
79 return entry->size - (entry->size > 0);
111
kono
parents:
diff changeset
80 }
kono
parents:
diff changeset
81
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
82 /* Return lower bound on estimated callee growth after inlining EDGE. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
83
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
84 static inline int
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
85 estimate_min_edge_growth (struct cgraph_edge *edge)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
86 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
87 ipa_call_summary *s = ipa_call_summaries->get (edge);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
88 struct cgraph_node *callee = edge->callee->ultimate_alias_target ();
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
89 return (ipa_fn_summaries->get (callee)->min_size - s->call_stmt_size);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
90 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
91
111
kono
parents:
diff changeset
92 /* Return estimated callee growth after inlining EDGE. */
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 static inline int
kono
parents:
diff changeset
95 estimate_edge_growth (struct cgraph_edge *edge)
kono
parents:
diff changeset
96 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
97 ipa_call_summary *s = ipa_call_summaries->get (edge);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
98 gcc_checking_assert (s->call_stmt_size || !edge->callee->analyzed);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
99 return (estimate_edge_size (edge) - s->call_stmt_size);
111
kono
parents:
diff changeset
100 }
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 /* Return estimated callee runtime increase after inlining
kono
parents:
diff changeset
103 EDGE. */
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 static inline sreal
kono
parents:
diff changeset
106 estimate_edge_time (struct cgraph_edge *edge, sreal *nonspec_time = NULL)
kono
parents:
diff changeset
107 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
108 edge_growth_cache_entry *entry;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
109 if (edge_growth_cache == NULL
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
110 || (entry = edge_growth_cache->get (edge)) == NULL
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
111 || entry->time == 0)
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
112 return do_estimate_edge_time (edge, nonspec_time);
111
kono
parents:
diff changeset
113 if (nonspec_time)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
114 *nonspec_time = edge_growth_cache->get (edge)->nonspec_time;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
115 return entry->time;
111
kono
parents:
diff changeset
116 }
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 /* Return estimated callee runtime increase after inlining
kono
parents:
diff changeset
120 EDGE. */
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 static inline ipa_hints
kono
parents:
diff changeset
123 estimate_edge_hints (struct cgraph_edge *edge)
kono
parents:
diff changeset
124 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
125 edge_growth_cache_entry *entry;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
126 if (edge_growth_cache == NULL
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
127 || (entry = edge_growth_cache->get (edge)) == NULL
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
128 || entry->hints == 0)
111
kono
parents:
diff changeset
129 return do_estimate_edge_hints (edge);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
130 return entry->hints - 1;
111
kono
parents:
diff changeset
131 }
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 #endif /* GCC_IPA_INLINE_H */