From: Julian Seward Date: Thu, 21 Nov 2019 07:55:43 +0000 (+0100) Subject: Add statistics printing for the new trace construction algorithm. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67c824937830cf4b45ad83d61efbf1d54175e008;p=thirdparty%2Fvalgrind.git Add statistics printing for the new trace construction algorithm. --- diff --git a/VEX/priv/guest_generic_bb_to_IR.c b/VEX/priv/guest_generic_bb_to_IR.c index 16d83a8846..7477641500 100644 --- a/VEX/priv/guest_generic_bb_to_IR.c +++ b/VEX/priv/guest_generic_bb_to_IR.c @@ -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) diff --git a/VEX/priv/guest_generic_bb_to_IR.h b/VEX/priv/guest_generic_bb_to_IR.h index 08d33ad3a6..cad6768a0b 100644 --- a/VEX/priv/guest_generic_bb_to_IR.h +++ b/VEX/priv/guest_generic_bb_to_IR.h @@ -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, diff --git a/VEX/priv/main_main.c b/VEX/priv/main_main.c index 0da2b46670..5acab9ebaf 100644 --- a/VEX/priv/main_main.c +++ b/VEX/priv/main_main.c @@ -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, diff --git a/VEX/pub/libvex.h b/VEX/pub/libvex.h index 5a6a0e8057..5d3733db0b 100644 --- a/VEX/pub/libvex.h +++ b/VEX/pub/libvex.h @@ -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; diff --git a/coregrind/m_translate.c b/coregrind/m_translate.c index ae1cfcd545..332202a915 100644 --- a/coregrind/m_translate.c +++ b/coregrind/m_translate.c @@ -64,6 +64,11 @@ /*--- 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