1 /* Inlining decision heuristics.
2 Copyright (C) 2003-2017 Free Software Foundation, Inc.
3 Contributed by Jan Hubicka
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef GCC_IPA_INLINE_H
22 #define GCC_IPA_INLINE_H
24 /* Data we cache about callgraph edges during inlining to avoid expensive
25 re-computations during the greedy algorithm. */
26 struct edge_growth_cache_entry
28 sreal time
, nonspec_time
;
33 extern vec
<edge_growth_cache_entry
> edge_growth_cache
;
35 /* In ipa-inline-analysis.c */
36 int estimate_size_after_inlining (struct cgraph_node
*, struct cgraph_edge
*);
37 int estimate_growth (struct cgraph_node
*);
38 bool growth_likely_positive (struct cgraph_node
*, int);
39 int do_estimate_edge_size (struct cgraph_edge
*edge
);
40 sreal
do_estimate_edge_time (struct cgraph_edge
*edge
);
41 ipa_hints
do_estimate_edge_hints (struct cgraph_edge
*edge
);
42 void initialize_growth_caches (void);
43 void free_growth_caches (void);
46 unsigned int early_inliner (function
*fun
);
47 bool inline_account_function_p (struct cgraph_node
*node
);
50 /* In ipa-inline-transform.c */
51 bool inline_call (struct cgraph_edge
*, bool, vec
<cgraph_edge
*> *, int *, bool,
52 bool *callee_removed
= NULL
);
53 unsigned int inline_transform (struct cgraph_node
*);
54 void clone_inlined_nodes (struct cgraph_edge
*e
, bool, bool, int *,
57 extern int ncalls_inlined
;
58 extern int nfunctions_inlined
;
60 /* Return estimated size of the inline sequence of EDGE. */
63 estimate_edge_size (struct cgraph_edge
*edge
)
66 if ((int)edge_growth_cache
.length () <= edge
->uid
67 || !(ret
= edge_growth_cache
[edge
->uid
].size
))
68 return do_estimate_edge_size (edge
);
69 return ret
- (ret
> 0);
72 /* Return estimated callee growth after inlining EDGE. */
75 estimate_edge_growth (struct cgraph_edge
*edge
)
77 gcc_checking_assert (ipa_call_summaries
->get (edge
)->call_stmt_size
78 || !edge
->callee
->analyzed
);
79 return (estimate_edge_size (edge
)
80 - ipa_call_summaries
->get (edge
)->call_stmt_size
);
83 /* Return estimated callee runtime increase after inlining
87 estimate_edge_time (struct cgraph_edge
*edge
, sreal
*nonspec_time
= NULL
)
90 if ((int)edge_growth_cache
.length () <= edge
->uid
91 || !edge_growth_cache
[edge
->uid
].size
)
92 return do_estimate_edge_time (edge
);
94 *nonspec_time
= edge_growth_cache
[edge
->uid
].nonspec_time
;
95 return edge_growth_cache
[edge
->uid
].time
;
99 /* Return estimated callee runtime increase after inlining
102 static inline ipa_hints
103 estimate_edge_hints (struct cgraph_edge
*edge
)
106 if ((int)edge_growth_cache
.length () <= edge
->uid
107 || !(ret
= edge_growth_cache
[edge
->uid
].hints
))
108 return do_estimate_edge_hints (edge
);
112 /* Reset cached value for EDGE. */
115 reset_edge_growth_cache (struct cgraph_edge
*edge
)
117 if ((int)edge_growth_cache
.length () > edge
->uid
)
119 struct edge_growth_cache_entry zero
= {0, 0, 0, 0};
120 edge_growth_cache
[edge
->uid
] = zero
;
124 #endif /* GCC_IPA_INLINE_H */