-static void
-create_program_flow_graph (bptr)
- struct bb_info_list *bptr;
-{
- long num_blocks, number_arcs, src, dest, flag_bits, num_arcs_per_block;
- int i;
- struct adj_list *arcptr;
- struct bb_info *bb_graph;
- long cfg_checksum;
- long instr_arcs = 0;
- gcov_type *profile;
- int profile_pos = 0;
- char *function_name;
- long function_name_len, tmp;
-
- /* Read function name. */
- __read_long (&tmp, bbg_file, 4); /* ignore -1. */
- __read_long (&function_name_len, bbg_file, 4);
- function_name = xmalloc (function_name_len + 1);
- fread (function_name, 1, function_name_len + 1, bbg_file);
-
- /* Skip padding. */
- tmp = (function_name_len + 1) % 4;
-
- if (tmp)
- fseek (bbg_file, 4 - tmp, SEEK_CUR);
-
- __read_long (&tmp, bbg_file, 4); /* ignore -1. */
-
- /* Read the cfg checksum. */
- __read_long (&cfg_checksum, bbg_file, 4);
-
- /* Read the number of blocks. */
- __read_long (&num_blocks, bbg_file, 4);
-
- /* Create an array of size bb number of bb_info structs. */
- bb_graph = (struct bb_info *) xcalloc (num_blocks, sizeof (struct bb_info));
-
- bptr->bb_graph = bb_graph;
- bptr->num_blocks = num_blocks;
-
- /* Read and create each arc from the .bbg file. */
- __read_long (&number_arcs, bbg_file, 4);
- for (i = 0; i < num_blocks; i++)
- {
- int j;
-
- __read_long (&num_arcs_per_block, bbg_file, 4);
- for (j = 0; j < num_arcs_per_block; j++)
- {
- if (number_arcs-- < 0)
- abort ();
-
- src = i;
- __read_long (&dest, bbg_file, 4);
-
- arcptr = (struct adj_list *) xmalloc (sizeof (struct adj_list));
- init_arc (arcptr, src, dest, bb_graph);
-
- __read_long (&flag_bits, bbg_file, 4);
- if (flag_bits & 0x1)
- arcptr->on_tree++;
- else
- instr_arcs++;
- arcptr->fake = !! (flag_bits & 0x2);
- arcptr->fall_through = !! (flag_bits & 0x4);
- }
- }
-
- if (number_arcs)
- abort ();
-
- /* Read and ignore the -1 separating the arc list from the arc list of the
- next function. */
- __read_long (&src, bbg_file, 4);
- if (src != -1)
- abort ();
-
- /* Must reverse the order of all succ arcs, to ensure that they match
- the order of the data in the .da file. */
-
- for (i = 0; i < num_blocks; i++)
- if (bb_graph[i].succ)
- bb_graph[i].succ = reverse_arcs (bb_graph[i].succ);