From: Julian Seward Date: Tue, 30 Apr 2002 00:29:36 +0000 (+0000) Subject: vg_improve() -- the ucode optimiser: consistently apply the X-Git-Tag: svn/VALGRIND_1_0_3~282 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13b8b25c374b959d5d694075a63bd977dc5cf5ce;p=thirdparty%2Fvalgrind.git vg_improve() -- the ucode optimiser: consistently apply the no-deferred-updates of %ESP rule, regardless of end use of the ucode. This seems more consistent, and was exposed following examination of code causing an assertion failure in the cache profiler. Added an assertion to check this too, and was surprised I hadn't had an assertion there in the first place. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@170 --- diff --git a/coregrind/vg_translate.c b/coregrind/vg_translate.c index 76c6ef8a9b..39f444ff7b 100644 --- a/coregrind/vg_translate.c +++ b/coregrind/vg_translate.c @@ -1359,11 +1359,11 @@ static void vg_improve ( UCodeBlock* cb ) # undef BIND_ARCH_TO_TEMP - /* PASS 2: redundant PUT elimination. If doing instrumentation, - don't annul (delay) puts of %ESP, since the memory check - machinery always requires the in-memory value of %ESP to be up - to date. - */ + /* PASS 2: redundant PUT elimination. Don't annul (delay) puts of + %ESP, since the memory check machinery always requires the + in-memory value of %ESP to be up to date. Although this isn't + actually required by other analyses (cache simulation), it's + simplest to be consistent for all end-uses. */ for (j = 0; j < 8; j++) annul_put[j] = False; @@ -1375,12 +1375,13 @@ static void vg_improve ( UCodeBlock* cb ) vg_assert(u->tag2 == ArchReg); actual_areg = containingArchRegOf ( 4, u->val2 ); if (annul_put[actual_areg]) { + vg_assert(actual_areg != R_ESP); u->opcode = NOP; u->tag1 = u->tag2 = NoValue; if (VG_(disassemble)) VG_(printf)("at %d: delete PUT\n", i ); } else { - if (!(VG_(clo_instrument) && actual_areg == R_ESP)) + if (actual_areg != R_ESP) annul_put[actual_areg] = True; } } diff --git a/vg_translate.c b/vg_translate.c index 76c6ef8a9b..39f444ff7b 100644 --- a/vg_translate.c +++ b/vg_translate.c @@ -1359,11 +1359,11 @@ static void vg_improve ( UCodeBlock* cb ) # undef BIND_ARCH_TO_TEMP - /* PASS 2: redundant PUT elimination. If doing instrumentation, - don't annul (delay) puts of %ESP, since the memory check - machinery always requires the in-memory value of %ESP to be up - to date. - */ + /* PASS 2: redundant PUT elimination. Don't annul (delay) puts of + %ESP, since the memory check machinery always requires the + in-memory value of %ESP to be up to date. Although this isn't + actually required by other analyses (cache simulation), it's + simplest to be consistent for all end-uses. */ for (j = 0; j < 8; j++) annul_put[j] = False; @@ -1375,12 +1375,13 @@ static void vg_improve ( UCodeBlock* cb ) vg_assert(u->tag2 == ArchReg); actual_areg = containingArchRegOf ( 4, u->val2 ); if (annul_put[actual_areg]) { + vg_assert(actual_areg != R_ESP); u->opcode = NOP; u->tag1 = u->tag2 = NoValue; if (VG_(disassemble)) VG_(printf)("at %d: delete PUT\n", i ); } else { - if (!(VG_(clo_instrument) && actual_areg == R_ESP)) + if (actual_areg != R_ESP) annul_put[actual_areg] = True; } }