]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix reg-alloc bug exposed by more aggressive code generation
authorJulian Seward <jseward@acm.org>
Thu, 19 Aug 2004 16:44:45 +0000 (16:44 +0000)
committerJulian Seward <jseward@acm.org>
Thu, 19 Aug 2004 16:44:45 +0000 (16:44 +0000)
enabled by recent iropt hacking.

When looking for a real-reg to house a virtual reg, reg-alloc
looks around for (v,r) pairs in which v is already dead, and
so r can be re-used for a new virtual reg.  However, it would
be too aggressive in this, and use v even if v went dead
immediately before the current insn, which means v could still
be read by the current insn.  This change requires that v go
dead before the insn prior to this one, so that we are
guaranteed v is not used in this insn.

This commit message is way longer than the actual bug fix :-)

git-svn-id: svn://svn.valgrind.org/vex/trunk@180

VEX/priv/host-generic/reg_alloc.c

index 7d4e4c2ba6e5d1b63c7687b07ad4e3ca74f73a56..cb8cfb947ec200b953897d8050dd571738e52a8e 100644 (file)
@@ -843,9 +843,9 @@ HInstrArray* doRegisterAllocation (
                 && hregClass(state[k].rreg) == hregClass(vreg)) {
                m = hregNumber(state[k].vreg);
                vassert(m >= 0 && m < n_vregs);
-               if (vreg_info[m].dead_before <= ii) {
-                  /* Ok, it's gone dead before this insn.  We can use
-                     it. */
+               if (vreg_info[m].dead_before < ii) {
+                  /* Ok, it's gone dead before the previous insn.  We
+                     can use it. */
                   break;
                }
             }