pass cfun to pass::execute
[gcc.git] / gcc / tree-ssa-loop-unswitch.c
index 9f4d4926a559cd44ab0e25d9c16fbef95f537e79..a9a27d7e70837b01d16d2c1c3761d1567c86e55e 100644 (file)
@@ -1,5 +1,5 @@
 /* Loop unswitching.
-   Copyright (C) 2004-2013 Free Software Foundation, Inc.
+   Copyright (C) 2004-2014 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -24,6 +24,10 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree.h"
 #include "tm_p.h"
 #include "basic-block.h"
+#include "tree-ssa-alias.h"
+#include "internal-fn.h"
+#include "gimple-expr.h"
+#include "is-a.h"
 #include "gimple.h"
 #include "gimplify.h"
 #include "gimple-ssa.h"
@@ -194,7 +198,7 @@ simplify_using_entry_checks (struct loop *loop, tree cond)
        return cond;
 
       e = single_pred_edge (e->src);
-      if (e->src == ENTRY_BLOCK_PTR)
+      if (e->src == ENTRY_BLOCK_PTR_FOR_FN (cfun))
        return cond;
     }
 }
@@ -398,21 +402,6 @@ tree_unswitch_loop (struct loop *loop,
 
 /* Loop unswitching pass.  */
 
-static unsigned int
-tree_ssa_loop_unswitch (void)
-{
-  if (number_of_loops (cfun) <= 1)
-    return 0;
-
-  return tree_ssa_unswitch_loops ();
-}
-
-static bool
-gate_tree_ssa_loop_unswitch (void)
-{
-  return flag_unswitch_loops != 0;
-}
-
 namespace {
 
 const pass_data pass_data_tree_unswitch =
@@ -420,7 +409,6 @@ const pass_data pass_data_tree_unswitch =
   GIMPLE_PASS, /* type */
   "unswitch", /* name */
   OPTGROUP_LOOP, /* optinfo_flags */
-  true, /* has_gate */
   true, /* has_execute */
   TV_TREE_LOOP_UNSWITCH, /* tv_id */
   PROP_cfg, /* properties_required */
@@ -438,11 +426,20 @@ public:
   {}
 
   /* opt_pass methods: */
-  bool gate () { return gate_tree_ssa_loop_unswitch (); }
-  unsigned int execute () { return tree_ssa_loop_unswitch (); }
+  virtual bool gate (function *) { return flag_unswitch_loops != 0; }
+  virtual unsigned int execute (function *);
 
 }; // class pass_tree_unswitch
 
+unsigned int
+pass_tree_unswitch::execute (function *fun)
+{
+  if (number_of_loops (fun) <= 1)
+    return 0;
+
+  return tree_ssa_unswitch_loops ();
+}
+
 } // anon namespace
 
 gimple_opt_pass *