diff options
Diffstat (limited to 'gcc/tree-inline.c')
-rw-r--r-- | gcc/tree-inline.c | 28 |
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) |