Commit d7d1d041 by Richard Guenther Committed by Richard Biener

re PR middle-end/47663 (Very simple wrapper not inlined)

2011-04-06  Richard Guenther  <rguenther@suse.de>
 
	PR tree-optimization/47663
	* cgraph.h (struct cgraph_edge): Add call_stmt_size and
	call_stmt_time fields.
	(cgraph_edge_inlinable_p): Declare.
	(cgraph_edge_recursive_p): New inline function.
	* cgraph.c (cgraph_create_edge_1): Initialize call_stmt_size.
	(cgraph_clone_edge): Copy it.
	* ipa-inline.c (cgraph_estimate_edge_time): New function.
	Account for call stmt time.
	(cgraph_estimate_time_after_inlining): Take edge argument.
	(cgraph_estimate_edge_growth): Account call stmt size.
	(cgraph_estimate_size_after_inlining): Take edge argument.
	(cgraph_mark_inline_edge): Adjust.
	(cgraph_check_inline_limits): Likewise.
	(cgraph_recursive_inlining_p): Remove.
	(cgraph_edge_badness): Use cgraph_edge_recursive_p.
	(cgraph_decide_recursive_inlining): Take edge argument and
	adjust.
	(cgraph_decide_inlining_of_small_functions): Do not avoid
	diags for recursive inlining here.
	(cgraph_flatten): Adjust.
	(cgraph_decide_inlining_incrementally): Likewise.
	(estimate_function_body_sizes): Remove call cost handling.
	(compute_inline_parameters): Initialize caller edge call costs.
	(cgraph_estimate_edge_growth): New function.
	(cgraph_estimate_growth): Use it.
	(cgraph_edge_badness): Likewise.
	(cgraph_check_inline_limits): Take an edge argument.
	(cgraph_decide_inlining_of_small_functions): Adjust.
	(cgraph_decide_inlining): Likewise.
	* tree-inline.c (estimate_num_insns): Only account for call
	return value if it is used.
	(expand_call_inline): Avoid diagnostics on recursive inline
	functions here.
	* lto-cgraph.c (lto_output_edge): Output edge call costs.
	(input_edge): Input edge call costs.

	* gcc.dg/tree-ssa/inline-8.c: New testcase.

From-SVN: r172023
parent 2feb95f7
2011-04-06 Richard Guenther <rguenther@suse.de>
PR tree-optimization/47663
* cgraph.h (struct cgraph_edge): Add call_stmt_size and
call_stmt_time fields.
(cgraph_edge_inlinable_p): Declare.
(cgraph_edge_recursive_p): New inline function.
* cgraph.c (cgraph_create_edge_1): Initialize call_stmt_size.
(cgraph_clone_edge): Copy it.
* ipa-inline.c (cgraph_estimate_edge_time): New function.
Account for call stmt time.
(cgraph_estimate_time_after_inlining): Take edge argument.
(cgraph_estimate_edge_growth): Account call stmt size.
(cgraph_estimate_size_after_inlining): Take edge argument.
(cgraph_mark_inline_edge): Adjust.
(cgraph_check_inline_limits): Likewise.
(cgraph_recursive_inlining_p): Remove.
(cgraph_edge_badness): Use cgraph_edge_recursive_p.
(cgraph_decide_recursive_inlining): Take edge argument and
adjust.
(cgraph_decide_inlining_of_small_functions): Do not avoid
diags for recursive inlining here.
(cgraph_flatten): Adjust.
(cgraph_decide_inlining_incrementally): Likewise.
(estimate_function_body_sizes): Remove call cost handling.
(compute_inline_parameters): Initialize caller edge call costs.
(cgraph_estimate_edge_growth): New function.
(cgraph_estimate_growth): Use it.
(cgraph_edge_badness): Likewise.
(cgraph_check_inline_limits): Take an edge argument.
(cgraph_decide_inlining_of_small_functions): Adjust.
(cgraph_decide_inlining): Likewise.
* tree-inline.c (estimate_num_insns): Only account for call
return value if it is used.
(expand_call_inline): Avoid diagnostics on recursive inline
functions here.
* lto-cgraph.c (lto_output_edge): Output edge call costs.
(input_edge): Input edge call costs.
2011-04-06 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* config/alpha/osf5.h (MAX_OFILE_ALIGNMENT): Define.
......
......@@ -1032,6 +1032,8 @@ cgraph_create_edge_1 (struct cgraph_node *caller, struct cgraph_node *callee,
edge->loop_nest = nest;
edge->call_stmt = call_stmt;
edge->call_stmt_size = 0;
edge->call_stmt_time = 0;
push_cfun (DECL_STRUCT_FUNCTION (caller->decl));
edge->can_throw_external
= call_stmt ? stmt_can_throw_external (call_stmt) : false;
......@@ -2141,6 +2143,8 @@ cgraph_clone_edge (struct cgraph_edge *e, struct cgraph_node *n,
}
}
new_edge->call_stmt_size = e->call_stmt_size;
new_edge->call_stmt_time = e->call_stmt_time;
new_edge->inline_failed = e->inline_failed;
new_edge->indirect_inlining_edge = e->indirect_inlining_edge;
new_edge->lto_stmt_uid = stmt_uid;
......
......@@ -431,6 +431,9 @@ struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"))) cgrap
int frequency;
/* Unique id of the edge. */
int uid;
/* Estimated size and time of the call statement. */
int call_stmt_size;
int call_stmt_time;
/* Depth of loop nest, 1 means no loop nest. */
unsigned short int loop_nest;
/* Whether this edge was made direct by indirect inlining. */
......@@ -771,6 +774,7 @@ varpool_next_static_initializer (struct varpool_node *node)
/* In ipa-inline.c */
void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool, bool);
void compute_inline_parameters (struct cgraph_node *);
cgraph_inline_failed_t cgraph_edge_inlinable_p (struct cgraph_edge *);
/* Create a new static variable of type TYPE. */
......@@ -958,6 +962,17 @@ varpool_all_refs_explicit_p (struct varpool_node *vnode)
/* Constant pool accessor function. */
htab_t constant_pool_htab (void);
/* Return true when the edge E represents a direct recursion. */
static inline bool
cgraph_edge_recursive_p (struct cgraph_edge *e)
{
if (e->caller->global.inlined_to)
return e->caller->global.inlined_to->decl == e->callee->decl;
else
return e->caller->decl == e->callee->decl;
}
/* FIXME: inappropriate dependency of cgraph on IPA. */
#include "ipa-ref-inline.h"
......
......@@ -285,6 +285,8 @@ lto_output_edge (struct lto_simple_output_block *ob, struct cgraph_edge *edge,
bp_pack_value (&bp, uid, HOST_BITS_PER_INT);
bp_pack_value (&bp, edge->inline_failed, HOST_BITS_PER_INT);
bp_pack_value (&bp, edge->frequency, HOST_BITS_PER_INT);
bp_pack_value (&bp, edge->call_stmt_size, HOST_BITS_PER_INT);
bp_pack_value (&bp, edge->call_stmt_time, HOST_BITS_PER_INT);
bp_pack_value (&bp, edge->loop_nest, 30);
bp_pack_value (&bp, edge->indirect_inlining_edge, 1);
bp_pack_value (&bp, edge->call_stmt_cannot_inline_p, 1);
......@@ -1215,6 +1217,7 @@ input_edge (struct lto_input_block *ib, VEC(cgraph_node_ptr, heap) *nodes,
cgraph_inline_failed_t inline_failed;
struct bitpack_d bp;
int ecf_flags = 0;
int call_stmt_time, call_stmt_size;
caller = VEC_index (cgraph_node_ptr, nodes, lto_input_sleb128 (ib));
if (caller == NULL || caller->decl == NULL_TREE)
......@@ -1236,6 +1239,8 @@ input_edge (struct lto_input_block *ib, VEC(cgraph_node_ptr, heap) *nodes,
inline_failed = (cgraph_inline_failed_t) bp_unpack_value (&bp,
HOST_BITS_PER_INT);
freq = (int) bp_unpack_value (&bp, HOST_BITS_PER_INT);
call_stmt_size = (int) bp_unpack_value (&bp, HOST_BITS_PER_INT);
call_stmt_time = (int) bp_unpack_value (&bp, HOST_BITS_PER_INT);
nest = (unsigned) bp_unpack_value (&bp, 30);
if (indirect)
......@@ -1248,6 +1253,8 @@ input_edge (struct lto_input_block *ib, VEC(cgraph_node_ptr, heap) *nodes,
edge->inline_failed = inline_failed;
edge->call_stmt_cannot_inline_p = bp_unpack_value (&bp, 1);
edge->can_throw_external = bp_unpack_value (&bp, 1);
edge->call_stmt_size = call_stmt_size;
edge->call_stmt_time = call_stmt_time;
if (indirect)
{
if (bp_unpack_value (&bp, 1))
......
2011-04-06 Richard Guenther <rguenther@suse.de>
PR tree-optimization/47663
* gcc.dg/tree-ssa/inline-8.c: New testcase.
2011-04-05 Eric Botcazou <ebotcazou@adacore.com>
* gcc.dg/torture/pr47917.c: Add -D_XOPEN_SOURCE=500 to dg-options for
......
/* { dg-do compile } */
/* { dg-options "-O -finline-small-functions --param early-inlining-insns=0 -fdump-tree-einline" } */
int foo0();
void bar0() { foo0(); }
void foobar0() { bar0(); }
void foo1();
void bar1() { foo1(); }
void foobar1() { bar1(); }
#if 0
int foo2();
int bar2() { return foo2(); }
/* The size estimate fails to see that inlining the call statement in bar2
will make its lhs dead. */
void foobar2() { bar2(); }
#endif
int foo3();
int bar3() { return foo3(); }
int foobar3() { return bar3(); }
int bar4() { return 0; }
void foobar4() { bar4(); }
int bar5() { return 0; }
int foobar5() { return bar5(); }
/* { dg-final { scan-tree-dump-times "Inlining" 5 "einline" } } */
/* { dg-final { cleanup-tree-dump "einline" } } */
......@@ -3514,7 +3514,8 @@ estimate_num_insns (gimple stmt, eni_weights *weights)
if (decl)
funtype = TREE_TYPE (decl);
if (!VOID_TYPE_P (TREE_TYPE (funtype)))
if (!VOID_TYPE_P (TREE_TYPE (funtype))
&& gimple_call_lhs (stmt))
cost += estimate_move_cost (TREE_TYPE (funtype));
if (funtype)
......@@ -3812,6 +3813,8 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id)
&& !DECL_IN_SYSTEM_HEADER (fn)
&& reason != CIF_UNSPECIFIED
&& !lookup_attribute ("noinline", DECL_ATTRIBUTES (fn))
/* Do not warn about not inlined recursive calls. */
&& !cgraph_edge_recursive_p (cg_edge)
/* Avoid warnings during early inline pass. */
&& cgraph_global_info_ready)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment