Re: [PATCH, MPX, 2/X] Pointers Checker [1/25] Hooks

2013-10-28 Thread Ilya Enkovich
On 24 Oct 23:21, Jeff Law wrote:
 On 10/24/13 02:24, Ilya Enkovich wrote:
 These two hooks are used by expand pass to pass/receive bounds for
 args. When bounds are passed in a register, expand does not need this
 hook and uses regular move insn. If we are out of bound register or
 platform does not have them at all, this hook is called. If bounded
 arg is passed in memory, regular way to store associated bounds is
 supposed to be used in hook. That is why no slot_no value is required,
 only arg and it's place (slot) are used. If bounded arg is passed in
 register (e.g. it happens on i386 with MPX when more that 4 pointers
 are passed in registers), then some special slot has to be used for
 bounds. slot_no here holds identifier of this special slot. E.g. if we
 call function with 6 pointer on i386, we call this hook passing R8 and
 R9 as slot with const1_rtx and const2_rtx as slot_no.
 So can we find a concise way to describe this and include that in
 the docs for the hooks.  Otherwise I can't see how a developer is
 going to know how to use this stuff.
 
 So how am I (as a GCC developer) suppsoed to know what BNDMK, BNDLDX, BNDCU,
 etc mean?  The names aren't particularly descriptive.  Are these documented
 elsewhere in a follow-up patch?  If not, it seems to me we need to document
 them here.
 
 Actually the next patch introduces them and is a good place for
 documentation. But currently this patch has documentation for user
 visible built-ins only. For now built-ins used for instrumentation are
 described on Wiki only
 (http://gcc.gnu.org/wiki/Intel%20MPX%20support%20in%20the%20GCC%20compiler#Builtins_used_for_instrumentation).
 Where should I move it? Does it also go to extend.texi?
 If they're strictly for developers, then there's not a real good
 place for them.  They're not really extensions we would expect the
 user to use, so extend.texi seems inappropriate.
 
 Perhaps a section in tm.texi?
 
 Jeff
 

I fixed documentation for bounds load/store hooks.  Also added documentation 
for list of builtins returned by builtin_chkp_function.

Thanks,
Ilya
--

gcc/

2013-10-28  Ilya Enkovich  ilya.enkov...@intel.com

* target.def (builtin_chkp_function): New.
(chkp_bound_type): New.
(chkp_bound_mode): New.
(fn_abi_va_list_bounds_size): New.
(load_bounds_for_arg): New.
(store_bounds_for_arg): New.
* targhooks.h (default_load_bounds_for_arg): New.
(default_store_bounds_for_arg): New.
(default_fn_abi_va_list_bounds_size): New.
(default_chkp_bound_type): New.
(default_chkp_bound_mode): New.
(default_builtin_chkp_function): New.
* targhooks.c (default_load_bounds_for_arg): New.
(default_store_bounds_for_arg): New.
(default_fn_abi_va_list_bounds_size): New.
(default_chkp_bound_type): New.
(default_chkp_bound_mode); New.
(default_builtin_chkp_function): New.
* doc/tm.texi.in (TARGET_FN_ABI_VA_LIST_BOUNDS_SIZE): New.
(TARGET_LOAD_BOUNDS_FOR_ARG): New.
(TARGET_STORE_BOUNDS_FOR_ARG): New.
(TARGET_BUILTIN_CHKP_FUNCTION): New.
(TARGET_CHKP_BOUND_TYPE): New.
(TARGET_CHKP_BOUND_MODE): New.
* doc/tm.texi: Regenerated.
* langhooks.h (lang_hooks): Add chkp_supported field.
* langhooks-def.h (LANG_HOOKS_CHKP_SUPPORTED): New.
(LANG_HOOKS_INITIALIZER); Add LANG_HOOKS_CHKP_SUPPORTED.


diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 8d220f3..c60ebef 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -4334,6 +4334,13 @@ This hook returns the va_list type of the calling 
convention specified by
 The default version of this hook returns @code{va_list_type_node}.
 @end deftypefn
 
+@deftypefn {Target Hook} tree TARGET_FN_ABI_VA_LIST_BOUNDS_SIZE (tree 
@var{fndecl})
+This hook returns size for @code{va_list} object in function specified
+by @var{fndecl}.  This hook is used by Pointer Bounds Checker to build bounds
+for @code{va_list} object.  Return @code{integer_zero_node} if no bounds
+should be used (e.g. @code{va_list} is a scalar pointer to the stack).
+@end deftypefn
+
 @deftypefn {Target Hook} tree TARGET_CANONICAL_VA_LIST_TYPE (tree @var{type})
 This hook returns the va_list type of the calling convention specified by the
 type of @var{type}. If @var{type} is not a valid va_list type, it returns
@@ -5151,6 +5158,26 @@ defined, then define this hook to return @code{true} if
 Otherwise, you should not define this hook.
 @end deftypefn
 
+@deftypefn {Target Hook} rtx TARGET_LOAD_BOUNDS_FOR_ARG (rtx @var{slot}, rtx 
@var{arg}, rtx @var{slot_no})
+This hook is used by expand pass to emit insn to load bounds of
+@var{arg} passed in @var{slot}.  Expand pass uses this hook in case
+bounds of @var{arg} are not passed in register.  If @var{slot} is a
+memory, then bounds are loaded as for regular pointer loaded from
+memory.  If @var{slot} is not a memory then @var{slot_no} is an integer
+constant holding 

Re: [PATCH, MPX, 2/X] Pointers Checker [1/25] Hooks

2013-10-28 Thread Jeff Law

On 10/28/13 09:12, Ilya Enkovich wrote:

I fixed documentation for bounds load/store hooks.  Also added documentation 
for list of builtins returned by builtin_chkp_function.

Thanks,
Ilya
--

gcc/

2013-10-28  Ilya Enkovich  ilya.enkov...@intel.com

* target.def (builtin_chkp_function): New.
(chkp_bound_type): New.
(chkp_bound_mode): New.
(fn_abi_va_list_bounds_size): New.
(load_bounds_for_arg): New.
(store_bounds_for_arg): New.
* targhooks.h (default_load_bounds_for_arg): New.
(default_store_bounds_for_arg): New.
(default_fn_abi_va_list_bounds_size): New.
(default_chkp_bound_type): New.
(default_chkp_bound_mode): New.
(default_builtin_chkp_function): New.
* targhooks.c (default_load_bounds_for_arg): New.
(default_store_bounds_for_arg): New.
(default_fn_abi_va_list_bounds_size): New.
(default_chkp_bound_type): New.
(default_chkp_bound_mode); New.
(default_builtin_chkp_function): New.
* doc/tm.texi.in (TARGET_FN_ABI_VA_LIST_BOUNDS_SIZE): New.
(TARGET_LOAD_BOUNDS_FOR_ARG): New.
(TARGET_STORE_BOUNDS_FOR_ARG): New.
(TARGET_BUILTIN_CHKP_FUNCTION): New.
(TARGET_CHKP_BOUND_TYPE): New.
(TARGET_CHKP_BOUND_MODE): New.
* doc/tm.texi: Regenerated.
* langhooks.h (lang_hooks): Add chkp_supported field.
* langhooks-def.h (LANG_HOOKS_CHKP_SUPPORTED): New.
(LANG_HOOKS_INITIALIZER); Add LANG_HOOKS_CHKP_SUPPORTED.

This is fine.

Please install after a bootstrap test to ensure everything builds correctly.

Thanks,
Jeff



Re: [PATCH, MPX, 2/X] Pointers Checker [1/25] Hooks

2013-10-24 Thread Ilya Enkovich
2013/10/24 Jeff Law l...@redhat.com:
 On 10/21/13 08:20, Ilya Enkovich wrote:

 diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
 index 8d220f3..79bd0f9 100644
 --- a/gcc/doc/tm.texi
 +++ b/gcc/doc/tm.texi
 +@deftypefn {Target Hook} rtx TARGET_LOAD_BOUNDS_FOR_ARG (rtx @var{slot},
 rtx @var{arg}, rtx @var{slot_no})
 +This hook is used to emit insn to load bounds of @var{arg} passed
 +in @var{slot}.  In case @var{slot} is not a memory, @var{slot_no} is RTX
 +constant holding number of the special slot we should get bounds from.
 +Return loaded bounds.
 +@end deftypefn
 +
 +@deftypefn {Target Hook} void TARGET_STORE_BOUNDS_FOR_ARG (rtx @var{arg},
 rtx @var{slot}, rtx @var{bounds}, rtx @var{slot_no})
 +This hook is used to emit insn to store bounds of @var{arg} passed
 +in @var{slot}.  In case @var{slot} is not a memory, @var{slot_no} is RTX
 +constant holding number of the special slot we should store bounds to.
 +@end deftypefn
 +

 Almost there. What I think is missing is more information about the case
 where SLOT is not a memory (presumably it's a reg) and how that relates to
 SLOT_NO.

 Isn't this just providing a mapping from the input argument registers to
 some set of bounds pointer registers?  Presumably you aren't really exposing
 the bound registers as argument registers hence this hack?

 Not asking you to change anything, just trying to understand the rationale.



These two hooks are used by expand pass to pass/receive bounds for
args. When bounds are passed in a register, expand does not need this
hook and uses regular move insn. If we are out of bound register or
platform does not have them at all, this hook is called. If bounded
arg is passed in memory, regular way to store associated bounds is
supposed to be used in hook. That is why no slot_no value is required,
only arg and it's place (slot) are used. If bounded arg is passed in
register (e.g. it happens on i386 with MPX when more that 4 pointers
are passed in registers), then some special slot has to be used for
bounds. slot_no here holds identifier of this special slot. E.g. if we
call function with 6 pointer on i386, we call this hook passing R8 and
R9 as slot with const1_rtx and const2_rtx as slot_no.




   @node Trampolines
   @section Trampolines for Nested Functions
   @cindex trampolines for nested functions
 @@ -10907,6 +10927,27 @@ ignored.  This function should return the result
 of the call to the
   built-in function.
   @end deftypefn

 +@deftypefn {Target Hook} tree TARGET_BUILTIN_CHKP_FUNCTION (unsigned
 @var{fcode})
 +This hook allows target to redefine built-in functions used by
 +Pointers Checker for code instrumentation.  Hook should return
 +fndecl of function implementing generic builtin whose code is
 +passed in @var{fcode}.  Currently following built-in functions are
 +obtained using this hook:
 +@code{BUILT_IN_CHKP_BNDMK}, @code{BUILT_IN_CHKP_BNDSTX},
 +@code{BUILT_IN_CHKP_BNDLDX}, @code{BUILT_IN_CHKP_BNDCL},
 +@code{BUILT_IN_CHKP_BNDCU}, @code{BUILT_IN_CHKP_BNDRET},
 +@code{BUILT_IN_CHKP_INTERSECT}, @code{BUILT_IN_CHKP_SET_PTR_BOUNDS},
 +@code{BUILT_IN_CHKP_NARROW}, @code{BUILT_IN_CHKP_ARG_BND},
 +@code{BUILT_IN_CHKP_SIZEOF}, @code{BUILT_IN_CHKP_EXTRACT_LOWER},
 +@code{BUILT_IN_CHKP_EXTRACT_UPPER}.
 +@end deftypefn
 +@deftypefn {Target Hook} tree TARGET_CHKP_BOUND_TYPE (void)
 +Return type to be used for bounds
 +@end deftypefn
 +@deftypefn {Target Hook} {enum machine_mode} TARGET_CHKP_BOUND_MODE
 (void)
 +Return mode to be used for bounds.
 +@end deftypefn

 So how am I (as a GCC developer) suppsoed to know what BNDMK, BNDLDX, BNDCU,
 etc mean?  The names aren't particularly descriptive.  Are these documented
 elsewhere in a follow-up patch?  If not, it seems to me we need to document
 them here.

Actually the next patch introduces them and is a good place for
documentation. But currently this patch has documentation for user
visible built-ins only. For now built-ins used for instrumentation are
described on Wiki only
(http://gcc.gnu.org/wiki/Intel%20MPX%20support%20in%20the%20GCC%20compiler#Builtins_used_for_instrumentation).
Where should I move it? Does it also go to extend.texi?

Thanks,
Ilya


 Jeff



Re: [PATCH, MPX, 2/X] Pointers Checker [1/25] Hooks

2013-10-24 Thread Jeff Law

On 10/24/13 02:24, Ilya Enkovich wrote:

2013/10/24 Jeff Law l...@redhat.com:

On 10/21/13 08:20, Ilya Enkovich wrote:


diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 8d220f3..79bd0f9 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
+@deftypefn {Target Hook} rtx TARGET_LOAD_BOUNDS_FOR_ARG (rtx @var{slot},
rtx @var{arg}, rtx @var{slot_no})
+This hook is used to emit insn to load bounds of @var{arg} passed
+in @var{slot}.  In case @var{slot} is not a memory, @var{slot_no} is RTX
+constant holding number of the special slot we should get bounds from.
+Return loaded bounds.
+@end deftypefn
+
+@deftypefn {Target Hook} void TARGET_STORE_BOUNDS_FOR_ARG (rtx @var{arg},
rtx @var{slot}, rtx @var{bounds}, rtx @var{slot_no})
+This hook is used to emit insn to store bounds of @var{arg} passed
+in @var{slot}.  In case @var{slot} is not a memory, @var{slot_no} is RTX
+constant holding number of the special slot we should store bounds to.
+@end deftypefn
+


Almost there. What I think is missing is more information about the case
where SLOT is not a memory (presumably it's a reg) and how that relates to
SLOT_NO.

Isn't this just providing a mapping from the input argument registers to
some set of bounds pointer registers?  Presumably you aren't really exposing
the bound registers as argument registers hence this hack?

Not asking you to change anything, just trying to understand the rationale.




These two hooks are used by expand pass to pass/receive bounds for
args. When bounds are passed in a register, expand does not need this
hook and uses regular move insn. If we are out of bound register or
platform does not have them at all, this hook is called. If bounded
arg is passed in memory, regular way to store associated bounds is
supposed to be used in hook. That is why no slot_no value is required,
only arg and it's place (slot) are used. If bounded arg is passed in
register (e.g. it happens on i386 with MPX when more that 4 pointers
are passed in registers), then some special slot has to be used for
bounds. slot_no here holds identifier of this special slot. E.g. if we
call function with 6 pointer on i386, we call this hook passing R8 and
R9 as slot with const1_rtx and const2_rtx as slot_no.
So can we find a concise way to describe this and include that in the 
docs for the hooks.  Otherwise I can't see how a developer is going to 
know how to use this stuff.



So how am I (as a GCC developer) suppsoed to know what BNDMK, BNDLDX, BNDCU,
etc mean?  The names aren't particularly descriptive.  Are these documented
elsewhere in a follow-up patch?  If not, it seems to me we need to document
them here.


Actually the next patch introduces them and is a good place for
documentation. But currently this patch has documentation for user
visible built-ins only. For now built-ins used for instrumentation are
described on Wiki only
(http://gcc.gnu.org/wiki/Intel%20MPX%20support%20in%20the%20GCC%20compiler#Builtins_used_for_instrumentation).
Where should I move it? Does it also go to extend.texi?
If they're strictly for developers, then there's not a real good place 
for them.  They're not really extensions we would expect the user to 
use, so extend.texi seems inappropriate.


Perhaps a section in tm.texi?

Jeff



Re: [PATCH, MPX, 2/X] Pointers Checker [1/25] Hooks

2013-10-23 Thread Jeff Law

On 10/21/13 08:20, Ilya Enkovich wrote:


diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 8d220f3..79bd0f9 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
+@deftypefn {Target Hook} rtx TARGET_LOAD_BOUNDS_FOR_ARG (rtx @var{slot}, rtx 
@var{arg}, rtx @var{slot_no})
+This hook is used to emit insn to load bounds of @var{arg} passed
+in @var{slot}.  In case @var{slot} is not a memory, @var{slot_no} is RTX
+constant holding number of the special slot we should get bounds from.
+Return loaded bounds.
+@end deftypefn
+
+@deftypefn {Target Hook} void TARGET_STORE_BOUNDS_FOR_ARG (rtx @var{arg}, rtx 
@var{slot}, rtx @var{bounds}, rtx @var{slot_no})
+This hook is used to emit insn to store bounds of @var{arg} passed
+in @var{slot}.  In case @var{slot} is not a memory, @var{slot_no} is RTX
+constant holding number of the special slot we should store bounds to.
+@end deftypefn
+
Almost there. What I think is missing is more information about the case 
where SLOT is not a memory (presumably it's a reg) and how that relates 
to SLOT_NO.


Isn't this just providing a mapping from the input argument registers to 
some set of bounds pointer registers?  Presumably you aren't really 
exposing the bound registers as argument registers hence this hack?


Not asking you to change anything, just trying to understand the rationale.





  @node Trampolines
  @section Trampolines for Nested Functions
  @cindex trampolines for nested functions
@@ -10907,6 +10927,27 @@ ignored.  This function should return the result of 
the call to the
  built-in function.
  @end deftypefn

+@deftypefn {Target Hook} tree TARGET_BUILTIN_CHKP_FUNCTION (unsigned 
@var{fcode})
+This hook allows target to redefine built-in functions used by
+Pointers Checker for code instrumentation.  Hook should return
+fndecl of function implementing generic builtin whose code is
+passed in @var{fcode}.  Currently following built-in functions are
+obtained using this hook:
+@code{BUILT_IN_CHKP_BNDMK}, @code{BUILT_IN_CHKP_BNDSTX},
+@code{BUILT_IN_CHKP_BNDLDX}, @code{BUILT_IN_CHKP_BNDCL},
+@code{BUILT_IN_CHKP_BNDCU}, @code{BUILT_IN_CHKP_BNDRET},
+@code{BUILT_IN_CHKP_INTERSECT}, @code{BUILT_IN_CHKP_SET_PTR_BOUNDS},
+@code{BUILT_IN_CHKP_NARROW}, @code{BUILT_IN_CHKP_ARG_BND},
+@code{BUILT_IN_CHKP_SIZEOF}, @code{BUILT_IN_CHKP_EXTRACT_LOWER},
+@code{BUILT_IN_CHKP_EXTRACT_UPPER}.
+@end deftypefn
+@deftypefn {Target Hook} tree TARGET_CHKP_BOUND_TYPE (void)
+Return type to be used for bounds
+@end deftypefn
+@deftypefn {Target Hook} {enum machine_mode} TARGET_CHKP_BOUND_MODE (void)
+Return mode to be used for bounds.
+@end deftypefn
So how am I (as a GCC developer) suppsoed to know what BNDMK, BNDLDX, 
BNDCU, etc mean?  The names aren't particularly descriptive.  Are these 
documented elsewhere in a follow-up patch?  If not, it seems to me we 
need to document them here.


Jeff



[PATCH, MPX, 2/X] Pointers Checker [1/25] Hooks

2013-10-21 Thread Ilya Enkovich
Hi,

This patch starts the series which introduces Pointers Checker and its support 
in i386 via Intel MPX. Pointers Checker is described on Wiki page - 
http://gcc.gnu.org/wiki/Intel%20MPX%20support%20in%20the%20GCC%20compiler. This 
series actually replaces previously sent patch 
(http://gcc.gnu.org/ml/gcc-patches/2013-08/msg01167.html) which seems too 
inconvenient for review.

The first patch in a series introduces new target and language hooks used by 
Pointers Checker.

Bootstrapped and tested on linux-x86_64.

Thanks,
Ilya
--

gcc/

2013-10-21  Ilya Enkovich  ilya.enkov...@intel.com

* target.def (builtin_chkp_function): New.
(chkp_bound_type): New.
(chkp_bound_mode): New.
(fn_abi_va_list_bounds_size): New.
(load_bounds_for_arg): New.
(store_bounds_for_arg): New.
* targhooks.h (default_load_bounds_for_arg): New.
(default_store_bounds_for_arg): New.
(default_fn_abi_va_list_bounds_size): New.
(default_chkp_bound_type): New.
(default_chkp_bound_mode): New.
(default_builtin_chkp_function): New.
* targhooks.c (default_load_bounds_for_arg): New.
(default_store_bounds_for_arg): New.
(default_fn_abi_va_list_bounds_size): New.
(default_chkp_bound_type): New.
(default_chkp_bound_mode); New.
(default_builtin_chkp_function): New.
* doc/tm.texi.in (TARGET_FN_ABI_VA_LIST_BOUNDS_SIZE): New.
(TARGET_LOAD_BOUNDS_FOR_ARG): New.
(TARGET_STORE_BOUNDS_FOR_ARG): New.
(TARGET_BUILTIN_CHKP_FUNCTION): New.
(TARGET_CHKP_BOUND_TYPE): New.
(TARGET_CHKP_BOUND_MODE): New.
* doc/tm.texi: Regenerated.
* langhooks.h (lang_hooks): Add chkp_supported field.
* langhooks-def.h (LANG_HOOKS_CHKP_SUPPORTED): New.
(LANG_HOOKS_INITIALIZER); Add LANG_HOOKS_CHKP_SUPPORTED.


diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 8d220f3..01462a2 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -4334,6 +4334,11 @@ This hook returns the va_list type of the calling 
convention specified by
 The default version of this hook returns @code{va_list_type_node}.
 @end deftypefn
 
+@deftypefn {Target Hook} tree TARGET_FN_ABI_VA_LIST_BOUNDS_SIZE (tree 
@var{fndecl})
+This hook returns size for va_list object or integer_zero_node if
+it does not have any (e.g. is scalar pointer to the stack).
+@end deftypefn
+
 @deftypefn {Target Hook} tree TARGET_CANONICAL_VA_LIST_TYPE (tree @var{type})
 This hook returns the va_list type of the calling convention specified by the
 type of @var{type}. If @var{type} is not a valid va_list type, it returns
@@ -5151,6 +5156,16 @@ defined, then define this hook to return @code{true} if
 Otherwise, you should not define this hook.
 @end deftypefn
 
+@deftypefn {Target Hook} rtx TARGET_LOAD_BOUNDS_FOR_ARG (rtx, @var{rtx}, 
@var{rtx})
+This hook is used to emit insn to load arg's bounds
+in case bounds are not passed on register.  Return loaded bounds
+@end deftypefn
+
+@deftypefn {Target Hook} void TARGET_STORE_BOUNDS_FOR_ARG (rtx, @var{rtx}, 
@var{rtx}, @var{rtx})
+This hook is used to emit insn to store arg's bounds
+in case bounds are not passed on register.
+@end deftypefn
+
 @node Trampolines
 @section Trampolines for Nested Functions
 @cindex trampolines for nested functions
@@ -10907,6 +10922,18 @@ ignored.  This function should return the result of 
the call to the
 built-in function.
 @end deftypefn
 
+@deftypefn {Target Hook} tree TARGET_BUILTIN_CHKP_FUNCTION (unsigned 
@var{fcode})
+Pointers checker instrumentation pass uses this hook to obtain
+target-specific functions which implement specified generic checker
+builtins.
+@end deftypefn
+@deftypefn {Target Hook} tree TARGET_CHKP_BOUND_TYPE (void)
+Return type to be used for bounds
+@end deftypefn
+@deftypefn {Target Hook} {enum machine_mode} TARGET_CHKP_BOUND_MODE (void)
+Return mode to be used for bounds.
+@end deftypefn
+
 @deftypefn {Target Hook} tree TARGET_RESOLVE_OVERLOADED_BUILTIN (unsigned int 
@var{loc}, tree @var{fndecl}, void *@var{arglist})
 Select a replacement for a machine specific built-in function that
 was set up by @samp{TARGET_INIT_BUILTINS}.  This is done
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 863e843a..2828361 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -3694,6 +3694,8 @@ stack.
 
 @hook TARGET_FN_ABI_VA_LIST
 
+@hook TARGET_FN_ABI_VA_LIST_BOUNDS_SIZE
+
 @hook TARGET_CANONICAL_VA_LIST_TYPE
 
 @hook TARGET_GIMPLIFY_VA_ARG_EXPR
@@ -4064,6 +4066,10 @@ These machine description macros help implement varargs:
 
 @hook TARGET_PRETEND_OUTGOING_VARARGS_NAMED
 
+@hook TARGET_LOAD_BOUNDS_FOR_ARG
+
+@hook TARGET_STORE_BOUNDS_FOR_ARG
+
 @node Trampolines
 @section Trampolines for Nested Functions
 @cindex trampolines for nested functions
@@ -8184,6 +8190,10 @@ to by @var{ce_info}.
 
 @hook TARGET_EXPAND_BUILTIN
 
+@hook TARGET_BUILTIN_CHKP_FUNCTION
+@hook TARGET_CHKP_BOUND_TYPE
+@hook 

Re: [PATCH, MPX, 2/X] Pointers Checker [1/25] Hooks

2013-10-21 Thread Joseph S. Myers
On Mon, 21 Oct 2013, Ilya Enkovich wrote:

 +DEFHOOK
 +(builtin_chkp_function,
 + Pointers checker instrumentation pass uses this hook to obtain\n\
 +target-specific functions which implement specified generic checker\n\
 +builtins.,
 + tree, (unsigned fcode),
 + default_builtin_chkp_function)

I don't think that's enough detail.  The audience for this hook 
description is back-end maintainers wanting to implement such hooks for 
their back ends, and the hook description should give sufficient 
information to do so.  This description says nothing at all about the 
semantics of the hook argument or return value.

If it seems difficult to describe things sufficiently in the context of 
individual hook descriptions, maybe an overview of the feature and 
implementation approach is needed as a new section in the internals 
manual, with hook descriptions then referring to that section, or going in 
appropriate places within that section (if the section is in tm.texi.in).

 +DEFHOOK
 +(fn_abi_va_list_bounds_size,
 + This hook returns size for va_list object or integer_zero_node if\n\
 +it does not have any (e.g. is scalar pointer to the stack).,
 + tree, (tree fndecl),
 + default_fn_abi_va_list_bounds_size)

@code{va_list}, @code{integer_zero_node}, specify semantics of fndecl 
argument.

  DEFHOOK
 +(load_bounds_for_arg,
 + This hook is used to emit insn to load arg's bounds\n\
 +in case bounds are not passed on register.  Return loaded bounds,
 + rtx, (rtx, rtx, rtx),
 + default_load_bounds_for_arg)

You need to name all the arguments and explain their semantics by name in 
the documentation (which should end with .).

 +DEFHOOK
 +(store_bounds_for_arg,
 + This hook is used to emit insn to store arg's bounds\n\
 +in case bounds are not passed on register.,
 + void, (rtx, rtx, rtx, rtx),
 + default_store_bounds_for_arg)

Likewise.

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [PATCH, MPX, 2/X] Pointers Checker [1/25] Hooks

2013-10-21 Thread Ilya Enkovich
esOn 21 Oct 11:44, Joseph S. Myers wrote:
 On Mon, 21 Oct 2013, Ilya Enkovich wrote:
 
  +DEFHOOK
  +(builtin_chkp_function,
  + Pointers checker instrumentation pass uses this hook to obtain\n\
  +target-specific functions which implement specified generic checker\n\
  +builtins.,
  + tree, (unsigned fcode),
  + default_builtin_chkp_function)
 
 I don't think that's enough detail.  The audience for this hook 
 description is back-end maintainers wanting to implement such hooks for 
 their back ends, and the hook description should give sufficient 
 information to do so.  This description says nothing at all about the 
 semantics of the hook argument or return value.
 
 If it seems difficult to describe things sufficiently in the context of 
 individual hook descriptions, maybe an overview of the feature and 
 implementation approach is needed as a new section in the internals 
 manual, with hook descriptions then referring to that section, or going in 
 appropriate places within that section (if the section is in tm.texi.in).
 
  +DEFHOOK
  +(fn_abi_va_list_bounds_size,
  + This hook returns size for va_list object or integer_zero_node if\n\
  +it does not have any (e.g. is scalar pointer to the stack).,
  + tree, (tree fndecl),
  + default_fn_abi_va_list_bounds_size)
 
 @code{va_list}, @code{integer_zero_node}, specify semantics of fndecl 
 argument.
 
   DEFHOOK
  +(load_bounds_for_arg,
  + This hook is used to emit insn to load arg's bounds\n\
  +in case bounds are not passed on register.  Return loaded bounds,
  + rtx, (rtx, rtx, rtx),
  + default_load_bounds_for_arg)
 
 You need to name all the arguments and explain their semantics by name in 
 the documentation (which should end with .).
 
  +DEFHOOK
  +(store_bounds_for_arg,
  + This hook is used to emit insn to store arg's bounds\n\
  +in case bounds are not passed on register.,
  + void, (rtx, rtx, rtx, rtx),
  + default_store_bounds_for_arg)
 
 Likewise.
 
 -- 
 Joseph S. Myers
 jos...@codesourcery.com

Hello Joseph,

Thanks for your comments! I attach a new patch version with changed hooks 
documentation. Hope it is more informative now.

Thanks,
Ilya
--

diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 8d220f3..79bd0f9 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -4334,6 +4334,13 @@ This hook returns the va_list type of the calling 
convention specified by
 The default version of this hook returns @code{va_list_type_node}.
 @end deftypefn
 
+@deftypefn {Target Hook} tree TARGET_FN_ABI_VA_LIST_BOUNDS_SIZE (tree 
@var{fndecl})
+This hook returns size for @code{va_list} object in function specified
+by @var{fndecl}.  This hook is used by Pointers Checker to build bounds for
+@code{va_list} object.  Return @code{integer_zero_node} if no bounds should
+be used (e.g. @code{va_list} is a scalar pointer to the stack).
+@end deftypefn
+
 @deftypefn {Target Hook} tree TARGET_CANONICAL_VA_LIST_TYPE (tree @var{type})
 This hook returns the va_list type of the calling convention specified by the
 type of @var{type}. If @var{type} is not a valid va_list type, it returns
@@ -5151,6 +5158,19 @@ defined, then define this hook to return @code{true} if
 Otherwise, you should not define this hook.
 @end deftypefn
 
+@deftypefn {Target Hook} rtx TARGET_LOAD_BOUNDS_FOR_ARG (rtx @var{slot}, rtx 
@var{arg}, rtx @var{slot_no})
+This hook is used to emit insn to load bounds of @var{arg} passed
+in @var{slot}.  In case @var{slot} is not a memory, @var{slot_no} is RTX
+constant holding number of the special slot we should get bounds from.
+Return loaded bounds.
+@end deftypefn
+
+@deftypefn {Target Hook} void TARGET_STORE_BOUNDS_FOR_ARG (rtx @var{arg}, rtx 
@var{slot}, rtx @var{bounds}, rtx @var{slot_no})
+This hook is used to emit insn to store bounds of @var{arg} passed
+in @var{slot}.  In case @var{slot} is not a memory, @var{slot_no} is RTX
+constant holding number of the special slot we should store bounds to.
+@end deftypefn
+
 @node Trampolines
 @section Trampolines for Nested Functions
 @cindex trampolines for nested functions
@@ -10907,6 +10927,27 @@ ignored.  This function should return the result of 
the call to the
 built-in function.
 @end deftypefn
 
+@deftypefn {Target Hook} tree TARGET_BUILTIN_CHKP_FUNCTION (unsigned 
@var{fcode})
+This hook allows target to redefine built-in functions used by
+Pointers Checker for code instrumentation.  Hook should return
+fndecl of function implementing generic builtin whose code is
+passed in @var{fcode}.  Currently following built-in functions are
+obtained using this hook:
+@code{BUILT_IN_CHKP_BNDMK}, @code{BUILT_IN_CHKP_BNDSTX},
+@code{BUILT_IN_CHKP_BNDLDX}, @code{BUILT_IN_CHKP_BNDCL},
+@code{BUILT_IN_CHKP_BNDCU}, @code{BUILT_IN_CHKP_BNDRET},
+@code{BUILT_IN_CHKP_INTERSECT}, @code{BUILT_IN_CHKP_SET_PTR_BOUNDS},
+@code{BUILT_IN_CHKP_NARROW}, @code{BUILT_IN_CHKP_ARG_BND},
+@code{BUILT_IN_CHKP_SIZEOF}, @code{BUILT_IN_CHKP_EXTRACT_LOWER},
+@code{BUILT_IN_CHKP_EXTRACT_UPPER}.
+@end deftypefn
+@deftypefn