This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
New flag: TREE_THIS_NOTRAP
- From: Andrew Haley <aph at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 9 Jun 2004 13:44:05 +0100
- Subject: New flag: TREE_THIS_NOTRAP
The idea here is to allow a language front end to tell the back end
what operands might generate traps. Java already knows which memory
references cannot trap, and marking these MEM_NOTRAP_P reduces the
number of exception edges and improves scheduling.
There aren't any bits left in tree_common, so this patch (ab)uses
nothrow_flag.
I'm not convinced that this is the best solution, but I'm not sure how
else to do it.
Andrew.
2004-06-09 Andrew Haley <aph@redhat.com>
* tree.h (TREE_THIS_NOTRAP): New.
* emit-rtl.c (set_mem_attributes_minus_bitpos): Set
MEM_NOTRAP_P from TREE_THIS_NOTRAP.
Index: emit-rtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/emit-rtl.c,v
retrieving revision 1.393
diff -p -2 -c -r1.393 emit-rtl.c
*** emit-rtl.c 28 May 2004 06:27:31 -0000 1.393
--- emit-rtl.c 9 Jun 2004 12:33:14 -0000
*************** set_mem_attributes_minus_bitpos (rtx ref
*** 1544,1547 ****
--- 1544,1548 ----
|| (! TYPE_P (t) && TREE_CONSTANT (t)));
MEM_POINTER (ref) = POINTER_TYPE_P (type);
+ MEM_NOTRAP_P (ref) = TREE_THIS_NOTRAP (t);
/* If we are making an object of this type, or if this is a DECL, we know
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.506
diff -p -2 -c -r1.506 tree.h
*** tree.h 7 Jun 2004 02:10:48 -0000 1.506
--- tree.h 9 Jun 2004 12:33:15 -0000
*************** struct tree_common GTY(())
*** 306,309 ****
--- 306,312 ----
..._TYPE
+ TREE_THIS_NOTRAP in
+ VAR_DECL, arithmetic expressions
+
deprecated_flag:
*************** extern void tree_operand_check_failed (i
*** 789,792 ****
--- 792,801 ----
#define TREE_THIS_VOLATILE(NODE) ((NODE)->common.volatile_flag)
+ /* Nonzero means this node will not trap. In a MEM, means accessing
+ the memory at this node won't generate a trap. However, this only
+ applies to an object when used appropriately: it doesn't mean that
+ writing a READONLY mem won't trap. */
+ #define TREE_THIS_NOTRAP(NODE) ((NODE)->common.nothrow_flag)
+
/* In a VAR_DECL, PARM_DECL or FIELD_DECL, or any kind of ..._REF node,
nonzero means it may not be the lhs of an assignment. */