summaryrefslogtreecommitdiff
path: root/cachegrind
diff options
context:
space:
mode:
authorsewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9>2005-10-23 12:06:55 +0000
committersewardj <sewardj@a5019735-40e9-0310-863c-91ae7b9d1cf9>2005-10-23 12:06:55 +0000
commita9f538cf1b5b61ddc88f51cee14a4636d9310149 (patch)
treed9f5c24c2ba2898fe0370b2e1e2975ea7bd2da66 /cachegrind
parente98d2c57183e93f14d1cce996769020dd01e72d3 (diff)
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 a5019735-40e9-0310-863c-91ae7b9d1cf9
Diffstat (limited to 'cachegrind')
-rw-r--r--cachegrind/cg_main.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/cachegrind/cg_main.c b/cachegrind/cg_main.c
index 6e7aea38..3e6008e4 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));