* [PATCH 7/7] GCOV: remove typedef of coverage_t.
2017-11-09 10:25 [PATCH 0/7] GCOV: infrastructure clean-up marxin
2017-11-09 10:25 ` [PATCH 3/7] GCOV: introduce vector for function_info::counts marxin
@ 2017-11-09 10:25 ` marxin
2017-11-09 15:23 ` Nathan Sidwell
2017-11-09 10:25 ` [PATCH 2/7] GCOV: simplify usage of function_info::artificial marxin
` (4 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: marxin @ 2017-11-09 10:25 UTC (permalink / raw)
To: gcc-patches; +Cc: nathan
gcc/ChangeLog:
2017-11-09 Martin Liska <mliska@suse.cz>
* gcov.c (struct coverage_info): Remove typedef of coverage_t.
(struct source_info): Likewise.
(add_branch_counts): Likewise.
(add_line_counts): Likewise.
(function_summary): Likewise.
(output_intermediate_line): Likewise.
(generate_results): Likewise.
---
gcc/gcov.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/gcc/gcov.c b/gcc/gcov.c
index 0e5ae8110ad..0669fd9deab 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -294,7 +294,7 @@ struct function_line_start_cmp
/* Describes coverage of a file or function. */
-typedef struct coverage_info
+struct coverage_info
{
int lines;
int lines_executed;
@@ -307,7 +307,7 @@ typedef struct coverage_info
int calls_executed;
char *name;
-} coverage_t;
+};
/* Describes a file mentioned in the block graph. Contains an array
of line info. */
@@ -329,7 +329,7 @@ struct source_info
/* Vector of line information. */
vector<line_info> lines;
- coverage_t coverage;
+ coverage_info coverage;
/* Functions in this source file. These are in ascending line
number order. */
@@ -533,10 +533,10 @@ static void read_graph_file (void);
static int read_count_file (void);
static void solve_flow_graph (function_info *);
static void find_exception_blocks (function_info *);
-static void add_branch_counts (coverage_t *, const arc_info *);
-static void add_line_counts (coverage_t *, function_info *);
+static void add_branch_counts (coverage_info *, const arc_info *);
+static void add_line_counts (coverage_info *, function_info *);
static void executed_summary (unsigned, unsigned);
-static void function_summary (const coverage_t *, const char *);
+static void function_summary (const coverage_info *, const char *);
static const char *format_gcov (gcov_type, gcov_type, int);
static void accumulate_line_counts (source_info *);
static void output_gcov_file (const char *, source_info *);
@@ -968,8 +968,8 @@ output_intermediate_line (FILE *f, line_info *line, unsigned line_num)
if (!(*it)->is_unconditional && !(*it)->is_call_non_return)
{
const char *branch_type;
- /* branch:<line_num>,<branch_coverage_type>
- branch_coverage_type
+ /* branch:<line_num>,<branch_coverage_infoype>
+ branch_coverage_infoype
: notexec (Branch not executed)
: taken (Branch executed and taken)
: nottaken (Branch executed, but not taken)
@@ -1234,7 +1234,7 @@ generate_results (const char *file_name)
it != functions.end (); it++)
{
function_info *fn = *it;
- coverage_t coverage;
+ coverage_info coverage;
memset (&coverage, 0, sizeof (coverage));
coverage.name = flag_demangled_names ? fn->demangled_name : fn->name;
@@ -2072,7 +2072,7 @@ find_exception_blocks (function_info *fn)
/* Increment totals in COVERAGE according to arc ARC. */
static void
-add_branch_counts (coverage_t *coverage, const arc_info *arc)
+add_branch_counts (coverage_info *coverage, const arc_info *arc)
{
if (arc->is_call_non_return)
{
@@ -2184,7 +2184,7 @@ executed_summary (unsigned lines, unsigned executed)
/* Output summary info for a function or file. */
static void
-function_summary (const coverage_t *coverage, const char *title)
+function_summary (const coverage_info *coverage, const char *title)
{
fnotice (stdout, "%s '%s'\n", title, coverage->name);
executed_summary (coverage->lines, coverage->lines_executed);
@@ -2421,7 +2421,7 @@ mangle_name (char const *base, char *ptr)
the appropriate basic block. */
static void
-add_line_counts (coverage_t *coverage, function_info *fn)
+add_line_counts (coverage_info *coverage, function_info *fn)
{
bool has_any_line = false;
/* Scan each basic block. */
--
2.14.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 5/7] GCOV: remove typedef for arc_t
2017-11-09 10:25 [PATCH 0/7] GCOV: infrastructure clean-up marxin
` (3 preceding siblings ...)
2017-11-09 10:25 ` [PATCH 1/7] GCOV: introduce global vector of functions marxin
@ 2017-11-09 10:25 ` marxin
2017-11-09 15:12 ` Nathan Sidwell
2017-11-09 10:26 ` [PATCH 4/7] GCOV: remove typedef for function_t marxin
2017-11-09 10:27 ` [PATCH 6/7] GCOV: remove typedef for block_t marxin
6 siblings, 1 reply; 15+ messages in thread
From: marxin @ 2017-11-09 10:25 UTC (permalink / raw)
To: gcc-patches; +Cc: nathan
gcc/ChangeLog:
2017-11-09 Martin Liska <mliska@suse.cz>
* gcov.c (struct arc_info): Remove typedef for arc_t.
(struct line_info): Likewise.
(add_branch_counts): Likewise.
(output_branch_count): Likewise.
(function_info::~function_info): Likewise.
(circuit): Likewise.
(output_intermediate_line): Likewise.
(read_graph_file): Likewise.
(solve_flow_graph): Likewise.
(find_exception_blocks): Likewise.
(add_line_counts): Likewise.
(accumulate_line_info): Likewise.
(output_line_details): Likewise.
(output_function_details): Likewise.
---
gcc/gcov.c | 58 +++++++++++++++++++++++++++++-----------------------------
1 file changed, 29 insertions(+), 29 deletions(-)
diff --git a/gcc/gcov.c b/gcc/gcov.c
index a1c489bccdc..e33c7b6f8cd 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -79,7 +79,7 @@ struct source_info;
/* Describes an arc between two basic blocks. */
-typedef struct arc_info
+struct arc_info
{
/* source and destination blocks. */
struct block_info *src;
@@ -113,7 +113,7 @@ typedef struct arc_info
/* Links to next arc on src and dst lists. */
struct arc_info *succ_next;
struct arc_info *pred_next;
-} arc_t;
+};
/* Describes which locations (lines and files) are associated with
a basic block. */
@@ -137,8 +137,8 @@ typedef struct block_info
block_info ();
/* Chain of exit and entry arcs. */
- arc_t *succ;
- arc_t *pred;
+ arc_info *succ;
+ arc_info *pred;
/* Number of unprocessed exit and entry arcs. */
gcov_type num_succ;
@@ -166,7 +166,7 @@ typedef struct block_info
{
/* Single line graph cycle workspace. Used for all-blocks
mode. */
- arc_t *arc;
+ arc_info *arc;
unsigned ident;
} cycle; /* Used in all-blocks mode, after blocks are linked onto
lines. */
@@ -200,7 +200,7 @@ struct line_info
gcov_type count;
/* Branches from blocks that end on this line. */
- vector<arc_t *> branches;
+ vector<arc_info *> branches;
/* blocks which start on this line. Used in all-blocks mode. */
vector<block_t *> blocks;
@@ -533,14 +533,14 @@ static void read_graph_file (void);
static int read_count_file (void);
static void solve_flow_graph (function_info *);
static void find_exception_blocks (function_info *);
-static void add_branch_counts (coverage_t *, const arc_t *);
+static void add_branch_counts (coverage_t *, const arc_info *);
static void add_line_counts (coverage_t *, function_info *);
static void executed_summary (unsigned, unsigned);
static void function_summary (const coverage_t *, const char *);
static const char *format_gcov (gcov_type, gcov_type, int);
static void accumulate_line_counts (source_info *);
static void output_gcov_file (const char *, source_info *);
-static int output_branch_count (FILE *, int, const arc_t *);
+static int output_branch_count (FILE *, int, const arc_info *);
static void output_lines (FILE *, const source_info *);
static char *make_gcov_file_name (const char *, const char *);
static char *mangle_name (const char *, char *);
@@ -559,7 +559,7 @@ function_info::~function_info ()
{
for (int i = blocks.size () - 1; i >= 0; i--)
{
- arc_t *arc, *arc_n;
+ arc_info *arc, *arc_n;
for (arc = blocks[i].succ; arc; arc = arc_n)
{
@@ -589,7 +589,7 @@ bool function_info::group_line_p (unsigned n, unsigned src_idx)
simple paths)--the node is unblocked only when it participates in a cycle.
*/
-typedef vector<arc_t *> arc_vector_t;
+typedef vector<arc_info *> arc_vector_t;
typedef vector<const block_t *> block_vector_t;
/* Enum with types of loop in CFG. */
@@ -671,7 +671,7 @@ circuit (block_t *v, arc_vector_t &path, block_t *start,
blocked.push_back (v);
block_lists.push_back (block_vector_t ());
- for (arc_t *arc = v->succ; arc; arc = arc->succ_next)
+ for (arc_info *arc = v->succ; arc; arc = arc->succ_next)
{
block_t *w = arc->dst;
if (w < start || !linfo.has_block (w))
@@ -690,7 +690,7 @@ circuit (block_t *v, arc_vector_t &path, block_t *start,
if (result != NO_LOOP)
unblock (v, blocked, block_lists);
else
- for (arc_t *arc = v->succ; arc; arc = arc->succ_next)
+ for (arc_info *arc = v->succ; arc; arc = arc->succ_next)
{
block_t *w = arc->dst;
if (w < start || !linfo.has_block (w))
@@ -960,7 +960,7 @@ output_intermediate_line (FILE *f, line_info *line, unsigned line_num)
format_gcov (line->count, 0, -1),
line->has_unexecuted_block);
- vector<arc_t *>::const_iterator it;
+ vector<arc_info *>::const_iterator it;
if (flag_branches)
for (it = line->branches.begin (); it != line->branches.end ();
it++)
@@ -1563,7 +1563,7 @@ read_graph_file (void)
if (dest >= fn->blocks.size ())
goto corrupt;
- arc = XCNEW (arc_t);
+ arc = XCNEW (arc_info);
arc->dst = &fn->blocks[dest];
arc->src = src_blk;
@@ -1782,7 +1782,7 @@ static void
solve_flow_graph (function_info *fn)
{
unsigned ix;
- arc_t *arc;
+ arc_info *arc;
gcov_type *count_ptr = &fn->counts.front ();
block_t *blk;
block_t *valid_blocks = NULL; /* valid, but unpropagated blocks. */
@@ -1791,7 +1791,7 @@ solve_flow_graph (function_info *fn)
/* The arcs were built in reverse order. Fix that now. */
for (ix = fn->blocks.size (); ix--;)
{
- arc_t *arc_p, *arc_n;
+ arc_info *arc_p, *arc_n;
for (arc_p = NULL, arc = fn->blocks[ix].succ; arc;
arc_p = arc, arc = arc_n)
@@ -1884,12 +1884,12 @@ solve_flow_graph (function_info *fn)
smart sort. */
if (out_of_order)
{
- arc_t *start = blk->succ;
+ arc_info *start = blk->succ;
unsigned changes = 1;
while (changes)
{
- arc_t *arc, *arc_p, *arc_n;
+ arc_info *arc, *arc_p, *arc_n;
changes = 0;
for (arc_p = NULL, arc = start; (arc_n = arc->succ_next);)
@@ -1927,7 +1927,7 @@ solve_flow_graph (function_info *fn)
while ((blk = invalid_blocks))
{
gcov_type total = 0;
- const arc_t *arc;
+ const arc_info *arc;
invalid_blocks = blk->chain;
blk->invalid_chain = 0;
@@ -1949,7 +1949,7 @@ solve_flow_graph (function_info *fn)
while ((blk = valid_blocks))
{
gcov_type total;
- arc_t *arc, *inv_arc;
+ arc_info *arc, *inv_arc;
valid_blocks = blk->chain;
blk->valid_chain = 0;
@@ -2057,7 +2057,7 @@ find_exception_blocks (function_info *fn)
for (ix = 1; ix;)
{
block_t *block = queue[--ix];
- const arc_t *arc;
+ const arc_info *arc;
for (arc = block->succ; arc; arc = arc->succ_next)
if (!arc->fake && !arc->is_throw && arc->dst->exceptional)
@@ -2072,7 +2072,7 @@ find_exception_blocks (function_info *fn)
/* Increment totals in COVERAGE according to arc ARC. */
static void
-add_branch_counts (coverage_t *coverage, const arc_t *arc)
+add_branch_counts (coverage_t *coverage, const arc_info *arc)
{
if (arc->is_call_non_return)
{
@@ -2489,7 +2489,7 @@ add_line_counts (coverage_t *coverage, function_info *fn)
if (flag_branches)
{
- arc_t *arc;
+ arc_info *arc;
for (arc = block->succ; arc; arc = arc->succ_next)
line->branches.push_back (arc);
@@ -2527,10 +2527,10 @@ static void accumulate_line_info (line_info *line, source_info *src,
for (vector<block_t *>::iterator it = line->blocks.begin ();
it != line->blocks.end (); it++)
{
- for (arc_t *arc = (*it)->pred; arc; arc = arc->pred_next)
+ for (arc_info *arc = (*it)->pred; arc; arc = arc->pred_next)
if (!line->has_block (arc->src))
count += arc->count;
- for (arc_t *arc = (*it)->succ; arc; arc = arc->succ_next)
+ for (arc_info *arc = (*it)->succ; arc; arc = arc->succ_next)
arc->cs_count = arc->count;
}
@@ -2615,7 +2615,7 @@ accumulate_line_counts (source_info *src)
anything is output. */
static int
-output_branch_count (FILE *gcov_file, int ix, const arc_t *arc)
+output_branch_count (FILE *gcov_file, int ix, const arc_info *arc)
{
if (arc->is_call_non_return)
{
@@ -2783,7 +2783,7 @@ output_line_details (FILE *f, const line_info *line, unsigned line_num)
{
if (flag_all_blocks)
{
- arc_t *arc;
+ arc_info *arc;
int ix, jx;
ix = jx = 0;
@@ -2811,7 +2811,7 @@ output_line_details (FILE *f, const line_info *line, unsigned line_num)
int ix;
ix = 0;
- for (vector<arc_t *>::const_iterator it = line->branches.begin ();
+ for (vector<arc_info *>::const_iterator it = line->branches.begin ();
it != line->branches.end (); it++)
ix += output_branch_count (f, ix, (*it));
}
@@ -2825,7 +2825,7 @@ output_function_details (FILE *f, const function_info *fn)
if (!flag_branches)
return;
- arc_t *arc = fn->blocks[EXIT_BLOCK].pred;
+ arc_info *arc = fn->blocks[EXIT_BLOCK].pred;
gcov_type return_count = fn->blocks[EXIT_BLOCK].count;
gcov_type called_count = fn->blocks[ENTRY_BLOCK].count;
--
2.14.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 0/7] GCOV: infrastructure clean-up
@ 2017-11-09 10:25 marxin
2017-11-09 10:25 ` [PATCH 3/7] GCOV: introduce vector for function_info::counts marxin
` (6 more replies)
0 siblings, 7 replies; 15+ messages in thread
From: marxin @ 2017-11-09 10:25 UTC (permalink / raw)
To: gcc-patches; +Cc: nathan
Hello.
Following patch series is quite mechanical, it adds usage of STL
containers and it removes many typedefs that are with C++ not needed
in my oppinion.
Patch survives gcov.exp test-suite.
Thanks,
Martin
marxin (7):
GCOV: introduce global vector of functions
GCOV: simplify usage of function_info::artificial.
GCOV: introduce vector for function_info::counts.
GCOV: remove typedef for function_t
GCOV: remove typedef for arc_t
GCOV: remove typedef for block_t
GCOV: remove typedef of coverage_t.
gcc/gcov.c | 365 ++++++++++++++++++++++++++++++-------------------------------
1 file changed, 177 insertions(+), 188 deletions(-)
--
2.14.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 3/7] GCOV: introduce vector for function_info::counts.
2017-11-09 10:25 [PATCH 0/7] GCOV: infrastructure clean-up marxin
@ 2017-11-09 10:25 ` marxin
2017-11-09 15:11 ` Nathan Sidwell
2017-11-09 10:25 ` [PATCH 7/7] GCOV: remove typedef of coverage_t marxin
` (5 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: marxin @ 2017-11-09 10:25 UTC (permalink / raw)
To: gcc-patches; +Cc: nathan
gcc/ChangeLog:
2017-11-09 Martin Liska <mliska@suse.cz>
* gcov.c (function_info::function_info): Remove num_counts
and add vector<gcov_type>.
(function_info::~function_info): Use the vector.
(process_file): Likewise.
(read_graph_file): Likewise.
(read_count_file): Likewise.
(solve_flow_graph): Likewise.
---
gcc/gcov.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/gcc/gcov.c b/gcc/gcov.c
index 3dc159726c7..02a01b51763 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -257,8 +257,7 @@ typedef struct function_info
unsigned blocks_executed;
/* Raw arc coverage counts. */
- gcov_type *counts;
- unsigned num_counts;
+ vector<gcov_type> counts;
/* First line number. */
unsigned start_line;
@@ -551,8 +550,8 @@ extern int main (int, char **);
function_info::function_info (): name (NULL), demangled_name (NULL),
ident (0), lineno_checksum (0), cfg_checksum (0), has_catch (0),
artificial (0), is_group (0),
- blocks (), blocks_executed (0), counts (NULL), num_counts (0),
- start_line (0), start_column (0), end_line (0), src (0), lines (), next (NULL)
+ blocks (), blocks_executed (0), counts (),
+ start_line (0), start_column (), end_line (0), src (0), lines (), next (NULL)
{
}
@@ -568,7 +567,6 @@ function_info::~function_info ()
free (arc);
}
}
- free (counts);
if (flag_demangled_names && demangled_name != name)
free (demangled_name);
free (name);
@@ -1140,7 +1138,7 @@ process_file (const char *file_name)
function_t *fn = *it;
unsigned src = fn->src;
- if (fn->counts || no_data_file)
+ if (!fn->counts.empty () || no_data_file)
{
source_info *s = &sources[src];
s->functions.push_back (fn);
@@ -1604,7 +1602,7 @@ read_graph_file (void)
}
if (!arc->on_tree)
- fn->num_counts++;
+ fn->counts.push_back (0);
}
if (mark_catches)
@@ -1755,13 +1753,10 @@ read_count_file (void)
}
else if (tag == GCOV_TAG_FOR_COUNTER (GCOV_COUNTER_ARCS) && fn)
{
- if (length != GCOV_TAG_COUNTER_LENGTH (fn->num_counts))
+ if (length != GCOV_TAG_COUNTER_LENGTH (fn->counts.size ()))
goto mismatch;
- if (!fn->counts)
- fn->counts = XCNEWVEC (gcov_type, fn->num_counts);
-
- for (ix = 0; ix != fn->num_counts; ix++)
+ for (ix = 0; ix != fn->counts.size (); ix++)
fn->counts[ix] += gcov_read_counter ();
}
gcov_sync (base, length);
@@ -1788,7 +1783,7 @@ solve_flow_graph (function_t *fn)
{
unsigned ix;
arc_t *arc;
- gcov_type *count_ptr = fn->counts;
+ gcov_type *count_ptr = &fn->counts.front ();
block_t *blk;
block_t *valid_blocks = NULL; /* valid, but unpropagated blocks. */
block_t *invalid_blocks = NULL; /* invalid, but inferable blocks. */
--
2.14.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 2/7] GCOV: simplify usage of function_info::artificial.
2017-11-09 10:25 [PATCH 0/7] GCOV: infrastructure clean-up marxin
2017-11-09 10:25 ` [PATCH 3/7] GCOV: introduce vector for function_info::counts marxin
2017-11-09 10:25 ` [PATCH 7/7] GCOV: remove typedef of coverage_t marxin
@ 2017-11-09 10:25 ` marxin
2017-11-09 15:11 ` Nathan Sidwell
2017-11-09 10:25 ` [PATCH 1/7] GCOV: introduce global vector of functions marxin
` (3 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: marxin @ 2017-11-09 10:25 UTC (permalink / raw)
To: gcc-patches; +Cc: nathan
gcc/ChangeLog:
2017-11-09 Martin Liska <mliska@suse.cz>
* gcov.c (is_artificial): New function.
(process_file): Erase all artificial early.
(generate_results): Skip as all artificial are already
removed.
---
gcc/gcov.c | 66 +++++++++++++++++++++++++++++++++++++-------------------------
1 file changed, 40 insertions(+), 26 deletions(-)
diff --git a/gcc/gcov.c b/gcc/gcov.c
index 83239639247..3dc159726c7 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -1088,6 +1088,14 @@ struct function_start_pair_hash : typed_noop_remove <function_start>
}
};
+/* Function filter based on function_info::artificial variable. */
+
+static bool
+is_artificial (function_info *fn)
+{
+ return fn->artificial;
+}
+
/* Process a single input file. */
static void
@@ -1122,33 +1130,40 @@ process_file (const char *file_name)
fn_map.put (needle, *it);
}
+ /* Remove all artificial function. */
+ functions.erase (remove_if (functions.begin (), functions.end (),
+ is_artificial), functions.end ());
+
for (vector<function_t *>::iterator it = functions.begin ();
it != functions.end (); it++)
{
function_t *fn = *it;
+ unsigned src = fn->src;
if (fn->counts || no_data_file)
{
- unsigned src = fn->src;
- unsigned block_no;
+ source_info *s = &sources[src];
+ s->functions.push_back (fn);
- /* Process only non-artificial functions. */
- if (!fn->artificial)
+ /* Mark last line in files touched by function. */
+ for (unsigned block_no = 0; block_no != fn->blocks.size ();
+ block_no++)
{
- source_info *s = &sources[src];
- s->functions.push_back (fn);
-
- /* Mark last line in files touched by function. */
- for (block_no = 0; block_no != fn->blocks.size (); block_no++)
+ block_t *block = &fn->blocks[block_no];
+ for (unsigned i = 0; i < block->locations.size (); i++)
{
- block_t *block = &fn->blocks[block_no];
- for (unsigned i = 0; i < block->locations.size (); i++)
+ /* Sort lines of locations. */
+ sort (block->locations[i].lines.begin (),
+ block->locations[i].lines.end ());
+
+ if (!block->locations[i].lines.empty ())
{
- /* Sort lines of locations. */
- sort (block->locations[i].lines.begin (),
- block->locations[i].lines.end ());
+ s = &sources[block->locations[i].source_file_idx];
+ unsigned last_line
+ = block->locations[i].lines.back ();
- if (!block->locations[i].lines.empty ())
+ /* Record new lines for the function. */
+ if (last_line >= s->lines.size ())
{
s = &sources[block->locations[i].source_file_idx];
unsigned last_line
@@ -1162,17 +1177,18 @@ process_file (const char *file_name)
}
}
}
-
- /* Allocate lines for group function, following start_line
- and end_line information of the function. */
- if (fn->is_group)
- fn->lines.resize (fn->end_line - fn->start_line + 1);
}
-
- solve_flow_graph (fn);
- if (fn->has_catch)
- find_exception_blocks (fn);
}
+
+ /* Allocate lines for group function, following start_line
+ and end_line information of the function. */
+ if (fn->is_group)
+ fn->lines.resize (fn->end_line - fn->start_line + 1);
+
+
+ solve_flow_graph (fn);
+ if (fn->has_catch)
+ find_exception_blocks (fn);
}
else
{
@@ -1221,8 +1237,6 @@ generate_results (const char *file_name)
{
function_t *fn = *it;
coverage_t coverage;
- if (fn->artificial)
- continue;
memset (&coverage, 0, sizeof (coverage));
coverage.name = flag_demangled_names ? fn->demangled_name : fn->name;
--
2.14.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 1/7] GCOV: introduce global vector of functions
2017-11-09 10:25 [PATCH 0/7] GCOV: infrastructure clean-up marxin
` (2 preceding siblings ...)
2017-11-09 10:25 ` [PATCH 2/7] GCOV: simplify usage of function_info::artificial marxin
@ 2017-11-09 10:25 ` marxin
2017-11-09 15:10 ` Nathan Sidwell
2017-11-09 10:25 ` [PATCH 5/7] GCOV: remove typedef for arc_t marxin
` (2 subsequent siblings)
6 siblings, 1 reply; 15+ messages in thread
From: marxin @ 2017-11-09 10:25 UTC (permalink / raw)
To: gcc-patches; +Cc: nathan
gcc/ChangeLog:
2017-11-09 Martin Liska <mliska@suse.cz>
* gcov.c (read_graph_file): Store to global vector of functions.
(read_count_file): Iterate the vector.
(process_file): Likewise.
(generate_results): Likewise.
(release_structures): Likewise.
---
gcc/gcov.c | 108 +++++++++++++++++++++++++------------------------------------
1 file changed, 44 insertions(+), 64 deletions(-)
diff --git a/gcc/gcov.c b/gcc/gcov.c
index 846a2326196..83239639247 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -392,10 +392,8 @@ public:
unsigned src; /* Source file */
};
-/* Holds a list of function basic block graphs. */
-
-static function_t *functions;
-static function_t **fn_end = &functions;
+/* Vector of all functions. */
+static vector<function_t *> functions;
/* Vector of source files. */
static vector<source_info> sources;
@@ -532,8 +530,8 @@ static void generate_results (const char *);
static void create_file_names (const char *);
static char *canonicalize_name (const char *);
static unsigned find_source (const char *);
-static function_t *read_graph_file (void);
-static int read_count_file (function_t *);
+static void read_graph_file (void);
+static int read_count_file (void);
static void solve_flow_graph (function_t *);
static void find_exception_blocks (function_t *);
static void add_branch_counts (coverage_t *, const arc_t *);
@@ -1095,42 +1093,40 @@ struct function_start_pair_hash : typed_noop_remove <function_start>
static void
process_file (const char *file_name)
{
- function_t *fns;
-
create_file_names (file_name);
- fns = read_graph_file ();
- if (!fns)
+ read_graph_file ();
+ if (functions.empty ())
return;
- read_count_file (fns);
+ read_count_file ();
hash_map<function_start_pair_hash, function_t *> fn_map;
/* Identify group functions. */
- for (function_t *f = fns; f; f = f->next)
- if (!f->artificial)
+ for (vector<function_t *>::iterator it = functions.begin ();
+ it != functions.end (); it++)
+ if (!(*it)->artificial)
{
function_start needle;
- needle.source_file_idx = f->src;
- needle.start_line = f->start_line;
+ needle.source_file_idx = (*it)->src;
+ needle.start_line = (*it)->start_line;
function_t **slot = fn_map.get (needle);
if (slot)
{
- gcc_assert ((*slot)->end_line == f->end_line);
+ gcc_assert ((*slot)->end_line == (*it)->end_line);
(*slot)->is_group = 1;
- f->is_group = 1;
+ (*it)->is_group = 1;
}
else
- fn_map.put (needle, f);
+ fn_map.put (needle, *it);
}
- while (fns)
+ for (vector<function_t *>::iterator it = functions.begin ();
+ it != functions.end (); it++)
{
- function_t *fn = fns;
+ function_t *fn = *it;
- fns = fn->next;
- fn->next = NULL;
if (fn->counts || no_data_file)
{
unsigned src = fn->src;
@@ -1177,14 +1173,12 @@ process_file (const char *file_name)
if (fn->has_catch)
find_exception_blocks (fn);
}
-
- *fn_end = fn;
- fn_end = &fn->next;
}
else
- /* The function was not in the executable -- some other
- instance must have been selected. */
- delete fn;
+ {
+ /* The function was not in the executable -- some other
+ instance must have been selected. */
+ }
}
}
@@ -1222,10 +1216,10 @@ output_gcov_file (const char *file_name, source_info *src)
static void
generate_results (const char *file_name)
{
- function_t *fn;
-
- for (fn = functions; fn; fn = fn->next)
+ for (vector<function_t *>::iterator it = functions.begin ();
+ it != functions.end (); it++)
{
+ function_t *fn = *it;
coverage_t coverage;
if (fn->artificial)
continue;
@@ -1291,13 +1285,11 @@ generate_results (const char *file_name)
static void
release_structures (void)
{
- function_t *fn;
+ for (vector<function_t *>::iterator it = functions.begin ();
+ it != functions.end (); it++)
+ delete (*it);
- while ((fn = functions))
- {
- functions = fn->next;
- delete fn;
- }
+ functions.resize (0);
}
/* Generate the names of the graph and data files. If OBJECT_DIRECTORY
@@ -1455,29 +1447,26 @@ find_source (const char *file_name)
return idx;
}
-/* Read the notes file. Return list of functions read -- in reverse order. */
+/* Read the notes file. Save functions to FUNCTIONS global vector. */
-static function_t *
+static void
read_graph_file (void)
{
unsigned version;
unsigned current_tag = 0;
- function_t *fn = NULL;
- function_t *fns = NULL;
- function_t **fns_end = &fns;
unsigned tag;
if (!gcov_open (bbg_file_name, 1))
{
fnotice (stderr, "%s:cannot open notes file\n", bbg_file_name);
- return fns;
+ return;
}
bbg_file_time = gcov_time ();
if (!gcov_magic (gcov_read_unsigned (), GCOV_NOTE_MAGIC))
{
fnotice (stderr, "%s:not a gcov notes file\n", bbg_file_name);
gcov_close ();
- return fns;
+ return;
}
version = gcov_read_unsigned ();
@@ -1493,6 +1482,7 @@ read_graph_file (void)
}
bbg_stamp = gcov_read_unsigned ();
+ function_t *fn = NULL;
while ((tag = gcov_read_unsigned ()))
{
unsigned length = gcov_read_unsigned ();
@@ -1514,7 +1504,8 @@ read_graph_file (void)
unsigned start_column = gcov_read_unsigned ();
unsigned end_line = gcov_read_unsigned ();
- fn = new function_t;
+ fn = new function_t ();
+ functions.push_back (fn);
fn->name = function_name;
if (flag_demangled_names)
{
@@ -1531,9 +1522,6 @@ read_graph_file (void)
fn->end_line = end_line;
fn->artificial = artificial;
- fn->next = NULL;
- *fns_end = fn;
- fns_end = &fn->next;
current_tag = tag;
}
else if (fn && tag == GCOV_TAG_BLOCKS)
@@ -1659,17 +1647,15 @@ read_graph_file (void)
}
gcov_close ();
- if (!fns)
+ if (functions.empty ())
fnotice (stderr, "%s:no functions found\n", bbg_file_name);
-
- return fns;
}
/* Reads profiles from the count file and attach to each
function. Return nonzero if fatal error. */
static int
-read_count_file (function_t *fns)
+read_count_file (void)
{
unsigned ix;
unsigned version;
@@ -1726,26 +1712,20 @@ read_count_file (function_t *fns)
else if (tag == GCOV_TAG_FUNCTION && length == GCOV_TAG_FUNCTION_LENGTH)
{
unsigned ident;
- struct function_info *fn_n;
/* Try to find the function in the list. To speed up the
search, first start from the last function found. */
ident = gcov_read_unsigned ();
- fn_n = fns;
- for (fn = fn ? fn->next : NULL; ; fn = fn->next)
+
+ fn = NULL;
+ for (vector<function_t *>::reverse_iterator it = functions.rbegin ();
+ it != functions.rend (); it++)
{
- if (fn)
- ;
- else if ((fn = fn_n))
- fn_n = NULL;
- else
+ if ((*it)->ident == ident)
{
- fnotice (stderr, "%s:unknown function '%u'\n",
- da_file_name, ident);
+ fn = *it;
break;
}
- if (fn->ident == ident)
- break;
}
if (!fn)
--
2.14.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 4/7] GCOV: remove typedef for function_t
2017-11-09 10:25 [PATCH 0/7] GCOV: infrastructure clean-up marxin
` (4 preceding siblings ...)
2017-11-09 10:25 ` [PATCH 5/7] GCOV: remove typedef for arc_t marxin
@ 2017-11-09 10:26 ` marxin
2017-11-09 15:12 ` Nathan Sidwell
2017-11-09 10:27 ` [PATCH 6/7] GCOV: remove typedef for block_t marxin
6 siblings, 1 reply; 15+ messages in thread
From: marxin @ 2017-11-09 10:26 UTC (permalink / raw)
To: gcc-patches; +Cc: nathan
gcc/ChangeLog:
2017-11-09 Martin Liska <mliska@suse.cz>
* gcov.c (struct function_info): Remove typedef for function_t.
(struct source_info): Likewise.
(source_info::get_functions_at_location): Likewise.
(solve_flow_graph): Likewise.
(find_exception_blocks): Likewise.
(add_line_counts): Likewise.
(output_intermediate_file): Likewise.
(process_file): Likewise.
(generate_results): Likewise.
(release_structures): Likewise.
(read_graph_file): Likewise.
(read_count_file): Likewise.
(accumulate_line_counts): Likewise.
(output_lines): Likewise.
---
gcc/gcov.c | 70 +++++++++++++++++++++++++++++++-------------------------------
1 file changed, 35 insertions(+), 35 deletions(-)
diff --git a/gcc/gcov.c b/gcc/gcov.c
index 02a01b51763..a1c489bccdc 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -223,7 +223,7 @@ line_info::has_block (block_t *needle)
/* Describes a single function. Contains an array of basic blocks. */
-typedef struct function_info
+struct function_info
{
function_info ();
~function_info ();
@@ -276,7 +276,7 @@ typedef struct function_info
/* Next function. */
struct function_info *next;
-} function_t;
+};
/* Function info comparer that will sort functions according to starting
line. */
@@ -317,7 +317,7 @@ struct source_info
/* Default constructor. */
source_info ();
- vector<function_t *> get_functions_at_location (unsigned line_num) const;
+ vector<function_info *> get_functions_at_location (unsigned line_num) const;
/* Index of the source_info in sources vector. */
unsigned index;
@@ -333,7 +333,7 @@ struct source_info
/* Functions in this source file. These are in ascending line
number order. */
- vector <function_t *> functions;
+ vector <function_info *> functions;
};
source_info::source_info (): index (0), name (NULL), file_time (),
@@ -341,12 +341,12 @@ source_info::source_info (): index (0), name (NULL), file_time (),
{
}
-vector<function_t *>
+vector<function_info *>
source_info::get_functions_at_location (unsigned line_num) const
{
- vector<function_t *> r;
+ vector<function_info *> r;
- for (vector<function_t *>::const_iterator it = functions.begin ();
+ for (vector<function_info *>::const_iterator it = functions.begin ();
it != functions.end (); it++)
{
if ((*it)->start_line == line_num && (*it)->src == index)
@@ -392,7 +392,7 @@ public:
};
/* Vector of all functions. */
-static vector<function_t *> functions;
+static vector<function_info *> functions;
/* Vector of source files. */
static vector<source_info> sources;
@@ -531,10 +531,10 @@ static char *canonicalize_name (const char *);
static unsigned find_source (const char *);
static void read_graph_file (void);
static int read_count_file (void);
-static void solve_flow_graph (function_t *);
-static void find_exception_blocks (function_t *);
+static void solve_flow_graph (function_info *);
+static void find_exception_blocks (function_info *);
static void add_branch_counts (coverage_t *, const arc_t *);
-static void add_line_counts (coverage_t *, function_t *);
+static void add_line_counts (coverage_t *, function_info *);
static void executed_summary (unsigned, unsigned);
static void function_summary (const coverage_t *, const char *);
static const char *format_gcov (gcov_type, gcov_type, int);
@@ -1001,7 +1001,7 @@ output_intermediate_file (FILE *gcov_file, source_info *src)
std::sort (src->functions.begin (), src->functions.end (),
function_line_start_cmp ());
- for (vector<function_t *>::iterator it = src->functions.begin ();
+ for (vector<function_info *>::iterator it = src->functions.begin ();
it != src->functions.end (); it++)
{
/* function:<name>,<line_number>,<execution_count> */
@@ -1012,10 +1012,10 @@ output_intermediate_file (FILE *gcov_file, source_info *src)
for (unsigned line_num = 0; line_num <= src->lines.size (); line_num++)
{
- vector<function_t *> fns = src->get_functions_at_location (line_num);
+ vector<function_info *> fns = src->get_functions_at_location (line_num);
/* Print first group functions that begin on the line. */
- for (vector<function_t *>::iterator it2 = fns.begin ();
+ for (vector<function_info *>::iterator it2 = fns.begin ();
it2 != fns.end (); it2++)
{
vector<line_info> &lines = (*it2)->lines;
@@ -1106,10 +1106,10 @@ process_file (const char *file_name)
read_count_file ();
- hash_map<function_start_pair_hash, function_t *> fn_map;
+ hash_map<function_start_pair_hash, function_info *> fn_map;
/* Identify group functions. */
- for (vector<function_t *>::iterator it = functions.begin ();
+ for (vector<function_info *>::iterator it = functions.begin ();
it != functions.end (); it++)
if (!(*it)->artificial)
{
@@ -1117,7 +1117,7 @@ process_file (const char *file_name)
needle.source_file_idx = (*it)->src;
needle.start_line = (*it)->start_line;
- function_t **slot = fn_map.get (needle);
+ function_info **slot = fn_map.get (needle);
if (slot)
{
gcc_assert ((*slot)->end_line == (*it)->end_line);
@@ -1132,10 +1132,10 @@ process_file (const char *file_name)
functions.erase (remove_if (functions.begin (), functions.end (),
is_artificial), functions.end ());
- for (vector<function_t *>::iterator it = functions.begin ();
+ for (vector<function_info *>::iterator it = functions.begin ();
it != functions.end (); it++)
{
- function_t *fn = *it;
+ function_info *fn = *it;
unsigned src = fn->src;
if (!fn->counts.empty () || no_data_file)
@@ -1230,10 +1230,10 @@ output_gcov_file (const char *file_name, source_info *src)
static void
generate_results (const char *file_name)
{
- for (vector<function_t *>::iterator it = functions.begin ();
+ for (vector<function_info *>::iterator it = functions.begin ();
it != functions.end (); it++)
{
- function_t *fn = *it;
+ function_info *fn = *it;
coverage_t coverage;
memset (&coverage, 0, sizeof (coverage));
@@ -1297,7 +1297,7 @@ generate_results (const char *file_name)
static void
release_structures (void)
{
- for (vector<function_t *>::iterator it = functions.begin ();
+ for (vector<function_info *>::iterator it = functions.begin ();
it != functions.end (); it++)
delete (*it);
@@ -1494,7 +1494,7 @@ read_graph_file (void)
}
bbg_stamp = gcov_read_unsigned ();
- function_t *fn = NULL;
+ function_info *fn = NULL;
while ((tag = gcov_read_unsigned ()))
{
unsigned length = gcov_read_unsigned ();
@@ -1516,7 +1516,7 @@ read_graph_file (void)
unsigned start_column = gcov_read_unsigned ();
unsigned end_line = gcov_read_unsigned ();
- fn = new function_t ();
+ fn = new function_info ();
functions.push_back (fn);
fn->name = function_name;
if (flag_demangled_names)
@@ -1672,7 +1672,7 @@ read_count_file (void)
unsigned ix;
unsigned version;
unsigned tag;
- function_t *fn = NULL;
+ function_info *fn = NULL;
int error = 0;
if (!gcov_open (da_file_name, 1))
@@ -1730,8 +1730,8 @@ read_count_file (void)
ident = gcov_read_unsigned ();
fn = NULL;
- for (vector<function_t *>::reverse_iterator it = functions.rbegin ();
- it != functions.rend (); it++)
+ for (vector<function_info *>::reverse_iterator it
+ = functions.rbegin (); it != functions.rend (); it++)
{
if ((*it)->ident == ident)
{
@@ -1779,7 +1779,7 @@ read_count_file (void)
to the blocks and the uninstrumented arcs. */
static void
-solve_flow_graph (function_t *fn)
+solve_flow_graph (function_info *fn)
{
unsigned ix;
arc_t *arc;
@@ -2042,7 +2042,7 @@ solve_flow_graph (function_t *fn)
/* Mark all the blocks only reachable via an incoming catch. */
static void
-find_exception_blocks (function_t *fn)
+find_exception_blocks (function_info *fn)
{
unsigned ix;
block_t **queue = XALLOCAVEC (block_t *, fn->blocks.size ());
@@ -2421,7 +2421,7 @@ mangle_name (char const *base, char *ptr)
the appropriate basic block. */
static void
-add_line_counts (coverage_t *coverage, function_t *fn)
+add_line_counts (coverage_t *coverage, function_info *fn)
{
bool has_any_line = false;
/* Scan each basic block. */
@@ -2553,7 +2553,7 @@ static void
accumulate_line_counts (source_info *src)
{
/* First work on group functions. */
- for (vector<function_t *>::iterator it = src->functions.begin ();
+ for (vector<function_info *>::iterator it = src->functions.begin ();
it != src->functions.end (); it++)
{
function_info *fn = *it;
@@ -2577,7 +2577,7 @@ accumulate_line_counts (source_info *src)
/* If not using intermediate mode, sum lines of group functions and
add them to lines that live in a source file. */
if (!flag_intermediate_format)
- for (vector<function_t *>::iterator it = src->functions.begin ();
+ for (vector<function_info *>::iterator it = src->functions.begin ();
it != src->functions.end (); it++)
{
function_info *fn = *it;
@@ -2880,7 +2880,7 @@ output_lines (FILE *gcov_file, const source_info *src)
source_lines.push_back (xstrdup (retval));
unsigned line_start_group = 0;
- vector<function_t *> fns;
+ vector<function_info *> fns;
for (unsigned line_num = 1; line_num <= source_lines.size (); line_num++)
{
@@ -2900,7 +2900,7 @@ output_lines (FILE *gcov_file, const source_info *src)
line_start_group = fns[0]->end_line;
else if (fns.size () == 1)
{
- function_t *fn = fns[0];
+ function_info *fn = fns[0];
output_function_details (gcov_file, fn);
}
}
@@ -2920,7 +2920,7 @@ output_lines (FILE *gcov_file, const source_info *src)
if (line_start_group == line_num)
{
- for (vector<function_t *>::iterator it = fns.begin ();
+ for (vector<function_info *>::iterator it = fns.begin ();
it != fns.end (); it++)
{
function_info *fn = *it;
--
2.14.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 6/7] GCOV: remove typedef for block_t
2017-11-09 10:25 [PATCH 0/7] GCOV: infrastructure clean-up marxin
` (5 preceding siblings ...)
2017-11-09 10:26 ` [PATCH 4/7] GCOV: remove typedef for function_t marxin
@ 2017-11-09 10:27 ` marxin
2017-11-09 15:12 ` Nathan Sidwell
6 siblings, 1 reply; 15+ messages in thread
From: marxin @ 2017-11-09 10:27 UTC (permalink / raw)
To: gcc-patches; +Cc: nathan
gcc/ChangeLog:
2017-11-09 Martin Liska <mliska@suse.cz>
* gcov.c (struct block_info): Remove typedef for block_t.
(struct line_info): Likewise.
(line_info::has_block): Likewise.
(EXIT_BLOCK): Likewise.
(unblock): Likewise.
(circuit): Likewise.
(get_cycles_count): Likewise.
(process_file): Likewise.
(read_graph_file): Likewise.
(solve_flow_graph): Likewise.
(find_exception_blocks): Likewise.
(add_line_counts): Likewise.
(accumulate_line_info): Likewise.
(output_line_details): Likewise.
---
gcc/gcov.c | 52 ++++++++++++++++++++++++++--------------------------
1 file changed, 26 insertions(+), 26 deletions(-)
diff --git a/gcc/gcov.c b/gcc/gcov.c
index e33c7b6f8cd..0e5ae8110ad 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -131,7 +131,7 @@ struct block_location_info
/* Describes a basic block. Contains lists of arcs to successor and
predecessor blocks. */
-typedef struct block_info
+struct block_info
{
/* Constructor. */
block_info ();
@@ -175,7 +175,7 @@ typedef struct block_info
line. */
struct block_info *chain;
-} block_t;
+};
block_info::block_info (): succ (NULL), pred (NULL), num_succ (0), num_pred (0),
id (0), count (0), count_valid (0), valid_chain (0), invalid_chain (0),
@@ -194,7 +194,7 @@ struct line_info
line_info ();
/* Return true when NEEDLE is one of basic blocks the line belongs to. */
- bool has_block (block_t *needle);
+ bool has_block (block_info *needle);
/* Execution count. */
gcov_type count;
@@ -203,7 +203,7 @@ struct line_info
vector<arc_info *> branches;
/* blocks which start on this line. Used in all-blocks mode. */
- vector<block_t *> blocks;
+ vector<block_info *> blocks;
unsigned exists : 1;
unsigned unexceptional : 1;
@@ -216,7 +216,7 @@ line_info::line_info (): count (0), branches (), blocks (), exists (false),
}
bool
-line_info::has_block (block_t *needle)
+line_info::has_block (block_info *needle)
{
return std::find (blocks.begin (), blocks.end (), needle) != blocks.end ();
}
@@ -253,7 +253,7 @@ struct function_info
at blocks[0] and the exit block is at blocks[1]. */
#define ENTRY_BLOCK (0)
#define EXIT_BLOCK (1)
- vector<block_t> blocks;
+ vector<block_info> blocks;
unsigned blocks_executed;
/* Raw arc coverage counts. */
@@ -590,7 +590,7 @@ bool function_info::group_line_p (unsigned n, unsigned src_idx)
*/
typedef vector<arc_info *> arc_vector_t;
-typedef vector<const block_t *> block_vector_t;
+typedef vector<const block_info *> block_vector_t;
/* Enum with types of loop in CFG. */
@@ -635,7 +635,7 @@ handle_cycle (const arc_vector_t &edges, int64_t &count)
blocked by U in BLOCK_LISTS. */
static void
-unblock (const block_t *u, block_vector_t &blocked,
+unblock (const block_info *u, block_vector_t &blocked,
vector<block_vector_t > &block_lists)
{
block_vector_t::iterator it = find (blocked.begin (), blocked.end (), u);
@@ -660,7 +660,7 @@ unblock (const block_t *u, block_vector_t &blocked,
Returns what type of loop it contains. */
static loop_type
-circuit (block_t *v, arc_vector_t &path, block_t *start,
+circuit (block_info *v, arc_vector_t &path, block_info *start,
block_vector_t &blocked, vector<block_vector_t> &block_lists,
line_info &linfo, int64_t &count)
{
@@ -673,7 +673,7 @@ circuit (block_t *v, arc_vector_t &path, block_t *start,
for (arc_info *arc = v->succ; arc; arc = arc->succ_next)
{
- block_t *w = arc->dst;
+ block_info *w = arc->dst;
if (w < start || !linfo.has_block (w))
continue;
@@ -692,7 +692,7 @@ circuit (block_t *v, arc_vector_t &path, block_t *start,
else
for (arc_info *arc = v->succ; arc; arc = arc->succ_next)
{
- block_t *w = arc->dst;
+ block_info *w = arc->dst;
if (w < start || !linfo.has_block (w))
continue;
@@ -721,7 +721,7 @@ get_cycles_count (line_info &linfo, bool handle_negative_cycles = true)
loop_type result = NO_LOOP;
gcov_type count = 0;
- for (vector<block_t *>::iterator it = linfo.blocks.begin ();
+ for (vector<block_info *>::iterator it = linfo.blocks.begin ();
it != linfo.blocks.end (); it++)
{
arc_vector_t path;
@@ -1147,7 +1147,7 @@ process_file (const char *file_name)
for (unsigned block_no = 0; block_no != fn->blocks.size ();
block_no++)
{
- block_t *block = &fn->blocks[block_no];
+ block_info *block = &fn->blocks[block_no];
for (unsigned i = 0; i < block->locations.size (); i++)
{
/* Sort lines of locations. */
@@ -1549,7 +1549,7 @@ read_graph_file (void)
unsigned src = gcov_read_unsigned ();
fn->blocks[src].id = src;
unsigned num_dests = GCOV_TAG_ARCS_NUM (length);
- block_t *src_blk = &fn->blocks[src];
+ block_info *src_blk = &fn->blocks[src];
unsigned mark_catches = 0;
struct arc_info *arc;
@@ -1622,7 +1622,7 @@ read_graph_file (void)
else if (fn && tag == GCOV_TAG_LINES)
{
unsigned blockno = gcov_read_unsigned ();
- block_t *block = &fn->blocks[blockno];
+ block_info *block = &fn->blocks[blockno];
if (blockno >= fn->blocks.size ())
goto corrupt;
@@ -1784,9 +1784,9 @@ solve_flow_graph (function_info *fn)
unsigned ix;
arc_info *arc;
gcov_type *count_ptr = &fn->counts.front ();
- block_t *blk;
- block_t *valid_blocks = NULL; /* valid, but unpropagated blocks. */
- block_t *invalid_blocks = NULL; /* invalid, but inferable blocks. */
+ block_info *blk;
+ block_info *valid_blocks = NULL; /* valid, but unpropagated blocks. */
+ block_info *invalid_blocks = NULL; /* invalid, but inferable blocks. */
/* The arcs were built in reverse order. Fix that now. */
for (ix = fn->blocks.size (); ix--;)
@@ -1837,7 +1837,7 @@ solve_flow_graph (function_info *fn)
for (unsigned i = 0; i < fn->blocks.size (); i++)
{
blk = &fn->blocks[i];
- block_t const *prev_dst = NULL;
+ block_info const *prev_dst = NULL;
int out_of_order = 0;
int non_fake_succ = 0;
@@ -1955,7 +1955,7 @@ solve_flow_graph (function_info *fn)
blk->valid_chain = 0;
if (blk->num_succ == 1)
{
- block_t *dst;
+ block_info *dst;
total = blk->count;
inv_arc = NULL;
@@ -1991,7 +1991,7 @@ solve_flow_graph (function_info *fn)
}
if (blk->num_pred == 1)
{
- block_t *src;
+ block_info *src;
total = blk->count;
inv_arc = NULL;
@@ -2045,7 +2045,7 @@ static void
find_exception_blocks (function_info *fn)
{
unsigned ix;
- block_t **queue = XALLOCAVEC (block_t *, fn->blocks.size ());
+ block_info **queue = XALLOCAVEC (block_info *, fn->blocks.size ());
/* First mark all blocks as exceptional. */
for (ix = fn->blocks.size (); ix--;)
@@ -2056,7 +2056,7 @@ find_exception_blocks (function_info *fn)
queue[0]->exceptional = 0;
for (ix = 1; ix;)
{
- block_t *block = queue[--ix];
+ block_info *block = queue[--ix];
const arc_info *arc;
for (arc = block->succ; arc; arc = arc->succ_next)
@@ -2428,7 +2428,7 @@ add_line_counts (coverage_t *coverage, function_info *fn)
for (unsigned ix = 0; ix != fn->blocks.size (); ix++)
{
line_info *line = NULL;
- block_t *block = &fn->blocks[ix];
+ block_info *block = &fn->blocks[ix];
if (block->count && ix && ix + 1 != fn->blocks.size ())
fn->blocks_executed++;
for (unsigned i = 0; i < block->locations.size (); i++)
@@ -2524,7 +2524,7 @@ static void accumulate_line_info (line_info *line, source_info *src,
gcov_type count = 0;
/* Cycle detection. */
- for (vector<block_t *>::iterator it = line->blocks.begin ();
+ for (vector<block_info *>::iterator it = line->blocks.begin ();
it != line->blocks.end (); it++)
{
for (arc_info *arc = (*it)->pred; arc; arc = arc->pred_next)
@@ -2787,7 +2787,7 @@ output_line_details (FILE *f, const line_info *line, unsigned line_num)
int ix, jx;
ix = jx = 0;
- for (vector<block_t *>::const_iterator it = line->blocks.begin ();
+ for (vector<block_info *>::const_iterator it = line->blocks.begin ();
it != line->blocks.end (); it++)
{
if (!(*it)->is_call_return)
--
2.14.3
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/7] GCOV: introduce global vector of functions
2017-11-09 10:25 ` [PATCH 1/7] GCOV: introduce global vector of functions marxin
@ 2017-11-09 15:10 ` Nathan Sidwell
0 siblings, 0 replies; 15+ messages in thread
From: Nathan Sidwell @ 2017-11-09 15:10 UTC (permalink / raw)
To: marxin, gcc-patches
On 11/09/2017 05:24 AM, marxin wrote:
> gcc/ChangeLog:
>
> 2017-11-09 Martin Liska <mliska@suse.cz>
>
> * gcov.c (read_graph_file): Store to global vector of functions.
> (read_count_file): Iterate the vector.
> (process_file): Likewise.
> (generate_results): Likewise.
> (release_structures): Likewise.
ok
--
Nathan Sidwell
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/7] GCOV: simplify usage of function_info::artificial.
2017-11-09 10:25 ` [PATCH 2/7] GCOV: simplify usage of function_info::artificial marxin
@ 2017-11-09 15:11 ` Nathan Sidwell
0 siblings, 0 replies; 15+ messages in thread
From: Nathan Sidwell @ 2017-11-09 15:11 UTC (permalink / raw)
To: marxin, gcc-patches
On 11/09/2017 05:24 AM, marxin wrote:
> gcc/ChangeLog:
>
> 2017-11-09 Martin Liska <mliska@suse.cz>
>
> * gcov.c (is_artificial): New function.
> (process_file): Erase all artificial early.
> (generate_results): Skip as all artificial are already
> removed.
> ---
> gcc/gcov.c | 66 +++++++++++++++++++++++++++++++++++++-------------------------
> 1 file changed, 40 insertions(+), 26 deletions(-)
>
> diff --git a/gcc/gcov.c b/gcc/gcov.c
> index 83239639247..3dc159726c7 100644
> --- a/gcc/gcov.c
> +++ b/gcc/gcov.c
> @@ -1088,6 +1088,14 @@ struct function_start_pair_hash : typed_noop_remove <function_start>
> }
> };
>
> +/* Function filter based on function_info::artificial variable. */
> +
> +static bool
> +is_artificial (function_info *fn)
> +{
> + return fn->artificial;
> +}
couldn't this be a member fn of function_info?
--
Nathan Sidwell
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 3/7] GCOV: introduce vector for function_info::counts.
2017-11-09 10:25 ` [PATCH 3/7] GCOV: introduce vector for function_info::counts marxin
@ 2017-11-09 15:11 ` Nathan Sidwell
0 siblings, 0 replies; 15+ messages in thread
From: Nathan Sidwell @ 2017-11-09 15:11 UTC (permalink / raw)
To: marxin, gcc-patches
On 11/09/2017 05:24 AM, marxin wrote:
> gcc/ChangeLog:
>
> 2017-11-09 Martin Liska <mliska@suse.cz>
>
> * gcov.c (function_info::function_info): Remove num_counts
> and add vector<gcov_type>.
> (function_info::~function_info): Use the vector.
> (process_file): Likewise.
> (read_graph_file): Likewise.
> (read_count_file): Likewise.
> (solve_flow_graph): Likewise.
ok
--
Nathan Sidwell
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 5/7] GCOV: remove typedef for arc_t
2017-11-09 10:25 ` [PATCH 5/7] GCOV: remove typedef for arc_t marxin
@ 2017-11-09 15:12 ` Nathan Sidwell
0 siblings, 0 replies; 15+ messages in thread
From: Nathan Sidwell @ 2017-11-09 15:12 UTC (permalink / raw)
To: marxin, gcc-patches
On 11/09/2017 05:24 AM, marxin wrote:
> gcc/ChangeLog:
>
> 2017-11-09 Martin Liska <mliska@suse.cz>
>
> * gcov.c (struct arc_info): Remove typedef for arc_t.
> (struct line_info): Likewise.
> (add_branch_counts): Likewise.
> (output_branch_count): Likewise.
> (function_info::~function_info): Likewise.
> (circuit): Likewise.
> (output_intermediate_line): Likewise.
> (read_graph_file): Likewise.
> (solve_flow_graph): Likewise.
> (find_exception_blocks): Likewise.
> (add_line_counts): Likewise.
> (accumulate_line_info): Likewise.
> (output_line_details): Likewise.
> (output_function_details): Likewise.
ok
--
Nathan Sidwell
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 4/7] GCOV: remove typedef for function_t
2017-11-09 10:26 ` [PATCH 4/7] GCOV: remove typedef for function_t marxin
@ 2017-11-09 15:12 ` Nathan Sidwell
0 siblings, 0 replies; 15+ messages in thread
From: Nathan Sidwell @ 2017-11-09 15:12 UTC (permalink / raw)
To: marxin, gcc-patches
On 11/09/2017 05:24 AM, marxin wrote:
> gcc/ChangeLog:
>
> 2017-11-09 Martin Liska <mliska@suse.cz>
>
> * gcov.c (struct function_info): Remove typedef for function_t.
> (struct source_info): Likewise.
> (source_info::get_functions_at_location): Likewise.
> (solve_flow_graph): Likewise.
> (find_exception_blocks): Likewise.
> (add_line_counts): Likewise.
> (output_intermediate_file): Likewise.
> (process_file): Likewise.
> (generate_results): Likewise.
> (release_structures): Likewise.
> (read_graph_file): Likewise.
> (read_count_file): Likewise.
> (accumulate_line_counts): Likewise.
> (output_lines): Likewise.
ok
--
Nathan Sidwell
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 6/7] GCOV: remove typedef for block_t
2017-11-09 10:27 ` [PATCH 6/7] GCOV: remove typedef for block_t marxin
@ 2017-11-09 15:12 ` Nathan Sidwell
0 siblings, 0 replies; 15+ messages in thread
From: Nathan Sidwell @ 2017-11-09 15:12 UTC (permalink / raw)
To: marxin, gcc-patches
On 11/09/2017 05:24 AM, marxin wrote:
> gcc/ChangeLog:
>
> 2017-11-09 Martin Liska <mliska@suse.cz>
>
> * gcov.c (struct block_info): Remove typedef for block_t.
> (struct line_info): Likewise.
> (line_info::has_block): Likewise.
> (EXIT_BLOCK): Likewise.
> (unblock): Likewise.
> (circuit): Likewise.
> (get_cycles_count): Likewise.
> (process_file): Likewise.
> (read_graph_file): Likewise.
> (solve_flow_graph): Likewise.
> (find_exception_blocks): Likewise.
> (add_line_counts): Likewise.
> (accumulate_line_info): Likewise.
> (output_line_details): Likewise.
ok
--
Nathan Sidwell
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 7/7] GCOV: remove typedef of coverage_t.
2017-11-09 10:25 ` [PATCH 7/7] GCOV: remove typedef of coverage_t marxin
@ 2017-11-09 15:23 ` Nathan Sidwell
0 siblings, 0 replies; 15+ messages in thread
From: Nathan Sidwell @ 2017-11-09 15:23 UTC (permalink / raw)
To: marxin, gcc-patches
On 11/09/2017 05:24 AM, marxin wrote:
> gcc/ChangeLog:
>
> 2017-11-09 Martin Liska <mliska@suse.cz>
>
> * gcov.c (struct coverage_info): Remove typedef of coverage_t.
> (struct source_info): Likewise.
> (add_branch_counts): Likewise.
> (add_line_counts): Likewise.
> (function_summary): Likewise.
> (output_intermediate_line): Likewise.
> (generate_results): Likewise.
ok
--
Nathan Sidwell
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2017-11-09 15:12 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-09 10:25 [PATCH 0/7] GCOV: infrastructure clean-up marxin
2017-11-09 10:25 ` [PATCH 3/7] GCOV: introduce vector for function_info::counts marxin
2017-11-09 15:11 ` Nathan Sidwell
2017-11-09 10:25 ` [PATCH 7/7] GCOV: remove typedef of coverage_t marxin
2017-11-09 15:23 ` Nathan Sidwell
2017-11-09 10:25 ` [PATCH 2/7] GCOV: simplify usage of function_info::artificial marxin
2017-11-09 15:11 ` Nathan Sidwell
2017-11-09 10:25 ` [PATCH 1/7] GCOV: introduce global vector of functions marxin
2017-11-09 15:10 ` Nathan Sidwell
2017-11-09 10:25 ` [PATCH 5/7] GCOV: remove typedef for arc_t marxin
2017-11-09 15:12 ` Nathan Sidwell
2017-11-09 10:26 ` [PATCH 4/7] GCOV: remove typedef for function_t marxin
2017-11-09 15:12 ` Nathan Sidwell
2017-11-09 10:27 ` [PATCH 6/7] GCOV: remove typedef for block_t marxin
2017-11-09 15:12 ` Nathan Sidwell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).