Message ID | 20100722200220.GB18378@tyan-ft48-01.lab.bos.redhat.com |
---|---|
State | New |
Headers | show |
On Thu, 22 Jul 2010, Jakub Jelinek wrote: > Hi! > > Bootstrap currently fails on sparc*-*-solaris*. The problem is > that first regcprop changes > mov %o0, %g1 > DEBUG this => %g1 > DEBUG somethingelse => %g1 > ... > stx %g1, [%fp + xxx] > # Both %o0 and %g1 dead now > > into > mov %o0, %g1 > DEBUG this => %g1 > DEBUG somethingelse => %g1 > ... > stx %o0, [%fp + xxx] > # Both %o0 and %g1 dead now > > the DEBUG insns weren't adjusted, because there weren't any uses of %o0 > found and debug insns are only changed if we know changing them won't > extend the lifetime of the function. The check is done before actually > propagating into the insn though (because in some cases the code afterwards > kills the chains). > > Then DCE sees the mov %o0, %g1 insn is useless and removes it (but doesn't > reset any of the following debug insns that depend on it). Which means > that the DEBUG insns now effectively refer to whatever the register had > before, and in the Solaris -mcmodel=medmid case that was a setm4 temporary, > and unspec from it leads to ICE in output_operand. > > The following patch fixes that by redoing the used regs discovery if a > normal insn has been actually changed. In the above case it means that it > notices %o0 being used after the DEBUG insns and so adjusts %g1 in them to > %o0. > > Arguably, DCE should be probably also fixed to note separately a weak use > between register setter and DEBUG insn consuming that register and if the > setter is being removed as useless, it should also reset the DEBUG insns. > Normally, such resetting or adjusting happens when computing the df note > problem, but apparently DCE doesn't do that. > > Bootstrapped/regtested on x86_64-linux and i686-linux. > Ok for trunk? Ok. Thanks, Richard. > 2010-07-22 Jakub Jelinek <jakub@redhat.com> > > PR bootstrap/45028 > * recgprop.c (copyprop_hardreg_forward_1): If changed is true, > call cprop_find_used_regs again via note_uses. > > --- gcc/regcprop.c.jj 2010-07-09 13:44:25.000000000 +0200 > +++ gcc/regcprop.c 2010-07-22 17:28:39.000000000 +0200 > @@ -947,7 +947,14 @@ copyprop_hardreg_forward_1 (basic_block > > did_replacement: > if (changed) > - anything_changed = true; > + { > + anything_changed = true; > + > + /* If something changed, perhaps further changes to earlier > + DEBUG_INSNs can be applied. */ > + if (vd->n_debug_insn_changes) > + note_uses (&PATTERN (insn), cprop_find_used_regs, vd); > + } > > /* Clobber call-clobbered registers. */ > if (CALL_P (insn)) > > > Jakub > >
--- gcc/regcprop.c.jj 2010-07-09 13:44:25.000000000 +0200 +++ gcc/regcprop.c 2010-07-22 17:28:39.000000000 +0200 @@ -947,7 +947,14 @@ copyprop_hardreg_forward_1 (basic_block did_replacement: if (changed) - anything_changed = true; + { + anything_changed = true; + + /* If something changed, perhaps further changes to earlier + DEBUG_INSNs can be applied. */ + if (vd->n_debug_insn_changes) + note_uses (&PATTERN (insn), cprop_find_used_regs, vd); + } /* Clobber call-clobbered registers. */ if (CALL_P (insn))