Fix TREE_READONLY check in ipa_find_agg_cst_from_init.
Corrects a check for read-only variables in aggregate constant finding within IPA.
This commit corrects a typo in the ipa_find_agg_cst_from_init function, ensuring it correctly identifies aggregate constants. The function previously had a flawed check that would reject non-constant, non-declaration variables unless they were TREE_READONLY. The fix clarifies that TREE_READONLY is a valid condition for such variables, improving the accuracy of interprocedural analysis.
In Details
In GCC's interprocedural analysis (IPA), ipa_find_agg_cst_from_init attempts to determine if an aggregate variable can be treated as a constant. The function's logic was intended to reject variables that are neither constants nor declarations unless they are marked TREE_READONLY. A typo in the condition VAR_P && TREE_READONLY was leading to incorrect rejections. This patch corrects the condition to accurately reflect the intended check for TREE_READONLY variables, ensuring that read-only aggregates are correctly handled.
- Interprocedural Analysis (IPA)
- A type of program analysis that considers the entire program, including all functions, to understand call relationships and data flow. This allows for optimizations that span across function calls.
- TREE_READONLY
- A GCC internal tree node flag indicating that a variable or object is read-only and cannot be modified. This is often used for constants or data that should not be changed.
- VAR_P
- A GCC internal predicate macro that returns true if a given tree node represents a variable.
- aggregate
- In programming, a composite data type that groups together other data types. Examples include structs, arrays, and unions.
- constant
- A value that does not change during program execution. In GCC's internal representation, constants are represented by specific tree nodes.