]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Make the IR sanity checker complain about dirty helpers that return
authorFlorian Krohm <florian@eich-krohm.de>
Thu, 5 Jul 2012 22:05:42 +0000 (22:05 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Thu, 5 Jul 2012 22:05:42 +0000 (22:05 +0000)
a value and are executed under a condition. That case is not handled
properly and will cause asserts down the road. As pointed out by Julian.

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

VEX/priv/ir_defs.c

index 2b8877c246f0d44f3341bd1683e7d225c077379a..89aec11d1c9bbe5452f881bb3ecff11ff171e4f3 100644 (file)
@@ -3672,11 +3672,18 @@ void tcStmt ( IRSB* bb, IRStmt* stmt, IRType gWordTy )
                   goto bad_dirty;
             }
          }
-         /* check types, minimally */
+         /* check guard */
          if (d->guard == NULL) goto bad_dirty;
          tcExpr( bb, stmt, d->guard, gWordTy );
          if (typeOfIRExpr(tyenv, d->guard) != Ity_I1)
             sanityCheckFail(bb,stmt,"IRStmt.Dirty.guard not :: Ity_I1");
+         /* A dirty helper that is executed conditionally (or not at all)
+            AND returns a value is not handled properly. */
+         if (d->tmp != IRTemp_INVALID &&
+            (d->guard->tag != Iex_Const || d->guard->Iex.Const.con->Ico.U1 == 0))
+            sanityCheckFail(bb,stmt,"IRStmt.Dirty with a return value"
+                            " is executed under a condition");
+         /* check types, minimally */
          if (d->tmp != IRTemp_INVALID
              && typeOfIRTemp(tyenv, d->tmp) == Ity_I1)
             sanityCheckFail(bb,stmt,"IRStmt.Dirty.dst :: Ity_I1");