It looks like IPA ICF does code generation based on the order of
a hahstable walk which is keyed on pointers.  That's a no-no.
Fixing that doesn't solve the cc1 miscompare for LTO bootstrap
but at least the IPA ICF WPA dumps are now consistent between
stages.

[LTO] Bootstrapped and tested on x86_64-unknown-linux-gnu, ok
for trunk (and branches)?

Will only get to applying after Christmas holidays so in case
you want to poke further feel free to apply yourself.

Thanks,
Richard.

2018-12-21  Richard Biener  <rguent...@suse.de>

        PR ipa/85574
        * ipa-icf.h (sem_item_optimizer::sort_congruence_split): Declare.
        * ipa-icf.c (sem_item_optimizer::sort_congruence_split): New
        function.
        (sem_item_optimizer::do_congruence_step_f): Sort the congruence
        set after UIDs before splitting them.

Index: gcc/ipa-icf.c
===================================================================
--- gcc/ipa-icf.c       (revision 267301)
+++ gcc/ipa-icf.c       (working copy)
@@ -3117,6 +3117,18 @@ sem_item_optimizer::traverse_congruence_
   return true;
 }
 
+int
+sem_item_optimizer::sort_congruence_split (const void *a_, const void *b_)
+{
+  const std::pair<congruence_class *, bitmap> *a = (const 
std::pair<congruence_class *, bitmap> *)a_;
+  const std::pair<congruence_class *, bitmap> *b = (const 
std::pair<congruence_class *, bitmap> *)b_;
+  if (a->first->id < b->first->id)
+    return -1;
+  else if (a->first->id > b->first->id)
+    return 1;
+  return 0;
+}
+
 /* Tests if a class CLS used as INDEXth splits any congruence classes.
    Bitmap stack BMSTACK is used for bitmap allocation.  */
 
@@ -3157,13 +3169,20 @@ sem_item_optimizer::do_congruence_step_f
        }
     }
 
+  auto_vec<std::pair<congruence_class *, bitmap> > to_split;
+  to_split.reserve_exact (split_map.elements ());
+  for (hash_map <congruence_class *, bitmap>::iterator i = split_map.begin ();
+       i != split_map.end (); ++i)
+    to_split.safe_push (*i);
+  to_split.qsort (sort_congruence_split);
+
   traverse_split_pair pair;
   pair.optimizer = this;
   pair.cls = cls;
 
   splitter_class_removed = false;
-  split_map.traverse <traverse_split_pair *,
-                     sem_item_optimizer::traverse_congruence_split> (&pair);
+  for (unsigned i = 0; i < to_split.length (); ++i)
+    traverse_congruence_split (to_split[i].first, to_split[i].second, &pair);
 
   /* Bitmap clean-up.  */
   split_map.traverse <traverse_split_pair *,
Index: gcc/ipa-icf.h
===================================================================
--- gcc/ipa-icf.h       (revision 267301)
+++ gcc/ipa-icf.h       (working copy)
@@ -599,6 +599,8 @@ private:
                                         bitmap const &b,
                                         traverse_split_pair *pair);
 
+  static int sort_congruence_split (const void *, const void *);
+
   /* Reads a section from LTO stream file FILE_DATA. Input block for DATA
      contains LEN bytes.  */
   void read_section (lto_file_decl_data *file_data, const char *data,

Reply via email to