This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] fix 17796
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 14 Oct 2005 17:38:46 +0100
- Subject: [C++ PATCH] fix 17796
I've installed this patch to fix 17796. We set DECL_USED for all but the first
cloned function. (I've been leaning more to the view that we shouldn't have
clones at all, but simply emit inlineable forwarding functions and let the
optimizers sort things out ... but that's not for now.)
built & tested on i686-pc-linux-gnu.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2005-10-14 Nathan Sidwell <nathan@codesourcery.com>
PR c++/17796
* optimize.c (update_cloned_parm): Add FIRST parameter. Use it.
(maybe_clone_body): Track the first clone.
Index: cp/optimize.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/optimize.c,v
retrieving revision 1.118
diff -c -3 -p -r1.118 optimize.c
*** cp/optimize.c 25 Jun 2005 00:58:13 -0000 1.118
--- cp/optimize.c 14 Oct 2005 16:26:49 -0000
*************** Software Foundation, 51 Franklin Street,
*** 45,51 ****
/* Prototypes. */
! static void update_cloned_parm (tree, tree);
/* CLONED_PARM is a copy of CLONE, generated for a cloned constructor
or destructor. Update it to ensure that the source-position for
--- 45,51 ----
/* Prototypes. */
! static void update_cloned_parm (tree, tree, bool);
/* CLONED_PARM is a copy of CLONE, generated for a cloned constructor
or destructor. Update it to ensure that the source-position for
*************** static void update_cloned_parm (tree, tr
*** 53,59 ****
debugging generation code will be able to find the original PARM. */
static void
! update_cloned_parm (tree parm, tree cloned_parm)
{
DECL_ABSTRACT_ORIGIN (cloned_parm) = parm;
--- 53,59 ----
debugging generation code will be able to find the original PARM. */
static void
! update_cloned_parm (tree parm, tree cloned_parm, bool first)
{
DECL_ABSTRACT_ORIGIN (cloned_parm) = parm;
*************** update_cloned_parm (tree parm, tree clon
*** 63,69 ****
/* The definition might have different constness. */
TREE_READONLY (cloned_parm) = TREE_READONLY (parm);
! TREE_USED (cloned_parm) = TREE_USED (parm);
/* The name may have changed from the declaration. */
DECL_NAME (cloned_parm) = DECL_NAME (parm);
--- 63,69 ----
/* The definition might have different constness. */
TREE_READONLY (cloned_parm) = TREE_READONLY (parm);
! TREE_USED (cloned_parm) = !first || TREE_USED (parm);
/* The name may have changed from the declaration. */
DECL_NAME (cloned_parm) = DECL_NAME (parm);
*************** bool
*** 79,84 ****
--- 79,85 ----
maybe_clone_body (tree fn)
{
tree clone;
+ bool first = true;
/* We only clone constructors and destructors. */
if (!DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (fn)
*************** maybe_clone_body (tree fn)
*** 118,124 ****
parm = DECL_ARGUMENTS (fn);
clone_parm = DECL_ARGUMENTS (clone);
/* Update the `this' parameter, which is always first. */
! update_cloned_parm (parm, clone_parm);
parm = TREE_CHAIN (parm);
clone_parm = TREE_CHAIN (clone_parm);
if (DECL_HAS_IN_CHARGE_PARM_P (fn))
--- 119,125 ----
parm = DECL_ARGUMENTS (fn);
clone_parm = DECL_ARGUMENTS (clone);
/* Update the `this' parameter, which is always first. */
! update_cloned_parm (parm, clone_parm, first);
parm = TREE_CHAIN (parm);
clone_parm = TREE_CHAIN (clone_parm);
if (DECL_HAS_IN_CHARGE_PARM_P (fn))
*************** maybe_clone_body (tree fn)
*** 130,136 ****
for (; parm;
parm = TREE_CHAIN (parm), clone_parm = TREE_CHAIN (clone_parm))
/* Update this parameter. */
! update_cloned_parm (parm, clone_parm);
/* Start processing the function. */
start_preparsed_function (clone, NULL_TREE, SF_PRE_PARSED);
--- 131,137 ----
for (; parm;
parm = TREE_CHAIN (parm), clone_parm = TREE_CHAIN (clone_parm))
/* Update this parameter. */
! update_cloned_parm (parm, clone_parm, first);
/* Start processing the function. */
start_preparsed_function (clone, NULL_TREE, SF_PRE_PARSED);
*************** maybe_clone_body (tree fn)
*** 206,211 ****
--- 207,213 ----
finish_function (0);
BLOCK_ABSTRACT_ORIGIN (DECL_INITIAL (clone)) = DECL_INITIAL (fn);
expand_or_defer_fn (clone);
+ first = false;
}
pop_from_top_level ();