Hi!

As discussed in the PR, the problem here is that when add_mem_for_addr
calls new_elt_loc_list, it adds the new MEM loc to canonical_cselib_val's
locs, so when mem_elt isn't canonical, we enter into addr_list as well as
first_containing_mem chain some VALUE that doesn't contain any MEM locs.
The check to avoid the duplicates isn't working either, because the only
loc non-canonical values have is the canonical VALUE.
While perhaps some more changes are needed and perhaps cselib_invalidate_mem
might need to call canonical_cselib_val too, I believe this patch is
correct and desirable and fixes both the ICEs I've analysed.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2012-01-02  Jakub Jelinek  <ja...@redhat.com>

        PR bootstrap/51725
        * cselib.c (add_mem_for_addr): Call canonical_cselib_val
        on mem_elt first.

--- gcc/cselib.c.jj     2012-01-01 19:54:46.000000000 +0100
+++ gcc/cselib.c        2012-01-02 17:34:16.982499767 +0100
@@ -1264,6 +1264,8 @@ add_mem_for_addr (cselib_val *addr_elt,
 {
   struct elt_loc_list *l;
 
+  mem_elt = canonical_cselib_val (mem_elt);
+
   /* Avoid duplicates.  */
   for (l = mem_elt->locs; l; l = l->next)
     if (MEM_P (l->loc)

        Jakub

Reply via email to