aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2013-02-04 09:30:12 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2013-02-04 09:30:12 +0000
commit139a0707cb46308598ece7785130679ea6e737a8 (patch)
treeb5efec18e5a7beed6df7b3fb140527980aaa96bb /gcc
parentfb84a0cb8411bdbbb8a1343216b9d76dcb935c94 (diff)
downloadgcc-139a0707cb46308598ece7785130679ea6e737a8.zip
gcc-139a0707cb46308598ece7785130679ea6e737a8.tar.gz
gcc-139a0707cb46308598ece7785130679ea6e737a8.tar.bz2
re PR c/56113 (out of memory when compiling a function with many goto labels (50k > ))
2013-02-04 Richard Biener <rguenther@suse.de> PR tree-optimization/56113 * tree-ssa-structalias.c (equiv_class_lookup, equiv_class_add): Merge into ... (equiv_class_lookup_or_add): ... this. (label_visit): Adjust and fix error in previous patch. (perform_var_substitution): Adjust. From-SVN: r195707
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/tree-ssa-structalias.c93
2 files changed, 40 insertions, 62 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 31a7ec6..12e070a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2013-02-04 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/56113
+ * tree-ssa-structalias.c (equiv_class_lookup, equiv_class_add):
+ Merge into ...
+ (equiv_class_lookup_or_add): ... this.
+ (label_visit): Adjust and fix error in previous patch.
+ (perform_var_substitution): Adjust.
+
2013-02-03 Oleg Endo <olegendo@gcc.gnu.org>
* config/sh/divtab.c: Fix formatting and comments throughout the file.
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index bee27b1..50a40a5 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -1908,54 +1908,29 @@ equiv_class_label_eq (const void *p1, const void *p2)
&& 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.
@@ -2150,6 +2125,10 @@ label_visit (constraint_graph_t graph, struct scc_info *si, unsigned int n)
}
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;
}
@@ -2167,22 +2146,17 @@ label_visit (constraint_graph_t graph, struct scc_info *si, unsigned int n)
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;
}
}
@@ -2222,7 +2196,6 @@ perform_var_substitution (constraint_graph_t graph)
bitmap pointed_by;
bitmap_iterator bi;
unsigned int j;
- unsigned int label;
if (!graph->pointed_by[i])
continue;
@@ -2240,14 +2213,10 @@ perform_var_substitution (constraint_graph_t graph)
/* 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))
@@ -2255,7 +2224,7 @@ perform_var_substitution (constraint_graph_t graph)
get_varinfo (i)->name);
BITMAP_FREE (pointed_by);
}
- graph->loc_label[i] = label;
+ graph->loc_label[i] = ecl->equivalence_class;
}