From: Julian Seward Date: Tue, 20 Jul 2004 11:42:24 +0000 (+0000) Subject: gcc sometimes generates "sbbl %reg,%reg" to convert the carry flag X-Git-Tag: svn/VALGRIND_2_2_0~124 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6c41529d54cff7f908854287af162c14bb252b8;p=thirdparty%2Fvalgrind.git 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. Hopefully fixes #84978 (unconfirmed) git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2512 --- diff --git a/coregrind/vg_to_ucode.c b/coregrind/vg_to_ucode.c index 5efd68b5ee..4ec2598964 100644 --- a/coregrind/vg_to_ucode.c +++ b/coregrind/vg_to_ucode.c @@ -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) {