public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Unreachable code in reload.c
@ 2004-12-06 21:38 Martin Koegler
  2004-12-06 21:59 ` Kazu Hirata
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Koegler @ 2004-12-06 21:38 UTC (permalink / raw)
  To: gcc

reload.c, function decompose, line 2355 (CVS HEAD version):

     val.start = true_regnum (x);
      if (val.start < 0)
        {
          /* A pseudo with no hard reg.  */
          val.start = REGNO (x);
          val.end = val.start + 1;
        }
      else
        /* A hard reg.  */
        val.end = val.start + hard_regno_nregs[val.start][GET_MODE (x)];


The then-part of the if statement can never be reached, because
true_regnum returns
* a register number, which is >0, if the x is an hard register.
* a register number >0, if x is a pseudo register and reg_renumber[REGNO(x)]>0
* else REGNO(x), which is >0

So the else case is used for every kind of register, which also means
that not renumbered pseudo registers cause an access over the array
bounds of hard_regno_nregs. (I don't know, if decompose can be called
with a pseudo-register).

mfg Martin Kögler
e9925248@stud4.tuwien.ac.at

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Unreachable code in reload.c
  2004-12-06 21:38 Unreachable code in reload.c Martin Koegler
@ 2004-12-06 21:59 ` Kazu Hirata
  0 siblings, 0 replies; 2+ messages in thread
From: Kazu Hirata @ 2004-12-06 21:59 UTC (permalink / raw)
  To: e9925248; +Cc: gcc

Hi Matrin,

> reload.c, function decompose, line 2355 (CVS HEAD version):
> 
>      val.start = true_regnum (x);
>       if (val.start < 0)
>         {
>           /* A pseudo with no hard reg.  */
>           val.start = REGNO (x);
>           val.end = val.start + 1;
>         }
>       else
>         /* A hard reg.  */
>         val.end = val.start + hard_regno_nregs[val.start][GET_MODE (x)];
> 
> 
> The then-part of the if statement can never be reached

Neither is a part of the SUBREG case pointed to with an arrow.

    case SUBREG:
      if (!REG_P (SUBREG_REG (x)))
	/* This could be more precise, but it's good enough.  */
	return decompose (SUBREG_REG (x));
      val.reg_flag = 1;
      val.start = true_regnum (x);
      if (val.start < 0)
	return decompose (SUBREG_REG (x));    <---
      else
	/* A hard reg.  */
	val.end = val.start + hard_regno_nregs[val.start][GET_MODE (x)];
      break;

because true_regnum returns a non-negative number for a SUBREG with
REG in it.  Perhaps you can convert these "if"s to gcc_assert like so?

  gcc_assert (val.start >= 0);

Kazu Hirata

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-12-06 21:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-06 21:38 Unreachable code in reload.c Martin Koegler
2004-12-06 21:59 ` Kazu Hirata

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).