Improve IPA propagation of readonly data with new predicates
GCC's IPA now better tracks and propagates information about readonly data, including string constants.
This patch enhances GCC’s interprocedural analysis (IPA) by improving the propagation of information about readonly data. It introduces new predicates to track values that might be modified during analysis but are guaranteed to be constant in the actual program execution, specifically handling string constants and other aggregate initializations. This allows for more precise analysis and optimization of functions that operate on or pass readonly data.
In Details
Commit a08d0e9eeaac6c67c22490a016ed2ab42f042f70 refines GCC's IPA subsystem by introducing the maybe_modified flag within struct condition and struct agg_position_info. This flag is crucial for correctly propagating information about aggregate parameters, especially string constants, that are accessed through pointers. The patch extends ipa_points_to_readonly_memory_p to accept constants and refines unmodified_parm_or_parm_agg_item to handle STRING_CST and other scalar initializations. This improves the analysis's ability to determine when parameters passed to inlined functions…
- Interprocedural Analysis (IPA)
- A compile-time analysis that examines relationships and dependencies between different functions within a program, rather than just a single function in isolation. It's used to enable optimizations that require knowledge beyond a single function's scope.
- IPA predicates
- A component within GCC's IPA subsystem that represents conditions and properties of function parameters and return values, used to guide optimization decisions.
- readonly
- Indicates that a memory region or variable cannot be modified after initialization. Compilers use this information to perform optimizations, such as placing data in read-only memory segments.
- STRING_CST
- An internal representation in GCC for a string constant.
- aggregate
- A data structure that groups together multiple values, such as a struct or an array.