]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Tighten up condition code handling in the back end, so as to placate
authorJulian Seward <jseward@acm.org>
Wed, 4 May 2011 09:50:48 +0000 (09:50 +0000)
committerJulian Seward <jseward@acm.org>
Wed, 4 May 2011 09:50:48 +0000 (09:50 +0000)
IBM's BEAM checker.  There is no error in the existing code.  However
BEAM doesn't know that when PPCCondCode::test == Pct_ALWAYS then the
::flag field is irrelevant, and so it believes it is being used
uninitialised.  Add a Pcf_NONE ::flag value for use in that case, and
add assertions to match.  (Untested!)

git-svn-id: svn://svn.valgrind.org/vex/trunk@2144

VEX/priv/host_ppc_defs.c
VEX/priv/host_ppc_defs.h
VEX/priv/host_ppc_isel.c

index b0b9b08a769bb28ab63901877f5d18ad76b6d117..2065824acf99e8bd280ee5272f6213b7e2cda392 100644 (file)
@@ -286,6 +286,8 @@ HChar* showPPCCondCode ( PPCCondCode cond )
       return (cond.test == Pct_TRUE) ? "cr7.gt=1" : "cr7.gt=0";
    case Pcf_7LT:
       return (cond.test == Pct_TRUE) ? "cr7.lt=1" : "cr7.lt=0";
+   case Pcf_NONE:
+      return "no-flag";
    default: vpanic("ppPPCCondCode");
    }
 }
@@ -296,6 +298,11 @@ PPCCondCode mk_PPCCondCode ( PPCCondTest test, PPCCondFlag flag )
    PPCCondCode cc;
    cc.flag = flag;
    cc.test = test;
+   if (test == Pct_ALWAYS) { 
+      vassert(flag == Pcf_NONE);
+   } else {
+      vassert(flag != Pcf_NONE);
+   }
    return cc;
 }
 
@@ -3152,6 +3159,7 @@ Int emit_PPCInstr ( UChar* buf, Int nbuf, PPCInstr* i,
          // Just load 1 to dst => li dst,1
          p = mkFormD(p, 14, r_dst, 0, 1);
       } else {
+         vassert(cond.flag != Pcf_NONE);
          rot_imm = 1 + cond.flag;
          r_tmp = 0;  // Not set in getAllocable, so no need to declare.
 
index f93a2104c655778dbd7b7dc38882cc192f08be64..c2bde5cdd2762da5b5fecfd433eceb89b7394c3d 100644 (file)
@@ -162,15 +162,16 @@ typedef
       Pcf_7LT  = 28,  /* neg  | lt          */
       Pcf_7GT  = 29,  /* pos  | gt          */
       Pcf_7EQ  = 30,  /* zero | equal       */
-      Pcf_7SO  = 31   /* summary overflow   */
+      Pcf_7SO  = 31,  /* summary overflow   */
+      Pcf_NONE = 32   /* no condition; used with Pct_ALWAYS */
    }
    PPCCondFlag;
 
 typedef
    enum {   /* Maps bc bitfield BO */
-      Pct_FALSE  = 0x4,
-      Pct_TRUE   = 0xC,
-      Pct_ALWAYS = 0x14
+      Pct_FALSE  = 0x4, /* associated PPCCondFlag must not be Pcf_NONE */
+      Pct_TRUE   = 0xC, /* associated PPCCondFlag must not be Pcf_NONE */
+      Pct_ALWAYS = 0x14 /* associated PPCCondFlag must be Pcf_NONE */
    }
    PPCCondTest;
 
index 0f82e85c91ac6a23db4a9512e48f13935725a0dd..7ea845051805de2e3b1bd0acac2e70166b5dde5b 100644 (file)
@@ -785,7 +785,7 @@ void doHelperCall ( ISelEnv* env,
       }
 
       /* Fast scheme only applies for unconditional calls.  Hence: */
-      cc.test = Pct_ALWAYS;
+      cc = mk_PPCCondCode( Pct_ALWAYS, Pcf_NONE );
 
    } else {
 
@@ -828,7 +828,7 @@ void doHelperCall ( ISelEnv* env,
          because the argument computations could trash the condition
          codes.  Be a bit clever to handle the common case where the
          guard is 1:Bit. */
-      cc.test = Pct_ALWAYS;
+      cc = mk_PPCCondCode( Pct_ALWAYS, Pcf_NONE );
       if (guard) {
          if (guard->tag == Iex_Const 
              && guard->Iex.Const.con->tag == Ico_U1