From bd9f3bb7502e32c85a9cd430df8570af012f99fd Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Tue, 24 Apr 2012 11:50:49 +0000 Subject: [PATCH] For --profile-flags=, weight the counts by the number of guest insns in each IRSB, rather than considering each IRSB to have a weight of 1. This probably gives more representative profiles, especially post t-chain merge, which made inter-SB transitions more or less free compared to what they were before. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12542 --- coregrind/m_translate.c | 1 + coregrind/m_transtab.c | 6 +++++- coregrind/pub_core_transtab.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/coregrind/m_translate.c b/coregrind/m_translate.c index 31740a3272..607b030f8f 100644 --- a/coregrind/m_translate.c +++ b/coregrind/m_translate.c @@ -1579,6 +1579,7 @@ Bool VG_(translate) ( ThreadId tid, tmpbuf_used, tres.n_sc_extents > 0, tres.offs_profInc, + tres.n_guest_instrs, vex_arch ); } else { vg_assert(tres.offs_profInc == -1); /* -1 == unset */ diff --git a/coregrind/m_transtab.c b/coregrind/m_transtab.c index 1d3cc206dc..7c08725bb4 100644 --- a/coregrind/m_transtab.c +++ b/coregrind/m_transtab.c @@ -1446,6 +1446,7 @@ void VG_(add_to_transtab)( VexGuestExtents* vge, UInt code_len, Bool is_self_checking, Int offs_profInc, + UInt n_guest_instrs, VexArch arch_host ) { Int tcAvailQ, reqdQ, y, i; @@ -1459,6 +1460,9 @@ void VG_(add_to_transtab)( VexGuestExtents* vge, /* 60000: should agree with N_TMPBUF in m_translate.c. */ vg_assert(code_len > 0 && code_len < 60000); + /* Generally stay sane */ + vg_assert(n_guest_instrs < 200); /* it can be zero, tho */ + if (0) VG_(printf)("add_to_transtab(entry = 0x%llx, len = %d)\n", entry, code_len); @@ -1548,7 +1552,7 @@ void VG_(add_to_transtab)( VexGuestExtents* vge, sectors[y].tt[i].status = InUse; sectors[y].tt[i].tcptr = tcptr; sectors[y].tt[i].count = 0; - sectors[y].tt[i].weight = 1; + sectors[y].tt[i].weight = n_guest_instrs == 0 ? 1 : n_guest_instrs; sectors[y].tt[i].vge = *vge; sectors[y].tt[i].entry = entry; diff --git a/coregrind/pub_core_transtab.h b/coregrind/pub_core_transtab.h index 046bc21a95..9a10b663e5 100644 --- a/coregrind/pub_core_transtab.h +++ b/coregrind/pub_core_transtab.h @@ -62,6 +62,7 @@ void VG_(add_to_transtab)( VexGuestExtents* vge, UInt code_len, Bool is_self_checking, Int offs_profInc, + UInt n_guest_instrs, VexArch arch_host ); extern -- 2.47.2