public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] doc: Fix documentation for __builtin_dynamic_object_size
@ 2022-12-15 16:58 Siddhesh Poyarekar
  2022-12-15 17:09 ` Jakub Jelinek
  0 siblings, 1 reply; 4+ messages in thread
From: Siddhesh Poyarekar @ 2022-12-15 16:58 UTC (permalink / raw)
  To: gcc-patches

__builtin_dynamic_object_size is missing from the full list of builtins,
so add it.  Also mention it alongside __builtin_object_size in the
passes description.

gcc/ChangeLog:

	* doc/extend.texi (__builtin_dynamic_object_size): Document
	builtin.
	* doc/passes.texi
	(Optimize calls to @code{__builtin_object_size}): Also mention
	__builtin_dynamic_object_size.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
---
 gcc/doc/extend.texi | 10 ++++++++--
 gcc/doc/passes.texi | 11 ++++++-----
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index d3812fa55b0..608ff54f845 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -14291,8 +14291,14 @@ and GCC does not issue a warning.
 @end deftypefn
 
 @deftypefn {Built-in Function}{size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})
-Returns the size of an object pointed to by @var{ptr}.  @xref{Object Size
-Checking}, for a detailed description of the function.
+Returns a constant size estimate of an object pointed to by @var{ptr}.
+@xref{Object Size Checking}, for a detailed description of the function.
+@end deftypefn
+
+@deftypefn {Built-in Function}{size_t} __builtin_dynamic_object_size (const void * @var{ptr}, int @var{type})
+Similar to @code{__builtin_object_size} except that the return value
+need not be a constant.  @xref{Object Size Checking}, for a detailed
+description of the function.
 @end deftypefn
 
 @deftypefn {Built-in Function} double __builtin_huge_val (void)
diff --git a/gcc/doc/passes.texi b/gcc/doc/passes.texi
index 9e8b4f50ad6..d649db72bbe 100644
--- a/gcc/doc/passes.texi
+++ b/gcc/doc/passes.texi
@@ -843,12 +843,13 @@ foo()}, this pass tries to change the call so that the address of
 pass is located in @code{tree-nrv.cc} and is described by
 @code{pass_return_slot}.
 
-@item Optimize calls to @code{__builtin_object_size}
+@item Optimize calls to @code{__builtin_object_size} or
+@code{__builtin_dynamic_object_size}
 
-This is a propagation pass similar to CCP that tries to remove calls
-to @code{__builtin_object_size} when the size of the object can be
-computed at compile-time.  This pass is located in
-@file{tree-object-size.cc} and is described by
+This is a propagation pass similar to CCP that tries to remove calls to
+@code{__builtin_object_size} or @code{__builtin_dynamic_object_size}
+when the size of the object can be computed at compile-time.  This pass
+is located in @file{tree-object-size.cc} and is described by
 @code{pass_object_sizes}.
 
 @item Loop invariant motion
-- 
2.38.1


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

* Re: [PATCH] doc: Fix documentation for __builtin_dynamic_object_size
  2022-12-15 16:58 [PATCH] doc: Fix documentation for __builtin_dynamic_object_size Siddhesh Poyarekar
@ 2022-12-15 17:09 ` Jakub Jelinek
  2022-12-15 17:21   ` Siddhesh Poyarekar
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2022-12-15 17:09 UTC (permalink / raw)
  To: Siddhesh Poyarekar; +Cc: gcc-patches

On Thu, Dec 15, 2022 at 11:58:14AM -0500, Siddhesh Poyarekar wrote:
> --- a/gcc/doc/extend.texi
> +++ b/gcc/doc/extend.texi
> @@ -14291,8 +14291,14 @@ and GCC does not issue a warning.
>  @end deftypefn
>  
>  @deftypefn {Built-in Function}{size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})
> -Returns the size of an object pointed to by @var{ptr}.  @xref{Object Size
> -Checking}, for a detailed description of the function.
> +Returns a constant size estimate of an object pointed to by @var{ptr}.
> +@xref{Object Size Checking}, for a detailed description of the function.
> +@end deftypefn
> +
> +@deftypefn {Built-in Function}{size_t} __builtin_dynamic_object_size (const void * @var{ptr}, int @var{type})
> +Similar to @code{__builtin_object_size} except that the return value
> +need not be a constant.  @xref{Object Size Checking}, for a detailed
> +description of the function.
>  @end deftypefn
>  
>  @deftypefn {Built-in Function} double __builtin_huge_val (void)

The above is ok.

> diff --git a/gcc/doc/passes.texi b/gcc/doc/passes.texi
> index 9e8b4f50ad6..d649db72bbe 100644
> --- a/gcc/doc/passes.texi
> +++ b/gcc/doc/passes.texi
> @@ -843,12 +843,13 @@ foo()}, this pass tries to change the call so that the address of
>  pass is located in @code{tree-nrv.cc} and is described by
>  @code{pass_return_slot}.
>  
> -@item Optimize calls to @code{__builtin_object_size}
> +@item Optimize calls to @code{__builtin_object_size} or
> +@code{__builtin_dynamic_object_size}
>  
> -This is a propagation pass similar to CCP that tries to remove calls
> -to @code{__builtin_object_size} when the size of the object can be
> -computed at compile-time.  This pass is located in
> -@file{tree-object-size.cc} and is described by
> +This is a propagation pass similar to CCP that tries to remove calls to
> +@code{__builtin_object_size} or @code{__builtin_dynamic_object_size}
> +when the size of the object can be computed at compile-time.  This pass

Can be computed at compile-time is only true for __bos, for
__bdos is if it can be computed.

> +is located in @file{tree-object-size.cc} and is described by
>  @code{pass_object_sizes}.
>  
>  @item Loop invariant motion

Otherwise LGTM.

	Jakub


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

* Re: [PATCH] doc: Fix documentation for __builtin_dynamic_object_size
  2022-12-15 17:09 ` Jakub Jelinek
@ 2022-12-15 17:21   ` Siddhesh Poyarekar
  2022-12-15 17:24     ` Jakub Jelinek
  0 siblings, 1 reply; 4+ messages in thread
From: Siddhesh Poyarekar @ 2022-12-15 17:21 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On 2022-12-15 12:09, Jakub Jelinek wrote:
>> -This is a propagation pass similar to CCP that tries to remove calls
>> -to @code{__builtin_object_size} when the size of the object can be
>> -computed at compile-time.  This pass is located in
>> -@file{tree-object-size.cc} and is described by
>> +This is a propagation pass similar to CCP that tries to remove calls to
>> +@code{__builtin_object_size} or @code{__builtin_dynamic_object_size}
>> +when the size of the object can be computed at compile-time.  This pass
> 
> Can be computed at compile-time is only true for __bos, for
> __bdos is if it can be computed.

How about:


This is a propagation pass similar to CCP that tries to remove calls to
@code{__builtin_object_size} when the size of the object can be computed 
at compile-time.  It also tries to replace calls to 

@code{__builtin_dynamic_object_size} with an expression that evaluates
the size of the object.  This pass is located in
@file{tree-object-size.cc} and is described by @code{pass_object_sizes}.

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

* Re: [PATCH] doc: Fix documentation for __builtin_dynamic_object_size
  2022-12-15 17:21   ` Siddhesh Poyarekar
@ 2022-12-15 17:24     ` Jakub Jelinek
  0 siblings, 0 replies; 4+ messages in thread
From: Jakub Jelinek @ 2022-12-15 17:24 UTC (permalink / raw)
  To: Siddhesh Poyarekar; +Cc: gcc-patches

On Thu, Dec 15, 2022 at 12:21:21PM -0500, Siddhesh Poyarekar wrote:
> On 2022-12-15 12:09, Jakub Jelinek wrote:
> > > -This is a propagation pass similar to CCP that tries to remove calls
> > > -to @code{__builtin_object_size} when the size of the object can be
> > > -computed at compile-time.  This pass is located in
> > > -@file{tree-object-size.cc} and is described by
> > > +This is a propagation pass similar to CCP that tries to remove calls to
> > > +@code{__builtin_object_size} or @code{__builtin_dynamic_object_size}
> > > +when the size of the object can be computed at compile-time.  This pass
> > 
> > Can be computed at compile-time is only true for __bos, for
> > __bdos is if it can be computed.
> 
> How about:
> 
> 
> This is a propagation pass similar to CCP that tries to remove calls to
> @code{__builtin_object_size} when the size of the object can be computed at
> compile-time.  It also tries to replace calls to
> 
> @code{__builtin_dynamic_object_size} with an expression that evaluates
> the size of the object.  This pass is located in
> @file{tree-object-size.cc} and is described by @code{pass_object_sizes}.

Without the empty space in between and perhaps with replacing size with
upper or lower bound for the size of the object in both cases ok.

	Jakub


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

end of thread, other threads:[~2022-12-15 17:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-15 16:58 [PATCH] doc: Fix documentation for __builtin_dynamic_object_size Siddhesh Poyarekar
2022-12-15 17:09 ` Jakub Jelinek
2022-12-15 17:21   ` Siddhesh Poyarekar
2022-12-15 17:24     ` Jakub Jelinek

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