tree-object-size: Fix reexamine propagation for dynamic object sizes
Corrects propagation of 'reexamine' flag in dynamic object size analysis to avoid stale SSA name references.
This commit addresses an issue in GCC’s tree-object-size optimization pass related to dynamic object size calculations. It corrects the propagation of the ‘reexamine’ flag, which is used to track temporary SSA names that can be freed during unknown propagation. The fix ensures that unknown values are not incorrectly marked for reexamination and extends this logic to cond_expr to prevent stale references, resolving PR127899.
In Details
The tree-object-size pass calculates object sizes at compile time. For OST_DYNAMIC, the reexamine flag is set on sites using temporary SSA names to allow their freeing during unknown propagation. This commit fixes plus_stmt_object_size to not mark unknown values for reexamination and extends this to cond_expr_object_size to prevent stale references that could be freed prematurely. An assert is added in collect_object_sizes_for to catch reexamined objects with unknown sizes.
- tree-object-size
- A GCC optimization pass that determines the size of objects at compile time, especially useful for dynamic memory allocation scenarios.
- SSA names
- Static Single Assignment (SSA) form uses unique names for variables, where each variable is assigned a value exactly once. Temporary SSA names are often used for intermediate values in optimizations.
- unknown propagation
- An optimization technique where the compiler attempts to determine or propagate values that are not explicitly known, often by making conservative assumptions or using symbolic analysis.
- reexamine flag
- A flag used within the tree-object-size pass to indicate that a particular site or variable needs to be re-evaluated during optimization, often related to dynamic or uncertain values.
- cond_expr
- GCC's internal representation for conditional expressions (ternary operator).