From: Florian Krohm Date: Tue, 12 Aug 2025 21:52:18 +0000 (+0000) Subject: New command line flag --vex-iropt-fold-expr X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=679e7bced9;p=thirdparty%2Fvalgrind.git New command line flag --vex-iropt-fold-expr Defaults to "yes". Add VexControl::iropt_fold_expr and observe it in fold_Expr_WRK. This flag will be used shortly in the iropt-test program. Users are not expected to use it which is why I'm not announcing it in NEWS. --- diff --git a/VEX/priv/ir_opt.c b/VEX/priv/ir_opt.c index ebea8ba0e..fa2877f6b 100644 --- a/VEX/priv/ir_opt.c +++ b/VEX/priv/ir_opt.c @@ -1462,6 +1462,8 @@ static IRExpr* chase1 ( IRExpr** env, IRExpr* e ) __attribute__((noinline)) static IRExpr* fold_Expr_WRK ( IRExpr** env, IRExpr* e ) { + if (UNLIKELY(vex_control.iropt_fold_expr == False)) return e; + Int shift; IRExpr* e2 = e; /* e2 is the result of folding e, if possible */ diff --git a/VEX/priv/main_globals.c b/VEX/priv/main_globals.c index 9167e8131..c0536bea7 100644 --- a/VEX/priv/main_globals.c +++ b/VEX/priv/main_globals.c @@ -57,7 +57,7 @@ Int vex_debuglevel = 0; Int vex_traceflags = 0; /* Max # guest insns per bb */ -VexControl vex_control = { 0,0,VexRegUpd_INVALID,0,0,False,0 }; +VexControl vex_control = { 0,0,VexRegUpd_INVALID,0,0,False,0,False }; diff --git a/VEX/priv/main_main.c b/VEX/priv/main_main.c index 619cace2e..3e64ad7de 100644 --- a/VEX/priv/main_main.c +++ b/VEX/priv/main_main.c @@ -204,6 +204,7 @@ void LibVEX_default_VexControl ( /*OUT*/ VexControl* vcon ) vcon->guest_max_insns = 60; vcon->guest_chase = True; vcon->regalloc_version = 3; + vcon->iropt_fold_expr = True; } void LibVEX_set_VexControl ( VexControl vcon ) diff --git a/VEX/pub/libvex.h b/VEX/pub/libvex.h index 177969978..da295f85f 100644 --- a/VEX/pub/libvex.h +++ b/VEX/pub/libvex.h @@ -572,6 +572,9 @@ typedef - '3': current, faster implementation; perhaps producing slightly worse spilling decisions. */ UInt regalloc_version; + /* When false constant folding and algebric simplification is disabled. + This is used in the iropt tester. */ + Bool iropt_fold_expr; } VexControl; diff --git a/coregrind/m_main.c b/coregrind/m_main.c index c94e5e053..87c75d2ac 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -294,6 +294,7 @@ static void usage_NORETURN ( int need_help ) " --vex-iropt-verbosity=<0..9> [0]\n" " --vex-iropt-level=<0..2> [2]\n" " --vex-iropt-unroll-thresh=<0..400> [120]\n" +" --vex-iropt-fold-expr=no|yes [yes]\n" " --vex-guest-max-insns=<1..100> [50]\n" " --vex-guest-chase=no|yes [yes]\n" " Precise exception control. Possible values for 'mode' are as follows\n" @@ -761,6 +762,8 @@ static void process_option (Clo_Mode mode, VG_(clo_vex_control).iropt_level, 0, 2) {} else if VG_BINT_CLO(arg, "--vex-regalloc-version", VG_(clo_vex_control).regalloc_version, 2, 3) {} + else if VG_BOOL_CLOM(cloPD, arg, "--vex-iropt-fold-expr", + VG_(clo_vex_control).iropt_fold_expr) {} else if (VG_STRINDEX_CLO(arg, "--vex-iropt-register-updates", pxStrings, ix)