[tree-ssa] Fun with exceptions -- opinions needed
Andrew Haley
aph@redhat.com
Sat Jun 14 11:13:00 GMT 2003
This is a patch that I wrote a while ago to track what instructions
might throw exceptions. In the case of Java, that's just MEMs and
divide instructions. This patch isn't directly applicable to mainline
because it breaks languages othen Java, but you can see what I had in
mind.
Andrew.
2003-04-01 Andrew Haley <aph@redhat.com>
* print-tree.c (print_node): Add TREE_MAY_TRAP_P.
* print-rtl.c (print_rtx): Add may_trap.
* emit-rtl.c (set_mem_attributes_minus_bitpos): Set MEM_MAY_TRAP_P.
* rtl.h (MEM_COPY_ATTRIBUTES): Add MEM_MAY_TRAP_P.
* rtlanal.c (may_trap_p): Use MEM_MAY_TRAP_P.
* tree.h (GTY): may_trap_flag: new flag.
(TREE_MAY_TRAP_P): New define.
Index: emit-rtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/emit-rtl.c,v
retrieving revision 1.315
diff -p -2 -c -r1.315 emit-rtl.c
*** emit-rtl.c 8 Mar 2003 19:24:02 -0000 1.315
--- emit-rtl.c 1 Apr 2003 15:15:42 -0000
*************** set_mem_attributes_minus_bitpos (ref, t,
*** 1885,1888 ****
--- 1885,1889 ----
&& (TYPE_READONLY (type) || TREE_READONLY (t)))
|| (! TYPE_P (t) && TREE_CONSTANT (t)));
+ MEM_MAY_TRAP_P (ref) = TREE_MAY_TRAP_P (t);
/* If we are making an object of this type, or if this is a DECL, we know
Index: print-rtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/print-rtl.c,v
retrieving revision 1.94
diff -p -2 -c -r1.94 print-rtl.c
*** print-rtl.c 26 Jan 2003 08:59:54 -0000 1.94
--- print-rtl.c 1 Apr 2003 15:15:48 -0000
*************** print_rtx (in_rtx)
*** 185,188 ****
--- 185,191 ----
fputs ("/c", outfile);
+ if (RTX_FLAG (in_rtx, may_trap))
+ fputs ("/t", outfile);
+
if (GET_MODE (in_rtx) != VOIDmode)
{
Index: print-tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/print-tree.c,v
retrieving revision 1.67
diff -p -2 -c -r1.67 print-tree.c
*** print-tree.c 2 Mar 2003 21:18:14 -0000 1.67
--- print-tree.c 1 Apr 2003 15:15:49 -0000
*************** print_node (file, prefix, node, indent)
*** 269,272 ****
--- 269,274 ----
if (TREE_THIS_VOLATILE (node))
fputs (" volatile", file);
+ if (TREE_MAY_TRAP_P (node))
+ fputs (" may trap", file);
if (TREE_UNSIGNED (node))
fputs (" unsigned", file);
Index: rtl.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.386
diff -p -2 -c -r1.386 rtl.h
*** rtl.h 28 Feb 2003 07:06:33 -0000 1.386
--- rtl.h 1 Apr 2003 15:15:50 -0000
*************** struct rtx_def GTY((chain_next ("RTX_NEX
*** 211,214 ****
--- 211,216 ----
unsigned frame_related : 1;
+ unsigned may_trap: 1;
+
/* The first element of the operands of this rtx.
The number of operands and their types are controlled
*************** do { \
*** 1095,1098 ****
--- 1097,1104 ----
ASM_INPUT)->volatil)
+ #define MEM_MAY_TRAP_P(RTX) \
+ (RTL_FLAG_CHECK3("MEM_MAY_TRAP_P", (RTX), MEM, ASM_OPERANDS, \
+ ASM_INPUT)->may_trap)
+
/* 1 if RTX is a mem that refers to an aggregate, either to the
aggregate itself of to a field of the aggregate. If zero, RTX may
*************** do { \
*** 1177,1180 ****
--- 1183,1187 ----
(MEM_VOLATILE_P (LHS) = MEM_VOLATILE_P (RHS), \
MEM_IN_STRUCT_P (LHS) = MEM_IN_STRUCT_P (RHS), \
+ MEM_MAY_TRAP_P (LHS) = MEM_MAY_TRAP_P (RHS), \
MEM_SCALAR_P (LHS) = MEM_SCALAR_P (RHS), \
RTX_UNCHANGING_P (LHS) = RTX_UNCHANGING_P (RHS), \
Index: rtlanal.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtlanal.c,v
retrieving revision 1.147
diff -p -2 -c -r1.147 rtlanal.c
*** rtlanal.c 11 Feb 2003 21:26:48 -0000 1.147
--- rtlanal.c 1 Apr 2003 15:15:52 -0000
*************** may_trap_p (x)
*** 2463,2467 ****
/* Memory ref can trap unless it's a static var or a stack slot. */
case MEM:
! return rtx_addr_can_trap_p (XEXP (x, 0));
/* Division by a non-constant might trap. */
--- 2463,2467 ----
/* Memory ref can trap unless it's a static var or a stack slot. */
case MEM:
! return MEM_MAY_TRAP_P (x);
/* Division by a non-constant might trap. */
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.385
diff -c -2 -p -r1.385 tree.h
*** tree.h 2 Mar 2003 21:18:15 -0000 1.385
--- tree.h 1 Apr 2003 15:32:52 -0000
*************** struct tree_common GTY(())
*** 156,160 ****
unsigned lang_flag_5 : 1;
unsigned lang_flag_6 : 1;
! unsigned unused_1 : 1;
};
--- 156,160 ----
unsigned lang_flag_5 : 1;
unsigned lang_flag_6 : 1;
! unsigned may_trap_flag : 1;
};
*************** extern void tree_vec_elt_check_failed PA
*** 577,580 ****
--- 577,582 ----
If this bit is set in an expression, so is TREE_SIDE_EFFECTS. */
#define TREE_THIS_VOLATILE(NODE) ((NODE)->common.volatile_flag)
+
+ #define TREE_MAY_TRAP_P(NODE) ((NODE)->common.may_trap_flag)
/* In a VAR_DECL, PARM_DECL or FIELD_DECL, or any kind of ..._REF node,
2003-04-01 Andrew Haley <aph@redhat.com>
* expr.c (build_java_indirect_ref): Set TREE_MAY_TRAP_P.
(java_check_reference): Likewise.
Index: java/expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/expr.c,v
retrieving revision 1.164
diff -p -2 -c -r1.164 expr.c
*** java/expr.c 11 Mar 2003 20:37:02 -0000 1.164
--- java/expr.c 1 Apr 2003 15:16:12 -0000
*************** java_check_reference (tree expr, int che
*** 707,711 ****
expr = build (COMPOUND_EXPR, TREE_TYPE (expr), cond, expr);
}
!
return expr;
}
--- 707,712 ----
expr = build (COMPOUND_EXPR, TREE_TYPE (expr), cond, expr);
}
!
! TREE_MAY_TRAP_P(expr) = 1;
return expr;
}
*************** tree
*** 716,720 ****
build_java_indirect_ref (tree type, tree expr, int check)
{
! return build1 (INDIRECT_REF, type, java_check_reference (expr, check));
}
--- 717,723 ----
build_java_indirect_ref (tree type, tree expr, int check)
{
! tree ref = build1 (INDIRECT_REF, type, java_check_reference (expr, check));
! TREE_MAY_TRAP_P(ref) = TREE_MAY_TRAP_P(expr);
! return ref;
}
More information about the Gcc
mailing list