Make the IR sanity checker complain about dirty helpers that return
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 8f6e269a-dfd6-0310-a8e1-e2731360e62c
diff --git a/priv/ir_defs.c b/priv/ir_defs.c
index 2b8877c..89aec11 100644
--- a/priv/ir_defs.c
+++ b/priv/ir_defs.c
@@ -3672,11 +3672,18 @@
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");