IPA PTA: Remove redundant iteration over fields of globals
IPA PTA's shadow variable logic no longer redundantly processes global variable fields.
The Interprocedural Analysis (IPA) Points-To Analysis (PTA) component has been optimized by removing a redundant iteration over fields of global variables. Previously, the shadow variable logic would iterate through each field of a global variable, and then again when processing global variables directly. This patch eliminates the nested loop, preventing multiple visits to the same variable fields and improving efficiency. The change addresses a latent issue, as the feature for handling global struct variables in IPA PTA is not currently enabled.
In Details
In IPA PTA's postprocessing for shadow variables, which are used to handle recursive function calls involving pointers to automatic variables, the code previously iterated over varinfo_t structs representing global variables. For global variables that are structs, an inner loop iterated over their fields. This inner loop was redundant because each field is itself treated as a global variable by IPA PTA. The fix removes this inner loop, ensuring each varinfo_t is processed only once. This optimization is latent as the global struct variable handling is not yet fully enabled.
- IPA PTA
- Interprocedural Analysis Points-To Analysis. A compiler technique that analyzes how pointers are used across different functions in a program to understand what memory locations a pointer might refer to.
- shadow variable
- A temporary variable used by the compiler during interprocedural analysis to track the state or value of another variable, especially in recursive function calls where stack frames might otherwise obscure the information.
- varinfo_t
- A data structure within GCC's internal representation that stores information about a variable, including its type, scope, and other properties relevant to compiler analysis.