]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/tree-chkp-opt.c
Update copyright years.
[thirdparty/gcc.git] / gcc / tree-chkp-opt.c
index ff390d7bb3ddc0a9cc2d9660d502a09479519d04..6c84caee8ce7d3de35c3758969f983155bb7b9b1 100644 (file)
@@ -1,5 +1,5 @@
 /* Pointer Bounds Checker optimization pass.
-   Copyright (C) 2014 Free Software Foundation, Inc.
+   Copyright (C) 2014-2017 Free Software Foundation, Inc.
    Contributed by Ilya Enkovich (ilya.enkovich@intel.com)
 
 This file is part of GCC.
@@ -21,37 +21,21 @@ along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
-#include "tree-core.h"
-#include "tree.h"
+#include "backend.h"
 #include "target.h"
-#include "tree-cfg.h"
-#include "tree-pass.h"
-#include "is-a.h"
-#include "cfgloop.h"
-#include "stringpool.h"
-#include "tree-ssa-alias.h"
-#include "tree-ssanames.h"
-#include "tree-ssa-operands.h"
-#include "tree-ssa-address.h"
-#include "tree-ssa.h"
-#include "predict.h"
-#include "dominance.h"
-#include "cfg.h"
-#include "basic-block.h"
-#include "tree-ssa-loop-niter.h"
-#include "gimple-expr.h"
+#include "rtl.h"
+#include "tree.h"
 #include "gimple.h"
-#include "tree-phinodes.h"
-#include "gimple-ssa.h"
-#include "ssa-iterators.h"
+#include "tree-pass.h"
+#include "ssa.h"
 #include "gimple-pretty-print.h"
+#include "diagnostic.h"
+#include "fold-const.h"
+#include "tree-cfg.h"
+#include "tree-ssa-loop-niter.h"
 #include "gimple-iterator.h"
-#include "gimplify.h"
-#include "gimplify-me.h"
-#include "expr.h"
 #include "tree-chkp.h"
 #include "ipa-chkp.h"
-#include "diagnostic.h"
 
 enum check_type
 {
@@ -80,7 +64,7 @@ struct check_info
   /* Bounds used for the check.  */
   tree bounds;
   /* Check statement.  Can be NULL for removed checks.  */
-  gimple stmt;
+  gimple *stmt;
 };
 
 /* Structure to hold checks information for BB.  */
@@ -100,7 +84,7 @@ static void chkp_collect_value (tree ssa_name, address_t &res);
 #define chkp_checku_fndecl \
   (targetm.builtin_chkp_function (BUILT_IN_CHKP_BNDCU))
 
-static vec<struct bb_checks, va_heap, vl_ptr> check_infos = vNULL;
+static vec<struct bb_checks, va_heap, vl_ptr> check_infos;
 
 /* Comparator for pol_item structures I1 and I2 to be used
    to find items with equal var.  Also used for polynomial
@@ -353,7 +337,7 @@ chkp_collect_addr_value (tree ptr, address_t &res)
 static void
 chkp_collect_value (tree ptr, address_t &res)
 {
-  gimple def_stmt;
+  gimple *def_stmt;
   enum gimple_code code;
   enum tree_code rhs_code;
   address_t addr;
@@ -442,7 +426,7 @@ chkp_collect_value (tree ptr, address_t &res)
 /* Fill check_info structure *CI with information about
    check STMT.  */
 static void
-chkp_fill_check_info (gimple stmt, struct check_info *ci)
+chkp_fill_check_info (gimple *stmt, struct check_info *ci)
 {
   ci->addr.pol.create (0);
   ci->bounds = gimple_call_arg (stmt, 1);
@@ -515,7 +499,7 @@ chkp_gather_checks_info (void)
 
       for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
         {
-         gimple stmt = gsi_stmt (i);
+         gimple *stmt = gsi_stmt (i);
 
          if (gimple_code (stmt) != GIMPLE_CALL)
            continue;
@@ -549,7 +533,7 @@ chkp_gather_checks_info (void)
 static int
 chkp_get_check_result (struct check_info *ci, tree bounds)
 {
-  gimple bnd_def;
+  gimple *bnd_def;
   address_t bound_val;
   int sign, res = 0;
 
@@ -626,7 +610,7 @@ chkp_get_check_result (struct check_info *ci, tree bounds)
       chkp_collect_value (DECL_INITIAL (bnd_var), bound_val);
       if (ci->type == CHECK_UPPER_BOUND)
        {
-         if (TREE_CODE (var) == VAR_DECL)
+         if (VAR_P (var))
            {
              if (DECL_SIZE (var)
                  && !chkp_variable_size_type (TREE_TYPE (var)))
@@ -747,7 +731,7 @@ chkp_remove_check_if_pass (struct check_info *ci)
 static void
 chkp_use_outer_bounds_if_possible (struct check_info *ci)
 {
-  gimple bnd_def;
+  gimple *bnd_def;
   tree bnd1, bnd2, bnd_res = NULL;
   int check_res1, check_res2;
 
@@ -977,7 +961,7 @@ chkp_optimize_string_function_calls (void)
 
       for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
         {
-         gimple stmt = gsi_stmt (i);
+         gimple *stmt = gsi_stmt (i);
          tree fndecl;
 
          if (gimple_code (stmt) != GIMPLE_CALL
@@ -1061,11 +1045,11 @@ chkp_optimize_string_function_calls (void)
                 checks only when size is not zero.  */
              if (!known)
                {
-                 gimple check = gimple_build_cond (NE_EXPR,
-                                                   size,
-                                                   size_zero_node,
-                                                   NULL_TREE,
-                                                   NULL_TREE);
+                 gimple *check = gimple_build_cond (NE_EXPR,
+                                                    size,
+                                                    size_zero_node,
+                                                    NULL_TREE,
+                                                    NULL_TREE);
 
                  /* Split block before string function call.  */
                  gsi_prev (&i);
@@ -1118,7 +1102,7 @@ chkp_reduce_bounds_lifetime (void)
 
   for (i = gsi_start_bb (bb); !gsi_end_p (i); )
     {
-      gimple dom_use, use_stmt, stmt = gsi_stmt (i);
+      gimple *dom_use, *use_stmt, *stmt = gsi_stmt (i);
       basic_block dom_bb;
       ssa_op_iter iter;
       imm_use_iterator use_iter;
@@ -1175,6 +1159,9 @@ chkp_reduce_bounds_lifetime (void)
 
       FOR_EACH_IMM_USE_STMT (use_stmt, use_iter, op)
        {
+         if (is_gimple_debug (use_stmt))
+           continue;
+
          if (dom_bb &&
              dominated_by_p (CDI_DOMINATORS,
                              dom_bb, gimple_bb (use_stmt)))
@@ -1249,6 +1236,8 @@ chkp_reduce_bounds_lifetime (void)
                  gsi_move_before (&i, &gsi);
                }
 
+             gimple_set_vdef (stmt, NULL_TREE);
+             gimple_set_vuse (stmt, NULL_TREE);
              update_stmt (stmt);
            }
        }
@@ -1278,6 +1267,8 @@ static void
 chkp_opt_fini (void)
 {
   chkp_fix_cfg ();
+
+  free_dominance_info (CDI_POST_DOMINATORS);
 }
 
 /* Checker optimization pass function.  */