Skip to content

Commit 56e0425

Browse files
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).
1 parent 0d8e648 commit 56e0425

File tree

9 files changed

+25
-47
lines changed

9 files changed

+25
-47
lines changed

VEX/priv/guest_generic_bb_to_IR.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -1237,8 +1237,7 @@ IRSB* bb_to_IR (
12371237
vassert(sizeof(HWord) == sizeof(void*));
12381238
vassert(vex_control.guest_max_insns >= 1);
12391239
vassert(vex_control.guest_max_insns <= 100);
1240-
vassert(vex_control.guest_chase_thresh >= 0);
1241-
vassert(vex_control.guest_chase_thresh < vex_control.guest_max_insns);
1240+
vassert(vex_control.guest_chase == False || vex_control.guest_chase == True);
12421241
vassert(guest_word_type == Ity_I32 || guest_word_type == Ity_I64);
12431242

12441243
if (guest_word_type == Ity_I32) {
@@ -1324,7 +1323,7 @@ IRSB* bb_to_IR (
13241323

13251324
// Reasons to give up immediately:
13261325
// User or tool asked us not to chase
1327-
if (vex_control.guest_chase_thresh == 0)
1326+
if (!vex_control.guest_chase)
13281327
break;
13291328

13301329
// Out of extent slots

VEX/pub/libvex.h

+6-11
Original file line numberDiff line numberDiff line change
@@ -512,17 +512,12 @@ typedef
512512
BBs longer than this are split up. Default=60 (guest
513513
insns). */
514514
Int guest_max_insns;
515-
/* How aggressive should front ends be in following
516-
unconditional branches to known destinations? Default=10,
517-
meaning that if a block contains less than 10 guest insns so
518-
far, the front end(s) will attempt to chase into its
519-
successor. A setting of zero disables chasing. */
520-
// FIXME change this to a Bool
521-
Int guest_chase_thresh;
522-
/* EXPERIMENTAL: chase across conditional branches? Not all
523-
front ends honour this. Default: NO. */
524-
// FIXME remove this completely.
525-
Bool guest_chase_cond;
515+
/* Should Vex try to construct superblocks, by chasing unconditional
516+
branches/calls to known destinations, and performing AND/OR idiom
517+
recognition? It is recommended to set this to True as that possibly
518+
improves performance a bit, and also is important for avoiding certain
519+
kinds of false positives in Memcheck. Default=True. */
520+
Bool guest_chase;
526521
/* Register allocator version. Allowed values are:
527522
- '2': previous, good and slow implementation.
528523
- '3': current, faster implementation; perhaps producing slightly worse

callgrind/main.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -2062,11 +2062,11 @@ void CLG_(post_clo_init)(void)
20622062
"=> resetting it back to 0\n");
20632063
VG_(clo_vex_control).iropt_unroll_thresh = 0; // cannot be overridden.
20642064
}
2065-
if (VG_(clo_vex_control).guest_chase_thresh != 0) {
2065+
if (VG_(clo_vex_control).guest_chase) {
20662066
VG_(message)(Vg_UserMsg,
2067-
"callgrind only works with --vex-guest-chase-thresh=0\n"
2068-
"=> resetting it back to 0\n");
2069-
VG_(clo_vex_control).guest_chase_thresh = 0; // cannot be overridden.
2067+
"callgrind only works with --vex-guest-chase=no\n"
2068+
"=> resetting it back to 'no'\n");
2069+
VG_(clo_vex_control).guest_chase = False; // cannot be overridden.
20702070
}
20712071

20722072
CLG_DEBUG(1, " dump threads: %s\n", CLG_(clo).separate_threads ? "Yes":"No");
@@ -2120,7 +2120,7 @@ void CLG_(pre_clo_init)(void)
21202120
= VexRegUpdSpAtMemAccess; // overridable by the user.
21212121

21222122
VG_(clo_vex_control).iropt_unroll_thresh = 0; // cannot be overridden.
2123-
VG_(clo_vex_control).guest_chase_thresh = 0; // cannot be overridden.
2123+
VG_(clo_vex_control).guest_chase = False; // cannot be overridden.
21242124

21252125
VG_(basic_tool_funcs) (CLG_(post_clo_init),
21262126
CLG_(instrument),

coregrind/m_main.c

+3-16
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,7 @@ static void usage_NORETURN ( int need_help )
271271
" --vex-iropt-level=<0..2> [2]\n"
272272
" --vex-iropt-unroll-thresh=<0..400> [120]\n"
273273
" --vex-guest-max-insns=<1..100> [50]\n"
274-
" --vex-guest-chase-thresh=<0..99> [10]\n"
275-
" --vex-guest-chase-cond=no|yes [no]\n"
274+
" --vex-guest-chase=no|yes [yes]\n"
276275
" Precise exception control. Possible values for 'mode' are as follows\n"
277276
" and specify the minimum set of registers guaranteed to be correct\n"
278277
" immediately prior to memory access instructions:\n"
@@ -723,10 +722,8 @@ static void process_option (Clo_Mode mode,
723722
VG_(clo_vex_control).iropt_unroll_thresh, 0, 400) {}
724723
else if VG_BINT_CLO(arg, "--vex-guest-max-insns",
725724
VG_(clo_vex_control).guest_max_insns, 1, 100) {}
726-
else if VG_BINT_CLO(arg, "--vex-guest-chase-thresh",
727-
VG_(clo_vex_control).guest_chase_thresh, 0, 99) {}
728-
else if VG_BOOL_CLO(arg, "--vex-guest-chase-cond",
729-
VG_(clo_vex_control).guest_chase_cond) {}
725+
else if VG_BOOL_CLO(arg, "--vex-guest-chase",
726+
VG_(clo_vex_control).guest_chase) {}
730727

731728
else if VG_INT_CLO(arg, "--log-fd", pos->tmp_log_fd) {
732729
pos->log_to = VgLogTo_Fd;
@@ -974,16 +971,6 @@ void main_process_cmd_line_options( void )
974971
if (VG_(clo_vgdb_prefix) == NULL)
975972
VG_(clo_vgdb_prefix) = VG_(vgdb_prefix_default)();
976973

977-
/* Make VEX control parameters sane */
978-
979-
if (VG_(clo_vex_control).guest_chase_thresh
980-
>= VG_(clo_vex_control).guest_max_insns)
981-
VG_(clo_vex_control).guest_chase_thresh
982-
= VG_(clo_vex_control).guest_max_insns - 1;
983-
984-
if (VG_(clo_vex_control).guest_chase_thresh < 0)
985-
VG_(clo_vex_control).guest_chase_thresh = 0;
986-
987974
/* Check various option values */
988975

989976
if (VG_(clo_verbosity) < 0)

docs/xml/manual-core-adv.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1563,8 +1563,7 @@ $3 = {lwpid = 0x4688, threadgroup = 0x4688, parent = 0x0,
15631563
(gdb) p vex_control
15641564
$5 = {iropt_verbosity = 0, iropt_level = 2,
15651565
iropt_register_updates = VexRegUpdUnwindregsAtMemAccess,
1566-
iropt_unroll_thresh = 120, guest_max_insns = 60, guest_chase_thresh = 10,
1567-
guest_chase_cond = 0 '\000'}
1566+
iropt_unroll_thresh = 120, guest_max_insns = 60, guest_chase_thresh = 10}
15681567
(gdb)
15691568
]]></screen>
15701569
</listitem>

exp-bbv/bbv_main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,8 @@ static void bbv_post_clo_init(void)
514514

515515
/* Try a closer approximation of basic blocks */
516516
/* This is the same as the command line option */
517-
/* --vex-guest-chase-thresh=0 */
518-
VG_(clo_vex_control).guest_chase_thresh = 0;
517+
/* --vex-guest-chase=no */
518+
VG_(clo_vex_control).guest_chase = False;
519519
}
520520

521521
/* Parse the command line options */

exp-sgcheck/pc_main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ static void pc_pre_clo_init(void)
147147
sg_pre_clo_init();
148148

149149
VG_(clo_vex_control).iropt_unroll_thresh = 0;
150-
VG_(clo_vex_control).guest_chase_thresh = 0;
150+
VG_(clo_vex_control).guest_chase = False;
151151
}
152152

153153
VG_DETERMINE_INTERFACE_VERSION(pc_pre_clo_init)

helgrind/hg_main.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -5954,14 +5954,13 @@ static void hg_post_clo_init ( void )
59545954
{
59555955
Thr* hbthr_root;
59565956

5957-
if (HG_(clo_delta_stacktrace)
5958-
&& VG_(clo_vex_control).guest_chase_thresh != 0) {
5957+
if (HG_(clo_delta_stacktrace) && VG_(clo_vex_control).guest_chase) {
59595958
if (VG_(clo_verbosity) >= 2)
59605959
VG_(message)(Vg_UserMsg,
59615960
"helgrind --delta-stacktrace=yes only works with "
5962-
"--vex-guest-chase-thresh=0\n"
5963-
"=> (re-setting it to 0)\n");
5964-
VG_(clo_vex_control).guest_chase_thresh = 0;
5961+
"--vex-guest-chase=no\n"
5962+
"=> (re-setting it to 'no')\n");
5963+
VG_(clo_vex_control).guest_chase = False;
59655964
}
59665965

59675966

none/tests/cmdline2.stdout.exp

+1-2
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ usage: valgrind [options] prog-and-args
184184
--vex-iropt-level=<0..2> [2]
185185
--vex-iropt-unroll-thresh=<0..400> [120]
186186
--vex-guest-max-insns=<1..100> [50]
187-
--vex-guest-chase-thresh=<0..99> [10]
188-
--vex-guest-chase-cond=no|yes [no]
187+
--vex-guest-chase=no|yes [yes]
189188
Precise exception control. Possible values for 'mode' are as follows
190189
and specify the minimum set of registers guaranteed to be correct
191190
immediately prior to memory access instructions:

0 commit comments

Comments
 (0)