annotate gcc/ipa-inline.h @ 128:fe568345ddd5

fix CbC-example
author mir3636
date Wed, 11 Apr 2018 19:32:28 +0900
parents 04ced10e8804
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Inlining decision heuristics.
kono
parents:
diff changeset
2 Copyright (C) 2003-2017 Free Software Foundation, Inc.
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. */
kono
parents:
diff changeset
26 struct edge_growth_cache_entry
kono
parents:
diff changeset
27 {
kono
parents:
diff changeset
28 sreal time, nonspec_time;
kono
parents:
diff changeset
29 int size;
kono
parents:
diff changeset
30 ipa_hints hints;
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 edge_growth_cache_entry()
kono
parents:
diff changeset
33 : size (0), hints (0) {}
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 edge_growth_cache_entry(int64_t time, int64_t nonspec_time,
kono
parents:
diff changeset
36 int size, ipa_hints hints)
kono
parents:
diff changeset
37 : time (time), nonspec_time (nonspec_time), size (size),
kono
parents:
diff changeset
38 hints (hints) {}
kono
parents:
diff changeset
39 };
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 extern vec<edge_growth_cache_entry> edge_growth_cache;
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 /* In ipa-inline-analysis.c */
kono
parents:
diff changeset
44 int estimate_size_after_inlining (struct cgraph_node *, struct cgraph_edge *);
kono
parents:
diff changeset
45 int estimate_growth (struct cgraph_node *);
kono
parents:
diff changeset
46 bool growth_likely_positive (struct cgraph_node *, int);
kono
parents:
diff changeset
47 int do_estimate_edge_size (struct cgraph_edge *edge);
kono
parents:
diff changeset
48 sreal do_estimate_edge_time (struct cgraph_edge *edge);
kono
parents:
diff changeset
49 ipa_hints do_estimate_edge_hints (struct cgraph_edge *edge);
kono
parents:
diff changeset
50 void initialize_growth_caches (void);
kono
parents:
diff changeset
51 void free_growth_caches (void);
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 /* In ipa-inline.c */
kono
parents:
diff changeset
54 unsigned int early_inliner (function *fun);
kono
parents:
diff changeset
55 bool inline_account_function_p (struct cgraph_node *node);
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 /* In ipa-inline-transform.c */
kono
parents:
diff changeset
59 bool inline_call (struct cgraph_edge *, bool, vec<cgraph_edge *> *, int *, bool,
kono
parents:
diff changeset
60 bool *callee_removed = NULL);
kono
parents:
diff changeset
61 unsigned int inline_transform (struct cgraph_node *);
kono
parents:
diff changeset
62 void clone_inlined_nodes (struct cgraph_edge *e, bool, bool, int *,
kono
parents:
diff changeset
63 int freq_scale);
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 extern int ncalls_inlined;
kono
parents:
diff changeset
66 extern int nfunctions_inlined;
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 /* Return estimated size of the inline sequence of EDGE. */
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 static inline int
kono
parents:
diff changeset
71 estimate_edge_size (struct cgraph_edge *edge)
kono
parents:
diff changeset
72 {
kono
parents:
diff changeset
73 int ret;
kono
parents:
diff changeset
74 if ((int)edge_growth_cache.length () <= edge->uid
kono
parents:
diff changeset
75 || !(ret = edge_growth_cache[edge->uid].size))
kono
parents:
diff changeset
76 return do_estimate_edge_size (edge);
kono
parents:
diff changeset
77 return ret - (ret > 0);
kono
parents:
diff changeset
78 }
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 /* Return estimated callee growth after inlining EDGE. */
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 static inline int
kono
parents:
diff changeset
83 estimate_edge_growth (struct cgraph_edge *edge)
kono
parents:
diff changeset
84 {
kono
parents:
diff changeset
85 gcc_checking_assert (ipa_call_summaries->get (edge)->call_stmt_size
kono
parents:
diff changeset
86 || !edge->callee->analyzed);
kono
parents:
diff changeset
87 return (estimate_edge_size (edge)
kono
parents:
diff changeset
88 - ipa_call_summaries->get (edge)->call_stmt_size);
kono
parents:
diff changeset
89 }
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 /* Return estimated callee runtime increase after inlining
kono
parents:
diff changeset
92 EDGE. */
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 static inline sreal
kono
parents:
diff changeset
95 estimate_edge_time (struct cgraph_edge *edge, sreal *nonspec_time = NULL)
kono
parents:
diff changeset
96 {
kono
parents:
diff changeset
97 sreal ret;
kono
parents:
diff changeset
98 if ((int)edge_growth_cache.length () <= edge->uid
kono
parents:
diff changeset
99 || !edge_growth_cache[edge->uid].size)
kono
parents:
diff changeset
100 return do_estimate_edge_time (edge);
kono
parents:
diff changeset
101 if (nonspec_time)
kono
parents:
diff changeset
102 *nonspec_time = edge_growth_cache[edge->uid].nonspec_time;
kono
parents:
diff changeset
103 return edge_growth_cache[edge->uid].time;
kono
parents:
diff changeset
104 }
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 /* Return estimated callee runtime increase after inlining
kono
parents:
diff changeset
108 EDGE. */
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 static inline ipa_hints
kono
parents:
diff changeset
111 estimate_edge_hints (struct cgraph_edge *edge)
kono
parents:
diff changeset
112 {
kono
parents:
diff changeset
113 ipa_hints ret;
kono
parents:
diff changeset
114 if ((int)edge_growth_cache.length () <= edge->uid
kono
parents:
diff changeset
115 || !(ret = edge_growth_cache[edge->uid].hints))
kono
parents:
diff changeset
116 return do_estimate_edge_hints (edge);
kono
parents:
diff changeset
117 return ret - 1;
kono
parents:
diff changeset
118 }
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 /* Reset cached value for EDGE. */
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 static inline void
kono
parents:
diff changeset
123 reset_edge_growth_cache (struct cgraph_edge *edge)
kono
parents:
diff changeset
124 {
kono
parents:
diff changeset
125 if ((int)edge_growth_cache.length () > edge->uid)
kono
parents:
diff changeset
126 {
kono
parents:
diff changeset
127 struct edge_growth_cache_entry zero (0, 0, 0, 0);
kono
parents:
diff changeset
128 edge_growth_cache[edge->uid] = zero;
kono
parents:
diff changeset
129 }
kono
parents:
diff changeset
130 }
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 #endif /* GCC_IPA_INLINE_H */