/* Routines to implement minimum-cost maximal flow algorithm used to smooth
basic block and edge frequency counts.
- Copyright (C) 2008, 2009
- Free Software Foundation, Inc.
+ Copyright (C) 2008-2013 Free Software Foundation, Inc.
Contributed by Paul Yuan (yingbo.com@gmail.com) and
Vinodha Ramasamy (vinodha@google.com).
#include "config.h"
#include "system.h"
#include "coretypes.h"
-#include "tm.h"
#include "basic-block.h"
-#include "output.h"
-#include "langhooks.h"
-#include "tree.h"
#include "gcov-io.h"
-
#include "profile.h"
+#include "dumpfile.h"
/* CAP_INFINITY: Constant to represent infinite capacity. */
#define CAP_INFINITY INTTYPE_MAXIMUM (HOST_WIDEST_INT)
typedef fixup_edge_type *fixup_edge_p;
-DEF_VEC_P (fixup_edge_p);
-DEF_VEC_ALLOC_P (fixup_edge_p, heap);
/* Structure to represent a vertex in the fixup graph. */
typedef struct fixup_vertex_d
{
- VEC (fixup_edge_p, heap) *succ_edges;
+ vec<fixup_edge_p> succ_edges;
} fixup_vertex_type;
typedef fixup_vertex_type *fixup_vertex_p;
fnum_edges = fixup_graph->num_edges;
fprintf (file, "\nDump fixup graph for %s(): %s.\n",
- lang_hooks.decl_printable_name (current_function_decl, 2), msg);
+ current_function_name (), msg);
fprintf (file,
"There are %d vertices and %d edges. new_exit_index is %d.\n\n",
fnum_vertices, fnum_edges, fixup_graph->new_exit_index);
{
pfvertex = fvertex_list + i;
fprintf (file, "vertex_list[%d]: %d succ fixup edges.\n",
- i, VEC_length (fixup_edge_p, pfvertex->succ_edges));
+ i, pfvertex->succ_edges.length ());
- for (j = 0; VEC_iterate (fixup_edge_p, pfvertex->succ_edges, j, pfedge);
+ for (j = 0; pfvertex->succ_edges.iterate (j, &pfedge);
j++)
{
/* Distinguish forward edges and backward edges in the residual flow
fixup_graph->num_edges++;
if (dump_file)
dump_fixup_edge (dump_file, fixup_graph, curr_edge);
- VEC_safe_push (fixup_edge_p, heap, curr_vertex->succ_edges, curr_edge);
+ curr_vertex->succ_edges.safe_push (curr_edge);
return curr_edge;
}
pfvertex = fixup_graph->vertex_list + src;
- for (j = 0; VEC_iterate (fixup_edge_p, pfvertex->succ_edges, j, pfedge);
+ for (j = 0; pfvertex->succ_edges.iterate (j, &pfedge);
j++)
if (pfedge->dest == dest)
return pfedge;
fixup_vertex_p pfvertex = fixup_graph->vertex_list;
for (i = 0; i < fnum_vertices; i++, pfvertex++)
- VEC_free (fixup_edge_p, heap, pfvertex->succ_edges);
+ pfvertex->succ_edges.release ();
free (fixup_graph->vertex_list);
free (fixup_graph->edge_list);
u = dequeue (queue_list);
is_visited[u] = 1;
pfvertex = fvertex_list + u;
- for (i = 0; VEC_iterate (fixup_edge_p, pfvertex->succ_edges, i, pfedge);
+ for (i = 0; pfvertex->succ_edges.iterate (i, &pfedge);
i++)
{
int dest = pfedge->dest;
if (dump_file)
{
fprintf (dump_file, "\nCheck %s() CFG flow conservation:\n",
- lang_hooks.decl_printable_name (current_function_decl, 2));
- FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR->next_bb, EXIT_BLOCK_PTR, next_bb)
+ current_function_name ());
+ FOR_EACH_BB (bb)
{
if ((bb->count != sum_edge_counts (bb->preds))
|| (bb->count != sum_edge_counts (bb->succs)))
/* Compute the sum of the edge counts in TO_EDGES. */
gcov_type
-sum_edge_counts (VEC (edge, gc) *to_edges)
+sum_edge_counts (vec<edge, va_gc> *to_edges)
{
gcov_type sum = 0;
edge e;
}
-/* Main routine. Smoothes the intial assigned basic block and edge counts using
+/* Main routine. Smoothes the initial assigned basic block and edge counts using
a minimum cost flow algorithm, to ensure that the flow consistency rule is
obeyed: sum of outgoing edges = sum of incoming edges for each basic
block. */