From: Julian Seward Date: Thu, 19 Aug 2004 16:44:45 +0000 (+0000) Subject: Fix reg-alloc bug exposed by more aggressive code generation X-Git-Tag: svn/VALGRIND_3_0_1^2~1154 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a52bc0f9d937dc5e8f911435e565b3f13cefab4;p=thirdparty%2Fvalgrind.git Fix reg-alloc bug exposed by more aggressive code generation 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 --- diff --git a/VEX/priv/host-generic/reg_alloc.c b/VEX/priv/host-generic/reg_alloc.c index 7d4e4c2ba6..cb8cfb947e 100644 --- a/VEX/priv/host-generic/reg_alloc.c +++ b/VEX/priv/host-generic/reg_alloc.c @@ -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; } }