|
From: <sv...@va...> - 2005-12-06 20:53:52
|
Author: njn
Date: 2005-12-06 20:53:44 +0000 (Tue, 06 Dec 2005)
New Revision: 5300
Log:
Added an --undef-value-errors option to Memcheck. When set to "no"
emulates Addrcheck in not doing undefined value checking. That was easie=
r
than I expected.
=20
On my machine I get speedups of 10--20% over normal Memcheck with this.
Some undefined parameter errors are still being found, we need to decide
if they should be reported in this mode.
Also, some extra folding rules for 128 bit stores might be useful.
Modified:
branches/COMPVBITS/memcheck/mac_shared.c
branches/COMPVBITS/memcheck/mac_shared.h
branches/COMPVBITS/memcheck/mc_main.c
branches/COMPVBITS/memcheck/mc_translate.c
Modified: branches/COMPVBITS/memcheck/mac_shared.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/COMPVBITS/memcheck/mac_shared.c 2005-12-06 19:07:08 UTC (rev=
5299)
+++ branches/COMPVBITS/memcheck/mac_shared.c 2005-12-06 20:53:44 UTC (rev=
5300)
@@ -64,12 +64,15 @@
VgRes MAC_(clo_leak_resolution) =3D Vg_LowRes;
Bool MAC_(clo_show_reachable) =3D False;
Bool MAC_(clo_workaround_gcc296_bugs) =3D False;
+Bool MAC_(clo_undef_value_errors) =3D True;
=20
Bool MAC_(process_common_cmd_line_option)(Char* arg)
{
VG_BOOL_CLO(arg, "--partial-loads-ok", MAC_(clo_partial_loads_ok))
else VG_BOOL_CLO(arg, "--show-reachable", MAC_(clo_show_reacha=
ble))
else VG_BOOL_CLO(arg, "--workaround-gcc296-bugs",MAC_(clo_workaround_=
gcc296_bugs))
+
+ else VG_BOOL_CLO(arg, "--undef-value-errors", MAC_(clo_undef_value=
_errors))
=20
else VG_BNUM_CLO(arg, "--freelist-vol", MAC_(clo_freelist_vol), 0, 1=
000000000)
=20
@@ -100,6 +103,7 @@
" --leak-check=3Dno|summary|full search for memory leaks at exit?=
[summary]\n"
" --leak-resolution=3Dlow|med|high how much bt merging in leak chec=
k [low]\n"
" --show-reachable=3Dno|yes show reachable blocks in leak ch=
eck? [no]\n"
+" --undef-value-errors=3Dno|yes check for undefined value errors=
[yes]\n"
" --partial-loads-ok=3Dno|yes too hard to explain here; see ma=
nual [no]\n"
" --freelist-vol=3D<number> volume of freed blocks queue [50=
00000]\n"
" --workaround-gcc296-bugs=3Dno|yes self explanatory [no]\n"
Modified: branches/COMPVBITS/memcheck/mac_shared.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/COMPVBITS/memcheck/mac_shared.h 2005-12-06 19:07:08 UTC (rev=
5299)
+++ branches/COMPVBITS/memcheck/mac_shared.h 2005-12-06 20:53:44 UTC (rev=
5300)
@@ -316,9 +316,21 @@
extern Bool MAC_(clo_show_reachable);
=20
/* Assume accesses immediately below %esp are due to gcc-2.96 bugs.
- * default: NO*/
+ * default: NO */
extern Bool MAC_(clo_workaround_gcc296_bugs);
=20
+/* Do undefined value checking? "No" gives Addrcheck-style behaviour, ie=
.
+ * faster but fewer errors found. Note that although Addrcheck had 1 bi=
t
+ * per byte overhead vs the old Memcheck's 9 bits per byte, with this mo=
de
+ * and compressed V bits, no memory is saved with this mode -- it's stil=
l
+ * 2 bits per byte overhead. This is a little wasteful -- it could be d=
one
+ * with 1 bit per byte -- but lets us reuse the many shadow memory acces=
s
+ * functions. Note also that in this mode the secondary V bit table is
+ * never used.
+ *
+ * default: YES */
+extern Bool MAC_(clo_undef_value_errors);
+
extern Bool MAC_(process_common_cmd_line_option) ( Char* arg );
extern void MAC_(print_common_usage) ( void );
extern void MAC_(print_common_debug_usage) ( void );
Modified: branches/COMPVBITS/memcheck/mc_main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/COMPVBITS/memcheck/mc_main.c 2005-12-06 19:07:08 UTC (rev 52=
99)
+++ branches/COMPVBITS/memcheck/mc_main.c 2005-12-06 20:53:44 UTC (rev 53=
00)
@@ -2485,6 +2485,13 @@
return False;
}
=20
+ /* If we're not checking for undefined value errors, the secondary V =
bit
+ * table should be empty. */
+ if (!MAC_(clo_undef_value_errors)) {
+ if (0 !=3D VG_(OSet_Size)(secVBitTable))
+ return False;
+ }
+
/* check nonsensical auxmap sizing */
if (auxmap_used > auxmap_size)
bad =3D True;
Modified: branches/COMPVBITS/memcheck/mc_translate.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/COMPVBITS/memcheck/mc_translate.c 2005-12-06 19:07:08 UTC (r=
ev 5299)
+++ branches/COMPVBITS/memcheck/mc_translate.c 2005-12-06 20:53:44 UTC (r=
ev 5300)
@@ -801,6 +801,10 @@
IRDirty* di;
IRAtom* cond;
=20
+ // Don't do V bit tests if we're not reporting undefined value errors=
.
+ if (!MAC_(clo_undef_value_errors))
+ return;
+
/* Since the original expression is atomic, there's no duplicated
work generated by making multiple V-expressions for it. So we
don't really care about the possibility that someone else may
@@ -918,6 +922,13 @@
IRAtom* atom, IRAtom* vatom )
{
IRType ty;
+
+ // Don't do shadow PUTs if we're not doing undefined value checking.
+ // Their absence lets Vex's optimiser remove all the shadow computati=
on
+ // that they depend on, which includes GETs of the shadow registers.
+ if (!MAC_(clo_undef_value_errors))
+ return;
+ =20
if (atom) {
tl_assert(!vatom);
tl_assert(isOriginalAtom(mce, atom));
@@ -951,6 +962,12 @@
IRType ty, tyS;
Int arrSize;;
=20
+ // Don't do shadow PUTIs if we're not doing undefined value checking.
+ // Their absence lets Vex's optimiser remove all the shadow computati=
on
+ // that they depend on, which includes GETIs of the shadow registers.
+ if (!MAC_(clo_undef_value_errors))
+ return;
+ =20
tl_assert(isOriginalAtom(mce,atom));
vatom =3D expr2vbits( mce, atom );
tl_assert(sameKindedAtoms(atom, vatom));
@@ -2481,6 +2498,7 @@
IRAtom *eBias, *eBiasLo64, *eBiasHi64;
void* helper =3D NULL;
Char* hname =3D NULL;
+ IRConst* c;
=20
tyAddr =3D mce->hWordTy;
mkAdd =3D tyAddr=3D=3DIty_I32 ? Iop_Add32 : Iop_Add64;
@@ -2506,6 +2524,21 @@
=20
ty =3D typeOfIRExpr(mce->bb->tyenv, vdata);
=20
+ // If we're not doing undefined value checking, pretend that this val=
ue
+ // is "all valid". That lets Vex's optimiser remove some of the V bi=
t
+ // shadow computation ops that precede it.
+ if (!MAC_(clo_undef_value_errors)) {
+ switch (ty) {
+ case Ity_V128: c =3D IRConst_V128(VGM_SHORT_VALID); break; // V=
128 weirdness
+ case Ity_I64: c =3D IRConst_U64(VGM_WORD64_VALID); break;
+ case Ity_I32: c =3D IRConst_U32(VGM_WORD32_VALID); break;
+ case Ity_I16: c =3D IRConst_U16(VGM_SHORT_VALID); break;
+ case Ity_I8: c =3D IRConst_U8(VGM_BYTE_VALID); break;
+ default: VG_(tool_panic)("memcheck:do_shadow_Store(LE)");
+ }
+ vdata =3D IRExpr_Const( c );
+ }
+
/* First, emit a definedness test for the address. This also sets
the address (shadow) to 'defined' following the test. */
complainIfUndefined( mce, addr );
|