This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RFC re static chain and inlining
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 24 Jul 04 12:31:53 EDT
- Subject: RFC re static chain and inlining
This relates to the message I sent earlier today to the GCC list.
The following patch fixes 38 ACATS tests, including c34007j.
It does so by treating static_chain_decl the same way the arguments are
handled, but I'm not sure that's correct, so I'd likesomebody who's more
familiar with this code than I to comment.
2004-07-24 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* function.h (struct function): Add field saved_static_chain_decl.
Fix comment for static_chain_decl.
* tree-inline.c (save_body): Add new arg and handle static_chain_decl.
* tree-inline.h (save_body): Add new arg.
* tree-optimize.c (tree_rest_of_compilation): Handle saving
static_chain_decl.
*** function.h 14 Jul 2004 07:30:15 -0000 1.129
--- function.h 24 Jul 2004 16:00:39 -0000
*************** struct function GTY(())
*** 174,177 ****
--- 174,178 ----
tree saved_tree;
tree saved_args;
+ tree saved_static_chain_decl;
/* For function.c. */
*************** struct function GTY(())
*** 255,259 ****
HOST_WIDE_INT x_frame_offset;
! /* A VAR_DECL that should contain the static chain for this function.
It will be initialized at the beginning of the function. */
tree static_chain_decl;
--- 256,260 ----
HOST_WIDE_INT x_frame_offset;
! /* A PARM_DECL that should contain the static chain for this function.
It will be initialized at the beginning of the function. */
tree static_chain_decl;
*** tree-inline.c 22 Jul 2004 19:01:03 -0000 1.130
--- tree-inline.c 24 Jul 2004 16:00:43 -0000
*************** clone_body (tree clone, tree fn, void *a
*** 1878,1885 ****
}
! /* Save duplicate of body in FN. MAP is used to pass around splay tree
! used to update arguments in restore_body. */
tree
! save_body (tree fn, tree *arg_copy)
{
inline_data id;
--- 1878,1886 ----
}
! /* Make and return duplicate of body in FN. Put copies of DECL_ARGUMENTS
! in *arg_copy and of the static chain, if any, in *sc_copy. */
!
tree
! save_body (tree fn, tree *arg_copy, tree *sc_copy)
{
inline_data id;
*************** save_body (tree fn, tree *arg_copy)
*** 1905,1908 ****
--- 1906,1921 ----
}
+ *sc_copy = DECL_STRUCT_FUNCTION (fn)->static_chain_decl;
+ if (*sc_copy)
+ {
+ tree new = copy_node (*sc_copy);
+
+ lang_hooks.dup_lang_specific_decl (new);
+ DECL_ABSTRACT_ORIGIN (new) = DECL_ORIGIN (*sc_copy);
+ insert_decl_map (&id, *sc_copy, new);
+ TREE_CHAIN (new) = TREE_CHAIN (*sc_copy);
+ *sc_copy = new;
+ }
+
insert_decl_map (&id, DECL_RESULT (fn), DECL_RESULT (fn));
*** tree-inline.h 3 Jul 2004 00:15:43 -0000 1.11
--- tree-inline.h 24 Jul 2004 16:00:43 -0000
*************** Boston, MA 02111-1307, USA. */
*** 27,34 ****
void optimize_inline_calls (tree);
bool tree_inlinable_function_p (tree);
! tree copy_tree_r (tree*, int*, void*);
! void clone_body (tree, tree, void*);
! tree save_body (tree, tree *);
! void remap_save_expr (tree*, void*, int*);
int estimate_num_insns (tree expr);
--- 27,34 ----
void optimize_inline_calls (tree);
bool tree_inlinable_function_p (tree);
! tree copy_tree_r (tree *, int *, void *);
! void clone_body (tree, tree, void *);
! tree save_body (tree, tree *, tree *);
! void remap_save_expr (tree *, void *, int *);
int estimate_num_insns (tree expr);
*** tree-optimize.c 22 Jul 2004 08:20:38 -0000 2.32
--- tree-optimize.c 24 Jul 2004 16:00:44 -0000
*************** tree_rest_of_compilation (tree fndecl, b
*** 519,523 ****
cgraph_clone_inlined_nodes (e, true);
}
! cfun->saved_tree = save_body (fndecl, &cfun->saved_args);
}
--- 521,527 ----
cgraph_clone_inlined_nodes (e, true);
}
! cfun->saved_static_chain_decl = cfun->static_chain_decl;
! cfun->saved_tree = save_body (fndecl, &cfun->saved_args,
! &cfun->saved_static_chain_decl);
}
*************** tree_rest_of_compilation (tree fndecl, b
*** 552,555 ****
--- 556,560 ----
DECL_SAVED_TREE (fndecl) = cfun->saved_tree;
DECL_ARGUMENTS (fndecl) = cfun->saved_args;
+ cfun->static_chain_decl = cfun->saved_static_chain_decl;
/* When not in unit-at-a-time mode, we must preserve out of line copy