]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Record edge true/false value for gcov
authorJørgen Kvalsvik <j@lambda.is>
Tue, 4 Jun 2024 12:16:22 +0000 (14:16 +0200)
committerJørgen Kvalsvik <j@lambda.is>
Wed, 26 Jun 2024 10:19:34 +0000 (12:19 +0200)
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
gcc/gcov.cc
gcc/profile.cc

index 20f805598f0828295c938fc67a910e30b6ea5e31..5dc467c92b12d027dc8f1830e4800e02668e75d0 100644 (file)
@@ -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.  */
 
index 6f3055718d28f514e4e80df7b1a8c4120c0bf90a..2e4bd9d3c5dab231016af8200296c8b534e02196 100644 (file)
@@ -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;
@@ -2010,6 +2016,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;
index 2b90e6cc5105d0451501cd5a0e77ae64ed3721ee..25d4f4a4b860b9d893b760b7a2aa3c89e75c9c15 100644 (file)
@@ -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)