[PR c++/86374] Name lookup failure in enclosing template
[official-gcc.git] / gcc / ipa-inline.h
blob02d6da06f6d9e1bb1fcfaaabd372da419495115b
1 /* Inlining decision heuristics.
2 Copyright (C) 2003-2018 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
10 version.
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
15 for more details.
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;
29 int size;
30 ipa_hints hints;
32 edge_growth_cache_entry()
33 : size (0), hints (0) {}
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) {}
41 extern call_summary<edge_growth_cache_entry *> *edge_growth_cache;
43 /* In ipa-inline-analysis.c */
44 int estimate_size_after_inlining (struct cgraph_node *, struct cgraph_edge *);
45 int estimate_growth (struct cgraph_node *);
46 bool growth_likely_positive (struct cgraph_node *, int);
47 int do_estimate_edge_size (struct cgraph_edge *edge);
48 sreal do_estimate_edge_time (struct cgraph_edge *edge);
49 ipa_hints do_estimate_edge_hints (struct cgraph_edge *edge);
50 void free_growth_caches (void);
52 /* In ipa-inline.c */
53 unsigned int early_inliner (function *fun);
54 bool inline_account_function_p (struct cgraph_node *node);
57 /* In ipa-inline-transform.c */
58 bool inline_call (struct cgraph_edge *, bool, vec<cgraph_edge *> *, int *, bool,
59 bool *callee_removed = NULL);
60 unsigned int inline_transform (struct cgraph_node *);
61 void clone_inlined_nodes (struct cgraph_edge *e, bool, bool, int *);
63 extern int ncalls_inlined;
64 extern int nfunctions_inlined;
66 /* Return estimated size of the inline sequence of EDGE. */
68 static inline int
69 estimate_edge_size (struct cgraph_edge *edge)
71 edge_growth_cache_entry *entry;
72 if (edge_growth_cache == NULL
73 || (entry = edge_growth_cache->get (edge)) == NULL
74 || entry->size == 0)
75 return do_estimate_edge_size (edge);
76 return entry->size - (entry->size > 0);
79 /* Return estimated callee growth after inlining EDGE. */
81 static inline int
82 estimate_edge_growth (struct cgraph_edge *edge)
84 ipa_call_summary *s = ipa_call_summaries->get (edge);
85 gcc_checking_assert (s->call_stmt_size || !edge->callee->analyzed);
86 return (estimate_edge_size (edge) - s->call_stmt_size);
89 /* Return estimated callee runtime increase after inlining
90 EDGE. */
92 static inline sreal
93 estimate_edge_time (struct cgraph_edge *edge, sreal *nonspec_time = NULL)
95 edge_growth_cache_entry *entry;
96 if (edge_growth_cache == NULL
97 || (entry = edge_growth_cache->get (edge)) == NULL
98 || entry->time == 0)
99 return do_estimate_edge_time (edge);
100 if (nonspec_time)
101 *nonspec_time = edge_growth_cache->get (edge)->nonspec_time;
102 return entry->time;
106 /* Return estimated callee runtime increase after inlining
107 EDGE. */
109 static inline ipa_hints
110 estimate_edge_hints (struct cgraph_edge *edge)
112 edge_growth_cache_entry *entry;
113 if (edge_growth_cache == NULL
114 || (entry = edge_growth_cache->get (edge)) == NULL
115 || entry->hints == 0)
116 return do_estimate_edge_hints (edge);
117 return entry->hints - 1;
120 #endif /* GCC_IPA_INLINE_H */