ipa-cp: Restrict all-context nodes to local cgraph nodes
IPA pass refined to only create all-context nodes for local cgraph nodes, preventing miscompilations.
The IPA-CP pass in GCC has been updated to only create all-context nodes for local call graph nodes. Previously, it created these nodes for all incoming edges, which could lead to miscompilations when indirect or unknown calls altered argument values. This change incorporates a fix for PR125207 by restricting all-context node creation to cases where it’s strictly necessary for recursive refinement, simplifying the decision-making process and improving correctness.
In Details
IPA-CP's all-context node creation logic was broadened beyond its original intent of handling recursive refinement. This commit reverts it to only create such nodes for truly local cgraph nodes, where indirect calls are impossible. This addresses a miscompilation in PR125207 caused by redirecting call graph edges from unknown/indirect calls. The change also simplifies decide_whether_version_node.
- IPA-CP
- Interprocedural Analysis - Call Graph Cloning. A GCC optimization pass that analyzes function calls to potentially create specialized versions (clones) of functions.
- cgraph node
- Represents a function in GCC's call graph IR. Each node holds information about a function, its callers, and its callees.
- all-context nodes
- A special type of cloned node in IPA-CP that considers constant values from all possible call contexts. This commit restricts their creation to local functions.
- recursive refinement
- A strategy in IPA-CP where a function clone is further refined by re-evaluating constants after more information becomes available, particularly useful in recursive function calls.