aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2007-12-13 14:22:23 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2007-12-13 14:22:23 +0000
commit863d2a5760cc1e9c2e64ab97c471cd37b7e254ca (patch)
treee093a6851a7defde4e02f4c80a5cdb3acacf2c70
parent3905a1b25a31c60a66b3736af9c71bc3cad8cdc2 (diff)
downloadgcc-863d2a5760cc1e9c2e64ab97c471cd37b7e254ca.zip
gcc-863d2a5760cc1e9c2e64ab97c471cd37b7e254ca.tar.gz
gcc-863d2a5760cc1e9c2e64ab97c471cd37b7e254ca.tar.bz2
re PR middle-end/34450 (compile takes up 1.8 GB RAM at -O1)
2007-12-13 Richard Guenther <rguenther@suse.de> PR tree-optimization/34450 * params.def (PARAM_SCCVN_MAX_SCC_SIZE): New param. * invoke.texi (sccvn-max-scc-size): Document. * Makefile.in (tree-ssa-sccvn.o): Add $(PARAMS_H) dependency. * tree-ssa-sccvn.h (run_scc_vn): Return true on success, false on error. * tree-ssa-sccvn.c (params.h): Include. (DFS): Return true if all went well, return false as soon as a SCC exceeds the size of PARAM_SCCVN_MAX_SCC_SIZE. (run_scc_vn): Return true if all went well, return false if we aborted during DFS. * tree-ssa-pre.c (execute_pre): Check if SCCVN finished successfully, otherwise bail out. From-SVN: r130895
-rw-r--r--gcc/ChangeLog16
-rw-r--r--gcc/Makefile.in3
-rw-r--r--gcc/doc/invoke.texi6
-rw-r--r--gcc/params.def11
-rw-r--r--gcc/tree-ssa-pre.c8
-rw-r--r--gcc/tree-ssa-sccvn.c36
-rw-r--r--gcc/tree-ssa-sccvn.h2
7 files changed, 74 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3cf9ec7..96a5d64 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,19 @@
+2007-12-13 Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/34450
+ * params.def (PARAM_SCCVN_MAX_SCC_SIZE): New param.
+ * invoke.texi (sccvn-max-scc-size): Document.
+ * Makefile.in (tree-ssa-sccvn.o): Add $(PARAMS_H) dependency.
+ * tree-ssa-sccvn.h (run_scc_vn): Return true on success, false
+ on error.
+ * tree-ssa-sccvn.c (params.h): Include.
+ (DFS): Return true if all went well, return false as soon as
+ a SCC exceeds the size of PARAM_SCCVN_MAX_SCC_SIZE.
+ (run_scc_vn): Return true if all went well, return false if
+ we aborted during DFS.
+ * tree-ssa-pre.c (execute_pre): Check if SCCVN finished
+ successfully, otherwise bail out.
+
2007-12-13 Olga Golovanevsky <olga@il.ibm.com>
* ipa-struct-reorg.c (is_candidate): Print information to dump
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 93ac8a5..fa8509e 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2075,7 +2075,8 @@ tree-ssa-sccvn.o : tree-ssa-sccvn.c $(TREE_FLOW_H) $(CONFIG_H) \
$(SYSTEM_H) $(TREE_H) $(GGC_H) $(DIAGNOSTIC_H) $(TIMEVAR_H) \
$(TM_H) coretypes.h $(TREE_DUMP_H) tree-pass.h $(FLAGS_H) $(CFGLOOP_H) \
alloc-pool.h $(BASIC_BLOCK_H) bitmap.h $(HASHTAB_H) $(TREE_GIMPLE_H) \
- $(TREE_INLINE_H) tree-iterator.h tree-ssa-propagate.h tree-ssa-sccvn.h
+ $(TREE_INLINE_H) tree-iterator.h tree-ssa-propagate.h tree-ssa-sccvn.h \
+ $(PARAMS_H)
tree-vn.o : tree-vn.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(GGC_H) \
$(TREE_H) $(TREE_FLOW_H) $(HASHTAB_H) langhooks.h tree-pass.h \
$(TREE_DUMP_H) $(DIAGNOSTIC_H) tree-ssa-sccvn.h
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index e8431da..b6c7665 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -7182,6 +7182,12 @@ parameter sets a limit on the length of the sets that are computed,
which prevents the runaway behaviour. Setting a value of 0 for
this paramter will allow an unlimited set length.
+@item sccvn-max-scc-size
+Maximum size of a strongly connected component (SCC) during SCCVN
+processing. If this limit is hit, SCCVN processing for the whole
+function will not be done and optimizations depending on it will
+be disabled. The default maximum SCC size is 10000.
+
@end table
@end table
diff --git a/gcc/params.def b/gcc/params.def
index fc85c88..1915727 100644
--- a/gcc/params.def
+++ b/gcc/params.def
@@ -713,6 +713,17 @@ DEFPARAM (PARAM_MAX_PARTIAL_ANTIC_LENGTH,
"Maximum length of partial antic set when performing tree pre optimization",
100, 0, 0)
+/* The following is used as a stop-gap limit for cases where really huge
+ SCCs blow up memory and compile-time use too much. If we hit this limit,
+ SCCVN and such FRE and PRE will be not done at all for the current
+ function. */
+
+DEFPARAM (PARAM_SCCVN_MAX_SCC_SIZE,
+ "sccvn-max-scc-size",
+ "Maximum size of a SCC before SCCVN stops processing a function",
+ 10000, 10, 0)
+
+
/*
Local variables:
mode:c
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index 59396fd..c947e0f 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -3933,7 +3933,13 @@ execute_pre (bool do_fre)
insert_fake_stores ();
/* Collect and value number expressions computed in each basic block. */
- run_scc_vn ();
+ if (!run_scc_vn ())
+ {
+ if (!do_fre)
+ remove_dead_inserted_code ();
+ fini_pre ();
+ return;
+ }
switch_to_PRE_table ();
compute_avail ();
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 8edd03b..a14c2a7 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -42,6 +42,7 @@ along with GCC; see the file COPYING3. If not see
#include "bitmap.h"
#include "langhooks.h"
#include "cfgloop.h"
+#include "params.h"
#include "tree-ssa-propagate.h"
#include "tree-ssa-sccvn.h"
@@ -1837,9 +1838,11 @@ process_scc (VEC (tree, heap) *scc)
/* Depth first search on NAME to discover and process SCC's in the SSA
graph.
Execution of this algorithm relies on the fact that the SCC's are
- popped off the stack in topological order. */
+ popped off the stack in topological order.
+ Returns true if successful, false if we stopped processing SCC's due
+ to ressource constraints. */
-static void
+static bool
DFS (tree name)
{
ssa_op_iter iter;
@@ -1870,7 +1873,8 @@ DFS (tree name)
if (! (VN_INFO (use)->visited))
{
- DFS (use);
+ if (!DFS (use))
+ return false;
VN_INFO (name)->low = MIN (VN_INFO (name)->low,
VN_INFO (use)->low);
}
@@ -1899,6 +1903,17 @@ DFS (tree name)
VEC_safe_push (tree, heap, scc, x);
} while (x != name);
+ /* Bail out of SCCVN in case a SCC turns out to be incredibly large. */
+ if (VEC_length (tree, scc)
+ > (unsigned)PARAM_VALUE (PARAM_SCCVN_MAX_SCC_SIZE))
+ {
+ if (dump_file)
+ fprintf (dump_file, "WARNING: Giving up with SCCVN due to "
+ "SCC size %u exceeding %u\n", VEC_length (tree, scc),
+ (unsigned)PARAM_VALUE (PARAM_SCCVN_MAX_SCC_SIZE));
+ return false;
+ }
+
if (VEC_length (tree, scc) > 1)
sort_scc (scc);
@@ -1909,6 +1924,8 @@ DFS (tree name)
VEC_free (tree, heap, scc);
}
+
+ return true;
}
static void
@@ -2074,7 +2091,10 @@ free_scc_vn (void)
}
}
-void
+/* Do SCCVN. Returns true if it finished, false if we bailed out
+ due to ressource constraints. */
+
+bool
run_scc_vn (void)
{
size_t i;
@@ -2100,7 +2120,11 @@ run_scc_vn (void)
if (name
&& VN_INFO (name)->visited == false
&& !has_zero_uses (name))
- DFS (name);
+ if (!DFS (name))
+ {
+ free_scc_vn ();
+ return false;
+ }
}
if (dump_file && (dump_flags & TDF_DETAILS))
@@ -2123,4 +2147,6 @@ run_scc_vn (void)
}
}
}
+
+ return true;
}
diff --git a/gcc/tree-ssa-sccvn.h b/gcc/tree-ssa-sccvn.h
index 6d8f258..f434e95 100644
--- a/gcc/tree-ssa-sccvn.h
+++ b/gcc/tree-ssa-sccvn.h
@@ -48,7 +48,7 @@ typedef struct vn_ssa_aux
/* Return the value numbering info for an SSA_NAME. */
extern vn_ssa_aux_t VN_INFO (tree);
extern vn_ssa_aux_t VN_INFO_GET (tree);
-void run_scc_vn (void);
+bool run_scc_vn (void);
void free_scc_vn (void);
void switch_to_PRE_table (void);
tree vn_binary_op_lookup (tree);