[tree-ssa mudflap] build/bug fixes

Frank Ch. Eigler fche@redhat.com
Sat Aug 31 02:54:00 GMT 2002


Hi -

Committing a build fix and a bug fix:

2002-08-31  Frank Ch. Eigler  <fche@redhat.com>

	* tree-mudflap.c (mf_build_check_statement_for): Tolerate dereference
	of void pointers.
	(mx_register_decl): Correct typo in below patch.


Index: tree-mudflap.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-mudflap.c,v
retrieving revision 1.1.2.10
diff -u -r1.1.2.10 tree-mudflap.c
--- tree-mudflap.c	31 Aug 2002 04:07:34 -0000	1.1.2.10
+++ tree-mudflap.c	31 Aug 2002 08:55:25 -0000
@@ -611,7 +611,7 @@
   tree t1_1;
   tree t1_2, t1_2_1;
   tree t1_3, t1_3_1;
-  tree t1_4, t1_4_1, t1_4_2;
+  tree t1_4, t1_4_1, t1_4_2, t1_4_size;
   tree t1_98;
   tree t1_99;
   tree t1;
@@ -653,6 +653,13 @@
   t1_3 = build1 (DECL_STMT, mf_cache_structptr_type, pushdecl (t1_3_1));
   TREE_CHAIN (t1_2) = t1_3;
   
+  t1_4_size = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (ptrvalue)));
+  if (t1_4_size == NULL_TREE)
+    {
+      /* We may be dereferencing a void pointer.  */
+      t1_4_size = integer_one_node;
+    }
+
   /* Quick validity check.  */
   t1_4_1 = build (BIT_IOR_EXPR, integer_type_node,
 		  build (GT_EXPR, integer_type_node,
@@ -669,10 +676,7 @@
 			 build (PLUS_EXPR, mf_uintptr_type, /* __mf_value + sizeof(T) - 1 */
 				t1_2_1,
 				fold (build (MINUS_EXPR, mf_uintptr_type,
-					     convert (mf_uintptr_type,
-						      TYPE_SIZE_UNIT 
-						      (TREE_TYPE 
-						       (TREE_TYPE (ptrvalue)))),
+					     convert (mf_uintptr_type, t1_4_size),
 					     integer_one_node)))));
   
   /* Mark condition as UNLIKELY using __builtin_expect.  */
@@ -688,8 +692,7 @@
 					   convert (mf_uintptr_type, t1_2_1),
 					   tree_cons (NULL_TREE, 
 						      convert (mf_uintptr_type, 
-							       TYPE_SIZE_UNIT 
-							       (TREE_TYPE (TREE_TYPE (ptrvalue)))),
+							       t1_4_size),
 						      tree_cons (NULL_TREE,
 								 location_string,
 								 NULL_TREE))));
@@ -898,7 +901,7 @@
 
 /* Destructively insert, between *posn and TREE_CHAIN(*posn), a pair of
    register / cleanup statements, corresponding to variable described in
-   decl, in the scope of the containing_stmt. Appending is done by  */
+   decl, in the scope of the containing_stmt. */
 
 static void
 mx_register_decl (posn, decl, containing_stmt)
@@ -911,10 +914,6 @@
       (! TREE_STATIC (decl)) &&
       mf_find_addrof (containing_stmt, decl))
     {
-
-      /* Hint to inhibit any fancy register optimizations on this variable. */
-      TREE_ADDRESSABLE(decl) = 1;
-
       /* Synthesize, for this DECL_STMT, a CLEANUP_DECL for the same
 	 VAR_DECL.  Arrange to call the __mf_register function now, and the
 	 __mf_unregister function later.  */
@@ -960,6 +959,9 @@
       
       tree register_fncall_stmt =
 	build1 (EXPR_STMT, void_type_node, register_fncall);
+
+      /* Hint to inhibit any fancy register optimizations on this variable. */
+      TREE_ADDRESSABLE(decl) = 1;
       
       /* Add the CLEANUP_STMT and register() call after *posn.  */
       TREE_CHAIN (cleanup_stmt) = register_fncall_stmt;



More information about the Gcc-patches mailing list