From: Julian Seward Date: Sun, 23 Oct 2005 12:06:55 +0000 (+0000) Subject: Don't assume the first statement is an IRMark, since it could instead X-Git-Tag: svn/VALGRIND_3_1_0~265 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ebb032b983a8eda8efe3122f752c65dac9eed439;p=thirdparty%2Fvalgrind.git Don't assume the first statement is an IRMark, since it could instead be part of a self-check. Instead, copy verbatim any IR preamble preceding the first IMark. This stops cachegrind asserting on self-checking translations. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4967 --- diff --git a/cachegrind/cg_main.c b/cachegrind/cg_main.c index 6e7aea3802..3e6008e4de 100644 --- a/cachegrind/cg_main.c +++ b/cachegrind/cg_main.c @@ -743,7 +743,6 @@ IRBB* cg_instrument ( IRBB* bbIn, VexGuestLayout* layout, IRTypeEnv* tyenv = bbIn->tyenv; InstrInfo* curr_inode = NULL; - if (gWordTy != hWordTy) { /* We don't currently support this case. */ VG_(tool_panic)("host/guest word size mismatch"); @@ -756,10 +755,17 @@ IRBB* cg_instrument ( IRBB* bbIn, VexGuestLayout* layout, cgs.bbOut->next = dopyIRExpr(bbIn->next); cgs.bbOut->jumpkind = bbIn->jumpkind; - // Get the first statement, and initial cia from it + // Copy verbatim any IR preamble preceding the first IMark i = 0; + while (i < bbIn->stmts_used && bbIn->stmts[i]->tag != Ist_IMark) { + addStmtToIRBB( cgs.bbOut, bbIn->stmts[i] ); + i++; + } + + // Get the first statement, and initial cia from it tl_assert(bbIn->stmts_used > 0); - st = bbIn->stmts[0]; + tl_assert(i < bbIn->stmts_used); + st = bbIn->stmts[i]; tl_assert(Ist_IMark == st->tag); cia = st->Ist.IMark.addr; @@ -773,7 +779,7 @@ IRBB* cg_instrument ( IRBB* bbIn, VexGuestLayout* layout, // Traverse the block, initialising inodes, adding events and flushing as // necessary. - for (i = 0; i < bbIn->stmts_used; i++) { + for (/*use current i*/; i < bbIn->stmts_used; i++) { st = bbIn->stmts[i]; tl_assert(isFlatIRStmt(st));