]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Remove first_pass_instance from pass_vrp
authorTom de Vries <tom@codesourcery.com>
Mon, 16 Nov 2015 12:40:05 +0000 (12:40 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Mon, 16 Nov 2015 12:40:05 +0000 (12:40 +0000)
2015-11-16  Tom de Vries  <tom@codesourcery.com>

* gdbhooks.py (class PassNames): Handle extra arg NEXT_PASS argument.
* gen-pass-instances.awk (handle_line): Same.
* pass_manager.h (class pass_manager): Define and undefine
NEXT_PASS_WITH_ARG.
* passes.c (opt_pass::set_pass_param): New function.
(pass_manager::pass_manager): Define and undefine NEXT_PASS_WITH_ARG.
* passes.def: Add extra arg to NEXT_PASS (pass_vrp).
* tree-pass.h (gimple_opt::set_pass_param): Declare.
* tree-vrp.c (vrp_finalize, execute_vrp): Add and handle
warn_array_bounds_p parameter.
(pass_vrp::pass_vrp): Initialize warn_array_bounds_p.
(pass_vrp::set_pass_param): New function.
(pass_vrp::execute): Add warn_array_bounds_p arg to execute_vrp call.
(pass_vrp::warn_array_bounds_p): New private member.

From-SVN: r230415

gcc/ChangeLog
gcc/gdbhooks.py
gcc/gen-pass-instances.awk
gcc/pass_manager.h
gcc/passes.c
gcc/passes.def
gcc/tree-pass.h
gcc/tree-vrp.c

index 889f434c0498da6dd29dfccf176988827216413f..e6e4fbee015417ff4c82c5aa763d6cfa01f0d1ab 100644 (file)
@@ -1,3 +1,20 @@
+2015-11-16  Tom de Vries  <tom@codesourcery.com>
+
+       * gdbhooks.py (class PassNames): Handle extra arg NEXT_PASS argument.
+       * gen-pass-instances.awk (handle_line): Same.
+       * pass_manager.h (class pass_manager): Define and undefine
+       NEXT_PASS_WITH_ARG.
+       * passes.c (opt_pass::set_pass_param): New function.
+       (pass_manager::pass_manager): Define and undefine NEXT_PASS_WITH_ARG.
+       * passes.def: Add extra arg to NEXT_PASS (pass_vrp).
+       * tree-pass.h (gimple_opt::set_pass_param): Declare.
+       * tree-vrp.c (vrp_finalize, execute_vrp): Add and handle
+       warn_array_bounds_p parameter.
+       (pass_vrp::pass_vrp): Initialize warn_array_bounds_p.
+       (pass_vrp::set_pass_param): New function.
+       (pass_vrp::execute): Add warn_array_bounds_p arg to execute_vrp call.
+       (pass_vrp::warn_array_bounds_p): New private member.
+
 2015-11-16  Eric Botcazou  <ebotcazou@adacore.com>
 
        * config/sparc/sparc.c (sparc_emit_probe_stack_range): Adjust.
index 2b9a94ca9f74b39d13d915b7fc3837a9826a016b..f920392b17f56b44a786ca1bcf90c0074209667f 100644 (file)
@@ -537,7 +537,7 @@ class PassNames:
         self.names = []
         with open(os.path.join(srcdir, 'passes.def')) as f:
             for line in f:
-                m = re.match('\s*NEXT_PASS \((.+)\);', line)
+                m = re.match('\s*NEXT_PASS \(([^,]+).*\);', line)
                 if m:
                     self.names.append(m.group(1))
 
index 9cff4297388c62aab7a04f7dddc98d8914812645..106a2f69a9e841c3eb5197d8ae7479824335508b 100644 (file)
@@ -61,12 +61,14 @@ function handle_line()
        len_of_args = len_of_call - (len_of_start + len_of_close);
        args_start_at = call_starts_at + len_of_start;
        args_str = substr(line, args_start_at, len_of_args);
+       split(args_str, args, ",");
 
-       # Set pass_name argument
-       pass_name = args_str;
+       # Set pass_name argument, an optional with_arg argument
+       pass_name = args[1];
+       with_arg = args[2];
 
-       # Find call expression prefix (until and including called function)
-       len_of_prefix = args_start_at - 1 - len_of_open;
+       # Find call expression prefix
+       len_of_prefix = call_starts_at - 1;
        prefix = substr(line, 1, len_of_prefix);
 
        # Find call expression postfix
@@ -82,7 +84,23 @@ function handle_line()
        pass_num = pass_counts[pass_name];
 
        # Print call expression with extra pass_num argument
-       printf "%s(%s, %s)%s\n", prefix, pass_name, pass_num, postfix;
+       printf "%s", prefix;
+       if (with_arg)
+       {
+               printf "NEXT_PASS_WITH_ARG";
+       }
+       else
+       {
+               printf "NEXT_PASS";
+       }
+       printf " (";
+       printf "%s", pass_name;
+       printf ", %s", pass_num;
+       if (with_arg)
+       {
+               printf ", %s", with_arg;
+       }
+       printf ")%s\n", postfix;
 }
 
 { handle_line() }
index 7d539e47aa81722a8d30317ad7184d38abf6bfe6..a8199e2f4138dca213933b89adff7d3992d3eac2 100644 (file)
@@ -120,6 +120,7 @@ private:
 #define PUSH_INSERT_PASSES_WITHIN(PASS)
 #define POP_INSERT_PASSES()
 #define NEXT_PASS(PASS, NUM) opt_pass *PASS ## _ ## NUM
+#define NEXT_PASS_WITH_ARG(PASS, NUM, ARG) NEXT_PASS (PASS, NUM)
 #define TERMINATE_PASS_LIST()
 
 #include "pass-instances.def"
@@ -128,6 +129,7 @@ private:
 #undef PUSH_INSERT_PASSES_WITHIN
 #undef POP_INSERT_PASSES
 #undef NEXT_PASS
+#undef NEXT_PASS_WITH_ARG
 #undef TERMINATE_PASS_LIST
 
 }; // class pass_manager
index dd8d00ad36af11ad728a2adf975d326acc6d716e..e634c5c7985a2ded85ce0a68aff289b2ab79f802 100644 (file)
@@ -81,6 +81,13 @@ opt_pass::clone ()
   internal_error ("pass %s does not support cloning", name);
 }
 
+void
+opt_pass::set_pass_param (unsigned int, bool)
+{
+  internal_error ("pass %s needs a set_pass_param implementation to handle the"
+                 " extra argument in NEXT_PASS", name);
+}
+
 bool
 opt_pass::gate (function *)
 {
@@ -1572,6 +1579,12 @@ pass_manager::pass_manager (context *ctxt)
     p = next_pass_1 (p, PASS ## _ ## NUM, PASS ## _1);  \
   } while (0)
 
+#define NEXT_PASS_WITH_ARG(PASS, NUM, ARG)             \
+    do {                                               \
+      NEXT_PASS (PASS, NUM);                           \
+      PASS ## _ ## NUM->set_pass_param (0, ARG);       \
+    } while (0)
+
 #define TERMINATE_PASS_LIST() \
   *p = NULL;
 
@@ -1581,6 +1594,7 @@ pass_manager::pass_manager (context *ctxt)
 #undef PUSH_INSERT_PASSES_WITHIN
 #undef POP_INSERT_PASSES
 #undef NEXT_PASS
+#undef NEXT_PASS_WITH_ARG
 #undef TERMINATE_PASS_LIST
 
   /* Register the passes with the tree dump code.  */
index db822d335971a059bf4cc2c7fc41b1435ef50812..64c1fa109152ed46271888d2bb283aa00d684972 100644 (file)
@@ -171,7 +171,7 @@ along with GCC; see the file COPYING3.  If not see
       NEXT_PASS (pass_return_slot);
       NEXT_PASS (pass_fre);
       NEXT_PASS (pass_merge_phi);
-      NEXT_PASS (pass_vrp);
+      NEXT_PASS (pass_vrp, true /* warn_array_bounds_p */);
       NEXT_PASS (pass_chkp_opt);
       NEXT_PASS (pass_dce);
       NEXT_PASS (pass_stdarg);
@@ -281,7 +281,7 @@ along with GCC; see the file COPYING3.  If not see
       NEXT_PASS (pass_tracer);
       NEXT_PASS (pass_dominator);
       NEXT_PASS (pass_strlen);
-      NEXT_PASS (pass_vrp);
+      NEXT_PASS (pass_vrp, false /* warn_array_bounds_p */);
       /* The only const/copy propagation opportunities left after
         DOM and VRP should be due to degenerate PHI nodes.  So rather than
         run the full propagators, run a specialized pass which
index da67761782688e0135c5f6373c726b5a82bf7cab..a672d528b0344b076c1e9898af83f0235663d876 100644 (file)
@@ -83,6 +83,7 @@ public:
 
      The default implementation prints an error message and aborts.  */
   virtual opt_pass *clone ();
+  virtual void set_pass_param (unsigned int, bool);
 
   /* This pass and all sub-passes are executed only if the function returns
      true.  The default implementation returns true.  */
index e2393e4d3a06c184ef5e4a27e9e931022e137cb9..5d085b42d458878eed6deffc982cd3ee52f87011 100644 (file)
@@ -10183,7 +10183,7 @@ finalize_jump_threads (void)
 /* Traverse all the blocks folding conditionals with known ranges.  */
 
 static void
-vrp_finalize (void)
+vrp_finalize (bool warn_array_bounds_p)
 {
   size_t i;
 
@@ -10199,7 +10199,7 @@ vrp_finalize (void)
   substitute_and_fold (op_with_constant_singleton_value_range,
                       vrp_fold_stmt, false);
 
-  if (warn_array_bounds && first_pass_instance)
+  if (warn_array_bounds && warn_array_bounds_p)
     check_all_array_refs ();
 
   /* We must identify jump threading opportunities before we release
@@ -10289,7 +10289,7 @@ vrp_finalize (void)
    probabilities to aid branch prediction.  */
 
 static unsigned int
-execute_vrp (void)
+execute_vrp (bool warn_array_bounds_p)
 {
   int i;
   edge e;
@@ -10313,7 +10313,7 @@ execute_vrp (void)
 
   vrp_initialize ();
   ssa_propagate (vrp_visit_stmt, vrp_visit_phi_node);
-  vrp_finalize ();
+  vrp_finalize (warn_array_bounds_p);
 
   free_numbers_of_iterations_estimates (cfun);
 
@@ -10386,14 +10386,22 @@ class pass_vrp : public gimple_opt_pass
 {
 public:
   pass_vrp (gcc::context *ctxt)
-    : gimple_opt_pass (pass_data_vrp, ctxt)
+    : gimple_opt_pass (pass_data_vrp, ctxt), warn_array_bounds_p (false)
   {}
 
   /* opt_pass methods: */
   opt_pass * clone () { return new pass_vrp (m_ctxt); }
+  void set_pass_param (unsigned int n, bool param)
+    {
+      gcc_assert (n == 0);
+      warn_array_bounds_p = param;
+    }
   virtual bool gate (function *) { return flag_tree_vrp != 0; }
-  virtual unsigned int execute (function *) { return execute_vrp (); }
+  virtual unsigned int execute (function *)
+    { return execute_vrp (warn_array_bounds_p); }
 
+ private:
+  bool warn_array_bounds_p;
 }; // class pass_vrp
 
 } // anon namespace