On Sat, Dec 18, 2021 at 06:05:11PM +0530, Siddhesh Poyarekar wrote:
> --- a/gcc/tree-object-size.c
> +++ b/gcc/tree-object-size.c
> @@ -107,6 +107,14 @@ size_unknown_p (tree val, int object_size_type)
> ? integer_zerop (val) : integer_all_onesp (val));
> }
>
> +/* Return true if VAL is represents a valid size for OBJECT_SIZE_TYPE. */
> +
> +static inline bool
> +size_valid_p (tree val, int object_size_type)
> +{
> + return ((object_size_type & OST_DYNAMIC) || TREE_CODE (val) ==
> INTEGER_CST);
> +}
It is fine to introduce this predicate, but then it should be consistenly
used wherever you check the above.
> @@ -1328,7 +1323,7 @@ plus_stmt_object_size (struct object_size_info *osi,
> tree var, gimple *stmt)
> return false;
>
> /* Handle PTR + OFFSET here. */
> - if (TREE_CODE (op1) == INTEGER_CST
> + if (((object_size_type & OST_DYNAMIC) || TREE_CODE (op1) == INTEGER_CST)
E.g. above.
Otherwise LGTM.
Jakub