Mercurial > hg > CbC > CbC_gcc
comparison gcc/ipa-inline.h @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 /* Inlining decision heuristics. | 1 /* Inlining decision heuristics. |
2 Copyright (C) 2003-2017 Free Software Foundation, Inc. | 2 Copyright (C) 2003-2018 Free Software Foundation, Inc. |
3 Contributed by Jan Hubicka | 3 Contributed by Jan Hubicka |
4 | 4 |
5 This file is part of GCC. | 5 This file is part of GCC. |
6 | 6 |
7 GCC is free software; you can redistribute it and/or modify it under | 7 GCC is free software; you can redistribute it and/or modify it under |
36 int size, ipa_hints hints) | 36 int size, ipa_hints hints) |
37 : time (time), nonspec_time (nonspec_time), size (size), | 37 : time (time), nonspec_time (nonspec_time), size (size), |
38 hints (hints) {} | 38 hints (hints) {} |
39 }; | 39 }; |
40 | 40 |
41 extern vec<edge_growth_cache_entry> edge_growth_cache; | 41 extern call_summary<edge_growth_cache_entry *> *edge_growth_cache; |
42 | 42 |
43 /* In ipa-inline-analysis.c */ | 43 /* In ipa-inline-analysis.c */ |
44 int estimate_size_after_inlining (struct cgraph_node *, struct cgraph_edge *); | 44 int estimate_size_after_inlining (struct cgraph_node *, struct cgraph_edge *); |
45 int estimate_growth (struct cgraph_node *); | 45 int estimate_growth (struct cgraph_node *); |
46 bool growth_likely_positive (struct cgraph_node *, int); | 46 bool growth_likely_positive (struct cgraph_node *, int); |
47 int do_estimate_edge_size (struct cgraph_edge *edge); | 47 int do_estimate_edge_size (struct cgraph_edge *edge); |
48 sreal do_estimate_edge_time (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); | 49 ipa_hints do_estimate_edge_hints (struct cgraph_edge *edge); |
50 void initialize_growth_caches (void); | |
51 void free_growth_caches (void); | 50 void free_growth_caches (void); |
52 | 51 |
53 /* In ipa-inline.c */ | 52 /* In ipa-inline.c */ |
54 unsigned int early_inliner (function *fun); | 53 unsigned int early_inliner (function *fun); |
55 bool inline_account_function_p (struct cgraph_node *node); | 54 bool inline_account_function_p (struct cgraph_node *node); |
57 | 56 |
58 /* In ipa-inline-transform.c */ | 57 /* In ipa-inline-transform.c */ |
59 bool inline_call (struct cgraph_edge *, bool, vec<cgraph_edge *> *, int *, bool, | 58 bool inline_call (struct cgraph_edge *, bool, vec<cgraph_edge *> *, int *, bool, |
60 bool *callee_removed = NULL); | 59 bool *callee_removed = NULL); |
61 unsigned int inline_transform (struct cgraph_node *); | 60 unsigned int inline_transform (struct cgraph_node *); |
62 void clone_inlined_nodes (struct cgraph_edge *e, bool, bool, int *, | 61 void clone_inlined_nodes (struct cgraph_edge *e, bool, bool, int *); |
63 int freq_scale); | |
64 | 62 |
65 extern int ncalls_inlined; | 63 extern int ncalls_inlined; |
66 extern int nfunctions_inlined; | 64 extern int nfunctions_inlined; |
67 | 65 |
68 /* Return estimated size of the inline sequence of EDGE. */ | 66 /* Return estimated size of the inline sequence of EDGE. */ |
69 | 67 |
70 static inline int | 68 static inline int |
71 estimate_edge_size (struct cgraph_edge *edge) | 69 estimate_edge_size (struct cgraph_edge *edge) |
72 { | 70 { |
73 int ret; | 71 edge_growth_cache_entry *entry; |
74 if ((int)edge_growth_cache.length () <= edge->uid | 72 if (edge_growth_cache == NULL |
75 || !(ret = edge_growth_cache[edge->uid].size)) | 73 || (entry = edge_growth_cache->get (edge)) == NULL |
74 || entry->size == 0) | |
76 return do_estimate_edge_size (edge); | 75 return do_estimate_edge_size (edge); |
77 return ret - (ret > 0); | 76 return entry->size - (entry->size > 0); |
78 } | 77 } |
79 | 78 |
80 /* Return estimated callee growth after inlining EDGE. */ | 79 /* Return estimated callee growth after inlining EDGE. */ |
81 | 80 |
82 static inline int | 81 static inline int |
83 estimate_edge_growth (struct cgraph_edge *edge) | 82 estimate_edge_growth (struct cgraph_edge *edge) |
84 { | 83 { |
85 gcc_checking_assert (ipa_call_summaries->get (edge)->call_stmt_size | 84 ipa_call_summary *s = ipa_call_summaries->get (edge); |
86 || !edge->callee->analyzed); | 85 gcc_checking_assert (s->call_stmt_size || !edge->callee->analyzed); |
87 return (estimate_edge_size (edge) | 86 return (estimate_edge_size (edge) - s->call_stmt_size); |
88 - ipa_call_summaries->get (edge)->call_stmt_size); | |
89 } | 87 } |
90 | 88 |
91 /* Return estimated callee runtime increase after inlining | 89 /* Return estimated callee runtime increase after inlining |
92 EDGE. */ | 90 EDGE. */ |
93 | 91 |
94 static inline sreal | 92 static inline sreal |
95 estimate_edge_time (struct cgraph_edge *edge, sreal *nonspec_time = NULL) | 93 estimate_edge_time (struct cgraph_edge *edge, sreal *nonspec_time = NULL) |
96 { | 94 { |
97 sreal ret; | 95 edge_growth_cache_entry *entry; |
98 if ((int)edge_growth_cache.length () <= edge->uid | 96 if (edge_growth_cache == NULL |
99 || !edge_growth_cache[edge->uid].size) | 97 || (entry = edge_growth_cache->get (edge)) == NULL |
98 || entry->time == 0) | |
100 return do_estimate_edge_time (edge); | 99 return do_estimate_edge_time (edge); |
101 if (nonspec_time) | 100 if (nonspec_time) |
102 *nonspec_time = edge_growth_cache[edge->uid].nonspec_time; | 101 *nonspec_time = edge_growth_cache->get (edge)->nonspec_time; |
103 return edge_growth_cache[edge->uid].time; | 102 return entry->time; |
104 } | 103 } |
105 | 104 |
106 | 105 |
107 /* Return estimated callee runtime increase after inlining | 106 /* Return estimated callee runtime increase after inlining |
108 EDGE. */ | 107 EDGE. */ |
109 | 108 |
110 static inline ipa_hints | 109 static inline ipa_hints |
111 estimate_edge_hints (struct cgraph_edge *edge) | 110 estimate_edge_hints (struct cgraph_edge *edge) |
112 { | 111 { |
113 ipa_hints ret; | 112 edge_growth_cache_entry *entry; |
114 if ((int)edge_growth_cache.length () <= edge->uid | 113 if (edge_growth_cache == NULL |
115 || !(ret = edge_growth_cache[edge->uid].hints)) | 114 || (entry = edge_growth_cache->get (edge)) == NULL |
115 || entry->hints == 0) | |
116 return do_estimate_edge_hints (edge); | 116 return do_estimate_edge_hints (edge); |
117 return ret - 1; | 117 return entry->hints - 1; |
118 } | |
119 | |
120 /* Reset cached value for EDGE. */ | |
121 | |
122 static inline void | |
123 reset_edge_growth_cache (struct cgraph_edge *edge) | |
124 { | |
125 if ((int)edge_growth_cache.length () > edge->uid) | |
126 { | |
127 struct edge_growth_cache_entry zero (0, 0, 0, 0); | |
128 edge_growth_cache[edge->uid] = zero; | |
129 } | |
130 } | 118 } |
131 | 119 |
132 #endif /* GCC_IPA_INLINE_H */ | 120 #endif /* GCC_IPA_INLINE_H */ |