[PATCH] PR 40219, avoid accessing outside built_in_decls array when computing tree hashes

Michael Meissner meissner@linux.vnet.ibm.com
Fri May 22 21:35:00 GMT 2009


On Fri, May 22, 2009 at 10:57:19PM +0200, Jakub Jelinek wrote:
> On Fri, May 22, 2009 at 04:42:34PM -0400, Michael Meissner wrote:
> > -      /* When referring to a built-in FUNCTION_DECL, use the
> > -	 __builtin__ form.  Otherwise nodes that compare equal
> > -	 according to operand_equal_p might get different
> > -	 hash codes.  */
> > -      if (DECL_BUILT_IN (t) && built_in_decls[DECL_FUNCTION_CODE (t)])
> > +      /* When referring to a built-in FUNCTION_DECL, use the __builtin__ form.
> > +	 Otherwise nodes that compare equal according to operand_equal_p might
> > +	 get different hash codes.  However, don't do this for machine specific
> > +	 or front end builtins, since the function code is overloaded in those
> > +	 cases.  */
> > +      if (DECL_BUILT_IN (t) && DECL_BUILT_IN_CLASS (t) == BUILT_IN_NORMAL
> > +	  && built_in_decls[DECL_FUNCTION_CODE (t)])
> 
> Why not just
> if (DECL_BUILT_IN_CLASS (t) == BUILT_IN_NORMAL
>     && built_in_decls[DECL_FUNCTION_CODE (t)])
> ?
> DECL_BUILT_IN (t) is DECL_BUILT_IN_CLASS (t) != NOT_BUILT_IN and
> AFAIK almost all places that check for BUILT_IN_NORMAL only
> check that and don't have DECL_BUILT_IN check before that
> (I count 5 exceptions).
> 
> 	Jakub

Ah yes, now that I look at the definition of DECL_BUILT_IN, it definately is a
redunant test:

/* In a FUNCTION_DECL, nonzero means a built in function.  */
#define DECL_BUILT_IN(NODE) (DECL_BUILT_IN_CLASS (NODE) != NOT_BUILT_IN)

Is it ok to check in the fixed change?

-- 
Michael Meissner, IBM
4 Technology Place Drive, MS 2203A, Westford, MA, 01886, USA
meissner@linux.vnet.ibm.com



More information about the Gcc-patches mailing list