+/* Hash function for a equiv_class_label_t */
+
+static hashval_t
+equiv_class_label_hash (const void *p)
+{
+ const_equiv_class_label_t const ecl = (const_equiv_class_label_t) p;
+ return ecl->hashcode;
+}
+
+/* Equality function for two equiv_class_label_t's. */
+
+static int
+equiv_class_label_eq (const void *p1, const void *p2)
+{
+ const_equiv_class_label_t const eql1 = (const_equiv_class_label_t) p1;
+ const_equiv_class_label_t const eql2 = (const_equiv_class_label_t) p2;
+ return bitmap_equal_p (eql1->labels, eql2->labels);
+}
+
+/* Lookup a equivalence class in TABLE by the bitmap of LABELS it
+ contains. */
+
+static unsigned int
+equiv_class_lookup (htab_t table, bitmap labels)
+{
+ void **slot;
+ struct equiv_class_label ecl;
+
+ ecl.labels = labels;
+ ecl.hashcode = bitmap_hash (labels);
+
+ slot = htab_find_slot_with_hash (table, &ecl,
+ ecl.hashcode, NO_INSERT);
+ if (!slot)
+ return 0;
+ else
+ return ((equiv_class_label_t) *slot)->equivalence_class;
+}
+
+
+/* Add an equivalence class named EQUIVALENCE_CLASS with labels LABELS
+ to TABLE. */
+
+static void
+equiv_class_add (htab_t table, unsigned int equivalence_class,
+ bitmap labels)
+{
+ void **slot;
+ equiv_class_label_t ecl = XNEW (struct equiv_class_label);
+
+ ecl->labels = labels;
+ ecl->equivalence_class = equivalence_class;
+ ecl->hashcode = bitmap_hash (labels);
+
+ slot = htab_find_slot_with_hash (table, ecl,
+ ecl->hashcode, INSERT);
+ gcc_assert (!*slot);
+ *slot = (void *) ecl;
+}
+
+/* Perform offline variable substitution.
+
+ This is a worst case quadratic time way of identifying variables
+ that must have equivalent points-to sets, including those caused by
+ static cycles, and single entry subgraphs, in the constraint graph.
+
+ The technique is described in "Exploiting Pointer and Location
+ Equivalence to Optimize Pointer Analysis. In the 14th International
+ Static Analysis Symposium (SAS), August 2007." It is known as the
+ "HU" algorithm, and is equivalent to value numbering the collapsed
+ constraint graph including evaluating unions.