]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
New command line flag --vex-iropt-fold-expr
authorFlorian Krohm <flo2030@eich-krohm.de>
Tue, 12 Aug 2025 21:52:18 +0000 (21:52 +0000)
committerFlorian Krohm <flo2030@eich-krohm.de>
Tue, 12 Aug 2025 21:52:18 +0000 (21:52 +0000)
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.

VEX/priv/ir_opt.c
VEX/priv/main_globals.c
VEX/priv/main_main.c
VEX/pub/libvex.h
coregrind/m_main.c

index ebea8ba0e34a93ff38801cf2dee8ee3051733662..fa2877f6bdaca46970967a6077f803edab06f5cf 100644 (file)
@@ -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 */
 
index 9167e8131cc83ab9bd2b0537f0ca122c948a6730..c0536bea72a3d69d6d02bf98b1d662690e765fb9 100644 (file)
@@ -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 };
 
 
 
index 619cace2e92c8e9bb284eacdca5c67e10fe393ac..3e64ad7de73295ee3d6146717e6820500e246c8c 100644 (file)
@@ -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 )
index 1779699785a0ef9a3a82030f4b7772077cd8ca36..da295f85feb2c58adcbc25dc2cc7d36ccf1a4ddd 100644 (file)
@@ -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;
 
index c94e5e0536e9a9a00fc93c67be183407e9499921..87c75d2ac16d2d8cbb6eb2bb8b95ce6d8c50c4a9 100644 (file)
@@ -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)