[PATCH v3 3/8] tree-object-size: Save sizes as trees and support negative offsets

Siddhesh Poyarekar siddhesh@gotplt.org
Fri Nov 26 17:59:41 GMT 2021

On 11/26/21 22:26, Jakub Jelinek wrote:
> On Fri, Nov 26, 2021 at 10:58:46AM +0530, Siddhesh Poyarekar wrote:
>> 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
>> account for that.
>> The trees in object_sizes are each a TREE_VEC with the first element
>> being the bytes from the pointer to the end of the object and the
>> second, the size of the whole object.  This allows analysis of negative
>> offsets, which can now be allowed to the extent of the object bounds.
>> Tests have been added to verify that it actually works.
> If you need pairs of trees, just use pairs of trees, using TREE_VEC for it
> will create lots of extra garbage.
> Either std::pair<tree, tree>, but most likely gengtype won't handle that
> right, so just create your own
> struct GTY(()) whatever {
>    /* Comment explaining what it is.  */
>    tree whatever1;
>    /* Comment explaining what it is.  */
>    tree whatever2;
> };
> and if that needs to go into e.g. object_sizes vectors, use vec<whatever>.

Got it, I'll make a new struct GTY(()).  I'm also using TREE_VEC to 
store PHI nodes args and the result (in patch 5/8) until they're emitted 
in gimplify_size_expressions.  It needs to be a tree since it would be 
stored in whatever1 and whatever2, would that be acceptable use?


More information about the Gcc-patches mailing list