===================================================================
@@ -3684,21 +3684,25 @@ decision_tree::gen (FILE *f, bool gimple
" gimple_seq *seq, tree (*valueize)(tree),\n"
" code_helper code, tree type");
else
fprintf (f, "\ntree\n"
"generic_simplify (location_t loc, enum tree_code code, "
"tree type ATTRIBUTE_UNUSED");
for (unsigned i = 0; i < n; ++i)
fprintf (f, ", tree op%d", i);
fprintf (f, ")\n");
fprintf (f, "{\n");
-
+ if (gimple)
+ {
+ fprintf (f, " depth_limiter d;\n");
+ fprintf (f, " if (d > 100) return false;\n");
+ }
if (gimple)
fprintf (f, " switch (code.get_rep())\n"
" {\n");
else
fprintf (f, " switch (code)\n"
" {\n");
for (unsigned i = 0; i < root->kids.length (); i++)
{
dt_operand *dop = static_cast<dt_operand *>(root->kids[i]);
expr *e = static_cast<expr *>(dop->op);
===================================================================
@@ -808,10 +808,22 @@ single_use (tree t)
}
/* Return true if math operations should be canonicalized,
e.g. sqrt(sqrt(x)) -> pow(x, 0.25). */
static inline bool
canonicalize_math_p ()
{
return !cfun || (cfun->curr_properties & PROP_gimple_opt_math) == 0;
}
+
+/* Simple way to prevent infinite recursion in simplification. */
+namespace {
+ struct depth_limiter
+ {
+ static int depth;
+ operator int () const { return depth; }
+ depth_limiter () { ++depth; }
+ ~depth_limiter () { --depth; }
+ };
+ int depth_limiter::depth = 0;
+}