gcc80: Handle TZ specific "%+" format in strftime.
[dragonfly.git] / contrib / gcc-8.0 / gcc / ipa-inline.h
1 /* Inlining decision heuristics.
2    Copyright (C) 2003-2018 Free Software Foundation, Inc.
3    Contributed by Jan Hubicka
4
5 This file is part of GCC.
6
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.
11
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.
16
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/>.  */
20
21 #ifndef GCC_IPA_INLINE_H
22 #define GCC_IPA_INLINE_H
23
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
27 {
28   sreal time, nonspec_time;
29   int size;
30   ipa_hints hints;
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) {}
39 };
40
41 extern vec<edge_growth_cache_entry> edge_growth_cache;
42
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 initialize_growth_caches (void);
51 void free_growth_caches (void);
52
53 /* In ipa-inline.c  */
54 unsigned int early_inliner (function *fun);
55 bool inline_account_function_p (struct cgraph_node *node);
56
57
58 /* In ipa-inline-transform.c  */
59 bool inline_call (struct cgraph_edge *, bool, vec<cgraph_edge *> *, int *, bool,
60                   bool *callee_removed = NULL);
61 unsigned int inline_transform (struct cgraph_node *);
62 void clone_inlined_nodes (struct cgraph_edge *e, bool, bool, int *);
63
64 extern int ncalls_inlined;
65 extern int nfunctions_inlined;
66
67 /* Return estimated size of the inline sequence of EDGE.  */
68
69 static inline int
70 estimate_edge_size (struct cgraph_edge *edge)
71 {
72   int ret;
73   if ((int)edge_growth_cache.length () <= edge->uid
74       || !(ret = edge_growth_cache[edge->uid].size))
75     return do_estimate_edge_size (edge);
76   return ret - (ret > 0);
77 }
78
79 /* Return estimated callee growth after inlining EDGE.  */
80
81 static inline int
82 estimate_edge_growth (struct cgraph_edge *edge)
83 {
84   gcc_checking_assert (ipa_call_summaries->get (edge)->call_stmt_size
85                        || !edge->callee->analyzed);
86   return (estimate_edge_size (edge)
87           - ipa_call_summaries->get (edge)->call_stmt_size);
88 }
89
90 /* Return estimated callee runtime increase after inlining
91    EDGE.  */
92
93 static inline sreal
94 estimate_edge_time (struct cgraph_edge *edge, sreal *nonspec_time = NULL)
95 {
96   sreal ret;
97   if ((int)edge_growth_cache.length () <= edge->uid
98       || !edge_growth_cache[edge->uid].size)
99     return do_estimate_edge_time (edge);
100   if (nonspec_time)
101     *nonspec_time = edge_growth_cache[edge->uid].nonspec_time;
102   return edge_growth_cache[edge->uid].time;
103 }
104
105
106 /* Return estimated callee runtime increase after inlining
107    EDGE.  */
108
109 static inline ipa_hints
110 estimate_edge_hints (struct cgraph_edge *edge)
111 {
112   ipa_hints ret;
113   if ((int)edge_growth_cache.length () <= edge->uid
114       || !(ret = edge_growth_cache[edge->uid].hints))
115     return do_estimate_edge_hints (edge);
116   return ret - 1;
117 }
118
119 /* Reset cached value for EDGE.  */
120
121 static inline void
122 reset_edge_growth_cache (struct cgraph_edge *edge)
123 {
124   if ((int)edge_growth_cache.length () > edge->uid)
125     {
126       struct edge_growth_cache_entry zero (0, 0, 0, 0);
127       edge_growth_cache[edge->uid] = zero;
128     }
129 }
130
131 #endif /* GCC_IPA_INLINE_H */