]> git.ipfire.org Git - thirdparty/valgrind.git/commit
Improve efficiency of SP tracking in helgrind (and incidentally in exp-sgheck)
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sat, 4 Nov 2017 22:32:19 +0000 (23:32 +0100)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Tue, 7 Nov 2017 20:18:31 +0000 (21:18 +0100)
commitcc897604813cee1f5d3c614c76e5ca9ce696e6c3
tree76f3f9666ff6308a554985649f1fc06af8762d8b
parent4d621f651033304e3f9d57f673dc872b662c2871
Improve efficiency of SP tracking in helgrind (and incidentally in exp-sgheck)

Helgrind (and incidentally exp-sgcheck) does not need both of
tracking new mem stack and die mem stack:
Helgrind only tracks new mem stack. exp-sgcheck only tracks die mem stack.

Currently, m_translate.c vg_SP_update_pass inserts helpers calls
for new and die mem stack, even if the tool only needs new mem stack (helgrind)
or die mem stack (exp-sgcheck).

The optimisation consists in not inserting helpers calls when the tool
does not need to see new (or die) mem stack.
Also, for helgrind, implement specialised new_mem_stack for known SP updates
with small values (like memcheck).

This reduces the size of the generated code for helgrind and exp-sgcheck.
(see below the diffs on perf/memrw). This does not impact the code generation
for tools that tracks both new and die mem stack (such as memcheck).

trunk:
exp-sgcheck: --28481--  transtab: new        2,256 (44,529 -> 581,402; ratio 13.1) [0 scs] avg tce size 257
helgrind:    --28496--  transtab: new        2,299 (46,667 -> 416,575; ratio 8.9) [0 scs] avg tce size 181
memcheck:    --28501--  transtab: new        2,220 (50,038 -> 777,139; ratio 15.5) [0 scs] avg tce size 350

with this patch:
exp-sgcheck: --28516--  transtab: new        2,254 (44,479 -> 567,196; ratio 12.8) [0 scs] avg tce size 251
helgrind:    --28512--  transtab: new        2,297 (46,620 -> 399,799; ratio 8.6) [0 scs] avg tce size 174
memcheck:    --28507--  transtab: new        2,219 (49,991 -> 776,028; ratio 15.5) [0 scs] avg tce size 349

More in details, the changes consist in:

pub_core_tooliface.h:
  * add 2 booleans any_new_mem_stack and any_die_mem_stack to the tdict struct
  * renamed VG_(sanity_check_needs) to VG_(finish_needs_init), as it
    does now more than sanity checks : it derives the 2 above booleans.
m_tooliface.c:
  * change VG_(sanity_check_needs) to VG_(finish_needs_init)
m_main.c:
  * update call to VG_(sanity_check_needs)
hg_main.c:
  * add a few inlines for functions just calling another function
  * define the functions evh__new_mem_stack_[4|8|12|16|32|112|128|144|160]
    (using the macro DCL_evh__new_mem_stack).
  * call the VG_(track_new_mem_stack_[4|8|12|16|32|112|128|144|160])
m_translate.c
  * n_SP_updates_* stats are now maintained separately for the new and die
    fast and known cases.
  * need_to_handle_SP_assignment can now check only the 2 booleans
    any_new_mem_stack and any_die_mem_stack
  * DO_NEW macro: does not insert anymore a helper call if the tool does
    not track 'new' mem_stack.
    In case there is no new tracking, it however still does update the
    SP aliases (and the n_SP_updates_new_fast).
  * similar changes for DO_DIE macro.
  * a bunch of white spaces changes
 Note: it is easier to look at the changes in this file using
   git diff -w
 to ignore the white spaces changes (e.g. due to DO_NEW/DO_DIE indentation
 changes).

regtested on debian/amd64 and on centos/ppc64
coregrind/m_main.c
coregrind/m_tooliface.c
coregrind/m_translate.c
coregrind/pub_core_tooliface.h
helgrind/hg_main.c