This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/24172] [4.1 Regression] error: incorrect sharing of tree nodes
- From: "hubicka at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Oct 2005 21:18:34 -0000
- Subject: [Bug tree-optimization/24172] [4.1 Regression] error: incorrect sharing of tree nodes
- References: <bug-24172-11423@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #13 from hubicka at gcc dot gnu dot org 2005-10-27 21:18 -------
This is patch I am testing to prevent the sharing. I think it is good idea in
addition to Richard's patch to make fold do it's job too:
void IOException( char);
inline int* dummy( const char* const mode )
{
IOException(*mode+*mode);
}
void prepare_inpaint( )
{
dummy ("rb");
}
Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.212
diff -c -3 -p -r1.212 tree-inline.c
*** tree-inline.c 12 Oct 2005 23:34:09 -0000 1.212
--- tree-inline.c 27 Oct 2005 21:16:34 -0000
*************** copy_body_r (tree *tp, int *walk_subtree
*** 639,644 ****
--- 639,645 ----
n = splay_tree_lookup (id->decl_map, (splay_tree_key) decl);
if (n)
{
+ tree new;
/* If we happen to get an ADDR_EXPR in n->value, strip
it manually here as we'll eventually get ADDR_EXPRs
which lie about their types pointed to. In this case
*************** copy_body_r (tree *tp, int *walk_subtree
*** 646,658 ****
but we absolutely rely on that. As fold_indirect_ref
does other useful transformations, try that first, though. */
tree type = TREE_TYPE (TREE_TYPE ((tree)n->value));
! *tp = fold_indirect_ref_1 (type, (tree)n->value);
if (! *tp)
{
! if (TREE_CODE ((tree)n->value) == ADDR_EXPR)
! *tp = TREE_OPERAND ((tree)n->value, 0);
else
! *tp = build1 (INDIRECT_REF, type, (tree)n->value);
}
*walk_subtrees = 0;
return NULL;
--- 647,660 ----
but we absolutely rely on that. As fold_indirect_ref
does other useful transformations, try that first, though. */
tree type = TREE_TYPE (TREE_TYPE ((tree)n->value));
! new = unshare_expr ((tree)n->value);
! *tp = fold_indirect_ref_1 (type, new);
if (! *tp)
{
! if (TREE_CODE (new) == ADDR_EXPR)
! *tp = TREE_OPERAND (new, 0);
else
! *tp = build1 (INDIRECT_REF, type, new);
}
*walk_subtrees = 0;
return NULL;
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24172