C++ PMF types handled in gimple-range-fold
Fixes gimple-range-fold to correctly handle C++ pointer-to-member-function types.
Recent changes to gimple-range-fold.cc caused issues with C++ pointer-to-member-function (PMF) types. The compiler’s frontend can create distinct RECORD_TYPEs for these, even if they are canonically equivalent. This patch modifies accumulate_range_from_component_ref to fall back to bit offset and size comparisons when field declarations and constructors use canonically compatible but not identical aggregate types, resolving mismatches and a new test case.
In Details
This commit adjusts the accumulate_range_from_component_ref function in gimple-range-fold.cc to accommodate C++'s handling of pointer-to-member-function (PMF) types. The C++ frontend may generate multiple RECORD_TYPEs for PMFs that are canonicalized to the same type. The original code relied on exact FIELD_DECL pointer equality, which failed when the frontend produced different FIELD_DECLs for canonically equivalent types. The fix introduces a fallback mechanism using bit offsets and sizes when TYPE_CANONICAL matches but FIELD_DECL pointers differ, preventing incorrect optimizat…
- GIMPLE
- GCC's internal representation for code during optimization. It's a three-address code form that simplifies analysis and transformation.
- Pointer-to-Member-Function (PMF)
- A C++ type that represents a pointer to a member function of a class. It's distinct from a regular function pointer as it needs to be associated with an object of the class.
- RECORD_TYPE
- An internal GCC representation for C/C++ structs and classes.
- TYPE_CANONICAL
- A GCC internal mechanism that identifies equivalent types, even if they are represented differently in the compiler's internal structures.
- FIELD_DECL
- Represents a field (member) within a structure or class.