phiopt: Reject incompatible pointer types in load factoring
phiopt pass rejects factoring loads with incompatible pointer types to avoid crashes.
The phiopt optimization pass now rejects cases where pointer types are incompatible, such as different address spaces or function pointers. This prevents crashes that could occur when creating a phi node with such pointers. The pass could be further refined to support specific address space differences, but the current change prioritizes stability by avoiding the more complex scenarios.
In Details
The phiopt pass in GCC's SSA optimization pipeline aims to simplify conditional loads by factoring them out. This commit modifies tree-ssa-phiopt.cc to reject operations that would create a phi node with pointers of incompatible types. Incompatibility is determined by GCC's internal type system, considering factors like address spaces. The change opts for rejecting these cases rather than attempting a complex, partial solution.
- phiopt
- A compiler optimization pass in GCC that performs optimizations related to PHI nodes, particularly those involving conditional loads. It aims to simplify control flow and improve code efficiency.
- SSA
- Static Single Assignment form. An intermediate representation used in compilers where every variable is assigned a value only once. This simplifies many optimization passes.
- PHI node
- A special node in SSA form that represents the merging of values from different control flow paths. It determines which value a variable should take at a join point in the program.
- address space
- A distinct memory region that a processor can access. Different address spaces can have different properties or access mechanisms, and pointers to them may not be directly comparable or usable together.