This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PR tree-opt/18067, ICE because no SAVE_EXPR


On Sun, Dec 19, 2004 at 12:49:56AM -0500, Andrew Pinski wrote:
> Take the following testcase:
> void foo(int i)
> {
>     const int j=i+1;
>     int a[1][j*j];
> }
> 
> When we compile this we don't add a SAVE_EXPR around the multiply as
> the expression is considered read only, this causes us to keep the
> SSA_NAME inside the type expression around even after out of SSA because
> out of SSA does not look inside type expressions.

Or, rather, that we have a tree sharing problem between types
and the gimplifier.


> This patch just removes the constraint of adding a SAVE_EXPR
> on a read-only object.

For other reasons (mostly to do with looking at the duplicate
expressions created by using a variable sized type multiple
times, and across nested functions), I suggest instead changing
variable_size to forcibly create a SAVE_EXPR.  Something like this.


r~




Index: stor-layout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/stor-layout.c,v
retrieving revision 1.220
diff -c -p -d -r1.220 stor-layout.c
*** stor-layout.c	18 Dec 2004 20:19:37 -0000	1.220
--- stor-layout.c	19 Dec 2004 07:30:05 -0000
*************** variable_size (tree size)
*** 125,135 ****
       just return SIZE unchanged.  Likewise for self-referential sizes and
       constant sizes.  */
    if (TREE_CONSTANT (size)
        || lang_hooks.decls.global_bindings_p () < 0
        || CONTAINS_PLACEHOLDER_P (size))
      return size;
  
!   size = save_expr (size);
  
    /* If an array with a variable number of elements is declared, and
       the elements require destruction, we will emit a cleanup for the
--- 125,143 ----
       just return SIZE unchanged.  Likewise for self-referential sizes and
       constant sizes.  */
    if (TREE_CONSTANT (size)
+       || TREE_CODE (size) == SAVE_EXPR
        || lang_hooks.decls.global_bindings_p () < 0
        || CONTAINS_PLACEHOLDER_P (size))
      return size;
  
!   /* Force creation of a SAVE_EXPR.  This solves (1) code duplication 
!      problems between parent and nested functions that occasionally can't
!      be cleaned up because of portions of the expression escaping the
!      parent function via the FRAME object, and (2) tree sharing problems
!      between the type system and the gimple code, which can leak SSA_NAME
!      objects into e.g. TYPE_SIZE, which causes heartburn when emitting
!      debug information.  */
!   size = build1 (SAVE_EXPR, TREE_TYPE (size), size);
  
    /* If an array with a variable number of elements is declared, and
       the elements require destruction, we will emit a cleanup for the


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]