[PATCH, Pointer Bounds Checker 14/x] Passes [10/n] Stores handler

Ilya Enkovich enkovich.gnu@gmail.com
Wed Oct 8 19:12:00 GMT 2014


Hi,

This patch adds an assignment processing function which is used by lnliner for newly generated stores.

Thanks,
Ilya
--
2014-10-08  Ilya Enkovich  <ilya.enkovich@intel.com>

	* tree-chkp.c (chkp_copy_bounds_for_assign): New.
	* tree-chkp.h (chkp_copy_bounds_for_assign): New.


diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
index 4b5a773..6f73699 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -3781,6 +3781,43 @@ chkp_process_stmt (gimple_stmt_iterator *iter, tree node,
     }
 }
 
+/* Add code to copy bounds for all pointers copied
+   in ASSIGN created during inline of EDGE.  */
+void
+chkp_copy_bounds_for_assign (gimple assign, struct cgraph_edge *edge)
+{
+  tree lhs = gimple_assign_lhs (assign);
+  tree rhs = gimple_assign_rhs1 (assign);
+  gimple_stmt_iterator iter = gsi_for_stmt (assign);
+
+  if (!flag_chkp_store_bounds)
+    return;
+
+  chkp_walk_pointer_assignments (lhs, rhs, &iter, chkp_copy_bounds_for_elem);
+
+  /* We should create edges for all created calls to bndldx and bndstx.  */
+  while (gsi_stmt (iter) != assign)
+    {
+      gimple stmt = gsi_stmt (iter);
+      if (gimple_code (stmt) == GIMPLE_CALL)
+	{
+	  tree fndecl = gimple_call_fndecl (stmt);
+	  struct cgraph_node *callee = cgraph_node::get_create (fndecl);
+	  struct cgraph_edge *new_edge;
+
+	  gcc_assert (fndecl == chkp_bndstx_fndecl
+		      || fndecl == chkp_bndldx_fndecl
+		      || fndecl == chkp_ret_bnd_fndecl);
+
+	  new_edge = edge->caller->create_edge (callee, stmt, edge->count,
+						edge->frequency);
+	  new_edge->frequency = compute_call_stmt_bb_frequency
+	    (edge->caller->decl, gimple_bb (stmt));
+	}
+      gsi_prev (&iter);
+    }
+}
+
 /* Some code transformation made during instrumentation pass
    may put code into inconsistent state.  Here we find and fix
    such flaws.  */
diff --git a/gcc/tree-chkp.h b/gcc/tree-chkp.h
index 81306ba..9a3c55d 100644
--- a/gcc/tree-chkp.h
+++ b/gcc/tree-chkp.h
@@ -46,6 +46,8 @@ extern void chkp_build_bndstx (tree addr, tree ptr, tree bounds,
 extern gimple chkp_retbnd_call_by_val (tree val);
 extern bool chkp_function_instrumented_p (tree fndecl);
 extern void chkp_function_mark_instrumented (tree fndecl);
+extern void chkp_copy_bounds_for_assign (gimple assign,
+					 struct cgraph_edge *edge);
 extern bool chkp_gimple_call_builtin_p (gimple call,
 					enum built_in_function code);
 extern void chkp_expand_bounds_reset_for_mem (tree mem, tree ptr);



More information about the Gcc-patches mailing list