re PR fortran/54107 ([F03] Memory hog with abstract interface)
[gcc.git] / gcc / graphds.c
index 7dcb04c139bcfa062e999ecf2727673c2e231e7a..3d64d8988cd40327d11c1fb7ca28f35301f6ffcb 100644 (file)
@@ -1,6 +1,5 @@
 /* Graph representation and manipulation functions.
-   Copyright (C) 2007
-   Free Software Foundation, Inc.
+   Copyright (C) 2007-2013 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -24,7 +23,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "obstack.h"
 #include "bitmap.h"
 #include "vec.h"
-#include "vecprim.h"
 #include "graphds.h"
 
 /* Dumps graph G into F.  */
@@ -187,7 +185,7 @@ dfs_next_edge (struct graph_edge *e, bool forward, bitmap subgraph)
    of the graph (number of the restarts of DFS).  */
 
 int
-graphds_dfs (struct graph *g, int *qs, int nq, VEC (int, heap) **qt,
+graphds_dfs (struct graph *g, int *qs, int nq, vec<int> *qt,
             bool forward, bitmap subgraph)
 {
   int i, tick = 0, v, comp = 0, top;
@@ -236,7 +234,7 @@ graphds_dfs (struct graph *g, int *qs, int nq, VEC (int, heap) **qt,
          if (!e)
            {
              if (qt)
-               VEC_safe_push (int, heap, *qt, v);
+               qt->safe_push (v);
              g->vertices[v].post = tick++;
 
              if (!top)
@@ -266,7 +264,7 @@ graphds_dfs (struct graph *g, int *qs, int nq, VEC (int, heap) **qt,
    numbers assigned by the previous pass.  If SUBGRAPH is not NULL, it
    specifies the subgraph of G whose strongly connected components we want
    to determine.
-   
+
    After running this function, v->component is the number of the strongly
    connected component for each vertex of G.  Returns the number of the
    sccs of G.  */
@@ -275,7 +273,7 @@ int
 graphds_scc (struct graph *g, bitmap subgraph)
 {
   int *queue = XNEWVEC (int, g->n_vertices);
-  VEC (int, heap) *postorder = NULL;
+  vec<int> postorder = vNULL;
   int nq, i, comp;
   unsigned v;
   bitmap_iterator bi;
@@ -296,14 +294,14 @@ graphds_scc (struct graph *g, bitmap subgraph)
     }
 
   graphds_dfs (g, queue, nq, &postorder, false, subgraph);
-  gcc_assert (VEC_length (int, postorder) == (unsigned) nq);
+  gcc_assert (postorder.length () == (unsigned) nq);
 
   for (i = 0; i < nq; i++)
-    queue[i] = VEC_index (int, postorder, nq - i - 1);
+    queue[i] = postorder[nq - i - 1];
   comp = graphds_dfs (g, queue, nq, NULL, true, subgraph);
 
   free (queue);
-  VEC_free (int, heap, postorder);
+  postorder.release ();
 
   return comp;
 }
@@ -401,7 +399,7 @@ void
 graphds_domtree (struct graph *g, int entry,
                 int *parent, int *son, int *brother)
 {
-  VEC (int, heap) *postorder = NULL;
+  vec<int> postorder = vNULL;
   int *marks = XCNEWVEC (int, g->n_vertices);
   int mark = 1, i, v, idom;
   bool changed = true;
@@ -409,7 +407,7 @@ graphds_domtree (struct graph *g, int entry,
 
   /* We use a slight modification of the standard iterative algorithm, as
      described in
-     
+
      K. D. Cooper, T. J. Harvey and K. Kennedy: A Simple, Fast Dominance
        Algorithm
 
@@ -432,8 +430,8 @@ graphds_domtree (struct graph *g, int entry,
       brother[i] = -1;
     }
   graphds_dfs (g, &entry, 1, &postorder, true, NULL);
-  gcc_assert (VEC_length (int, postorder) == (unsigned) g->n_vertices);
-  gcc_assert (VEC_index (int, postorder, g->n_vertices - 1) == entry);
+  gcc_assert (postorder.length () == (unsigned) g->n_vertices);
+  gcc_assert (postorder[g->n_vertices - 1] == entry);
 
   while (changed)
     {
@@ -441,7 +439,7 @@ graphds_domtree (struct graph *g, int entry,
 
       for (i = g->n_vertices - 2; i >= 0; i--)
        {
-         v = VEC_index (int, postorder, i);
+         v = postorder[i];
          idom = -1;
          for (e = g->vertices[v].pred; e; e = e->pred_next)
            {
@@ -461,7 +459,7 @@ graphds_domtree (struct graph *g, int entry,
     }
 
   free (marks);
-  VEC_free (int, heap, postorder);
+  postorder.release ();
 
   for (i = 0; i < g->n_vertices; i++)
     if (parent[i] != -1)