summaryrefslogtreecommitdiff
path: root/gcc/tree-inline.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2005-10-30 19:14:15 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2005-10-30 18:14:15 +0000
commit5e13fdf7526539b77f38ed6aa14f993d542c4b9d (patch)
tree547504d63ebc99e12b881ae303cb2482daa00135 /gcc/tree-inline.c
parent25d8f0a2839a99417ab79879fb55f2ead76fcf2a (diff)
downloadgcc-5e13fdf7526539b77f38ed6aa14f993d542c4b9d.tar.gz
re PR tree-optimization/24172 (error: incorrect sharing of tree nodes)
PR tree-optimization/24172 * tree-inline.c (copy_body_r): Unshare the substituted value first. * g++.dg/tree-ssa/pr24172.C: New testcase. From-SVN: r106247
Diffstat (limited to 'gcc/tree-inline.c')
-rw-r--r--gcc/tree-inline.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 0f7ea978b72..228252fd709 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -639,6 +639,7 @@ copy_body_r (tree *tp, int *walk_subtrees, void *data)
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
@@ -646,13 +647,14 @@ copy_body_r (tree *tp, int *walk_subtrees, void *data)
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);
+ new = unshare_expr ((tree)n->value);
+ *tp = fold_indirect_ref_1 (type, new);
if (! *tp)
{
- if (TREE_CODE ((tree)n->value) == ADDR_EXPR)
- *tp = TREE_OPERAND ((tree)n->value, 0);
+ if (TREE_CODE (new) == ADDR_EXPR)
+ *tp = TREE_OPERAND (new, 0);
else
- *tp = build1 (INDIRECT_REF, type, (tree)n->value);
+ *tp = build1 (INDIRECT_REF, type, new);
}
*walk_subtrees = 0;
return NULL;