comparison gcc/ipa-inline.h @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* Inlining decision heuristics. 1 /* Inlining decision heuristics.
2 Copyright (C) 2003-2018 Free Software Foundation, Inc. 2 Copyright (C) 2003-2020 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
21 #ifndef GCC_IPA_INLINE_H 21 #ifndef GCC_IPA_INLINE_H
22 #define GCC_IPA_INLINE_H 22 #define GCC_IPA_INLINE_H
23 23
24 /* Data we cache about callgraph edges during inlining to avoid expensive 24 /* Data we cache about callgraph edges during inlining to avoid expensive
25 re-computations during the greedy algorithm. */ 25 re-computations during the greedy algorithm. */
26 struct edge_growth_cache_entry 26 class edge_growth_cache_entry
27 { 27 {
28 public:
28 sreal time, nonspec_time; 29 sreal time, nonspec_time;
29 int size; 30 int size;
30 ipa_hints hints; 31 ipa_hints hints;
31 32
32 edge_growth_cache_entry() 33 edge_growth_cache_entry()
36 int size, ipa_hints hints) 37 int size, ipa_hints hints)
37 : time (time), nonspec_time (nonspec_time), size (size), 38 : time (time), nonspec_time (nonspec_time), size (size),
38 hints (hints) {} 39 hints (hints) {}
39 }; 40 };
40 41
41 extern call_summary<edge_growth_cache_entry *> *edge_growth_cache; 42 extern fast_call_summary<edge_growth_cache_entry *, va_heap> *edge_growth_cache;
42 43
43 /* In ipa-inline-analysis.c */ 44 /* In ipa-inline-analysis.c */
44 int estimate_size_after_inlining (struct cgraph_node *, struct cgraph_edge *); 45 int estimate_size_after_inlining (struct cgraph_node *, struct cgraph_edge *);
45 int estimate_growth (struct cgraph_node *); 46 int estimate_growth (struct cgraph_node *);
46 bool growth_likely_positive (struct cgraph_node *, int); 47 bool growth_positive_p (struct cgraph_node *, struct cgraph_edge *, int);
47 int do_estimate_edge_size (struct cgraph_edge *edge); 48 int do_estimate_edge_size (struct cgraph_edge *edge);
48 sreal do_estimate_edge_time (struct cgraph_edge *edge); 49 sreal do_estimate_edge_time (struct cgraph_edge *edge, sreal *nonspec_time = NULL);
49 ipa_hints do_estimate_edge_hints (struct cgraph_edge *edge); 50 ipa_hints do_estimate_edge_hints (struct cgraph_edge *edge);
51 void reset_node_cache (struct cgraph_node *node);
52 void initialize_growth_caches ();
50 void free_growth_caches (void); 53 void free_growth_caches (void);
51 54
52 /* In ipa-inline.c */ 55 /* In ipa-inline.c */
53 unsigned int early_inliner (function *fun); 56 unsigned int early_inliner (function *fun);
54 bool inline_account_function_p (struct cgraph_node *node); 57 bool inline_account_function_p (struct cgraph_node *node);
74 || entry->size == 0) 77 || entry->size == 0)
75 return do_estimate_edge_size (edge); 78 return do_estimate_edge_size (edge);
76 return entry->size - (entry->size > 0); 79 return entry->size - (entry->size > 0);
77 } 80 }
78 81
82 /* Return lower bound on estimated callee growth after inlining EDGE. */
83
84 static inline int
85 estimate_min_edge_growth (struct cgraph_edge *edge)
86 {
87 ipa_call_summary *s = ipa_call_summaries->get (edge);
88 struct cgraph_node *callee = edge->callee->ultimate_alias_target ();
89 return (ipa_fn_summaries->get (callee)->min_size - s->call_stmt_size);
90 }
91
79 /* Return estimated callee growth after inlining EDGE. */ 92 /* Return estimated callee growth after inlining EDGE. */
80 93
81 static inline int 94 static inline int
82 estimate_edge_growth (struct cgraph_edge *edge) 95 estimate_edge_growth (struct cgraph_edge *edge)
83 { 96 {
94 { 107 {
95 edge_growth_cache_entry *entry; 108 edge_growth_cache_entry *entry;
96 if (edge_growth_cache == NULL 109 if (edge_growth_cache == NULL
97 || (entry = edge_growth_cache->get (edge)) == NULL 110 || (entry = edge_growth_cache->get (edge)) == NULL
98 || entry->time == 0) 111 || entry->time == 0)
99 return do_estimate_edge_time (edge); 112 return do_estimate_edge_time (edge, nonspec_time);
100 if (nonspec_time) 113 if (nonspec_time)
101 *nonspec_time = edge_growth_cache->get (edge)->nonspec_time; 114 *nonspec_time = edge_growth_cache->get (edge)->nonspec_time;
102 return entry->time; 115 return entry->time;
103 } 116 }
104 117