aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-inline.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2003-07-09 02:31:20 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2003-07-09 00:31:20 +0000
commit084c1779088967df7cde7aef1ac91587d68ab3bb (patch)
tree5029eb04a9f787f6958b11882444a0e5bc409cfb /gcc/tree-inline.c
parent1b1838b64cf2ee0cc35ddf75020894de2a84ee38 (diff)
downloadgcc-084c1779088967df7cde7aef1ac91587d68ab3bb.zip
gcc-084c1779088967df7cde7aef1ac91587d68ab3bb.tar.gz
gcc-084c1779088967df7cde7aef1ac91587d68ab3bb.tar.bz2
java-tree.h (DECL_NUM_STMTS): Rename to...
* java-tree.h (DECL_NUM_STMTS): Rename to... (DECL_ESTIMATED_INSNS): ... this. * lang.c (java_estimate_num_insns, java_estimate_num_insns_1): New static functions. (LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS): Define. * parser.y (add_stmt_to_compound): Do not account statements. * cp-lang.c (LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS): New. * decl.c (duplicate_decls): Use DECL_ESTIMATED_INSNS. (start_function): Use DECL_ESTIMATED_INSNS. * optimize.c (maybe_clone_body): Use DECL_ESTIMATED_INSNS. * decl2.c (maybe_emit_vtables): Fix marking vtables as needed in unit-at-a-time * c-common.c (c_estimate_num_insns_1): New static function. (c_estimate_num_insns): New global function. * c-common.h (DECL_NUM_STMTS): Rename to... (DECL_ESTIMATED_INSNS): ... this. (c_estimate_num_insns): Declare. * c-decl.c (duplicate_decls): Use DECL_ESTIMATED_INSNS. * c-lang.c (LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS): New. * c-semantics.c (add_stmt): Do not account statements. * langhooks-def.h (LANG_HOOKS_TREE_INLINING_ESTIMATE_NUM_INSNS): New. * langhooks.h (lang_hooks_for_tree_inlining): Add estimate_num_insns * params.def (max-inline-insns-auto, max-inline-insns-auto): set to 100. (max-inline-insns): set to 300. (min-inline-insns): set to 10. * tree-inline.c (struct inline_data): Rename inlined_stmts to inlined-insns. (INSNS_PER_STMT): Kill. (inlinable_function_p): Compute and store body size. (expand_call_inline): Likewise. (optimize_inline_calls): Likewise. From-SVN: r69113
Diffstat (limited to 'gcc/tree-inline.c')
-rw-r--r--gcc/tree-inline.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index c41ccea..3e68983f 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -93,9 +93,9 @@ typedef struct inline_data
int in_target_cleanup_p;
/* A list of the functions current function has inlined. */
varray_type inlined_fns;
- /* The approximate number of statements we have inlined in the
+ /* The approximate number of instructions we have inlined in the
current call stack. */
- int inlined_stmts;
+ int inlined_insns;
/* We use the same mechanism to build clones that we do to perform
inlining. However, there are a few places where we need to
distinguish between those two situations. This flag is true if
@@ -131,11 +131,6 @@ static tree find_alloca_call (tree);
static tree find_builtin_longjmp_call_1 (tree *, int *, void *);
static tree find_builtin_longjmp_call (tree);
-/* The approximate number of instructions per statement. This number
- need not be particularly accurate; it is used only to make
- decisions about when a function is too big to inline. */
-#define INSNS_PER_STMT (10)
-
/* Remap DECL during the copying of the BLOCK tree for the function. */
static tree
@@ -939,7 +934,7 @@ static int
inlinable_function_p (tree fn, inline_data *id, int nolimit)
{
int inlinable;
- int currfn_insns;
+ int currfn_insns = 0;
int max_inline_insns_single = MAX_INLINE_INSNS_SINGLE;
/* If we've already decided this function shouldn't be inlined,
@@ -959,7 +954,10 @@ inlinable_function_p (tree fn, inline_data *id, int nolimit)
max_inline_insns_single = MAX_INLINE_INSNS_AUTO;
/* The number of instructions (estimated) of current function. */
- currfn_insns = DECL_NUM_STMTS (fn) * INSNS_PER_STMT;
+ if (!nolimit && !DECL_ESTIMATED_INSNS (fn))
+ DECL_ESTIMATED_INSNS (fn)
+ = (*lang_hooks.tree_inlining.estimate_num_insns) (fn);
+ currfn_insns = DECL_ESTIMATED_INSNS (fn);
/* If we're not inlining things, then nothing is inlinable. */
if (! flag_inline_trees)
@@ -1008,8 +1006,7 @@ inlinable_function_p (tree fn, inline_data *id, int nolimit)
if (! (*lang_hooks.tree_inlining.disregard_inline_limits) (fn)
&& inlinable && !nolimit)
{
- int sum_insns = (id ? id->inlined_stmts : 0) * INSNS_PER_STMT
- + currfn_insns;
+ int sum_insns = (id ? id->inlined_insns : 0) + currfn_insns;
/* In the extreme case that we have exceeded the recursive inlining
limit by a huge factor (128), we just say no. Should not happen
in real life. */
@@ -1394,9 +1391,9 @@ expand_call_inline (tree *tp, int *walk_subtrees, void *data)
TREE_USED (*tp) = 1;
/* Our function now has more statements than it did before. */
- DECL_NUM_STMTS (VARRAY_TREE (id->fns, 0)) += DECL_NUM_STMTS (fn);
+ DECL_ESTIMATED_INSNS (VARRAY_TREE (id->fns, 0)) += DECL_ESTIMATED_INSNS (fn);
/* For accounting, subtract one for the saved call/ret. */
- id->inlined_stmts += DECL_NUM_STMTS (fn) - 1;
+ id->inlined_insns += DECL_ESTIMATED_INSNS (fn) - 1;
/* Update callgraph if needed. */
if (id->decl && flag_unit_at_a_time)
@@ -1412,7 +1409,7 @@ expand_call_inline (tree *tp, int *walk_subtrees, void *data)
/* If we've returned to the top level, clear out the record of how
much inlining has been done. */
if (VARRAY_ACTIVE_SIZE (id->fns) == id->first_inlined_fn)
- id->inlined_stmts = 0;
+ id->inlined_insns = 0;
/* Don't walk into subtrees. We've already handled them above. */
*walk_subtrees = 0;
@@ -1452,6 +1449,9 @@ optimize_inline_calls (tree fn)
/* Don't allow recursion into FN. */
VARRAY_TREE_INIT (id.fns, 32, "fns");
VARRAY_PUSH_TREE (id.fns, fn);
+ if (!DECL_ESTIMATED_INSNS (fn))
+ DECL_ESTIMATED_INSNS (fn)
+ = (*lang_hooks.tree_inlining.estimate_num_insns) (fn);
/* Or any functions that aren't finished yet. */
prev_fn = NULL_TREE;
if (current_function_decl)