diff gcc/tree-ssa-coalesce.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
line wrap: on
line diff
--- a/gcc/tree-ssa-coalesce.c	Thu Oct 25 07:37:49 2018 +0900
+++ b/gcc/tree-ssa-coalesce.c	Thu Feb 13 11:34:05 2020 +0900
@@ -1,5 +1,5 @@
 /* Coalesce SSA_NAMES together for the out-of-ssa pass.
-   Copyright (C) 2004-2018 Free Software Foundation, Inc.
+   Copyright (C) 2004-2020 Free Software Foundation, Inc.
    Contributed by Andrew MacLeod <amacleod@redhat.com>
 
 This file is part of GCC.
@@ -135,6 +135,7 @@
   coalesce_pair **sorted;	/* List when sorted.  */
   int num_sorted;		/* Number in the sorted list.  */
   cost_one_pair *cost_one_list;/* Single use coalesces with cost 1.  */
+  obstack ob;
 };
 
 #define NO_BEST_COALESCE	-1
@@ -226,8 +227,6 @@
   *p2 = ptr->second_element;
   cl->cost_one_list = ptr->next;
 
-  free (ptr);
-
   return 1;
 }
 
@@ -251,7 +250,6 @@
   *p1 = node->first_element;
   *p2 = node->second_element;
   ret = node->cost;
-  free (node);
 
   return ret;
 }
@@ -273,6 +271,7 @@
   list->sorted = NULL;
   list->num_sorted = 0;
   list->cost_one_list = NULL;
+  gcc_obstack_init (&list->ob);
   return list;
 }
 
@@ -287,6 +286,7 @@
   cl->list = NULL;
   free (cl->sorted);
   gcc_assert (cl->num_sorted == 0);
+  obstack_free (&cl->ob, NULL);
   free (cl);
 }
 
@@ -328,7 +328,7 @@
 
   if (!*slot)
     {
-      struct coalesce_pair * pair = XNEW (struct coalesce_pair);
+      struct coalesce_pair * pair = XOBNEW (&cl->ob, struct coalesce_pair);
       gcc_assert (cl->sorted == NULL);
       pair->first_element = p.first_element;
       pair->second_element = p.second_element;
@@ -346,7 +346,7 @@
 {
   cost_one_pair *pair;
 
-  pair = XNEW (cost_one_pair);
+  pair = XOBNEW (&cl->ob, cost_one_pair);
   pair->first_element = p1;
   pair->second_element = p2;
   pair->next = cl->cost_one_list;
@@ -674,11 +674,12 @@
    marked as being live.  This delays clearing of these bitmaps until
    they are actually needed again.  */
 
-struct live_track
+class live_track
 {
+public:
   bitmap_obstack obstack;	/* A place to allocate our bitmaps.  */
-  bitmap live_base_var;		/* Indicates if a basevar is live.  */
-  bitmap *live_base_partitions;	/* Live partitions for each basevar.  */
+  bitmap_head live_base_var;		/* Indicates if a basevar is live.  */
+  bitmap_head *live_base_partitions;	/* Live partitions for each basevar.  */
   var_map map;			/* Var_map being used for partition mapping.  */
 };
 
@@ -695,14 +696,14 @@
   /* Make sure there is a partition view in place.  */
   gcc_assert (map->partition_to_base_index != NULL);
 
-  ptr = (live_track *) xmalloc (sizeof (live_track));
+  ptr = XNEW (live_track);
   ptr->map = map;
   lim = num_basevars (map);
   bitmap_obstack_initialize (&ptr->obstack);
-  ptr->live_base_partitions = (bitmap *) xmalloc (sizeof (bitmap *) * lim);
-  ptr->live_base_var = BITMAP_ALLOC (&ptr->obstack);
+  ptr->live_base_partitions = XNEWVEC (bitmap_head, lim);
+  bitmap_initialize (&ptr->live_base_var, &ptr->obstack);
   for (x = 0; x < lim; x++)
-    ptr->live_base_partitions[x] = BITMAP_ALLOC (&ptr->obstack);
+    bitmap_initialize (&ptr->live_base_partitions[x], &ptr->obstack);
   return ptr;
 }
 
@@ -713,8 +714,8 @@
 delete_live_track (live_track *ptr)
 {
   bitmap_obstack_release (&ptr->obstack);
-  free (ptr->live_base_partitions);
-  free (ptr);
+  XDELETEVEC (ptr->live_base_partitions);
+  XDELETE (ptr);
 }
 
 
@@ -726,10 +727,10 @@
   int root;
 
   root = basevar_index (ptr->map, partition);
-  bitmap_clear_bit (ptr->live_base_partitions[root], partition);
+  bitmap_clear_bit (&ptr->live_base_partitions[root], partition);
   /* If the element list is empty, make the base variable not live either.  */
-  if (bitmap_empty_p (ptr->live_base_partitions[root]))
-    bitmap_clear_bit (ptr->live_base_var, root);
+  if (bitmap_empty_p (&ptr->live_base_partitions[root]))
+    bitmap_clear_bit (&ptr->live_base_var, root);
 }
 
 
@@ -743,9 +744,9 @@
   root = basevar_index (ptr->map, partition);
   /* If this base var wasn't live before, it is now.  Clear the element list
      since it was delayed until needed.  */
-  if (bitmap_set_bit (ptr->live_base_var, root))
-    bitmap_clear (ptr->live_base_partitions[root]);
-  bitmap_set_bit (ptr->live_base_partitions[root], partition);
+  if (bitmap_set_bit (&ptr->live_base_var, root))
+    bitmap_clear (&ptr->live_base_partitions[root]);
+  bitmap_set_bit (&ptr->live_base_partitions[root], partition);
 
 }
 
@@ -774,8 +775,8 @@
   if (p != NO_PARTITION)
     {
       root = basevar_index (ptr->map, p);
-      if (bitmap_bit_p (ptr->live_base_var, root))
-	return bitmap_bit_p (ptr->live_base_partitions[root], p);
+      if (bitmap_bit_p (&ptr->live_base_var, root))
+	return bitmap_bit_p (&ptr->live_base_partitions[root], p);
     }
   return false;
 }
@@ -819,9 +820,9 @@
 
   /* If the bitmap isn't empty now, conflicts need to be added.  */
   root = basevar_index (ptr->map, p);
-  if (bitmap_bit_p (ptr->live_base_var, root))
+  if (bitmap_bit_p (&ptr->live_base_var, root))
     {
-      b = ptr->live_base_partitions[root];
+      b = &ptr->live_base_partitions[root];
       EXECUTE_IF_SET_IN_BITMAP (b, 0, x, bi)
         ssa_conflicts_add (graph, p, x);
     }
@@ -850,7 +851,7 @@
   /* Simply clear the live base list.  Anything marked as live in the element
      lists will be cleared later if/when the base variable ever comes alive
      again.  */
-  bitmap_clear (ptr->live_base_var);
+  bitmap_clear (&ptr->live_base_var);
 }