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]

Patch: RFC: langhooks -vs- PR java/19295


I'm looking at PR java/19295, one of the more important java
regressions.

The underlying cause of this regression is that java uses fold(), but
of course fold() changes from time to time, sometimes in ways that
break gcj's bytecode back end.  While I believe the long term fix is
not to use fold() for gcj's front end purposes (language-mandated
constant expression evaluation), I think it is too late in the 4.0
cycle to do this.

The last time this sort of problem occurred, we fixed it by adding a
special lang hook for bit field handling.  So, one fix (patch
appended) is to reuse this hook in the appropriate spot to fix this
PR.  Note that only gcj uses this lang hook.

Another choice would be basically the same patch, but also rename the
lang hook to something a bit more generic.

A third choice would be to add a completely new lang hook for this
particular case.

Any preferences?

There may still be bytecode generation bugs caused by other
improvements to fold().  We really have no way of knowing.

Tom


Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	PR java/19295:
	* fold-const.c (fold): Use can_use_bit_fields_p lang hook before
	calling fold_single_bit_test.

Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.493
diff -u -r1.493 fold-const.c
--- fold-const.c 15 Jan 2005 09:46:02 -0000 1.493
+++ fold-const.c 19 Jan 2005 23:56:51 -0000
@@ -1,6 +1,6 @@
 /* Fold a constant sub-tree into a single node for C-compiler
    Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+   2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -8727,9 +8727,12 @@
 
       /* If we have (A & C) != 0 or (A & C) == 0 and C is a power of
 	 2, then fold the expression into shifts and logical operations.  */
-      tem = fold_single_bit_test (code, arg0, arg1, type);
-      if (tem)
-	return tem;
+      if (lang_hooks.can_use_bit_fields_p ())
+	{
+	  tem = fold_single_bit_test (code, arg0, arg1, type);
+	  if (tem)
+	    return tem;
+	}
 
       /* If we have (A & C) == D where D & ~C != 0, convert this into 0.
 	 Similarly for NE_EXPR.  */


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