]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add statistics printing for the new trace construction algorithm.
authorJulian Seward <jseward@acm.org>
Thu, 21 Nov 2019 07:55:43 +0000 (08:55 +0100)
committerJulian Seward <jseward@acm.org>
Thu, 21 Nov 2019 07:55:43 +0000 (08:55 +0100)
VEX/priv/guest_generic_bb_to_IR.c
VEX/priv/guest_generic_bb_to_IR.h
VEX/priv/main_main.c
VEX/pub/libvex.h
coregrind/m_translate.c

index 16d83a8846d3f54d3a3f8ba0a7f1fe99a8f28716..7477641500b9df4e4375dc6745ab7d54d15a3dfc 100644 (file)
@@ -1209,6 +1209,8 @@ IRSB* bb_to_IR (
          /*OUT*/VexGuestExtents* vge,
          /*OUT*/UInt*            n_sc_extents,
          /*OUT*/UInt*            n_guest_instrs, /* stats only */
+         /*OUT*/UShort*          n_uncond_in_trace, /* stats only */
+         /*OUT*/UShort*          n_cond_in_trace, /* stats only */
          /*MOD*/VexRegisterUpdates* pxControl,
          /*IN*/ void*            callback_opaque,
          /*IN*/ DisOneInstrFn    dis_instr_fn,
@@ -1252,6 +1254,8 @@ IRSB* bb_to_IR (
    vge->n_used     = 0;
    *n_sc_extents   = 0;
    *n_guest_instrs = 0;
+   *n_uncond_in_trace = 0;
+   *n_cond_in_trace   = 0;
 
    /* And a new IR superblock to dump the result into. */
    IRSB* irsb = emptyIRSB();
@@ -1375,6 +1379,7 @@ IRSB* bb_to_IR (
          add_extent(vge, bb_base, bb_len);
          update_instr_budget(&instrs_avail, &verbose_mode,
                              bb_instrs_used, bb_verbose_seen);
+         *n_uncond_in_trace += 1;
       } // if (be.tag == Be_Uncond)
    
       // Try for an extend based on a conditional branch, specifically in the
@@ -1567,6 +1572,7 @@ IRSB* bb_to_IR (
             add_extent(vge, sx_base, sx_len);
             update_instr_budget(&instrs_avail, &verbose_mode,
                                 sx_instrs_used, sx_verbose_seen);
+            *n_cond_in_trace += 1;
          }
          break;
       } // if (be.tag == Be_Cond)
index 08d33ad3a674384a47226c5443e1e34e04212319..cad6768a0b4f8ffedf7674cff91f8e0aa22d672a 100644 (file)
@@ -143,6 +143,8 @@ IRSB* bb_to_IR (
          /*OUT*/VexGuestExtents* vge,
          /*OUT*/UInt*            n_sc_extents,
          /*OUT*/UInt*            n_guest_instrs, /* stats only */
+         /*OUT*/UShort*          n_uncond_in_trace, /* stats only */
+         /*OUT*/UShort*          n_cond_in_trace, /* stats only */
          /*MOD*/VexRegisterUpdates* pxControl,
          /*IN*/ void*            callback_opaque,
          /*IN*/ DisOneInstrFn    dis_instr_fn,
index 0da2b46670422f7cb30a34c3a69266a2b78bdc46..5acab9ebafbf71c7995127ea404bf4d9cab2a279 100644 (file)
@@ -554,6 +554,8 @@ IRSB* LibVEX_FrontEnd ( /*MOD*/ VexTranslateArgs* vta,
    res->n_sc_extents   = 0;
    res->offs_profInc   = -1;
    res->n_guest_instrs = 0;
+   res->n_uncond_in_trace = 0;
+   res->n_cond_in_trace = 0;
 
 #ifndef VEXMULTIARCH
    /* yet more sanity checks ... */
@@ -581,6 +583,8 @@ IRSB* LibVEX_FrontEnd ( /*MOD*/ VexTranslateArgs* vta,
    irsb = bb_to_IR ( vta->guest_extents,
                      &res->n_sc_extents,
                      &res->n_guest_instrs,
+                     &res->n_uncond_in_trace,
+                     &res->n_cond_in_trace,
                      pxControl,
                      vta->callback_opaque,
                      disInstrFn,
index 5a6a0e8057e54bc8ba716b2c836cf2e7c479cd32..5d3733db0b8dbd8bbe3f5f82d017b3a6a4ae2a3c 100644 (file)
@@ -651,6 +651,12 @@ typedef
       /* Stats only: the number of guest insns included in the
          translation.  It may be zero (!). */
       UInt n_guest_instrs;
+      /* Stats only: the number of unconditional branches incorporated into the
+         trace. */
+      UShort n_uncond_in_trace;
+      /* Stats only: the number of conditional branches incorporated into the
+         trace. */
+      UShort n_cond_in_trace;
    }
    VexTranslateResult;
 
index ae1cfcd545540727bd91c334580cbc3114c390eb..332202a915252926308030dc4156be568777df22 100644 (file)
 /*--- Stats                                                ---*/
 /*------------------------------------------------------------*/
 
+static ULong n_TRACE_total_constructed              = 0;
+static ULong n_TRACE_total_guest_insns              = 0;
+static ULong n_TRACE_total_uncond_branches_followed = 0;
+static ULong n_TRACE_total_cond_branches_followed   = 0;
+
 static ULong n_SP_updates_new_fast            = 0;
 static ULong n_SP_updates_new_generic_known   = 0;
 static ULong n_SP_updates_die_fast            = 0;
@@ -77,6 +82,13 @@ static ULong n_PX_VexRegUpdAllregsAtEachInsn     = 0;
 
 void VG_(print_translation_stats) ( void )
 {
+   VG_(message)
+      (Vg_DebugMsg,
+       "translate: %'llu guest insns, %'llu traces, "
+       "%'llu uncond chased, %llu cond chased\n",
+       n_TRACE_total_guest_insns, n_TRACE_total_constructed,
+       n_TRACE_total_uncond_branches_followed,
+       n_TRACE_total_cond_branches_followed);
    UInt n_SP_updates = n_SP_updates_new_fast + n_SP_updates_new_generic_known
                      + n_SP_updates_die_fast + n_SP_updates_die_generic_known
                      + n_SP_updates_generic_unknown;
@@ -1819,6 +1831,11 @@ Bool VG_(translate) ( ThreadId tid,
    vg_assert(tres.n_sc_extents >= 0 && tres.n_sc_extents <= 3);
    vg_assert(tmpbuf_used <= N_TMPBUF);
    vg_assert(tmpbuf_used > 0);
+
+   n_TRACE_total_constructed += 1;
+   n_TRACE_total_guest_insns += tres.n_guest_instrs;
+   n_TRACE_total_uncond_branches_followed += tres.n_uncond_in_trace;
+   n_TRACE_total_cond_branches_followed   += tres.n_cond_in_trace;
    } /* END new scope specially for 'seg' */
 
    /* Tell aspacem of all segments that have had translations taken