annotate gcc/ipa-inline.h @ 144:8f4e72ab4e11

fix segmentation fault caused by nothing next cur_op to end
author Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sun, 23 Dec 2018 21:23:56 +0900
parents 84e7813d76e9
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Inlining decision heuristics.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2 Copyright (C) 2003-2018 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. */
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
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
41 extern call_summary<edge_growth_cache_entry *> *edge_growth_cache;
111
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 free_growth_caches (void);
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 /* In ipa-inline.c */
kono
parents:
diff changeset
53 unsigned int early_inliner (function *fun);
kono
parents:
diff changeset
54 bool inline_account_function_p (struct cgraph_node *node);
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 /* In ipa-inline-transform.c */
kono
parents:
diff changeset
58 bool inline_call (struct cgraph_edge *, bool, vec<cgraph_edge *> *, int *, bool,
kono
parents:
diff changeset
59 bool *callee_removed = NULL);
kono
parents:
diff changeset
60 unsigned int inline_transform (struct cgraph_node *);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
61 void clone_inlined_nodes (struct cgraph_edge *e, bool, bool, int *);
111
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 extern int ncalls_inlined;
kono
parents:
diff changeset
64 extern int nfunctions_inlined;
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 /* Return estimated size of the inline sequence of EDGE. */
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 static inline int
kono
parents:
diff changeset
69 estimate_edge_size (struct cgraph_edge *edge)
kono
parents:
diff changeset
70 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
71 edge_growth_cache_entry *entry;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
72 if (edge_growth_cache == NULL
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
73 || (entry = edge_growth_cache->get (edge)) == NULL
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
74 || entry->size == 0)
111
kono
parents:
diff changeset
75 return do_estimate_edge_size (edge);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
76 return entry->size - (entry->size > 0);
111
kono
parents:
diff changeset
77 }
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 /* Return estimated callee growth after inlining EDGE. */
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 static inline int
kono
parents:
diff changeset
82 estimate_edge_growth (struct cgraph_edge *edge)
kono
parents:
diff changeset
83 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
84 ipa_call_summary *s = ipa_call_summaries->get (edge);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
85 gcc_checking_assert (s->call_stmt_size || !edge->callee->analyzed);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
86 return (estimate_edge_size (edge) - s->call_stmt_size);
111
kono
parents:
diff changeset
87 }
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 /* Return estimated callee runtime increase after inlining
kono
parents:
diff changeset
90 EDGE. */
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 static inline sreal
kono
parents:
diff changeset
93 estimate_edge_time (struct cgraph_edge *edge, sreal *nonspec_time = NULL)
kono
parents:
diff changeset
94 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
95 edge_growth_cache_entry *entry;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
96 if (edge_growth_cache == NULL
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
97 || (entry = edge_growth_cache->get (edge)) == NULL
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
98 || entry->time == 0)
111
kono
parents:
diff changeset
99 return do_estimate_edge_time (edge);
kono
parents:
diff changeset
100 if (nonspec_time)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
101 *nonspec_time = edge_growth_cache->get (edge)->nonspec_time;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
102 return entry->time;
111
kono
parents:
diff changeset
103 }
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 /* Return estimated callee runtime increase after inlining
kono
parents:
diff changeset
107 EDGE. */
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 static inline ipa_hints
kono
parents:
diff changeset
110 estimate_edge_hints (struct cgraph_edge *edge)
kono
parents:
diff changeset
111 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
112 edge_growth_cache_entry *entry;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
113 if (edge_growth_cache == NULL
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
114 || (entry = edge_growth_cache->get (edge)) == NULL
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
115 || entry->hints == 0)
111
kono
parents:
diff changeset
116 return do_estimate_edge_hints (edge);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
117 return entry->hints - 1;
111
kono
parents:
diff changeset
118 }
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 #endif /* GCC_IPA_INLINE_H */