diff mbox series

[1/2] Record edge true/false value for gcov

Message ID 20240625080408.1517769-1-j@lambda.is
State New
Headers show
Series [1/2] Record edge true/false value for gcov | expand

Commit Message

Jørgen Kvalsvik June 25, 2024, 8:04 a.m. UTC
Make gcov aware which edges are the true/false to more accurately
reconstruct the CFG.  There are plenty of bits left in arc_info and it
opens up for richer reporting.

gcc/ChangeLog:

	* gcov-io.h (GCOV_ARC_TRUE): New.
	(GCOV_ARC_FALSE): New.
	* gcov.cc (struct arc_info): Add true_value, false_value.
	(read_graph_file): Read true_value, false_value.
	* profile.cc (branch_prob): Write GCOV_ARC_TRUE, GCOV_ARC_FALSE.
---
 gcc/gcov-io.h  | 2 ++
 gcc/gcov.cc    | 8 ++++++++
 gcc/profile.cc | 4 ++++
 3 files changed, 14 insertions(+)

Comments

Jeff Law June 25, 2024, 9:37 p.m. UTC | #1
On 6/25/24 2:04 AM, Jørgen Kvalsvik wrote:
> Make gcov aware which edges are the true/false to more accurately
> reconstruct the CFG.  There are plenty of bits left in arc_info and it
> opens up for richer reporting.
> 
> gcc/ChangeLog:
> 
> 	* gcov-io.h (GCOV_ARC_TRUE): New.
> 	(GCOV_ARC_FALSE): New.
> 	* gcov.cc (struct arc_info): Add true_value, false_value.
> 	(read_graph_file): Read true_value, false_value.
> 	* profile.cc (branch_prob): Write GCOV_ARC_TRUE, GCOV_ARC_FALSE.
I thought I'd already acked this patch.

So OK, again :-)

jeff
Jørgen Kvalsvik June 26, 2024, 10:20 a.m. UTC | #2
On 6/25/24 23:37, Jeff Law wrote:
> 
> 
> On 6/25/24 2:04 AM, Jørgen Kvalsvik wrote:
>> Make gcov aware which edges are the true/false to more accurately
>> reconstruct the CFG.  There are plenty of bits left in arc_info and it
>> opens up for richer reporting.
>>
>> gcc/ChangeLog:
>>
>>     * gcov-io.h (GCOV_ARC_TRUE): New.
>>     (GCOV_ARC_FALSE): New.
>>     * gcov.cc (struct arc_info): Add true_value, false_value.
>>     (read_graph_file): Read true_value, false_value.
>>     * profile.cc (branch_prob): Write GCOV_ARC_TRUE, GCOV_ARC_FALSE.
> I thought I'd already acked this patch.
> 
> So OK, again :-)
> 
> jeff
> 

Thanks! Pushed.
diff mbox series

Patch

diff --git a/gcc/gcov-io.h b/gcc/gcov-io.h
index 20f805598f0..5dc467c92b1 100644
--- a/gcc/gcov-io.h
+++ b/gcc/gcov-io.h
@@ -337,6 +337,8 @@  GCOV_COUNTERS
 #define GCOV_ARC_ON_TREE 	(1 << 0)
 #define GCOV_ARC_FAKE		(1 << 1)
 #define GCOV_ARC_FALLTHROUGH	(1 << 2)
+#define GCOV_ARC_TRUE		(1 << 3)
+#define GCOV_ARC_FALSE		(1 << 4)
 
 /* Object & program summary record.  */
 
diff --git a/gcc/gcov.cc b/gcc/gcov.cc
index 1e2e193d79d..b9e41fd5172 100644
--- a/gcc/gcov.cc
+++ b/gcc/gcov.cc
@@ -117,6 +117,12 @@  struct arc_info
   /* Loop making arc.  */
   unsigned int cycle : 1;
 
+  /* Is a true arc.  */
+  unsigned int true_value : 1;
+
+  /* Is a false arc.  */
+  unsigned int false_value : 1;
+
   /* Links to next arc on src and dst lists.  */
   struct arc_info *succ_next;
   struct arc_info *pred_next;
@@ -2095,6 +2101,8 @@  read_graph_file (void)
 	      arc->on_tree = !!(flags & GCOV_ARC_ON_TREE);
 	      arc->fake = !!(flags & GCOV_ARC_FAKE);
 	      arc->fall_through = !!(flags & GCOV_ARC_FALLTHROUGH);
+	      arc->true_value = !!(flags & GCOV_ARC_TRUE);
+	      arc->false_value = !!(flags & GCOV_ARC_FALSE);
 
 	      arc->succ_next = src_blk->succ;
 	      src_blk->succ = arc;
diff --git a/gcc/profile.cc b/gcc/profile.cc
index 2b90e6cc510..25d4f4a4b86 100644
--- a/gcc/profile.cc
+++ b/gcc/profile.cc
@@ -1456,6 +1456,10 @@  branch_prob (bool thunk)
 		    flag_bits |= GCOV_ARC_FAKE;
 		  if (e->flags & EDGE_FALLTHRU)
 		    flag_bits |= GCOV_ARC_FALLTHROUGH;
+		  if (e->flags & EDGE_TRUE_VALUE)
+		    flag_bits |= GCOV_ARC_TRUE;
+		  if (e->flags & EDGE_FALSE_VALUE)
+		    flag_bits |= GCOV_ARC_FALSE;
 		  /* On trees we don't have fallthru flags, but we can
 		     recompute them from CFG shape.  */
 		  if (e->flags & (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE)