]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
gcc sometimes generates "sbbl %reg,%reg" to convert the carry flag
authorJulian Seward <jseward@acm.org>
Tue, 20 Jul 2004 11:42:24 +0000 (11:42 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 20 Jul 2004 11:42:24 +0000 (11:42 +0000)
into 0 or -1 in reg.  This has no actual dependency on reg, but
memcheck can't see that, and so will yelp if reg contains garbage.  A
simple fix is to put zero into reg before we start, zapping any
undefinedness it might otherwise contain.

Hopefully fixes #84978 (unconfirmed)

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

coregrind/vg_to_ucode.c

index 5efd68b5ee2de295aeb6bab7a3f0bd25e51e29d7..4ec2598964139cd2944e12e547242e5639db4a2b 100644 (file)
@@ -1114,6 +1114,20 @@ Addr dis_op2_G_E ( UCodeBlock* cb,
          return 1+eip0;
       }
 
+      /* gcc sometimes generates "sbbl %reg,%reg" to convert the carry
+         flag into 0 or -1 in reg.  This has no actual dependency on
+         reg, but memcheck can't see that, and so will yelp if reg
+         contains garbage.  A simple fix is to put zero into reg
+         before we start, zapping any undefinedness it might otherwise
+         contain.
+      */
+      if (opc == SBB && gregOfRM(rm) == eregOfRM(rm)) {
+         Int tzero = newTemp(cb);
+         uInstr2(cb, MOV, size, Literal, 0, TempReg, tzero);
+         uLiteral(cb, 0);
+         uInstr2(cb, PUT, size, TempReg, tzero, ArchReg, eregOfRM(rm));
+      }
+
       uInstr2(cb, GET, size, ArchReg, eregOfRM(rm), TempReg, tmp);
 
       if (opc == AND || opc == OR) {