GCC Middle and Back End API Reference
ipa-inline.h
Go to the documentation of this file.
1/* Inlining decision heuristics.
2 Copyright (C) 2003-2024 Free Software Foundation, Inc.
3 Contributed by Jan Hubicka
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 3, or (at your option) any later
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
18along 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. */
41
43
44/* In ipa-inline-analysis.cc */
46int estimate_growth (struct cgraph_node *);
47bool growth_positive_p (struct cgraph_node *, struct cgraph_edge *, int);
49sreal do_estimate_edge_time (struct cgraph_edge *edge, sreal *nonspec_time = NULL);
51void reset_node_cache (struct cgraph_node *node);
53void free_growth_caches (void);
54
55/* In ipa-inline.cc */
56unsigned int early_inliner (function *fun);
57bool inline_account_function_p (struct cgraph_node *node);
58
59
60/* In ipa-inline-transform.cc */
61bool inline_call (struct cgraph_edge *, bool, vec<cgraph_edge *> *, int *, bool,
62 bool *callee_removed = NULL);
63unsigned int inline_transform (struct cgraph_node *);
64void clone_inlined_nodes (struct cgraph_edge *e, bool, bool, int *);
65
66extern int ncalls_inlined;
67extern int nfunctions_inlined;
69
70/* Return estimated size of the inline sequence of EDGE. */
71
72inline int
74{
77 || (entry = edge_growth_cache->get (edge)) == NULL
78 || entry->size == 0)
80 return entry->size - (entry->size > 0);
81}
82
83/* Return lower bound on estimated callee growth after inlining EDGE. */
84
85inline int
87{
89 struct cgraph_node *callee = edge->callee->ultimate_alias_target ();
90 return (ipa_fn_summaries->get (callee)->min_size - s->call_stmt_size);
91}
92
93/* Return estimated callee growth after inlining EDGE. */
94
95inline int
102
103/* Return estimated callee runtime increase after inlining
104 EDGE. */
105
106inline sreal
107estimate_edge_time (struct cgraph_edge *edge, sreal *nonspec_time = NULL)
108{
111 || (entry = edge_growth_cache->get (edge)) == NULL
112 || entry->time == 0)
113 return do_estimate_edge_time (edge, nonspec_time);
114 if (nonspec_time)
115 *nonspec_time = edge_growth_cache->get (edge)->nonspec_time;
116 return entry->time;
117}
118
119
120/* Return estimated callee runtime increase after inlining
121 EDGE. */
122
123inline ipa_hints
125{
128 || (entry = edge_growth_cache->get (edge)) == NULL
129 || entry->hints == 0)
131 return entry->hints - 1;
132}
133
134#endif /* GCC_IPA_INLINE_H */
Definition cgraph.h:1696
Definition ipa-inline.h:27
sreal nonspec_time
Definition ipa-inline.h:29
ipa_hints hints
Definition ipa-inline.h:31
edge_growth_cache_entry()
Definition ipa-inline.h:33
edge_growth_cache_entry(int64_t time, int64_t nonspec_time, int size, ipa_hints hints)
Definition ipa-inline.h:36
sreal time
Definition ipa-inline.h:29
int size
Definition ipa-inline.h:30
Definition symbol-summary.h:827
Definition ipa-fnsummary.h:277
int call_stmt_size
Definition ipa-fnsummary.h:302
Definition sreal.h:41
class edge_def * edge
Definition coretypes.h:342
T * ggc_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:184
fast_call_summary< ipa_call_summary *, va_heap > * ipa_call_summaries
Definition ipa-fnsummary.cc:97
fast_function_summary< ipa_fn_summary *, va_gc > * ipa_fn_summaries
Definition ipa-fnsummary.cc:95
int ipa_hints
Definition ipa-fnsummary.h:58
int nfunctions_inlined
Definition ipa-inline-transform.cc:59
int estimate_min_edge_growth(struct cgraph_edge *edge)
Definition ipa-inline.h:86
void clone_inlined_nodes(struct cgraph_edge *e, bool, bool, int *)
Definition ipa-inline-transform.cc:170
void free_growth_caches(void)
Definition ipa-inline-analysis.cc:141
int estimate_size_after_inlining(struct cgraph_node *, struct cgraph_edge *)
Definition ipa-inline-analysis.cc:383
unsigned int inline_transform(struct cgraph_node *)
Definition ipa-inline-transform.cc:729
int do_estimate_edge_size(struct cgraph_edge *edge)
Definition ipa-inline-analysis.cc:316
int estimate_edge_growth(struct cgraph_edge *edge)
Definition ipa-inline.h:96
bool growth_positive_p(struct cgraph_node *, struct cgraph_edge *, int)
Definition ipa-inline-analysis.cc:540
bool inline_call(struct cgraph_edge *, bool, vec< cgraph_edge * > *, int *, bool, bool *callee_removed=NULL)
Definition ipa-inline-transform.cc:337
sreal do_estimate_edge_time(struct cgraph_edge *edge, sreal *nonspec_time=NULL)
Definition ipa-inline-analysis.cc:186
int ncalls_inlined
Definition ipa-inline-transform.cc:58
int estimate_growth(struct cgraph_node *)
Definition ipa-inline-analysis.cc:469
unsigned int early_inliner(function *fun)
Definition ipa-inline.cc:3082
void reset_node_cache(struct cgraph_node *node)
Definition ipa-inline-analysis.cc:296
function_summary< tree * > * ipa_saved_clone_sources
Definition ipa-inline-transform.cc:556
ipa_hints do_estimate_edge_hints(struct cgraph_edge *edge)
Definition ipa-inline-analysis.cc:350
fast_call_summary< edge_growth_cache_entry *, va_heap > * edge_growth_cache
Definition ipa-inline-analysis.cc:56
void initialize_growth_caches()
Definition ipa-inline-analysis.cc:127
sreal estimate_edge_time(struct cgraph_edge *edge, sreal *nonspec_time=NULL)
Definition ipa-inline.h:107
int estimate_edge_size(struct cgraph_edge *edge)
Definition ipa-inline.h:73
ipa_hints estimate_edge_hints(struct cgraph_edge *edge)
Definition ipa-inline.h:124
bool inline_account_function_p(struct cgraph_node *node)
Definition ipa-inline.cc:2020
Definition cgraph.h:875
cgraph_node * ultimate_alias_target(availability *availability=NULL, symtab_node *ref=NULL)
Definition cgraph.h:3243
Definition function.h:249
Definition vec.h:450
#define NULL
Definition system.h:50
#define gcc_checking_assert(EXPR)
Definition system.h:828