]>
Commit | Line | Data |
---|---|---|
03dfc36d JH |
1 | /* Inlining decision heuristics. |
2 | Copyright (C) 2003, 2004, 2007, 2008, 2009, 2010, 2011 | |
3 | Free Software Foundation, Inc. | |
4 | Contributed by Jan Hubicka | |
5 | ||
6 | This file is part of GCC. | |
7 | ||
8 | GCC is free software; you can redistribute it and/or modify it under | |
9 | the terms of the GNU General Public License as published by the Free | |
10 | Software Foundation; either version 3, or (at your option) any later | |
11 | version. | |
12 | ||
13 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
14 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 | for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with GCC; see the file COPYING3. If not see | |
20 | <http://www.gnu.org/licenses/>. */ | |
21 | ||
10a5dd5d JH |
22 | /* Function inlining information. */ |
23 | ||
24 | struct inline_summary | |
25 | { | |
e7f23018 JH |
26 | /* Information about the function body itself. */ |
27 | ||
10a5dd5d JH |
28 | /* Estimated stack frame consumption by the function. */ |
29 | HOST_WIDE_INT estimated_self_stack_size; | |
10a5dd5d JH |
30 | /* Size of the function body. */ |
31 | int self_size; | |
32 | /* How many instructions are likely going to disappear after inlining. */ | |
33 | int size_inlining_benefit; | |
34 | /* Estimated time spent executing the function body. */ | |
35 | int self_time; | |
36 | /* How much time is going to be saved by inlining. */ | |
37 | int time_inlining_benefit; | |
e7f23018 JH |
38 | |
39 | /* False when there something makes inlining impossible (such as va_arg). */ | |
40 | unsigned inlinable : 1; | |
41 | /* False when there something makes versioning impossible. | |
42 | Currently computed and used only by ipa-cp. */ | |
43 | unsigned versionable : 1; | |
e7f23018 JH |
44 | |
45 | /* Information about function that will result after applying all the | |
46 | inline decisions present in the callgraph. Generally kept up to | |
47 | date only for functions that are not inline clones. */ | |
48 | ||
49 | /* Estimated stack frame consumption by the function. */ | |
50 | HOST_WIDE_INT estimated_stack_size; | |
51 | /* Expected offset of the stack frame of inlined function. */ | |
52 | HOST_WIDE_INT stack_frame_offset; | |
53 | /* Estimated size of the function after inlining. */ | |
54 | int time; | |
55 | int size; | |
56 | /* Cached estimated growth after inlining. | |
57 | INT_MIN if not computed. */ | |
58 | int estimated_growth; | |
10a5dd5d JH |
59 | }; |
60 | ||
61 | typedef struct inline_summary inline_summary_t; | |
62 | DEF_VEC_O(inline_summary_t); | |
63 | DEF_VEC_ALLOC_O(inline_summary_t,heap); | |
64 | extern VEC(inline_summary_t,heap) *inline_summary_vec; | |
65 | ||
fee8b6da | 66 | /* In ipa-inline-analysis.c */ |
10a5dd5d JH |
67 | void debug_inline_summary (struct cgraph_node *); |
68 | void dump_inline_summaries (FILE *f); | |
03dfc36d JH |
69 | void inline_generate_summary (void); |
70 | void inline_read_summary (void); | |
71 | void inline_write_summary (cgraph_node_set, varpool_node_set); | |
72 | void inline_free_summary (void); | |
e7f23018 | 73 | void initialize_inline_failed (struct cgraph_edge *); |
03dfc36d JH |
74 | int estimate_time_after_inlining (struct cgraph_node *, struct cgraph_edge *); |
75 | int estimate_size_after_inlining (struct cgraph_node *, struct cgraph_edge *); | |
76 | int estimate_growth (struct cgraph_node *); | |
77 | ||
fee8b6da JH |
78 | /* In ipa-inline-transform.c */ |
79 | bool inline_call (struct cgraph_edge *, bool, VEC (cgraph_edge_p, heap) **, int *); | |
80 | unsigned int inline_transform (struct cgraph_node *); | |
81 | void clone_inlined_nodes (struct cgraph_edge *e, bool, bool, int *); | |
82 | ||
83 | extern int ncalls_inlined; | |
84 | extern int nfunctions_inlined; | |
85 | ||
03dfc36d JH |
86 | static inline struct inline_summary * |
87 | inline_summary (struct cgraph_node *node) | |
88 | { | |
10a5dd5d | 89 | return VEC_index (inline_summary_t, inline_summary_vec, node->uid); |
03dfc36d JH |
90 | } |
91 | ||
92 | /* Estimate the growth of the caller when inlining EDGE. */ | |
93 | ||
94 | static inline int | |
95 | estimate_edge_growth (struct cgraph_edge *edge) | |
96 | { | |
97 | int call_stmt_size; | |
e7f23018 | 98 | struct inline_summary *info = inline_summary (edge->callee); |
10a5dd5d JH |
99 | call_stmt_size = edge->call_stmt_size; |
100 | gcc_checking_assert (call_stmt_size); | |
e7f23018 JH |
101 | return (info->size |
102 | - info->size_inlining_benefit | |
03dfc36d JH |
103 | - call_stmt_size); |
104 | } |