This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] Unshare TREE_SIZE for variable sized types
- From: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 2 Oct 2003 22:23:26 +0200
- Subject: [tree-ssa] Unshare TREE_SIZE for variable sized types
Hello,
lhd_unsave_expr_now called from tree_rest_of_compilation currently does
not unshare TREE_SIZE and TREE_SIZE_UNIT for variable sized types.
Variables in them are replaced with copies, this causes crash when
the attempt is made to use them to compute size of parameters to call.
The gcc.c-torture/compile/20030224-1.c failure at -O3 is fixed by this
patch.
Zdenek
* tree-inline.c (remap_decl): Unshare TREE_SIZE for variable
sized types.
Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.26.2.50
diff -c -3 -p -r1.26.2.50 tree-inline.c
*** tree-inline.c 29 Sep 2003 02:41:31 -0000 1.26.2.50
--- tree-inline.c 2 Oct 2003 20:15:59 -0000
*************** remap_decl (tree decl, inline_data *id)
*** 162,168 ****
create one now. */
if (!n)
{
! tree t;
/* Make a copy of the variable or label. */
t = copy_decl_for_inlining (decl, fn,
--- 162,168 ----
create one now. */
if (!n)
{
! tree t, *type;
/* Make a copy of the variable or label. */
t = copy_decl_for_inlining (decl, fn,
*************** remap_decl (tree decl, inline_data *id)
*** 171,184 ****
/* The decl T could be a dynamic array or other variable size type,
in which case some fields need to be remapped because they may
contain SAVE_EXPRs. */
! if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE
! && TYPE_DOMAIN (TREE_TYPE (t)))
{
! TREE_TYPE (t) = copy_node (TREE_TYPE (t));
! TYPE_DOMAIN (TREE_TYPE (t))
! = copy_node (TYPE_DOMAIN (TREE_TYPE (t)));
! walk_tree (&TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (t))),
! copy_body_r, id, NULL);
}
#if 0
--- 171,195 ----
/* The decl T could be a dynamic array or other variable size type,
in which case some fields need to be remapped because they may
contain SAVE_EXPRs. */
! type = &TREE_TYPE (t);
! if (*type
! && ((TREE_CODE (*type) == ARRAY_TYPE && TYPE_DOMAIN (*type))
! || (TYPE_SIZE (*type) && !TREE_CONSTANT (TYPE_SIZE (*type)))))
{
! *type = copy_node (*type);
!
! if (TREE_CODE (*type) == ARRAY_TYPE && TYPE_DOMAIN (*type))
! {
! TYPE_DOMAIN (*type)
! = copy_node (TYPE_DOMAIN (*type));
! walk_tree (&TYPE_MAX_VALUE (TYPE_DOMAIN (*type)),
! copy_body_r, id, NULL);
! }
! if (!TREE_CONSTANT (TYPE_SIZE (*type)))
! {
! walk_tree (&TYPE_SIZE (*type), copy_body_r, id, NULL);
! walk_tree (&TYPE_SIZE_UNIT (*type), copy_body_r, id, NULL);
! }
}
#if 0