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] [Annotalysis] Fix to memory corruption issue in Annotalysis


This patch changes lock_expr_tab so that it is allocated by the
garbage collector, and properly marked as a GC root.

Bootstrapped and passed GCC regression testsuite on x86_64-unknown-linux-gnu.

Okay for branches/annotalysis and google/main?

 -DeLesley


2011-07-19   DeLesley Hutchins  <delesley@google.com>

     * tree-threadsafe-analyze.c:  Changes lock_expr_tab to be allocated by
     the garbage collector, and marked as a GC root.


Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in	(revision 176187)
+++ gcc/Makefile.in	(working copy)
@@ -3762,6 +3762,7 @@ GTFILES = $(CPP_ID_DATA_H) $(srcdir)/input.h $(src
   $(srcdir)/tree-iterator.c $(srcdir)/gimplify.c \
   $(srcdir)/tree-chrec.h \
   $(srcdir)/tree-scalar-evolution.c \
+  $(srcdir)/tree-threadsafe-analyze.c \
   $(srcdir)/tree-ssa-operands.h \
   $(srcdir)/tree-profile.c $(srcdir)/tree-nested.c \
   $(srcdir)/varpool.c \
Index: gcc/tree-threadsafe-analyze.c
===================================================================
--- gcc/tree-threadsafe-analyze.c	(revision 176188)
+++ gcc/tree-threadsafe-analyze.c	(working copy)
@@ -239,11 +239,11 @@ static struct pointer_map_t *lock_locus_map;

 /* Each entry maps a lock to its canonicalized expression (see
    get_canonical_lock_expr()).  */
-static htab_t lock_expr_tab;
+static GTY((param_is (union tree_node))) htab_t lock_expr_tab = NULL;

 /* Each entry is a gimple call statement. Calls to the same function with
    symbolically identical arguments will hash to the same entry.  */
-static htab_t gimple_call_tab;
+static htab_t gimple_call_tab = NULL;

 /* Each entry maps a trylock call expr to its trylock_info.  */
 static struct pointer_map_t *trylock_info_map;
@@ -517,11 +517,8 @@ destroy_acquired_after_set (const void * ARG_UNUSE
 void
 clean_up_threadsafe_analysis (void)
 {
-  if (lock_expr_tab)
-    {
-      htab_delete (lock_expr_tab);
-      lock_expr_tab = NULL;
-    }
+  /* lock_expr_tab is garbage collected. */
+  lock_expr_tab = NULL;

   /* Free the lock acquired_after map and the sets */
   if (lock_acquired_after_map)
@@ -989,7 +984,7 @@ get_canonical_lock_expr (tree lock, tree base_obj,
      in the lock_expr_tab. If so, grab and return it. Otherwise, insert the
      new lock expr to the map.  */
   if (lock_expr_tab == NULL)
-    lock_expr_tab = htab_create (10, lock_expr_hash, lock_expr_eq, NULL);
+    lock_expr_tab = htab_create_ggc (10, lock_expr_hash, lock_expr_eq, NULL);

   canon_lock = (tree) htab_find_with_hash (lock_expr_tab, lock, hash);
   if (canon_lock)
@@ -3560,6 +3555,7 @@ execute_threadsafe_analyze (void)
   pointer_map_traverse (trylock_info_map, delete_trylock_info, NULL);
   pointer_map_destroy (trylock_info_map);
   htab_delete (gimple_call_tab);
+  gimple_call_tab = NULL;

   /* The flag that controls the warning of mismatched lock acquire/release
      could be turned off when we see an unlock primitive with an unsupported
@@ -3596,3 +3592,5 @@ struct gimple_opt_pass pass_threadsafe_analyze =
     TODO_dump_func                        /* todo_flags_finish */
   }
 };
+
+#include "gt-tree-threadsafe-analyze.h"


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