From: Richard Biener Date: Mon, 4 Feb 2013 09:30:12 +0000 (+0000) Subject: re PR c/56113 (out of memory when compiling a function with many goto labels (50k... X-Git-Tag: upstream/12.2.0~71449 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=139a0707cb46308598ece7785130679ea6e737a8;p=platform%2Fupstream%2Fgcc.git re PR c/56113 (out of memory when compiling a function with many goto labels (50k > )) 2013-02-04 Richard Biener 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 --- 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 + + 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 * 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; }