]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add experimental omission of V-bits for address values, using
authorJulian Seward <jseward@acm.org>
Mon, 25 Mar 2002 00:07:36 +0000 (00:07 +0000)
committerJulian Seward <jseward@acm.org>
Mon, 25 Mar 2002 00:07:36 +0000 (00:07 +0000)
--check-addrVs=no.  The default behaviour, =yes, is the original
behaviour.  So far this is undocumented.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@32

coregrind/valgrind.in
coregrind/vg_include.h
coregrind/vg_main.c
coregrind/vg_translate.c
valgrind.in
vg_include.h
vg_main.c
vg_translate.c

index f791c663ad2d81bf031a2014a9e337f411bfbec6..0b566c94cfba3cfe08e34615743a20e240639ab9 100755 (executable)
@@ -40,6 +40,8 @@ do
     --verbose)              vgopts="$vgopts -v"; shift;;
     -q)                     vgopts="$vgopts $arg"; shift;;
     --quiet)                vgopts="$vgopts $arg"; shift;;
+    --check-addrVs=no)      vgopts="$vgopts $arg"; shift;;
+    --check-addrVs=yes)     vgopts="$vgopts $arg"; shift;;
     --gdb-attach=no)        vgopts="$vgopts $arg"; shift;;
     --gdb-attach=yes)       vgopts="$vgopts $arg"; shift;;
     --demangle=no)          vgopts="$vgopts $arg"; shift;;
@@ -130,6 +132,8 @@ if [ z"$argopts" = z   -o   z"$dousage" = z1 ]; then
    echo "    --suppressions=<filename> suppress errors described in"
    echo "                              suppressions file <filename>"
    echo "    --client-perms=no|yes     handle client VG_MAKE_* requests? [no]"
+   echo "    --check-addrVs=no|yes     experimental lighterweight checking? [yes]"
+   echo "                              yes == Valgrind's original behaviour"
    echo
    echo "  options for debugging Valgrind itself are:"
    echo "    --sanity-level=<number>   level of sanity checking to do [1]"
index cf0237ec9ca599e60b2aebe3e833ea53e64368d1..3181fd8f8fff2a6274ded426f1e2a792a0942e29 100644 (file)
@@ -165,6 +165,8 @@ typedef unsigned char Bool;
 
 #define VG_CLO_MAX_SFILES 10
 
+/* Shall we V-check addrs (they are always A checked too): default: YES */
+extern Bool VG_(clo_check_addrVs);
 /* Enquire about whether to attach to GDB at errors?   default: NO */
 extern Bool  VG_(clo_GDB_attach);
 /* Sanity-check level: 0 = none, 1 (default), > 1 = expensive. */
index da674106ab0c0c0cca909f14edb2457bbcd3ff8e..2fb92cf2047b553a172091967a0ec6d051f88768 100644 (file)
@@ -433,6 +433,7 @@ UInt VG_(sanity_slow_count) = 0;
    Values derived from command-line options.
    ------------------------------------------------------------------ */
 
+Bool   VG_(clo_check_addrVs);
 Bool   VG_(clo_GDB_attach);
 Int    VG_(sanity_level);
 Int    VG_(clo_verbosity);
@@ -685,6 +686,7 @@ static void process_cmd_line_options ( void )
 #  define STREQN(nn,s1,s2) (0==VG_(strncmp_ws)((s1),(s2),(nn)))
 
    /* Set defaults. */
+   VG_(clo_check_addrVs)     = True;
    VG_(clo_GDB_attach)       = False;
    VG_(sanity_level)         = 1;
    VG_(clo_verbosity)        = 1;
@@ -852,6 +854,11 @@ static void process_cmd_line_options ( void )
       else if (STREQ(argv[i], "-q") || STREQ(argv[i], "--quiet"))
          VG_(clo_verbosity)--;
 
+      else if (STREQ(argv[i], "--check-addrVs=yes"))
+         VG_(clo_check_addrVs) = True;
+      else if (STREQ(argv[i], "--check-addrVs=no"))
+         VG_(clo_check_addrVs) = False;
+
       else if (STREQ(argv[i], "--gdb-attach=yes"))
          VG_(clo_GDB_attach) = True;
       else if (STREQ(argv[i], "--gdb-attach=no"))
index 18749ac40c02e09328a8607ee76472fcbd8dbe8a..1423b8d3da951e21473ddb2e6df18218ead509e7 100644 (file)
@@ -2113,20 +2113,31 @@ static UCodeBlock* vg_instrument ( UCodeBlock* cb_in )
             copyUInstr(cb, u_in);
             break;
 
-         /* Loads and stores.  Test the V bits for the address.
+         /* Loads and stores.  Test the V bits for the address.  24
+            Mar 02: since the address is A-checked anyway, there's not
+            really much point in doing the V-check too, unless you
+            think that you might use addresses which are undefined but
+            still addressible.  Hence the optionalisation of the V
+            check.
+
             The LOADV/STOREV does an addressibility check for the
             address. */
+
          case LOAD: 
-            uInstr1(cb, TESTV, 4, TempReg, SHADOW(u_in->val1));
-            uInstr1(cb, SETV,  4, TempReg, SHADOW(u_in->val1));
+            if (VG_(clo_check_addrVs)) {
+               uInstr1(cb, TESTV, 4, TempReg, SHADOW(u_in->val1));
+               uInstr1(cb, SETV,  4, TempReg, SHADOW(u_in->val1));
+            }
             uInstr2(cb, LOADV, u_in->size, 
                         TempReg, u_in->val1,
                         TempReg, SHADOW(u_in->val2));
             copyUInstr(cb, u_in);
             break;
          case STORE:
-            uInstr1(cb, TESTV,  4, TempReg, SHADOW(u_in->val2));
-            uInstr1(cb, SETV,   4, TempReg, SHADOW(u_in->val2));
+            if (VG_(clo_check_addrVs)) {
+               uInstr1(cb, TESTV,  4, TempReg, SHADOW(u_in->val2));
+               uInstr1(cb, SETV,   4, TempReg, SHADOW(u_in->val2));
+            }
             uInstr2(cb, STOREV, u_in->size,
                         TempReg, SHADOW(u_in->val1), 
                         TempReg, u_in->val2);
@@ -2654,6 +2665,40 @@ static void vg_delete_redundant_SETVs ( UCodeBlock* cb )
    for (i = cb->used-1; i >= 0; i--) {
       u = &cb->instrs[i];
 
+      /* If we're not checking address V bits, there will be a lot of
+         GETVs, TAG1s and TAG2s calculating values which are never
+         used.  These first three cases get rid of them. */
+
+      if (u->opcode == GETV && VGC_IS_SHADOW(u->val2) 
+                            && next_is_write[u->val2]
+                            && !VG_(clo_check_addrVs)) {
+         u->opcode = NOP;
+         u->size = 0;
+         if (VG_(disassemble)) 
+            VG_(printf)("at %d: delete GETV\n", i);
+      } else
+
+      if (u->opcode == TAG1 && VGC_IS_SHADOW(u->val1) 
+                            && next_is_write[u->val1]
+                            && !VG_(clo_check_addrVs)) {
+         u->opcode = NOP;
+         u->size = 0;
+         if (VG_(disassemble)) 
+            VG_(printf)("at %d: delete TAG1\n", i);
+      } else
+
+      if (u->opcode == TAG2 && VGC_IS_SHADOW(u->val2) 
+                            && next_is_write[u->val2]
+                            && !VG_(clo_check_addrVs)) {
+         u->opcode = NOP;
+         u->size = 0;
+         if (VG_(disassemble)) 
+            VG_(printf)("at %d: delete TAG2\n", i);
+      } else
+
+      /* We do the rest of these regardless of whether or not
+         addresses are V-checked. */
+
       if (u->opcode == MOV && VGC_IS_SHADOW(u->val2) 
                            && next_is_write[u->val2]) {
          /* This MOV is pointless because the target is dead at this
index f791c663ad2d81bf031a2014a9e337f411bfbec6..0b566c94cfba3cfe08e34615743a20e240639ab9 100755 (executable)
@@ -40,6 +40,8 @@ do
     --verbose)              vgopts="$vgopts -v"; shift;;
     -q)                     vgopts="$vgopts $arg"; shift;;
     --quiet)                vgopts="$vgopts $arg"; shift;;
+    --check-addrVs=no)      vgopts="$vgopts $arg"; shift;;
+    --check-addrVs=yes)     vgopts="$vgopts $arg"; shift;;
     --gdb-attach=no)        vgopts="$vgopts $arg"; shift;;
     --gdb-attach=yes)       vgopts="$vgopts $arg"; shift;;
     --demangle=no)          vgopts="$vgopts $arg"; shift;;
@@ -130,6 +132,8 @@ if [ z"$argopts" = z   -o   z"$dousage" = z1 ]; then
    echo "    --suppressions=<filename> suppress errors described in"
    echo "                              suppressions file <filename>"
    echo "    --client-perms=no|yes     handle client VG_MAKE_* requests? [no]"
+   echo "    --check-addrVs=no|yes     experimental lighterweight checking? [yes]"
+   echo "                              yes == Valgrind's original behaviour"
    echo
    echo "  options for debugging Valgrind itself are:"
    echo "    --sanity-level=<number>   level of sanity checking to do [1]"
index cf0237ec9ca599e60b2aebe3e833ea53e64368d1..3181fd8f8fff2a6274ded426f1e2a792a0942e29 100644 (file)
@@ -165,6 +165,8 @@ typedef unsigned char Bool;
 
 #define VG_CLO_MAX_SFILES 10
 
+/* Shall we V-check addrs (they are always A checked too): default: YES */
+extern Bool VG_(clo_check_addrVs);
 /* Enquire about whether to attach to GDB at errors?   default: NO */
 extern Bool  VG_(clo_GDB_attach);
 /* Sanity-check level: 0 = none, 1 (default), > 1 = expensive. */
index da674106ab0c0c0cca909f14edb2457bbcd3ff8e..2fb92cf2047b553a172091967a0ec6d051f88768 100644 (file)
--- a/vg_main.c
+++ b/vg_main.c
@@ -433,6 +433,7 @@ UInt VG_(sanity_slow_count) = 0;
    Values derived from command-line options.
    ------------------------------------------------------------------ */
 
+Bool   VG_(clo_check_addrVs);
 Bool   VG_(clo_GDB_attach);
 Int    VG_(sanity_level);
 Int    VG_(clo_verbosity);
@@ -685,6 +686,7 @@ static void process_cmd_line_options ( void )
 #  define STREQN(nn,s1,s2) (0==VG_(strncmp_ws)((s1),(s2),(nn)))
 
    /* Set defaults. */
+   VG_(clo_check_addrVs)     = True;
    VG_(clo_GDB_attach)       = False;
    VG_(sanity_level)         = 1;
    VG_(clo_verbosity)        = 1;
@@ -852,6 +854,11 @@ static void process_cmd_line_options ( void )
       else if (STREQ(argv[i], "-q") || STREQ(argv[i], "--quiet"))
          VG_(clo_verbosity)--;
 
+      else if (STREQ(argv[i], "--check-addrVs=yes"))
+         VG_(clo_check_addrVs) = True;
+      else if (STREQ(argv[i], "--check-addrVs=no"))
+         VG_(clo_check_addrVs) = False;
+
       else if (STREQ(argv[i], "--gdb-attach=yes"))
          VG_(clo_GDB_attach) = True;
       else if (STREQ(argv[i], "--gdb-attach=no"))
index 18749ac40c02e09328a8607ee76472fcbd8dbe8a..1423b8d3da951e21473ddb2e6df18218ead509e7 100644 (file)
@@ -2113,20 +2113,31 @@ static UCodeBlock* vg_instrument ( UCodeBlock* cb_in )
             copyUInstr(cb, u_in);
             break;
 
-         /* Loads and stores.  Test the V bits for the address.
+         /* Loads and stores.  Test the V bits for the address.  24
+            Mar 02: since the address is A-checked anyway, there's not
+            really much point in doing the V-check too, unless you
+            think that you might use addresses which are undefined but
+            still addressible.  Hence the optionalisation of the V
+            check.
+
             The LOADV/STOREV does an addressibility check for the
             address. */
+
          case LOAD: 
-            uInstr1(cb, TESTV, 4, TempReg, SHADOW(u_in->val1));
-            uInstr1(cb, SETV,  4, TempReg, SHADOW(u_in->val1));
+            if (VG_(clo_check_addrVs)) {
+               uInstr1(cb, TESTV, 4, TempReg, SHADOW(u_in->val1));
+               uInstr1(cb, SETV,  4, TempReg, SHADOW(u_in->val1));
+            }
             uInstr2(cb, LOADV, u_in->size, 
                         TempReg, u_in->val1,
                         TempReg, SHADOW(u_in->val2));
             copyUInstr(cb, u_in);
             break;
          case STORE:
-            uInstr1(cb, TESTV,  4, TempReg, SHADOW(u_in->val2));
-            uInstr1(cb, SETV,   4, TempReg, SHADOW(u_in->val2));
+            if (VG_(clo_check_addrVs)) {
+               uInstr1(cb, TESTV,  4, TempReg, SHADOW(u_in->val2));
+               uInstr1(cb, SETV,   4, TempReg, SHADOW(u_in->val2));
+            }
             uInstr2(cb, STOREV, u_in->size,
                         TempReg, SHADOW(u_in->val1), 
                         TempReg, u_in->val2);
@@ -2654,6 +2665,40 @@ static void vg_delete_redundant_SETVs ( UCodeBlock* cb )
    for (i = cb->used-1; i >= 0; i--) {
       u = &cb->instrs[i];
 
+      /* If we're not checking address V bits, there will be a lot of
+         GETVs, TAG1s and TAG2s calculating values which are never
+         used.  These first three cases get rid of them. */
+
+      if (u->opcode == GETV && VGC_IS_SHADOW(u->val2) 
+                            && next_is_write[u->val2]
+                            && !VG_(clo_check_addrVs)) {
+         u->opcode = NOP;
+         u->size = 0;
+         if (VG_(disassemble)) 
+            VG_(printf)("at %d: delete GETV\n", i);
+      } else
+
+      if (u->opcode == TAG1 && VGC_IS_SHADOW(u->val1) 
+                            && next_is_write[u->val1]
+                            && !VG_(clo_check_addrVs)) {
+         u->opcode = NOP;
+         u->size = 0;
+         if (VG_(disassemble)) 
+            VG_(printf)("at %d: delete TAG1\n", i);
+      } else
+
+      if (u->opcode == TAG2 && VGC_IS_SHADOW(u->val2) 
+                            && next_is_write[u->val2]
+                            && !VG_(clo_check_addrVs)) {
+         u->opcode = NOP;
+         u->size = 0;
+         if (VG_(disassemble)) 
+            VG_(printf)("at %d: delete TAG2\n", i);
+      } else
+
+      /* We do the rest of these regardless of whether or not
+         addresses are V-checked. */
+
       if (u->opcode == MOV && VGC_IS_SHADOW(u->val2) 
                            && next_is_write[u->val2]) {
          /* This MOV is pointless because the target is dead at this