[PATCH 04/10] tree-object-size: Single pass dependency loop resolution
Tue Nov 23 12:07:42 GMT 2021
On Wed, Nov 10, 2021 at 12:31:30AM +0530, Siddhesh Poyarekar wrote:
> Use SSA names as placeholders self-referencing variables to generate
> expressions for object sizes and then reduce those size expressions
> to constants instead of repeatedly walking through statements.
> This change also makes sure that object sizes for an SSA name are
> updated at most twice, once if there is a dependency loop and then the
> final time upon computation of object size. Iteration to deduce the
> final size is now done on the size expressions instead of walking
> through the object references.
> Added test to include a case where __builtin_object_size incorrectly
> returned the minimum object size as zero.
This feels way too risky to me. I think making some code do something
different between (x & OST_DYNAMIC) == 0 and == 1 is just fine,
it doesn't have to share everything. After all, for __bdos we actually
emit code to compute it at runtime, while for __bos we don't.
So I'd keep e.g. .pass = 0, .pass = 1 and .pass = 2 (in a loop) in
compute_builtin_object_size for non-OST_DYNAMIC and only use your new
stuff for __bdos.
E.g. creating new SSA_NAMEs for __bos doesn't look like a good idea to me.
The GCC __bos testsuite is not big enough that it covers everything and
even in it we sometimes reexamine 2, 3 or 4 times.
> * tree-object-size.c (struct object_size_info): Remove pass,
> changed, depths, stack and tos. Add tempsize_objs.
> (OST_TREE_CODE): New macro.
> (expr_object_size, merge_object_sizes, plus_stmt_object_size,
> cond_expr_object_size): Return tree and don't pass pointer tree.
> (object_sizes_set): Return void. Adjust implementation to hold
> placeholder SSA names and their values in different slots.
> (addr_object_size): Adjust for single pass.
> (reducing_size, estimate_size, resolve_dependency_loops): New
> (compute_builtin_object_size): Call them.
> (make_tempsize): New function.
> (collect_object_sizes_for): Use it. Update object_sizes at most
> (check_for_plus_in_loops, check_for_plus_in_loops_1): Remove
> * gcc.dg/builtin-object-size-1.c (test6): New test for
> * gcc.dg/builtin-object-size-2.c: Likewise.
> * gcc.dg/builtin-object-size-3.c: Likewise.
> * gcc.dg/builtin-object-size-4.c: Likewise.
More information about the Gcc-patches