return walker.eliminate_cleanup ();
}
-static unsigned
+unsigned
do_rpo_vn (function *fn, edge entry, bitmap exit_bbs,
- bool iterate, bool eliminate);
+ bool iterate, bool eliminate, vn_lookup_kind kind);
void
run_rpo_vn (vn_lookup_kind kind)
{
- default_vn_walk_kind = kind;
- do_rpo_vn (cfun, NULL, NULL, true, false);
+ do_rpo_vn (cfun, NULL, NULL, true, false, kind);
/* ??? Prune requirement of these. */
constant_to_value_id = new hash_table<vn_constant_hasher> (23);
executed and iterate. If ELIMINATE is true then perform
elimination, otherwise leave that to the caller. */
-static unsigned
+unsigned
do_rpo_vn (function *fn, edge entry, bitmap exit_bbs,
- bool iterate, bool eliminate)
+ bool iterate, bool eliminate, vn_lookup_kind kind)
{
unsigned todo = 0;
+ default_vn_walk_kind = kind;
/* We currently do not support region-based iteration when
elimination is requested. */
unsigned
do_rpo_vn (function *fn, edge entry, bitmap exit_bbs)
{
- default_vn_walk_kind = VN_WALKREWRITE;
- unsigned todo = do_rpo_vn (fn, entry, exit_bbs, false, true);
+ unsigned todo = do_rpo_vn (fn, entry, exit_bbs, false, true, VN_WALKREWRITE);
free_rpo_vn ();
return todo;
}
if (iterate_p)
loop_optimizer_init (AVOID_CFG_MODIFICATIONS);
- default_vn_walk_kind = VN_WALKREWRITE;
- todo = do_rpo_vn (fun, NULL, NULL, iterate_p, true);
+ todo = do_rpo_vn (fun, NULL, NULL, iterate_p, true, VN_WALKREWRITE);
free_rpo_vn ();
if (iterate_p)
#include "builtins.h"
#include "calls.h"
#include "gimple-range.h"
-
#include "gimple-predicate-analysis.h"
+#include "domwalk.h"
+#include "tree-ssa-sccvn.h"
/* This implements the pass that does predicate aware warning on uses of
possibly uninitialized variables. The pass first collects the set of
basic_block bb;
FOR_EACH_BB_FN (bb, cfun)
{
+ edge_iterator ei;
+ edge e;
+ FOR_EACH_EDGE (e, ei, bb->preds)
+ if (e->flags & EDGE_EXECUTABLE)
+ break;
+ /* Skip unreachable blocks. For early analysis we use VN to
+ determine edge executability when wmaybe_uninit. */
+ if (!e)
+ continue;
+
basic_block succ = single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun));
+ /* ??? This could be improved when we use a greedy walk and have
+ some edges marked as not executable. */
wlims.always_executed = dominated_by_p (CDI_POST_DOMINATORS, succ, bb);
if (wlims.always_executed)
calculate_dominance_info (CDI_DOMINATORS);
calculate_dominance_info (CDI_POST_DOMINATORS);
+
+ /* Mark all edges executable, warn_uninitialized_vars will skip
+ unreachable blocks. */
+ set_all_edges_as_executable (fun);
+
/* Re-do the plain uninitialized variable check, as optimization may have
straightened control flow. Do this first so that we don't accidentally
get a "may be" warning when we'd have seen an "is" warning later. */
}
static unsigned int
-execute_early_warn_uninitialized (void)
+execute_early_warn_uninitialized (struct function *fun)
{
/* Currently, this pass runs always but
execute_late_warn_uninitialized only runs with optimization. With
calculate_dominance_info (CDI_DOMINATORS);
calculate_dominance_info (CDI_POST_DOMINATORS);
+ /* Use VN in its cheapest incarnation and without doing any
+ elimination to compute edge reachability. Don't bother when
+ we only warn for unconditionally executed code though. */
+ if (!optimize)
+ {
+ do_rpo_vn (fun, NULL, NULL, false, false, VN_NOWALK);
+ free_rpo_vn ();
+ }
+ else
+ set_all_edges_as_executable (fun);
+
warn_uninitialized_vars (/*warn_maybe_uninitialized=*/!optimize);
/* Post-dominator information cannot be reliably updated. Free it
const pass_data pass_data_early_warn_uninitialized =
{
GIMPLE_PASS, /* type */
- "*early_warn_uninitialized", /* name */
+ "early_uninit", /* name */
OPTGROUP_NONE, /* optinfo_flags */
TV_TREE_UNINIT, /* tv_id */
PROP_ssa, /* properties_required */
/* opt_pass methods: */
virtual bool gate (function *) { return gate_warn_uninitialized (); }
- virtual unsigned int execute (function *)
+ virtual unsigned int execute (function *fun)
{
- return execute_early_warn_uninitialized ();
+ return execute_early_warn_uninitialized (fun);
}
}; // class pass_early_warn_uninitialized