[vta, vta4.4] fix mode-change debug info propagation in combine

Adam Nemet anemet@caviumnetworks.com
Wed Aug 5 17:37:00 GMT 2009


Alexandre Oliva <aoliva@redhat.com> writes:
> +  if (MAY_HAVE_DEBUG_INSNS)
> +    {
> +      struct undo *undo;
> +
> +      for (undo = undobuf.undos; undo; undo = undo->next)
> +	if (undo->kind == UNDO_MODE)
> +	  {
> +	    rtx reg = *undo->where.r;
> +	    enum machine_mode new_mode = GET_MODE (reg);
> +	    enum machine_mode old_mode = undo->old_contents.m;
> +
> +	    /* Temporarily revert mode back.  */
> +	    adjust_reg_mode (reg, old_mode);
> +
> +	    if (reg == i2dest && i2scratch)
> +	      {
> +		/* If we used i2dest as a scratch register with a
> +		   different mode, substitute it for the original
> +		   i2src while its original mode is temporarily
> +		   restored, and then clear i2scratch so that we don't
> +		   do it again later.  */
> +		propagate_for_debug (i2, i3, reg, i2src, false);
> +		i2scratch = false;
> +		/* Put back the new mode.  */
> +		adjust_reg_mode (reg, new_mode);
> +	      }
> +	    else
> +	      {
> +		rtx tempreg = gen_raw_REG (old_mode, REGNO (reg));
> +		rtx first, last;
> +
> +		if (reg == i2dest)
> +		  {
> +		    first = i2;
> +		    last = i3;
> +		  }
> +		else
> +		  {
> +		    first = i3;
> +		    last = undobuf.other_insn;
> +		    gcc_assert (last);
> +		  }
> +
> +		/* We're dealing with a reg that changed mode but not
> +		   meaning, so we want to turn it into a subreg for
> +		   the new mode.  However, because of REG sharing and
> +		   because its mode had already changed, we have to do
> +		   it in two steps.  First, replace any debug uses of
> +		   reg, with its original mode temporarily restored,
> +		   with this copy we have created; then, replace the
> +		   copy with the SUBREG of the original shared reg,
> +		   once again changed to the new mode.  */
> +		propagate_for_debug (first, last, reg, tempreg, false);
> +		adjust_reg_mode (reg, new_mode);
> +		propagate_for_debug (first, last, tempreg,
> +				     lowpart_subreg (old_mode, reg, new_mode),
> +				     false);
> +	      }
> +	  }
> +    }

Any chance you can put this into a separate function?  try_combine is
already spaghetti-enough without this.

Adam



More information about the Gcc-patches mailing list