[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pcc-list
Subject:    Re: reg prnting bug
From:       Anders Magnusson <ragge () ludd ! ltu ! se>
Date:       2007-12-10 18:17:18
Message-ID: 200712101817.lBAIHIPe002735 () mother ! ludd ! ltu ! se
[Download RAW message or body]

> 
> On Sun, Dec 09, 2007 at 07:41:47PM +0000, mickey wrote:
> > On Sun, Dec 09, 2007 at 07:09:46PM +0100, Anders Magnusson wrote:
> > > > 
> > > > On Fri, Dec 07, 2007 at 03:39:39PM +0100, Anders Magnusson wrote:
> > > > > mickey wrote:
> > > > > >re
> > > > > >as much as the check is bogus by itself it is also broken (:
> > > > > >a pointer can easily be above 0x80000000 and thus negative
> > > > > >as an integer (not to mention 64bit freakiness).
> > > > > >this way it is a bit more reliable...
> > > > > >  
> > > > > Ok.  It's ugly but fortunately it's only used for debugging :-)
> > > > 
> > > > a slightely better check as before it was still making false positives.
> > > > this seems to work much better now...
> > > >
> > > That will always fail on little-endian targets because p->n_reg will
> > > never be negative.  I don't think it's a good solution for this.
> 
> even better upper limit (as before it can still choose wrong
> on a pointer) and yes lower bounds is 0 because pointer can be
> higher than 0x80000000 (and thus negative).
>
Looks better, yes.  Have you tested it on i386? If so, then go ahead.

-- Ragge

> cu
> -- 
>     paranoic mickey       (my employers have changed but, the name has remained)
> 
> Index: reader.c
> ===================================================================
> RCS file: /cvsroot/pcc/mip/reader.c,v
> retrieving revision 1.211
> diff -u -r1.211 reader.c
> --- reader.c	28 Nov 2007 03:02:08 -0000	1.211
> +++ reader.c	10 Dec 2007 13:33:57 -0000
> @@ -758,7 +758,8 @@
>  		int gregn(struct regw *);
>  		if (p->n_reg == -1)
>  			fprintf(prfil, "REG <undef>");
> -		else if (p->n_reg < 100000) /* XXX */
> +		else if (0 <= p->n_reg &&
> +		    p->n_reg < (ENCRD(MAXREGS) + ENCRA(MAXREGS,0))) /* XXX */
>  			fprintf(prfil, "REG %s", rnames[DECRA(p->n_reg, 0)]);
>  		else
>  			fprintf(prfil, "TEMP %d", gregn(p->n_regw));
> 

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic