This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [lto][patch] Stream missing fields in FUNCTION_DECL causing builtins to break


On Fri, Jun 27, 2008 at 3:44 PM, Diego Novillo <dnovillo@google.com> wrote:

> I guess the failure here was forgetting to stream DECL_BUILTIN_CODE
> and such?  Could we conditinalize this in DECL_IS_BUILTIN?

Hmm, there is a curious redundancy.  There is a macro DECL_BUILT_IN,
which tests the built_in_class field, which is allegedly the discriminant for
function_code.   It is valid only for function decls.   DECL_IS_BUILTIN
appears to be valid for any declaration, and tests source position.  I would
expect the former to be used when generating code for builtin functions,
and the latter to be used when generating diagnostics, but I suppose I wouldn't
be surprised if GCC were not consistent about this.  Here are relevant snippets
from tree.h:

#define DECL_IS_BUILTIN(DECL) \
 (DECL_SOURCE_LOCATION (DECL) <= BUILTINS_LOCATION)

/* For FUNCTION_DECL, if it is built-in, this identifies which built-in
  operation it is.  Note, however, that this field is overloaded, with
  DECL_BUILT_IN_CLASS as the discriminant, so the latter must always be
  checked before any access to the former.  */
#define DECL_FUNCTION_CODE(NODE) \
 (FUNCTION_DECL_CHECK (NODE)->function_decl.function_code)

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

/* For a builtin function, identify which part of the compiler defined it.  */
#define DECL_BUILT_IN_CLASS(NODE) \
  (FUNCTION_DECL_CHECK (NODE)->function_decl.built_in_class)

It appears that function_code has no meaning in the case that
built_in_class == NOT_BUILT_IN, so I could conditionalize on DECL_BUILT_IN
to save a zero byte in the stream in the usual case.  Is this what you
were after?

As a separate issue, we may not be reconstructing the location correctly for
builtins, as locations are expanded into file/line/column form in the
serialized stream.
I'll look into this.

> I'm not sure, though.  When reading in the function in
> input_function_decl we may not have enough to recognize whether the
> decl is a builtin (we use DECL_SOURCE_LOCATION for that).

DECL_BUILT_IN should be sufficient for a function_decl, should it not?

--Bill


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]