aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>1999-12-13 08:40:04 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1999-12-13 08:40:04 +0000
commit92e8164f763bb6082f8c3067ef95c302dfce6f09 (patch)
treeb88606b40861d33205c04c18d76e5072f2192a7e /gcc
parent2ecac43338fb3bf41c7d5d56049fa865df5f71f0 (diff)
downloadgcc-92e8164f763bb6082f8c3067ef95c302dfce6f09.zip
gcc-92e8164f763bb6082f8c3067ef95c302dfce6f09.tar.gz
gcc-92e8164f763bb6082f8c3067ef95c302dfce6f09.tar.bz2
optimize.c (initialize_inlined_parameters): Take FN to which the parameters belong as an argument.
* optimize.c (initialize_inlined_parameters): Take FN to which the parameters belong as an argument. (expand_call_inline): Expand calls into the parameter initializations before pushing the function onto the list of functions we are presently expanding. From-SVN: r30888
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/optimize.c38
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/inline2.C11
3 files changed, 41 insertions, 16 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 640a164..9521c19 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+1999-12-13 Mark Mitchell <mark@codesourcery.com>
+
+ * optimize.c (initialize_inlined_parameters): Take FN to which the
+ parameters belong as an argument.
+ (expand_call_inline): Expand calls into the parameter
+ initializations before pushing the function onto the list of
+ functions we are presently expanding.
+
1999-12-11 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* class.c (get_vtable_name): Use a literal format string and
diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c
index 374e90b..ee33886 100644
--- a/gcc/cp/optimize.c
+++ b/gcc/cp/optimize.c
@@ -67,7 +67,7 @@ typedef struct inline_data
/* Prototypes. */
-static tree initialize_inlined_parameters PROTO((inline_data *, tree));
+static tree initialize_inlined_parameters PROTO((inline_data *, tree, tree));
static tree declare_return_variable PROTO((inline_data *, tree *));
static tree copy_body_r PROTO((tree *, int *, void *));
static tree copy_body PROTO((inline_data *));
@@ -342,18 +342,17 @@ copy_body (id)
top of the stack in ID from the ARGS (presented as a TREE_LIST). */
static tree
-initialize_inlined_parameters (id, args)
+initialize_inlined_parameters (id, args, fn)
inline_data *id;
tree args;
+ tree fn;
{
- tree fn;
tree init_stmts;
tree parms;
tree a;
tree p;
/* Figure out what the parameters are. */
- fn = VARRAY_TOP_TREE (id->fns);
parms = DECL_ARGUMENTS (fn);
/* Start with no initializations whatsoever. */
@@ -517,6 +516,7 @@ expand_call_inline (tp, walk_subtrees, data)
tree fn;
tree scope_stmt;
tree use_stmt;
+ tree arg_inits;
splay_tree st;
/* See what we've got. */
@@ -570,11 +570,6 @@ expand_call_inline (tp, walk_subtrees, data)
if (!inlinable_function_p (fn, id))
return NULL_TREE;
- /* Return statements in the function body will be replaced by jumps
- to the RET_LABEL. */
- id->ret_label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
- DECL_CONTEXT (id->ret_label) = VARRAY_TREE (id->fns, 0);
-
/* Build a statement-expression containing code to initialize the
arguments, the actual inline expansion of the body, and a label
for the return statements within the function to jump to. The
@@ -582,10 +577,6 @@ expand_call_inline (tp, walk_subtrees, data)
function call. */
expr = build_min (STMT_EXPR, TREE_TYPE (TREE_TYPE (fn)), NULL_TREE);
- /* Record the function we are about to inline so that we can avoid
- recursing into it. */
- VARRAY_PUSH_TREE (id->fns, fn);
-
/* Local declarations will be replaced by their equivalents in this
map. */
st = id->decl_map;
@@ -593,9 +584,24 @@ expand_call_inline (tp, walk_subtrees, data)
NULL, NULL);
/* Initialize the parameters. */
- STMT_EXPR_STMT (expr)
- = initialize_inlined_parameters (id, TREE_OPERAND (t, 1));
-
+ arg_inits = initialize_inlined_parameters (id, TREE_OPERAND (t, 1), fn);
+ /* Expand any inlined calls in the initializers. Do this before we
+ push FN on the stack of functions we are inlining; we want to
+ inline calls to FN that appear in the initializers for the
+ parameters. */
+ expand_calls_inline (&arg_inits, id);
+ /* And add them to the tree. */
+ STMT_EXPR_STMT (expr) = chainon (STMT_EXPR_STMT (expr), arg_inits);
+
+ /* Record the function we are about to inline so that we can avoid
+ recursing into it. */
+ VARRAY_PUSH_TREE (id->fns, fn);
+
+ /* Return statements in the function body will be replaced by jumps
+ to the RET_LABEL. */
+ id->ret_label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
+ DECL_CONTEXT (id->ret_label) = VARRAY_TREE (id->fns, 0);
+
/* Create a block to put the parameters in. We have to do this
after the parameters have been remapped because remapping
parameters is different from remapping ordinary variables. */
diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline2.C b/gcc/testsuite/g++.old-deja/g++.other/inline2.C
new file mode 100644
index 0000000..eb7794d
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/inline2.C
@@ -0,0 +1,11 @@
+// Origin: Martin Reinecke <martin@MPA-Garching.MPG.DE>
+// Build don't link:
+// Special g++ Options: -O2 -Winline
+
+#include <cmath>
+
+int main()
+{
+ double foo = 4.5;
+ if (abs (0.5-abs (foo-0.5)) < 1e-10) foo+=1;
+}