#include "bitmap.h"
#include "langhooks.h"
#include "cfgloop.h"
+#include "params.h"
#include "tree-ssa-propagate.h"
#include "tree-ssa-sccvn.h"
/* 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;
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);
}
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);
VEC_free (tree, heap, scc);
}
+
+ return true;
}
static 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;
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))
}
}
}
+
+ return true;
}