tree-ssa-structalias.cc: Why do we iterate over fields of a global varinfo
Investigating IPA PTA code regarding shadow vars and global aggregate fields.
Filip Kastl questions why IPA PTA code in tree-ssa-structalias.cc iterates over fields of a global aggregate variable. He wonders if varinfos representing fields of global aggregates are not marked as global, making the second loop redundant. A subsequent comment from Filip suggests he found an explanation in gimple-ssa-pta-constraints.cc, indicating that subfields for globals are not used in IPA mode.
- proposer
Asks why the IPA PTA code iterates over fields of a global aggregate variable, questioning if those fields are not marked as global and if the second loop is redundant.
“Are the varinfos that represent fields of a global aggregate variable not is_global_var = true? If they were is_global_var = true, then the for loop would be redundant, right?”
- contributor
Found a comment in gimple-ssa-pta-constraints.cc that explains why separate varinfos for fields might not be created for globals in IPA mode.
“So that would explain why I couldn't see separate varinfos for fields. Indeed, if compile the testcase from my previous mail and d”
- reviewer
Acknowledges Filip's initial question about the IPA PTA code and global aggregate fields.
Technical Tradeoffs
- Potential redundancy in analysis loops.
- Correctness of handling global aggregate field information.
In Details
This discussion concerns the Interprocedural Analysis (IPA) Pointer Analysis (PTA) component in GCC, specifically within tree-ssa-structalias.cc. The question revolves around the handling of varinfo_t structures representing fields of global aggregate variables. The proposer is investigating why the code appears to iterate over fields when it might not be necessary if those fields are already treated as global.
- IPA PTA
- Interprocedural Analysis Pointer Analysis. A static analysis technique used by compilers to determine which memory locations a pointer can possibly point to, considering function calls across the entire program.
- varinfo_t
- A data structure likely representing variable information within GCC's internal compiler representation, used for tracking variables and their properties during analysis.
- shadow vars
- In the context of GCC's analysis, shadow variables are auxiliary variables used to track information about other variables, often for specific analysis purposes like aliasing or point-to analysis.
- aggregate variable
- A variable composed of multiple data elements, such as C structs, arrays, or unions.