[tree-ssa] fix java Array_3 and friends

Richard Henderson rth@redhat.com
Sat May 8 00:57:00 GMT 2004


Latent bug exposed by Jason's recent front-end work.  We were only
looking through a single level of references, so

	arr-><D1234>.length

was not seen to be a memory reference that might trap.  My libjava
results are now

FAIL: PR4766 -O3 compilation from source
FAIL: linking cxxtest
FAIL: String_overflow -O3 compilation from source
FAIL: err3 output - source compiled test
FAIL: err3 -O3 output - source compiled test


r~


        * tree-eh.c (tree_could_trap_p): Use get_base_address on references.

Index: tree-eh.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-eh.c,v
retrieving revision 1.1.2.23
diff -c -p -d -r1.1.2.23 tree-eh.c
*** tree-eh.c	15 Jan 2004 06:43:19 -0000	1.1.2.23
--- tree-eh.c	7 May 2004 22:53:36 -0000
*************** bool
*** 1673,1685 ****
  tree_could_trap_p (tree expr)
  {
    enum tree_code code = TREE_CODE (expr);
!   if (code == INDIRECT_REF
!       || (code == COMPONENT_REF
! 	  && (TREE_CODE (TREE_OPERAND (expr, 0)) == INDIRECT_REF)))
!     return true;
!   
    switch (code)
      {
      case TRUNC_DIV_EXPR:
      case CEIL_DIV_EXPR:
      case FLOOR_DIV_EXPR:
--- 1673,1691 ----
  tree_could_trap_p (tree expr)
  {
    enum tree_code code = TREE_CODE (expr);
!   tree t;
! 
    switch (code)
      {
+     case ARRAY_REF:
+     case COMPONENT_REF:
+     case REALPART_EXPR:
+     case IMAGPART_EXPR:
+     case BIT_FIELD_REF:
+       t = get_base_address (expr);
+       return !t || TREE_CODE (t) == INDIRECT_REF;
+ 
+     case INDIRECT_REF:
      case TRUNC_DIV_EXPR:
      case CEIL_DIV_EXPR:
      case FLOOR_DIV_EXPR:
*************** tree_could_trap_p (tree expr)
*** 1690,1695 ****
--- 1696,1702 ----
      case ROUND_MOD_EXPR:
      case TRUNC_MOD_EXPR:
        return true;
+ 
      default:
        break;
      }



More information about the Gcc-patches mailing list