From: Julian Seward Date: Tue, 22 Jul 2008 09:59:48 +0000 (+0000) Subject: Origin-tracking fix: make sure that we have a shadow-origin (B) X-Git-Tag: svn/VALGRIND_3_4_0~313 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba8c821703d82356d5bb8ffabbb63172683bce12;p=thirdparty%2Fvalgrind.git Origin-tracking fix: make sure that we have a shadow-origin (B) temporary defined for every (original) temp used in the block's IR preamble, as is already done of the shadow-definedness (V) temporaries. Otherwise we can end up generating references to B temporaries that have no assigned value, which causes the IR sanity checker to complain. Only observed (and even then rarely) on the complex preambles sometimes used for TOC-afflicted platforms. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8450 --- diff --git a/memcheck/mc_translate.c b/memcheck/mc_translate.c index 67dab52c7a..738b4313c9 100644 --- a/memcheck/mc_translate.c +++ b/memcheck/mc_translate.c @@ -119,6 +119,7 @@ struct _MCEnv; static IRType shadowTypeV ( IRType ty ); static IRExpr* expr2vbits ( struct _MCEnv* mce, IRExpr* e ); +static IRTemp findShadowTmpB ( struct _MCEnv* mce, IRTemp orig ); /*------------------------------------------------------------*/ @@ -3520,22 +3521,31 @@ IRSB* MC_(instrument) ( VgCallbackClosure* closure, The following loop therefore scans the preamble looking for assignments to temporaries. For each one found it creates an - assignment to the corresponding shadow temp, marking it as + assignment to the corresponding (V) shadow temp, marking it as 'defined'. This is the same resulting IR as if the main instrumentation loop before had been applied to the statement 'tmp = CONSTANT'. + + Similarly, if origin tracking is enabled, we must generate an + assignment for the corresponding origin (B) shadow, claiming + no-origin, as appropriate for a defined value. */ for (j = 0; j < i; j++) { if (bb_in->stmts[j]->tag == Ist_WrTmp) { /* findShadowTmpV checks its arg is an original tmp; no need to assert that here. */ IRTemp tmp_o = bb_in->stmts[j]->Ist.WrTmp.tmp; - IRTemp tmp_s = findShadowTmpV(&mce, tmp_o); - IRType ty_s = typeOfIRTemp(bb->tyenv, tmp_s); - assign( 'V', &mce, tmp_s, definedOfType( ty_s ) ); + IRTemp tmp_v = findShadowTmpV(&mce, tmp_o); + IRType ty_v = typeOfIRTemp(bb->tyenv, tmp_v); + assign( 'V', &mce, tmp_v, definedOfType( ty_v ) ); + if (MC_(clo_mc_level) == 3) { + IRTemp tmp_b = findShadowTmpB(&mce, tmp_o); + tl_assert(typeOfIRTemp(bb->tyenv, tmp_b) == Ity_I32); + assign( 'B', &mce, tmp_b, mkU32(0)/* UNKNOWN ORIGIN */); + } if (0) { - VG_(printf)("create shadow tmp for preamble tmp [%d] ty ", j); - ppIRType( ty_s ); + VG_(printf)("create shadow tmp(s) for preamble tmp [%d] ty ", j); + ppIRType( ty_v ); VG_(printf)("\n"); } }