aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vrp.cc
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2024-06-05 15:12:27 -0400
committerAndrew MacLeod <amacleod@redhat.com>2024-06-10 16:26:58 -0400
commit74ee12ff68243bb177fb8653474dff80c3792139 (patch)
tree6c006043c78264870d2d3424305ee5cd489fee29 /gcc/tree-vrp.cc
parent9aaf29b9ba5ffe332220d002ddde85d96fd6657d (diff)
downloadgcc-74ee12ff68243bb177fb8653474dff80c3792139.zip
gcc-74ee12ff68243bb177fb8653474dff80c3792139.tar.gz
gcc-74ee12ff68243bb177fb8653474dff80c3792139.tar.bz2
Move array_bounds warnings into a separate pass.
Array bounds checking is currently tied to VRP. This causes issues with using laternate VRP algorithms as well as experimenting with moving the location of the warnings later. This moves it to its own pass and cleans up the vrp_pass object. * gimple-array-bounds.cc (array_bounds_checker::array_bounds_checker): Always use current range_query. (pass_data_array_bounds): New. (pass_array_bounds): New. (make_pass_array_bounds): New. * gimple-array-bounds.h (array_bounds_checker): Adjust prototype. * passes.def (pass_array_bounds): New. Add after VRP1. * timevar.def (TV_TREE_ARRAY_BOUNDS): New timevar. * tree-pass.h (make_pass_array_bounds): Add prototype. * tree-vrp.cc (execute_ranger_vrp): Remove warning param and do not invoke array bounds warning pass. (pass_vrp::pass_vrp): Adjust params. (pass_vrp::close): Adjust parameters. (pass_vrp::warn_array_bounds_p): Remove. (make_pass_vrp): Remove warning param. (make_pass_early_vrp): Remove warning param. (make_pass_fast_vrp): Remove warning param.
Diffstat (limited to 'gcc/tree-vrp.cc')
-rw-r--r--gcc/tree-vrp.cc40
1 files changed, 8 insertions, 32 deletions
diff --git a/gcc/tree-vrp.cc b/gcc/tree-vrp.cc
index 1c7b451..1f6b578 100644
--- a/gcc/tree-vrp.cc
+++ b/gcc/tree-vrp.cc
@@ -1095,8 +1095,7 @@ private:
from anywhere to perform a VRP pass, including from EVRP. */
unsigned int
-execute_ranger_vrp (struct function *fun, bool warn_array_bounds_p,
- bool final_p)
+execute_ranger_vrp (struct function *fun, bool final_p)
{
loop_optimizer_init (LOOPS_NORMAL | LOOPS_HAVE_RECORDED_EXITS);
rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
@@ -1113,27 +1112,6 @@ execute_ranger_vrp (struct function *fun, bool warn_array_bounds_p,
if (dump_file && (dump_flags & TDF_DETAILS))
ranger->dump (dump_file);
- if ((warn_array_bounds || warn_strict_flex_arrays) && warn_array_bounds_p)
- {
- // Set all edges as executable, except those ranger says aren't.
- int non_exec_flag = ranger->non_executable_edge_flag;
- basic_block bb;
- FOR_ALL_BB_FN (bb, fun)
- {
- edge_iterator ei;
- edge e;
- FOR_EACH_EDGE (e, ei, bb->succs)
- if (e->flags & non_exec_flag)
- e->flags &= ~EDGE_EXECUTABLE;
- else
- e->flags |= EDGE_EXECUTABLE;
- }
- scev_reset ();
- array_bounds_checker array_checker (fun, ranger);
- array_checker.check ();
- }
-
-
if (Value_Range::supports_type_p (TREE_TYPE
(TREE_TYPE (current_function_decl)))
&& flag_ipa_vrp
@@ -1330,14 +1308,13 @@ const pass_data pass_data_fast_vrp =
class pass_vrp : public gimple_opt_pass
{
public:
- pass_vrp (gcc::context *ctxt, const pass_data &data_, bool warn_p)
- : gimple_opt_pass (data_, ctxt), data (data_),
- warn_array_bounds_p (warn_p), final_p (false)
+ pass_vrp (gcc::context *ctxt, const pass_data &data_)
+ : gimple_opt_pass (data_, ctxt), data (data_), final_p (false)
{ }
/* opt_pass methods: */
opt_pass * clone () final override
- { return new pass_vrp (m_ctxt, data, false); }
+ { return new pass_vrp (m_ctxt, data); }
void set_pass_param (unsigned int n, bool param) final override
{
gcc_assert (n == 0);
@@ -1350,12 +1327,11 @@ public:
if (&data == &pass_data_fast_vrp)
return execute_fast_vrp (fun);
- return execute_ranger_vrp (fun, warn_array_bounds_p, final_p);
+ return execute_ranger_vrp (fun, final_p);
}
private:
const pass_data &data;
- bool warn_array_bounds_p;
bool final_p;
}; // class pass_vrp
@@ -1426,19 +1402,19 @@ public:
gimple_opt_pass *
make_pass_vrp (gcc::context *ctxt)
{
- return new pass_vrp (ctxt, pass_data_vrp, true);
+ return new pass_vrp (ctxt, pass_data_vrp);
}
gimple_opt_pass *
make_pass_early_vrp (gcc::context *ctxt)
{
- return new pass_vrp (ctxt, pass_data_early_vrp, false);
+ return new pass_vrp (ctxt, pass_data_early_vrp);
}
gimple_opt_pass *
make_pass_fast_vrp (gcc::context *ctxt)
{
- return new pass_vrp (ctxt, pass_data_fast_vrp, false);
+ return new pass_vrp (ctxt, pass_data_fast_vrp);
}
gimple_opt_pass *