Remove gimple_before_inlining
Richard Henderson
rth@redhat.com
Wed Jul 7 03:25:00 GMT 2004
It's not actually used by any of the front ends anymore.
And, really, can't be due to function unnesting.
r~
* langhooks-def.h (LANG_HOOKS_GIMPLE_BEFORE_INLINING): Remove.
* langhooks.h (struct lang_hooks): Remove gimple_before_inlining.
* tree-inline.c (copy_body_r, setup_one_parameter,
initialize_inlined_parameters, expand_call_inline,
declare_inline_vars): Don't check it.
(expand_calls_inline): Remove old version, rename new version
from gimple_expand_calls_inline.
* tree-optimize.c (execute_gimple): Remove.
(pass_gimple): Don't run anything.
Index: langhooks-def.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks-def.h,v
retrieving revision 1.82
diff -c -p -d -r1.82 langhooks-def.h
*** langhooks-def.h 6 Jul 2004 02:20:05 -0000 1.82
--- langhooks-def.h 7 Jul 2004 03:15:11 -0000
*************** extern int lhd_gimplify_expr (tree *, tr
*** 201,207 ****
/* Hooks for tree gimplification. */
#define LANG_HOOKS_GIMPLIFY_EXPR lhd_gimplify_expr
#define LANG_HOOKS_FOLD_OBJ_TYPE_REF NULL
- #define LANG_HOOKS_GIMPLE_BEFORE_INLINING true
/* Tree dump hooks. */
extern bool lhd_tree_dump_dump_tree (void *, tree);
--- 201,206 ----
*************** extern tree lhd_make_node (enum tree_cod
*** 319,325 ****
LANG_HOOKS_FOR_TYPES_INITIALIZER, \
LANG_HOOKS_GIMPLIFY_EXPR, \
LANG_HOOKS_FOLD_OBJ_TYPE_REF, \
- LANG_HOOKS_GIMPLE_BEFORE_INLINING \
}
#endif /* GCC_LANG_HOOKS_DEF_H */
--- 318,323 ----
Index: langhooks.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks.h,v
retrieving revision 1.88
diff -c -p -d -r1.88 langhooks.h
*** langhooks.h 6 Jul 2004 02:20:05 -0000 1.88
--- langhooks.h 7 Jul 2004 03:15:11 -0000
*************** struct lang_hooks
*** 427,436 ****
KNOWN_TYPE carries the true type of the OBJ_TYPE_REF_OBJECT. */
tree (*fold_obj_type_ref) (tree, tree);
- /* True if the front end has gimplified the function before running the
- inliner, false if the front end generates GENERIC directly. */
- bool gimple_before_inlining;
-
/* Whenever you add entries here, make sure you adjust langhooks-def.h
and langhooks.c accordingly. */
};
--- 427,432 ----
Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.123
diff -c -p -d -r1.123 tree-inline.c
*** tree-inline.c 6 Jul 2004 20:01:09 -0000 1.123
--- tree-inline.c 7 Jul 2004 03:15:11 -0000
*************** copy_body_r (tree *tp, int *walk_subtree
*** 483,491 ****
if (assignment)
{
/* Do not create a statement containing a naked RESULT_DECL. */
! if (lang_hooks.gimple_before_inlining)
! if (TREE_CODE (assignment) == RESULT_DECL)
! gimplify_stmt (&assignment);
*tp = build (BIND_EXPR, void_type_node, NULL, NULL, NULL);
append_to_statement_list (assignment, &BIND_EXPR_BODY (*tp));
--- 483,490 ----
if (assignment)
{
/* Do not create a statement containing a naked RESULT_DECL. */
! if (TREE_CODE (assignment) == RESULT_DECL)
! gimplify_stmt (&assignment);
*tp = build (BIND_EXPR, void_type_node, NULL, NULL, NULL);
append_to_statement_list (assignment, &BIND_EXPR_BODY (*tp));
*************** setup_one_parameter (inline_data *id, tr
*** 709,732 ****
Theoretically, we could check the expression to see if
all of the variables that determine its value are
read-only, but we don't bother. */
! if ((TREE_CONSTANT (value) || TREE_READONLY_DECL_P (value))
! /* We may produce non-gimple trees by adding NOPs or introduce
! invalid sharing when operand is not really constant.
! It is not big deal to prohibit constant propagation here as
! we will constant propagate in DOM1 pass anyway. */
! && (!lang_hooks.gimple_before_inlining
! || (is_gimple_min_invariant (value)
! && TREE_TYPE (value) == TREE_TYPE (p))))
{
- /* If this is a declaration, wrap it a NOP_EXPR so that
- we don't try to put the VALUE on the list of BLOCK_VARS. */
- if (DECL_P (value))
- value = build1 (NOP_EXPR, TREE_TYPE (value), value);
-
- /* If this is a constant, make sure it has the right type. */
- else if (TREE_TYPE (value) != TREE_TYPE (p))
- value = fold (build1 (NOP_EXPR, TREE_TYPE (p), value));
-
insert_decl_map (id, p, value);
return;
}
--- 708,720 ----
Theoretically, we could check the expression to see if
all of the variables that determine its value are
read-only, but we don't bother. */
! /* We may produce non-gimple trees by adding NOPs or introduce
! invalid sharing when operand is not really constant.
! It is not big deal to prohibit constant propagation here as
! we will constant propagate in DOM1 pass anyway. */
! if (is_gimple_min_invariant (value)
! && lang_hooks.types_compatible_p (TREE_TYPE (value), TREE_TYPE (p)))
{
insert_decl_map (id, p, value);
return;
}
*************** setup_one_parameter (inline_data *id, tr
*** 760,766 ****
*vars = var;
/* Make gimplifier happy about this variable. */
! DECL_SEEN_IN_BIND_EXPR_P (var) = lang_hooks.gimple_before_inlining;
/* Even if P was TREE_READONLY, the new VAR should not be.
In the original code, we would have constructed a
--- 748,754 ----
*vars = var;
/* Make gimplifier happy about this variable. */
! DECL_SEEN_IN_BIND_EXPR_P (var) = 1;
/* Even if P was TREE_READONLY, the new VAR should not be.
In the original code, we would have constructed a
*************** initialize_inlined_parameters (inline_da
*** 856,862 ****
&gimplify_init_stmts_p);
}
! if (gimplify_init_stmts_p && lang_hooks.gimple_before_inlining)
gimplify_body (&init_stmts, current_function_decl);
declare_inline_vars (bind_expr, vars);
--- 844,850 ----
&gimplify_init_stmts_p);
}
! if (gimplify_init_stmts_p)
gimplify_body (&init_stmts, current_function_decl);
declare_inline_vars (bind_expr, vars);
*************** expand_call_inline (tree *tp, int *walk_
*** 1637,1687 ****
/* The new expression has side-effects if the old one did. */
TREE_SIDE_EFFECTS (expr) = TREE_SIDE_EFFECTS (t);
! /* If we are working with gimple form, then we need to keep the tree
! in gimple form. If we are not in gimple form, we can just replace
! *tp with the new BIND_EXPR. */
! if (lang_hooks.gimple_before_inlining)
! {
! tree save_decl;
!
! /* We want to create a new variable to hold the result of the inlined
! body. This new variable needs to be added to the function which we
! are inlining into, thus the saving and restoring of
! current_function_decl. */
! save_decl = current_function_decl;
! current_function_decl = id->node->decl;
! inline_result = voidify_wrapper_expr (expr, NULL);
! current_function_decl = save_decl;
!
! /* If the inlined function returns a result that we care about,
! then we're going to need to splice in a MODIFY_EXPR. Otherwise
! the call was a standalone statement and we can just replace it
! with the BIND_EXPR inline representation of the called function. */
! if (TREE_CODE (tsi_stmt (id->tsi)) != CALL_EXPR)
! {
! tsi_link_before (&id->tsi, expr, TSI_SAME_STMT);
! *tp = inline_result;
! }
! else
! *tp = expr;
!
! /* When we gimplify a function call, we may clear TREE_SIDE_EFFECTS on
! the call if it is to a "const" function. Thus the copy of
! TREE_SIDE_EFFECTS from the CALL_EXPR to the BIND_EXPR above with
! result in TREE_SIDE_EFFECTS not being set for the inlined copy of a
! "const" function.
!
! Unfortunately, that is wrong as inlining the function can
! create/expose interesting side effects (such as setting of a return
! value).
! The easiest solution is to simply recalculate TREE_SIDE_EFFECTS for
! the toplevel expression. */
! recalculate_side_effects (expr);
}
else
*tp = expr;
/* If the value of the new expression is ignored, that's OK. We
don't warn about this for CALL_EXPRs, so we shouldn't warn about
the equivalent inlined version either. */
--- 1625,1666 ----
/* The new expression has side-effects if the old one did. */
TREE_SIDE_EFFECTS (expr) = TREE_SIDE_EFFECTS (t);
! /* We want to create a new variable to hold the result of the inlined
! body. This new variable needs to be added to the function which we
! are inlining into, thus the saving and restoring of
! current_function_decl. */
! {
! tree save_decl = current_function_decl;
! current_function_decl = id->node->decl;
! inline_result = voidify_wrapper_expr (expr, NULL);
! current_function_decl = save_decl;
! }
! /* If the inlined function returns a result that we care about,
! then we're going to need to splice in a MODIFY_EXPR. Otherwise
! the call was a standalone statement and we can just replace it
! with the BIND_EXPR inline representation of the called function. */
! if (TREE_CODE (tsi_stmt (id->tsi)) != CALL_EXPR)
! {
! tsi_link_before (&id->tsi, expr, TSI_SAME_STMT);
! *tp = inline_result;
}
else
*tp = expr;
+ /* When we gimplify a function call, we may clear TREE_SIDE_EFFECTS on
+ the call if it is to a "const" function. Thus the copy of
+ TREE_SIDE_EFFECTS from the CALL_EXPR to the BIND_EXPR above with
+ result in TREE_SIDE_EFFECTS not being set for the inlined copy of a
+ "const" function.
+
+ Unfortunately, that is wrong as inlining the function can create/expose
+ interesting side effects (such as setting of a return value).
+
+ The easiest solution is to simply recalculate TREE_SIDE_EFFECTS for
+ the toplevel expression. */
+ recalculate_side_effects (expr);
+
/* If the value of the new expression is ignored, that's OK. We
don't warn about this for CALL_EXPRs, so we shouldn't warn about
the equivalent inlined version either. */
*************** expand_call_inline (tree *tp, int *walk_
*** 1706,1712 ****
}
static void
! gimple_expand_calls_inline (tree *stmt_p, inline_data *id)
{
tree stmt = *stmt_p;
enum tree_code code = TREE_CODE (stmt);
--- 1685,1691 ----
}
static void
! expand_calls_inline (tree *stmt_p, inline_data *id)
{
tree stmt = *stmt_p;
enum tree_code code = TREE_CODE (stmt);
*************** gimple_expand_calls_inline (tree *stmt_p
*** 1722,1728 ****
for (i = tsi_start (stmt); !tsi_end_p (i); )
{
id->tsi = i;
! gimple_expand_calls_inline (tsi_stmt_ptr (i), id);
new = tsi_stmt (i);
if (TREE_CODE (new) == STATEMENT_LIST)
--- 1701,1707 ----
for (i = tsi_start (stmt); !tsi_end_p (i); )
{
id->tsi = i;
! expand_calls_inline (tsi_stmt_ptr (i), id);
new = tsi_stmt (i);
if (TREE_CODE (new) == STATEMENT_LIST)
*************** gimple_expand_calls_inline (tree *stmt_p
*** 1737,1762 ****
break;
case COND_EXPR:
! gimple_expand_calls_inline (&COND_EXPR_THEN (stmt), id);
! gimple_expand_calls_inline (&COND_EXPR_ELSE (stmt), id);
break;
case CATCH_EXPR:
! gimple_expand_calls_inline (&CATCH_BODY (stmt), id);
break;
case EH_FILTER_EXPR:
! gimple_expand_calls_inline (&EH_FILTER_FAILURE (stmt), id);
break;
case TRY_CATCH_EXPR:
case TRY_FINALLY_EXPR:
! gimple_expand_calls_inline (&TREE_OPERAND (stmt, 0), id);
! gimple_expand_calls_inline (&TREE_OPERAND (stmt, 1), id);
break;
case BIND_EXPR:
! gimple_expand_calls_inline (&BIND_EXPR_BODY (stmt), id);
break;
case COMPOUND_EXPR:
--- 1716,1741 ----
break;
case COND_EXPR:
! expand_calls_inline (&COND_EXPR_THEN (stmt), id);
! expand_calls_inline (&COND_EXPR_ELSE (stmt), id);
break;
case CATCH_EXPR:
! expand_calls_inline (&CATCH_BODY (stmt), id);
break;
case EH_FILTER_EXPR:
! expand_calls_inline (&EH_FILTER_FAILURE (stmt), id);
break;
case TRY_CATCH_EXPR:
case TRY_FINALLY_EXPR:
! expand_calls_inline (&TREE_OPERAND (stmt, 0), id);
! expand_calls_inline (&TREE_OPERAND (stmt, 1), id);
break;
case BIND_EXPR:
! expand_calls_inline (&BIND_EXPR_BODY (stmt), id);
break;
case COMPOUND_EXPR:
*************** gimple_expand_calls_inline (tree *stmt_p
*** 1788,1817 ****
}
}
- /* Walk over the entire tree *TP, replacing CALL_EXPRs with inline
- expansions as appropriate. */
-
- static void
- expand_calls_inline (tree *tp, inline_data *id)
- {
- /* If we are not in gimple form, then we want to walk the tree
- recursively as we do not know anything about the structure
- of the tree. */
-
- if (!lang_hooks.gimple_before_inlining)
- {
- walk_tree (tp, expand_call_inline, id, id->tree_pruner);
- return;
- }
-
- /* We are in gimple form. We want to stay in gimple form. Walk
- the statements, inlining calls in each statement. By walking
- the statements, we have enough information to keep the tree
- in gimple form as we insert inline bodies. */
-
- gimple_expand_calls_inline (tp, id);
- }
-
/* Expand calls to inline functions in the body of FN. */
void
--- 1767,1772 ----
*************** debug_find_tree (tree top, tree search)
*** 2510,2522 ****
static void
declare_inline_vars (tree bind_expr, tree vars)
{
! if (lang_hooks.gimple_before_inlining)
! {
! tree t;
!
! for (t = vars; t; t = TREE_CHAIN (t))
! DECL_SEEN_IN_BIND_EXPR_P (t) = 1;
! }
add_var_to_bind_expr (bind_expr, vars);
}
--- 2465,2473 ----
static void
declare_inline_vars (tree bind_expr, tree vars)
{
! tree t;
! for (t = vars; t; t = TREE_CHAIN (t))
! DECL_SEEN_IN_BIND_EXPR_P (t) = 1;
add_var_to_bind_expr (bind_expr, vars);
}
Index: tree-optimize.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-optimize.c,v
retrieving revision 2.25
diff -c -p -d -r2.25 tree-optimize.c
*** tree-optimize.c 1 Jul 2004 01:12:17 -0000 2.25
--- tree-optimize.c 7 Jul 2004 03:15:11 -0000
*************** bool in_gimple_form;
*** 57,78 ****
/* The root of the compilation pass tree, once constructed. */
static struct tree_opt_pass *all_passes;
! /* Pass: gimplify the function if it's not been done. */
!
! static void
! execute_gimple (void)
! {
! /* We have this test here rather than as the gate because we always
! want to dump the original gimplified function. */
! if (!lang_hooks.gimple_before_inlining)
! gimplify_function_tree (current_function_decl);
! }
static struct tree_opt_pass pass_gimple =
{
"gimple", /* name */
NULL, /* gate */
! execute_gimple, /* execute */
NULL, /* sub */
NULL, /* next */
0, /* static_pass_number */
--- 57,69 ----
/* The root of the compilation pass tree, once constructed. */
static struct tree_opt_pass *all_passes;
! /* Pass: dump the gimplified, inlined, functions. */
static struct tree_opt_pass pass_gimple =
{
"gimple", /* name */
NULL, /* gate */
! NULL, /* execute */
NULL, /* sub */
NULL, /* next */
0, /* static_pass_number */
More information about the Gcc-patches
mailing list