@@ -63,6 +63,7 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostic-core.h" /* for fnotice */
#include "stringpool.h"
#include "attribs.h"
+#include "tree-scalar-evolution.h" /* for verify_scev_cache. */
using namespace gcc;
@@ -1994,9 +1995,13 @@ execute_function_todo (function *fn, void *data)
verify_gimple_in_seq (gimple_body (cfun->decl));
}
if (cfun->curr_properties & PROP_ssa)
- /* IPA passes leave stmts to be fixed up, so make sure to
- not verify SSA operands whose verifier will choke on that. */
- verify_ssa (true, !from_ipa_pass);
+ {
+ /* IPA passes leave stmts to be fixed up, so make sure to
+ not verify SSA operands whose verifier will choke on that. */
+ verify_ssa (true, !from_ipa_pass);
+ if (scev_initialized_p ())
+ verify_scev_cache ();
+ }
/* IPA passes leave basic-blocks unsplit, so make sure to
not trip on that. */
if ((cfun->curr_properties & PROP_cfg)
@@ -284,6 +284,7 @@ along with GCC; see the file COPYING3. If not see
#include "tree-into-ssa.h"
#include "builtins.h"
#include "case-cfn-macros.h"
+#include "diagnostic.h"
static tree analyze_scalar_evolution_1 (class loop *, tree);
static tree analyze_scalar_evolution_for_address_of (class loop *loop,
@@ -3025,6 +3026,34 @@ scev_reset (void)
}
}
+/* CHREC walker for verify_scev_cache. */
+
+static tree
+verify_scev_cache_r (tree *tp, int *walk_subtrees, void *)
+{
+ if (TREE_CODE (*tp) == SSA_NAME
+ && SSA_NAME_IN_FREE_LIST (*tp))
+ internal_error ("stale SCEV hash table entries");
+ if (!EXPR_P (*tp))
+ *walk_subtrees = 0;
+ return NULL_TREE;
+}
+
+/* Verify the SCEV cache has no stale entries. */
+
+void
+verify_scev_cache ()
+{
+ for (auto i = scalar_evolution_info->begin ();
+ i != scalar_evolution_info->end (); ++i)
+ {
+ if ((*i)->name_version >= num_ssa_names
+ || ! ssa_name ((*i)->name_version))
+ internal_error ("stale SCEV hash table entries");
+ walk_tree (&(*i)->chrec, verify_scev_cache_r, NULL, NULL);
+ }
+}
+
/* Return true if the IV calculation in TYPE can overflow based on the knowledge
of the upper bound on the number of iterations of LOOP, the BASE and STEP
of IV.
@@ -42,6 +42,7 @@ extern bool simple_iv (class loop *, class loop *, tree, struct affine_iv *,
bool);
extern bool iv_can_overflow_p (class loop *, tree, tree, tree);
extern tree compute_overall_effect_of_inner_loop (class loop *, tree);
+extern void verify_scev_cache ();
/* Returns the basic block preceding LOOP, or the CFG entry block when
the loop is function's body. */