&& bitmap_equal_p (eql1->labels, eql2->labels));
}
-/* Lookup a equivalence class in TABLE by the bitmap of LABELS it
- contains. Sets *REF_LABELS to the bitmap LABELS is equivalent to. */
+/* Lookup a equivalence class in TABLE by the bitmap of LABELS with
+ hash HAS it contains. Sets *REF_LABELS to the bitmap LABELS
+ is equivalent to. */
-static unsigned int
-equiv_class_lookup (htab_t table, bitmap labels, bitmap *ref_labels)
+static equiv_class_label *
+equiv_class_lookup_or_add (htab_t table, bitmap labels)
{
- void **slot;
- struct equiv_class_label ecl;
+ equiv_class_label **slot;
+ 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)
+ slot = (equiv_class_label **) htab_find_slot_with_hash (table, &ecl,
+ ecl.hashcode, INSERT);
+ if (!*slot)
{
- if (ref_labels)
- *ref_labels = NULL;
- return 0;
+ *slot = XNEW (struct equiv_class_label);
+ (*slot)->labels = labels;
+ (*slot)->hashcode = ecl.hashcode;
+ (*slot)->equivalence_class = 0;
}
- else
- {
- equiv_class_label_t ec = (equiv_class_label_t) *slot;
- if (ref_labels)
- *ref_labels = ec->labels;
- return ec->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;
+ return *slot;
}
/* Perform offline variable substitution.
}
bitmap_set_bit (graph->points_to[n], FIRST_REF_NODE + n);
graph->pointer_label[n] = pointer_equiv_class++;
+ equiv_class_label_t ecl;
+ ecl = equiv_class_lookup_or_add (pointer_equiv_class_table,
+ graph->points_to[n]);
+ ecl->equivalence_class = graph->pointer_label[n];
return;
}
if (!bitmap_empty_p (graph->points_to[n]))
{
- bitmap ref_points_to;
- unsigned int label = equiv_class_lookup (pointer_equiv_class_table,
- graph->points_to[n],
- &ref_points_to);
- if (!label)
- {
- label = pointer_equiv_class++;
- equiv_class_add (pointer_equiv_class_table,
- label, graph->points_to[n]);
- }
+ equiv_class_label_t ecl;
+ ecl = equiv_class_lookup_or_add (pointer_equiv_class_table,
+ graph->points_to[n]);
+ if (ecl->equivalence_class == 0)
+ ecl->equivalence_class = pointer_equiv_class++;
else
{
BITMAP_FREE (graph->points_to[n]);
- graph->points_to[n] = ref_points_to;
+ graph->points_to[n] = ecl->labels;
}
- graph->pointer_label[n] = label;
+ graph->pointer_label[n] = ecl->equivalence_class;
}
}
bitmap pointed_by;
bitmap_iterator bi;
unsigned int j;
- unsigned int label;
if (!graph->pointed_by[i])
continue;
/* Look up the location equivalence label if one exists, or make
one otherwise. */
- label = equiv_class_lookup (location_equiv_class_table,
- pointed_by, NULL);
- if (label == 0)
- {
- label = location_equiv_class++;
- equiv_class_add (location_equiv_class_table,
- label, pointed_by);
- }
+ equiv_class_label_t ecl;
+ ecl = equiv_class_lookup_or_add (location_equiv_class_table, pointed_by);
+ if (ecl->equivalence_class == 0)
+ ecl->equivalence_class = location_equiv_class++;
else
{
if (dump_file && (dump_flags & TDF_DETAILS))
get_varinfo (i)->name);
BITMAP_FREE (pointed_by);
}
- graph->loc_label[i] = label;
+ graph->loc_label[i] = ecl->equivalence_class;
}