public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, Pointer Bounds Checker 14/x] Passes [10/n] Stores handler
@ 2014-10-08 19:12 Ilya Enkovich
  2014-10-09 18:53 ` Jeff Law
  0 siblings, 1 reply; 4+ messages in thread
From: Ilya Enkovich @ 2014-10-08 19:12 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jeff Law

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);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH, Pointer Bounds Checker 14/x] Passes [10/n] Stores handler
  2014-10-08 19:12 [PATCH, Pointer Bounds Checker 14/x] Passes [10/n] Stores handler Ilya Enkovich
@ 2014-10-09 18:53 ` Jeff Law
  2014-10-13 11:23   ` Ilya Enkovich
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Law @ 2014-10-09 18:53 UTC (permalink / raw)
  To: Ilya Enkovich, gcc-patches

On 10/08/14 13:12, Ilya Enkovich wrote:
> 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.
This probably should have been part of the inliner submission since 
that's the only place its used and one needs the inliner context to know 
how this function is going to be used.

Presumably the reason its not in tree-inline and static is you want to 
utilize chkp_walk_pointer_assignments?

The code is fine, just want to make sure its goes into a logical place.

Jeff


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH, Pointer Bounds Checker 14/x] Passes [10/n] Stores handler
  2014-10-09 18:53 ` Jeff Law
@ 2014-10-13 11:23   ` Ilya Enkovich
  2014-10-13 17:01     ` Jeff Law
  0 siblings, 1 reply; 4+ messages in thread
From: Ilya Enkovich @ 2014-10-13 11:23 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc-patches

2014-10-09 22:51 GMT+04:00 Jeff Law <law@redhat.com>:
> On 10/08/14 13:12, Ilya Enkovich wrote:
>>
>> 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.
>
> This probably should have been part of the inliner submission since that's
> the only place its used and one needs the inliner context to know how this
> function is going to be used.
>
> Presumably the reason its not in tree-inline and static is you want to
> utilize chkp_walk_pointer_assignments?
>
> The code is fine, just want to make sure its goes into a logical place.
>
> Jeff
>
>

I have to export either chkp_copy_bounds_for_assign or
chkp_walk_pointer_assignments with chkp_copy_bounds_for_elem.  No much
difference but I'd prefer to keep all memrefs processing codes in
tree-chkp.c.

Ilya

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH, Pointer Bounds Checker 14/x] Passes [10/n] Stores handler
  2014-10-13 11:23   ` Ilya Enkovich
@ 2014-10-13 17:01     ` Jeff Law
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Law @ 2014-10-13 17:01 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: gcc-patches

On 10/13/14 05:23, Ilya Enkovich wrote:
> 2014-10-09 22:51 GMT+04:00 Jeff Law <law@redhat.com>:
>> On 10/08/14 13:12, Ilya Enkovich wrote:
>>>
>>> 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.
>>
>> This probably should have been part of the inliner submission since that's
>> the only place its used and one needs the inliner context to know how this
>> function is going to be used.
>>
>> Presumably the reason its not in tree-inline and static is you want to
>> utilize chkp_walk_pointer_assignments?
>>
>> The code is fine, just want to make sure its goes into a logical place.
>>
>> Jeff
>>
>>
>
> I have to export either chkp_copy_bounds_for_assign or
> chkp_walk_pointer_assignments with chkp_copy_bounds_for_elem.  No much
> difference but I'd prefer to keep all memrefs processing codes in
> tree-chkp.c.
OK.
jeff

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-10-13 16:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-08 19:12 [PATCH, Pointer Bounds Checker 14/x] Passes [10/n] Stores handler Ilya Enkovich
2014-10-09 18:53 ` Jeff Law
2014-10-13 11:23   ` Ilya Enkovich
2014-10-13 17:01     ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).