Nice solution :)! A few things inline below:

> +  /* Read and process the symbol table.  */
> +  pph_in_symtab (stream);
>  }
>

Why read the symbol table last? I would expect that we would read this
first, before reading the bindings, then we don't need to change the
actual pph_in_* functions to delay some of the input as the bindings
read would read a shared cache entry and simply get the already
allocated structure.

>
> @@ -1479,10 +1497,7 @@ pph_in_function_decl (pph_stream *stream, tree fndecl)
>   DECL_INITIAL (fndecl) = pph_in_tree (stream);
>   pph_in_lang_specific (stream, fndecl);
>   DECL_SAVED_TREE (fndecl) = pph_in_tree (stream);
> -  DECL_STRUCT_FUNCTION (fndecl) = pph_in_struct_function (stream, fndecl);
>   DECL_CHAIN (fndecl) = pph_in_tree (stream);
> -  if (DECL_SAVED_TREE (fndecl))
> -    VEC_safe_push (tree, gc, stream->fns_to_expand, fndecl);
>  }
>

(If we read symbol table first we can probably keep this logic as is)

> @@ -1282,13 +1320,19 @@ pph_out_tree_header (struct output_block *ob, tree 
> expr)
>  static void
>  pph_out_function_decl (pph_stream *stream, tree fndecl, bool ref_p)
>  {
> +  /* Note that we do not output DECL_STRUCT_FUNCTION here.  This is
> +     emitted at the end of the PPH file in pph_out_symtab.
> +     This way, we will be able to re-instantiate them in the same
> +     order when reading the image (the allocation of
> +     DECL_STRUCT_FUNCTION has the side effect of generating function
> +     sequence numbers (function.funcdef_no).  */
>   pph_out_tree_or_ref_1 (stream, DECL_INITIAL (fndecl), ref_p, 3);
>   pph_out_lang_specific (stream, fndecl, ref_p);
>   pph_out_tree_or_ref_1 (stream, DECL_SAVED_TREE (fndecl), ref_p, 3);
> -  pph_out_struct_function (stream, DECL_STRUCT_FUNCTION (fndecl), ref_p);
>   pph_out_tree_or_ref_1 (stream, DECL_CHAIN (fndecl), ref_p, 3);
>  }
>

(again, i think we should output this normally, but output the symtab
first so that at this point this is just a ref)

> +/* Add DECL to the list of symbols that need to be registered with the
> +   middle end when reading current_pph_stream.  */
> +
> +void
> +pph_add_decl_to_register (tree decl)
> +{
> +  if (decl)
> +    VEC_safe_push (tree, heap, decls_to_register, decl);
> +}

should we inline this?

> --
> This patch is available for review at http://codereview.appspot.com/4732043
>

Cheers,
Gab

Reply via email to