|
From: <sv...@va...> - 2005-10-07 11:09:01
|
Author: sewardj
Date: 2005-10-07 12:08:55 +0100 (Fri, 07 Oct 2005)
New Revision: 4888
Log:
Fix the handling of CmpORD32{S,U} which was completely bogus and
would have caused ppc32 to miss many uninitialised value errors.
(Change affects ppc32 only).
Also add reference to the Usenix paper.
Modified:
trunk/memcheck/mc_translate.c
Modified: trunk/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
--- trunk/memcheck/mc_translate.c 2005-10-07 09:49:53 UTC (rev 4887)
+++ trunk/memcheck/mc_translate.c 2005-10-07 11:08:55 UTC (rev 4888)
@@ -38,6 +38,20 @@
#include "mc_include.h"
=20
=20
+/* This file implements the Memcheck instrumentation, and in
+ particular contains the core of its undefined value detection
+ machinery. For a comprehensive background of the terminology,
+ algorithms and rationale used herein, read:
+
+ Using Valgrind to detect undefined value errors with
+ bit-precision
+
+ Julian Seward and Nicholas Nethercote
+
+ 2005 USENIX Annual Technical Conference (General Track),
+ Anaheim, CA, USA, April 10-15, 2005.
+*/
+
/*------------------------------------------------------------*/
/*--- Forward decls ---*/
/*------------------------------------------------------------*/
@@ -658,6 +672,48 @@
}
=20
=20
+/* --------- Semi-accurate interpretation of CmpORD. --------- */
+
+/* CmpORD32{S,U} does PowerPC-style 3-way comparisons:
+
+ CmpORD32S(x,y) =3D 1<<3 if x <s y
+ =3D 1<<2 if x >s y
+ =3D 1<<1 if x =3D=3D y
+
+ and similarly the unsigned variant. The default interpretation is:
+
+ CmpORD32{S,U}#(x,y,x#,y#) =3D PCast(x# `UifU` y#) =20
+ & (7<<1)
+
+ The "& (7<<1)" reflects the fact that all result bits except 3,2,1
+ are zero and therefore defined (viz, zero).
+*/
+static IRAtom* doCmpORD32 ( MCEnv* mce,
+ IROp cmp_op,
+ IRAtom* xxhash, IRAtom* yyhash,=20
+ IRAtom* xx, IRAtom* yy )
+{
+ tl_assert(isShadowAtom(mce,xxhash));
+ tl_assert(isShadowAtom(mce,yyhash));
+ tl_assert(isOriginalAtom(mce,xx));
+ tl_assert(isOriginalAtom(mce,yy));
+ tl_assert(sameKindedAtoms(xxhash,xx));
+ tl_assert(sameKindedAtoms(yyhash,yy));
+ tl_assert(cmp_op =3D=3D Iop_CmpORD32S || cmp_op =3D=3D Iop_CmpORD32U)=
;
+
+ return=20
+ binop(=20
+ Iop_And32,=20
+ assignNew(=20
+ mce,Ity_I32,
+ mkPCastTo( mce,Ity_I32,
+ assignNew( mce,Ity_I32,
+ mkUifU32(mce, xxhash,yyhash))) ),
+ mkU32(7<<1)
+ );
+}
+
+
/*------------------------------------------------------------*/
/*--- Emit a test and complaint if something is undefined. ---*/
/*------------------------------------------------------------*/
@@ -1752,9 +1808,11 @@
=20
cheap_AddSub32:
case Iop_Mul32:
+ return mkLeft32(mce, mkUifU32(mce, vatom1,vatom2));
+
case Iop_CmpORD32S:
case Iop_CmpORD32U:
- return mkLeft32(mce, mkUifU32(mce, vatom1,vatom2));
+ return doCmpORD32(mce, op, vatom1,vatom2, atom1,atom2);
=20
case Iop_Add64:
if (mce->bogusLiterals)
|