Re: [PATCH 03/10] tree-object-size: Use tree instead of HOST_WIDE_INT

2021-11-23 Thread Siddhesh Poyarekar
On 11/23/21 17:28, Jakub Jelinek wrote: On Mon, Nov 22, 2021 at 01:32:22PM +0100, Jakub Jelinek via Gcc-patches wrote: On Mon, Nov 22, 2021 at 06:01:08PM +0530, Siddhesh Poyarekar wrote: On 11/22/21 17:30, Siddhesh Poyarekar wrote: So I've got patch 10/10, which handles dynamic (and

Re: [PATCH 03/10] tree-object-size: Use tree instead of HOST_WIDE_INT

2021-11-23 Thread Jakub Jelinek via Gcc-patches
On Mon, Nov 22, 2021 at 01:32:22PM +0100, Jakub Jelinek via Gcc-patches wrote: > On Mon, Nov 22, 2021 at 06:01:08PM +0530, Siddhesh Poyarekar wrote: > > On 11/22/21 17:30, Siddhesh Poyarekar wrote: > > > So I've got patch 10/10, which handles dynamic (and consequently > > > negative) offsets.  It

Re: [PATCH 03/10] tree-object-size: Use tree instead of HOST_WIDE_INT

2021-11-22 Thread Jakub Jelinek via Gcc-patches
On Mon, Nov 22, 2021 at 06:01:08PM +0530, Siddhesh Poyarekar wrote: > On 11/22/21 17:30, Siddhesh Poyarekar wrote: > > So I've got patch 10/10, which handles dynamic (and consequently > > negative) offsets.  It basically computes a "whole size", which then > > gives the extent to which a negative

Re: [PATCH 03/10] tree-object-size: Use tree instead of HOST_WIDE_INT

2021-11-22 Thread Siddhesh Poyarekar
On 11/22/21 17:30, Siddhesh Poyarekar wrote: So I've got patch 10/10, which handles dynamic (and consequently negative) offsets.  It basically computes a "whole size", which then gives the extent to which a negative offset is valid, making the estimates a bit more precise.  I didn't do it for

Re: [PATCH 03/10] tree-object-size: Use tree instead of HOST_WIDE_INT

2021-11-22 Thread Siddhesh Poyarekar
On 11/22/21 16:01, Jakub Jelinek wrote: On Mon, Nov 22, 2021 at 03:41:57PM +0530, Siddhesh Poyarekar wrote: So I played around a bit with this. Basically: char buf[8]; __SIZE_TYPE__ test (void) { char *p = [0x9004]; return __builtin_object_size (p + 2, 0); } when built with -m32

Re: [PATCH 03/10] tree-object-size: Use tree instead of HOST_WIDE_INT

2021-11-22 Thread Jakub Jelinek via Gcc-patches
On Mon, Nov 22, 2021 at 03:41:57PM +0530, Siddhesh Poyarekar wrote: > So I played around a bit with this. Basically: > > char buf[8]; > > __SIZE_TYPE__ test (void) > { > char *p = [0x9004]; > return __builtin_object_size (p + 2, 0); > } > > when built with -m32 returns 0x7002 but

Re: [PATCH 03/10] tree-object-size: Use tree instead of HOST_WIDE_INT

2021-11-22 Thread Siddhesh Poyarekar
On 11/20/21 00:31, Siddhesh Poyarekar wrote: This doesn't match what the code did and I'm surprised if it works at all. TREE_OPERAND (pt_var, 1), while it is an INTEGER_CST or POLY_INT_CST, has in its type encoded the type for aliasing, so the type is some pointer type.  Performing size_binop

Re: [PATCH 03/10] tree-object-size: Use tree instead of HOST_WIDE_INT

2021-11-22 Thread Richard Biener via Gcc-patches
On Fri, Nov 19, 2021 at 8:17 PM Jakub Jelinek via Gcc-patches wrote: > > On Sat, Nov 20, 2021 at 12:31:19AM +0530, Siddhesh Poyarekar wrote: > > > Neither of these are equivalent to what it used to do before. > > > If some target has e.g. pointers wider than size_t, then previously we > > >

Re: [PATCH 03/10] tree-object-size: Use tree instead of HOST_WIDE_INT

2021-11-19 Thread Jakub Jelinek via Gcc-patches
On Sat, Nov 20, 2021 at 12:31:19AM +0530, Siddhesh Poyarekar wrote: > > Neither of these are equivalent to what it used to do before. > > If some target has e.g. pointers wider than size_t, then previously we could > > compute bytes that doesn't fit into size_t and would return NULL which > >

Re: [PATCH 03/10] tree-object-size: Use tree instead of HOST_WIDE_INT

2021-11-19 Thread Siddhesh Poyarekar
On 11/19/21 22:36, Jakub Jelinek wrote: On Wed, Nov 10, 2021 at 12:31:29AM +0530, Siddhesh Poyarekar wrote: * tree-object-size.h (compute_builtin_object_size): Return tree instead of HOST_WIDE_INT. * builtins.c (fold_builtin_object_size): Adjust. * gimple-fold.c

Re: [PATCH 03/10] tree-object-size: Use tree instead of HOST_WIDE_INT

2021-11-19 Thread Jakub Jelinek via Gcc-patches
On Wed, Nov 10, 2021 at 12:31:29AM +0530, Siddhesh Poyarekar wrote: > * tree-object-size.h (compute_builtin_object_size): Return tree > instead of HOST_WIDE_INT. > * builtins.c (fold_builtin_object_size): Adjust. > * gimple-fold.c (gimple_fold_builtin_strncat): Likewise. >

[PATCH 03/10] tree-object-size: Use tree instead of HOST_WIDE_INT

2021-11-09 Thread Siddhesh Poyarekar
Transform tree-object-size to operate on tree objects instead of host wide integers. This makes it easier to extend to dynamic expressions for object sizes. The compute_builtin_object_size interface also now returns a tree expression instead of HOST_WIDE_INT, so callers have been adjusted to