Message ID | 20141008191247.GJ13454@msticlxl57.ims.intel.com |
---|---|
State | New |
Headers | show |
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
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
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
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);