This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2] vrp_prop: Use dom_walker for -Warray-bounds (PR tree-optimization/83312)


On 13 December 2017 22:30:12 CET, David Malcolm <dmalcolm@redhat.com> wrote:
 
>-/* Walk over all statements of all reachable BBs and call
>check_array_bounds
>-   on them.  */
>+/* A dom_walker subclass for use by vrp_prop::check_all_array_refs,
>+   to walk over all statements of all reachable BBs and call

Not all statements, see below.

>+   check_array_bounds on them.  */
> 
>-void
>-vrp_prop::check_all_array_refs ()
>+class check_array_bounds_dom_walker : public dom_walker
> {
>-  basic_block bb;
>-  gimple_stmt_iterator si;
>+ public:
>+  check_array_bounds_dom_walker (vrp_prop *prop)
>+    : dom_walker (CDI_DOMINATORS, true), m_prop (prop) {}
>+  ~check_array_bounds_dom_walker () {}
> 
>-  FOR_EACH_BB_FN (bb, cfun)
>-    {
>-      edge_iterator ei;
>-      edge e;
>-      bool executable = false;
>+  edge before_dom_children (basic_block) FINAL OVERRIDE;
> 
>-      /* Skip blocks that were found to be unreachable.  */
>-      FOR_EACH_EDGE (e, ei, bb->preds)
>-	executable |= !!(e->flags & EDGE_EXECUTABLE);
>-      if (!executable)
>-	continue;
>+ private:
>+  vrp_prop *m_prop;
>+};
> 
>-      for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
>-	{
>-	  gimple *stmt = gsi_stmt (si);
>-	  struct walk_stmt_info wi;
>-	  if (!gimple_has_location (stmt)
>-	      || is_gimple_debug (stmt))
>-	    continue;
>+/* Implementation of dom_walker::before_dom_children.
> 
>-	  memset (&wi, 0, sizeof (wi));
>+   Walk over all statements of BB and call check_array_bounds on them,

Not all but all non-debug statements of BB with location (which statements don't, here?)

>+   and determine if there's a unique successor edge.  */
> 
>-	  wi.info = this;
>+edge
>+check_array_bounds_dom_walker::before_dom_children (basic_block bb)
>+{
>+  gimple_stmt_iterator si;
>+  for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))

for (si = gsi_start_nondebug_bb (bb); !gsi_end_p (si); gsi_next_nondebug (&si))

assuming you want to walk also phis(?).

>+    {
>+      gimple *stmt = gsi_stmt (si);
>+      struct walk_stmt_info wi;
>+      if (!gimple_has_location (stmt)

Hence:
- >+	  || is_gimple_debug (stmt))
>+	continue;

thanks, 
> 
>-	  walk_gimple_op (gsi_stmt (si),
>-			  check_array_bounds,
>-			  &wi);
>-	}
>+      memset (&wi, 0, sizeof (wi));
>+
>+      wi.info = m_prop;
>+
>+      walk_gimple_op (stmt, check_array_bounds, &wi);
>     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]