@@ -2426,9 +2426,6 @@ pph_in_tree (pph_stream *stream)
PPH image. */
expr = (tree) pph_cache_find (stream, PPH_RECORD_XREF, image_ix, ix,
PPH_any_tree);
-
- /* Read the internal cache slot where EXPR should be stored at. */
- ix = pph_in_uint (stream);
}
else if (marker == PPH_RECORD_START_MERGE_BODY)
{
@@ -2438,12 +2435,13 @@ pph_in_tree (pph_stream *stream)
expr = (tree) pph_cache_get (&stream->cache, ix);
}
- /* Add the new tree to the cache and read its body. The tree is
- added to the cache before we read its body to handle circular
- references and references from children nodes. If we are reading
- a merge body, then the tree is already in the cache (it was added
- by pph_in_merge_key_tree). */
- if (marker != PPH_RECORD_START_MERGE_BODY)
+ /* If we are starting to read a full tree, add its pointer to the
+ cache and read its body. The tree is added to the cache before
+ we read its body to handle circular references and references
+ from children nodes. If we are reading a merge body, then the
+ tree is already in the cache (it was added by
+ pph_in_merge_key_tree). */
+ if (marker == PPH_RECORD_START)
pph_cache_insert_at (&stream->cache, expr, ix, pph_tree_code_to_tag (expr));
if (flag_pph_tracer)
@@ -696,33 +696,32 @@ pph_out_start_tree_record (pph_stream *stream, tree t)
}
else if (marker == PPH_RECORD_START_MUTATED)
{
- unsigned int internal_ix;
+ unsigned new_crc;
+ size_t nbytes;
+ pph_cache *ext_cache;
/* We found T in an external PPH file, but it has mutated since
we originally read it. We are going to write out T again,
- but the reader should not re-allocate T, rather it should
+ but the reader should not re-allocate T. Rather, it should
read the contents of T on top of the existing address.
- We also add T to STREAM's internal cache so further
- references go to it rather than the external version.
- Note that although we add an entry for T in STREAM's internal
- cache, the reference we write to the stream is to the
- external version of T. This way the reader will get the
- location of T from the external reference and overwrite it
- with the contents that we are going to write here. */
- pph_cache_add (&stream->cache, t, &internal_ix, tag);
+ We also re-compute T's CRC and update its cache entry. This
+ way, further references to T will become regular external
+ references. */
pph_out_record_marker (stream, marker, tag);
+ /* Update the CRC for T in the external cache, so we don't
+ continue to consider it mutated. */
+ new_crc = pph_get_signature (t, &nbytes);
+ ext_cache = pph_cache_select (stream, PPH_RECORD_XREF, include_ix);
+ pph_cache_sign (ext_cache, ix, new_crc, nbytes);
+
/* Write the location of T in the external cache. */
gcc_assert (include_ix != -1u);
pph_out_uint (stream, include_ix);
gcc_assert (ix != -1u);
pph_out_uint (stream, ix);
-
- /* Now write the location of the new version of T in the
- internal cache. */
- pph_out_uint (stream, internal_ix);
}
else
gcc_unreachable ();
@@ -2304,7 +2303,6 @@ pph_out_tree (pph_stream *stream, tree expr)
if (marker == PPH_RECORD_START || marker == PPH_RECORD_START_MUTATED)
{
-
/* This is the first time we see EXPR, write it out. */
if (marker == PPH_RECORD_START)
{