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]

[Committed] PR17454: --enable-checking=fold failures


The following pair of fixes resolve PR tree-optimization/17454 which
is a bootstrap failure with --enable-checking=fold.  It turns out that
both problems are issues with the "checking" machinery and not problems
with "fold" at all.  The first is an ICE in cp_tree_size when the
fold checking code enquires about the size of a TREE_BINFO.  This is
an "exceptional" language-independent tree code that should be handled
in tree.c's tree_size rather than fall through to the language specific
routine, and from there call gcc_unreachable.

Once this is fixed, the second problem is a bogus "original tree
changed by fold error".  The problem is that a recent transformation
in fold innocently calls build_pointer_type, which modifies GCC's
type nodes to contain a new TYPE_POINTER_TO entry.  This is already
handled in the tree checksum code, but exposes a latent bug whereby
we now incorrectly overwrite the TYPE_CACHED_VALUES field on that
type node.  This is an overloaded field, and help useful/different
information before this type was pointed to, that gets accidentally
blown away in the checksum code, resulting in a comparison failure.
The solution is to check that TYPE_CACHED_VALUES_P is set, before
nuking the contents of TYPE_CACHED_VALUES for comparison.


The following patch completed a full top-level "make bootstrap" on
x86_64-unknown-linux-gnu  with --enable-checking=fold, all default
languages.

Committed to mainline CVS.  I'll apply it to the 4.0 branch once an
--enable-checking=fold bootstrap and regression test completes there.


2005-03-15  Roger Sayle  <roger@eyesopen.com>

	PR tree-optimization/17454
	* tree.c (tree_size): Add case for TREE_BINFO.
	* fold-const.c (fold_checksum_tree): Only clear the overloaded
	field TYPE_CACHED_VALUES if TYPE_CACHED_VALUES_P is set.


Index: tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.c,v
retrieving revision 1.468
diff -c -3 -p -r1.468 tree.c
*** tree.c	13 Mar 2005 22:34:01 -0000	1.468
--- tree.c	15 Mar 2005 22:18:41 -0000
*************** tree_size (tree node)
*** 243,248 ****
--- 243,252 ----
        return (sizeof (struct tree_phi_node)
  	      + (PHI_ARG_CAPACITY (node) - 1) * sizeof (struct phi_arg_d));

+     case TREE_BINFO:
+       return (offsetof (struct tree_binfo, base_binfos)
+ 	      + VEC_embedded_size (tree, BINFO_N_BASE_BINFOS (node)));
+
      case TREE_VEC:
        return (sizeof (struct tree_vec)
  	      + (TREE_VEC_LENGTH (node) - 1) * sizeof(char *));
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.542
diff -c -3 -p -r1.542 fold-const.c
*** fold-const.c	13 Mar 2005 22:34:03 -0000	1.542
--- fold-const.c	15 Mar 2005 22:18:43 -0000
*************** fold_checksum_tree (tree expr, struct md
*** 10049,10056 ****
        expr = (tree) buf;
        TYPE_POINTER_TO (expr) = NULL;
        TYPE_REFERENCE_TO (expr) = NULL;
!       TYPE_CACHED_VALUES_P (expr) = 0;
!       TYPE_CACHED_VALUES (expr) = NULL;
      }
    md5_process_bytes (expr, tree_size (expr), ctx);
    fold_checksum_tree (TREE_TYPE (expr), ctx, ht);
--- 10049,10059 ----
        expr = (tree) buf;
        TYPE_POINTER_TO (expr) = NULL;
        TYPE_REFERENCE_TO (expr) = NULL;
!       if (TYPE_CACHED_VALUES_P (expr))
! 	{
! 	  TYPE_CACHED_VALUES_P (expr) = 0;
! 	  TYPE_CACHED_VALUES (expr) = NULL;
! 	}
      }
    md5_process_bytes (expr, tree_size (expr), ctx);
    fold_checksum_tree (TREE_TYPE (expr), ctx, ht);

Roger
--


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