optimize.c (expand_call_inline): Don't recurse into the code used to initialize the parameters more than once.

* optimize.c (expand_call_inline): Don't recurse into the code
	used to initialize the parameters more than once.

From-SVN: r34501
This commit is contained in:
Mark Mitchell 2000-06-12 19:26:43 +00:00 committed by Mark Mitchell
parent f6f8291af0
commit 071f9809f9
3 changed files with 44 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2000-06-12 Mark Mitchell <mark@codesourcery.com>
* optimize.c (expand_call_inline): Don't recurse into the code
used to initialize the parameters more than once.
2000-06-11 Mark Mitchell <mark@codesourcery.com>
* mangle.c (NESTED_TEMPLATE_MATCH): Fix typo in comment.

View File

@ -612,6 +612,7 @@ expand_call_inline (tp, walk_subtrees, data)
tree scope_stmt;
tree use_stmt;
tree arg_inits;
tree *inlined_body;
splay_tree st;
/* See what we've got. */
@ -724,8 +725,10 @@ expand_call_inline (tp, walk_subtrees, data)
/* After we've initialized the parameters, we insert the body of the
function itself. */
STMT_EXPR_STMT (expr)
= chainon (STMT_EXPR_STMT (expr), copy_body (id));
inlined_body = &STMT_EXPR_STMT (expr);
while (*inlined_body)
inlined_body = &TREE_CHAIN (*inlined_body);
*inlined_body = copy_body (id);
/* Close the block for the parameters. */
scope_stmt = build_min_nt (SCOPE_STMT, DECL_INITIAL (fn));
@ -771,7 +774,7 @@ expand_call_inline (tp, walk_subtrees, data)
TREE_USED (*tp) = 1;
/* Recurse into the body of the just inlined function. */
expand_calls_inline (tp, id);
expand_calls_inline (inlined_body, id);
VARRAY_POP (id->fns);
/* Don't walk into subtrees. We've already handled them above. */

View File

@ -0,0 +1,33 @@
// Origin: Jakub Jelinek <jakub@redhat.com>
// Special g++ Options: -O2
class baz
{
public:
baz& operator += (const baz&);
};
inline baz& baz::operator += (const baz& r)
{
return *this;
}
inline baz operator + (int x, const baz& y)
{
return y;
}
static inline baz bar (int alpha);
static inline baz foo (int alpha)
{
baz tmp = alpha + foo (alpha);
tmp += alpha + bar (alpha);
return tmp;
}
static inline baz bar (int alpha)
{
baz tmp = alpha + bar (alpha);
tmp += alpha + foo (alpha);
return tmp;
}