Detect one class of invalid merges.
When merging two different EXPRs, we are currently merging some trees
that should not be merged. This patch tries to identify one case
where we can certainly detect that a bad merge is about to happen.
This fixes no tests, but diagnoses quite a few bad merges in our
internal testing. Lawrence will be producing test cases for those.
2012-03-14 Diego Novillo <dnovi...@google.com>
* pph-in.c (pph_in_merge_key_tree_with_searcher): Detect and
diagnose attempts to merge two distinct trees from the same
diff --git a/gcc/cp/pph-in.c b/gcc/cp/pph-in.c
index a328e13..ba89aa4 100644
@@ -2625,7 +2625,23 @@ pph_in_merge_key_tree_with_searcher (pph_stream *stream,
gcc_assert (expr != NULL);
if (expr != read_expr)
- pph_merge_tree_attributes (expr, read_expr);
+ /* When STREAM was generated, EXPR and READ_EXPR were saved as
+ distinct trees (otherwise, we would have gotten READ_EXPR as
+ an internal reference). That's why we are reading them now as
+ distinct pointers.
+ So, if we find that EXPR has already been registered in
+ STREAM's cache, it means that we should not be trying to
+ merge them. After all, the writer considered them different
+ objects. */
+ if (pph_cache_lookup (&stream->cache, expr, NULL,
+ pph_tree_code_to_tag (expr)))
+ fatal_error ("Trying to merge distinct trees from the same "
+ "PPH image %s", stream->name);
+ pph_merge_tree_attributes (expr, read_expr);
pph_cache_insert_at (&stream->cache, expr, ix,
This patch is available for review at http://codereview.appspot.com/5822054