From: Julian Seward Date: Mon, 18 Nov 2019 18:12:49 +0000 (+0100) Subject: Rationalise --vex-guest* flags in the new IRSB construction framework X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e4db6e9172a55a983105c8e73c89987ce97308a;p=thirdparty%2Fvalgrind.git Rationalise --vex-guest* flags in the new IRSB construction framework * removes --vex-guest-chase-cond=no|yes. This was never used in practice. * rename --vex-guest-chase-thresh=<0..99> to --vex-guest-chase=no|yes. In otherwords, downgrade it from a numeric flag to a boolean one, that can simply disable all chasing if required. (Some tools, notably Callgrind, force-disable block chasing, so this functionality at least needs to be retained). --- diff --git a/VEX/priv/guest_generic_bb_to_IR.c b/VEX/priv/guest_generic_bb_to_IR.c index 3da99bc25b..16d83a8846 100644 --- a/VEX/priv/guest_generic_bb_to_IR.c +++ b/VEX/priv/guest_generic_bb_to_IR.c @@ -1237,8 +1237,7 @@ IRSB* bb_to_IR ( vassert(sizeof(HWord) == sizeof(void*)); vassert(vex_control.guest_max_insns >= 1); vassert(vex_control.guest_max_insns <= 100); - vassert(vex_control.guest_chase_thresh >= 0); - vassert(vex_control.guest_chase_thresh < vex_control.guest_max_insns); + vassert(vex_control.guest_chase == False || vex_control.guest_chase == True); vassert(guest_word_type == Ity_I32 || guest_word_type == Ity_I64); if (guest_word_type == Ity_I32) { @@ -1324,7 +1323,7 @@ IRSB* bb_to_IR ( // Reasons to give up immediately: // User or tool asked us not to chase - if (vex_control.guest_chase_thresh == 0) + if (!vex_control.guest_chase) break; // Out of extent slots diff --git a/VEX/pub/libvex.h b/VEX/pub/libvex.h index 5a76066d76..5a6a0e8057 100644 --- a/VEX/pub/libvex.h +++ b/VEX/pub/libvex.h @@ -512,17 +512,12 @@ typedef BBs longer than this are split up. Default=60 (guest insns). */ Int guest_max_insns; - /* How aggressive should front ends be in following - unconditional branches to known destinations? Default=10, - meaning that if a block contains less than 10 guest insns so - far, the front end(s) will attempt to chase into its - successor. A setting of zero disables chasing. */ - // FIXME change this to a Bool - Int guest_chase_thresh; - /* EXPERIMENTAL: chase across conditional branches? Not all - front ends honour this. Default: NO. */ - // FIXME remove this completely. - Bool guest_chase_cond; + /* Should Vex try to construct superblocks, by chasing unconditional + branches/calls to known destinations, and performing AND/OR idiom + recognition? It is recommended to set this to True as that possibly + improves performance a bit, and also is important for avoiding certain + kinds of false positives in Memcheck. Default=True. */ + Bool guest_chase; /* Register allocator version. Allowed values are: - '2': previous, good and slow implementation. - '3': current, faster implementation; perhaps producing slightly worse diff --git a/callgrind/main.c b/callgrind/main.c index 47369d1305..904eb42a99 100644 --- a/callgrind/main.c +++ b/callgrind/main.c @@ -2062,11 +2062,11 @@ void CLG_(post_clo_init)(void) "=> resetting it back to 0\n"); VG_(clo_vex_control).iropt_unroll_thresh = 0; // cannot be overridden. } - if (VG_(clo_vex_control).guest_chase_thresh != 0) { + if (VG_(clo_vex_control).guest_chase) { VG_(message)(Vg_UserMsg, - "callgrind only works with --vex-guest-chase-thresh=0\n" - "=> resetting it back to 0\n"); - VG_(clo_vex_control).guest_chase_thresh = 0; // cannot be overridden. + "callgrind only works with --vex-guest-chase=no\n" + "=> resetting it back to 'no'\n"); + VG_(clo_vex_control).guest_chase = False; // cannot be overridden. } CLG_DEBUG(1, " dump threads: %s\n", CLG_(clo).separate_threads ? "Yes":"No"); @@ -2120,7 +2120,7 @@ void CLG_(pre_clo_init)(void) = VexRegUpdSpAtMemAccess; // overridable by the user. VG_(clo_vex_control).iropt_unroll_thresh = 0; // cannot be overridden. - VG_(clo_vex_control).guest_chase_thresh = 0; // cannot be overridden. + VG_(clo_vex_control).guest_chase = False; // cannot be overridden. VG_(basic_tool_funcs) (CLG_(post_clo_init), CLG_(instrument), diff --git a/coregrind/m_main.c b/coregrind/m_main.c index 6ad1b93d1c..38f7d9769e 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -271,8 +271,7 @@ static void usage_NORETURN ( int need_help ) " --vex-iropt-level=<0..2> [2]\n" " --vex-iropt-unroll-thresh=<0..400> [120]\n" " --vex-guest-max-insns=<1..100> [50]\n" -" --vex-guest-chase-thresh=<0..99> [10]\n" -" --vex-guest-chase-cond=no|yes [no]\n" +" --vex-guest-chase=no|yes [yes]\n" " Precise exception control. Possible values for 'mode' are as follows\n" " and specify the minimum set of registers guaranteed to be correct\n" " immediately prior to memory access instructions:\n" @@ -714,10 +713,8 @@ static void process_option (Clo_Mode mode, VG_(clo_vex_control).iropt_unroll_thresh, 0, 400) {} else if VG_BINT_CLO(arg, "--vex-guest-max-insns", VG_(clo_vex_control).guest_max_insns, 1, 100) {} - else if VG_BINT_CLO(arg, "--vex-guest-chase-thresh", - VG_(clo_vex_control).guest_chase_thresh, 0, 99) {} - else if VG_BOOL_CLO(arg, "--vex-guest-chase-cond", - VG_(clo_vex_control).guest_chase_cond) {} + else if VG_BOOL_CLO(arg, "--vex-guest-chase", + VG_(clo_vex_control).guest_chase) {} else if VG_INT_CLO(arg, "--log-fd", pos->tmp_log_fd) { pos->log_to = VgLogTo_Fd; @@ -965,16 +962,6 @@ void main_process_cmd_line_options( void ) if (VG_(clo_vgdb_prefix) == NULL) VG_(clo_vgdb_prefix) = VG_(vgdb_prefix_default)(); - /* Make VEX control parameters sane */ - - if (VG_(clo_vex_control).guest_chase_thresh - >= VG_(clo_vex_control).guest_max_insns) - VG_(clo_vex_control).guest_chase_thresh - = VG_(clo_vex_control).guest_max_insns - 1; - - if (VG_(clo_vex_control).guest_chase_thresh < 0) - VG_(clo_vex_control).guest_chase_thresh = 0; - /* Check various option values */ if (VG_(clo_verbosity) < 0) diff --git a/docs/xml/manual-core-adv.xml b/docs/xml/manual-core-adv.xml index 11afbeb931..362b916db9 100644 --- a/docs/xml/manual-core-adv.xml +++ b/docs/xml/manual-core-adv.xml @@ -1563,8 +1563,7 @@ $3 = {lwpid = 0x4688, threadgroup = 0x4688, parent = 0x0, (gdb) p vex_control $5 = {iropt_verbosity = 0, iropt_level = 2, iropt_register_updates = VexRegUpdUnwindregsAtMemAccess, - iropt_unroll_thresh = 120, guest_max_insns = 60, guest_chase_thresh = 10, - guest_chase_cond = 0 '\000'} + iropt_unroll_thresh = 120, guest_max_insns = 60, guest_chase_thresh = 10} (gdb) ]]> diff --git a/exp-bbv/bbv_main.c b/exp-bbv/bbv_main.c index 438edbfb01..e632ea11f7 100644 --- a/exp-bbv/bbv_main.c +++ b/exp-bbv/bbv_main.c @@ -514,8 +514,8 @@ static void bbv_post_clo_init(void) /* Try a closer approximation of basic blocks */ /* This is the same as the command line option */ - /* --vex-guest-chase-thresh=0 */ - VG_(clo_vex_control).guest_chase_thresh = 0; + /* --vex-guest-chase=no */ + VG_(clo_vex_control).guest_chase = False; } /* Parse the command line options */ diff --git a/exp-sgcheck/pc_main.c b/exp-sgcheck/pc_main.c index 93f4b1e409..fc13d6afa3 100644 --- a/exp-sgcheck/pc_main.c +++ b/exp-sgcheck/pc_main.c @@ -147,7 +147,7 @@ static void pc_pre_clo_init(void) sg_pre_clo_init(); VG_(clo_vex_control).iropt_unroll_thresh = 0; - VG_(clo_vex_control).guest_chase_thresh = 0; + VG_(clo_vex_control).guest_chase = False; } VG_DETERMINE_INTERFACE_VERSION(pc_pre_clo_init) diff --git a/helgrind/hg_main.c b/helgrind/hg_main.c index ddf582f84b..8b8dd05498 100644 --- a/helgrind/hg_main.c +++ b/helgrind/hg_main.c @@ -5954,14 +5954,13 @@ static void hg_post_clo_init ( void ) { Thr* hbthr_root; - if (HG_(clo_delta_stacktrace) - && VG_(clo_vex_control).guest_chase_thresh != 0) { + if (HG_(clo_delta_stacktrace) && VG_(clo_vex_control).guest_chase) { if (VG_(clo_verbosity) >= 2) VG_(message)(Vg_UserMsg, "helgrind --delta-stacktrace=yes only works with " - "--vex-guest-chase-thresh=0\n" - "=> (re-setting it to 0)\n"); - VG_(clo_vex_control).guest_chase_thresh = 0; + "--vex-guest-chase=no\n" + "=> (re-setting it to 'no')\n"); + VG_(clo_vex_control).guest_chase = False; } diff --git a/none/tests/cmdline2.stdout.exp b/none/tests/cmdline2.stdout.exp index cfa3060525..9e8e3df01f 100644 --- a/none/tests/cmdline2.stdout.exp +++ b/none/tests/cmdline2.stdout.exp @@ -184,8 +184,7 @@ usage: valgrind [options] prog-and-args --vex-iropt-level=<0..2> [2] --vex-iropt-unroll-thresh=<0..400> [120] --vex-guest-max-insns=<1..100> [50] - --vex-guest-chase-thresh=<0..99> [10] - --vex-guest-chase-cond=no|yes [no] + --vex-guest-chase=no|yes [yes] Precise exception control. Possible values for 'mode' are as follows and specify the minimum set of registers guaranteed to be correct immediately prior to memory access instructions: