out-of-SSA: Split partitions of parameters and results
out-of-SSA now splits partitions for parameters and results, fixing miscompilations on aarch64.
The split_overlapping_partition_decls function in the out-of-SSA pass has been modified to also split partitions associated with PARM_DECL and RESULT_DECL. Previously, these were excluded, leading to incorrect code generation when parameters or results needed multiple memory partitions (e.g., incoming argument slot and a local slot). This fix addresses miscompilations observed on aarch64 at -Os by ensuring that distinct memory slots for parameters and results are correctly handled, preventing erroneous fusion of memory accesses.
In Details
This change modifies split_overlapping_partition_decls in tree-outof-ssa.cc to no longer exclude PARM_DECL and RESULT_DECL from partition splitting. The prior exclusion was based on the assumption that these declarations required a single canonical partition. However, situations like oversized vector parameters or call-clobbered return values necessitate multiple memory partitions (e.g., incoming argument vs. local spill slot). When both partitions share the same PARM_DECL as their MEM_EXPR base, the load/store pair fusion pass incorrectly fuses accesses, causing miscompiles like…
- out-of-SSA
- A GCC pass that converts SSA (Static Single Assignment) form back into a more traditional three-address representation, necessary for certain optimizations and code generation phases.
- partition
- In the context of out-of-SSA, a partition represents a set of memory locations that are treated as a single unit for analysis and transformation.
- PARM_DECL
- A GCC internal representation node for a function parameter declaration.
- RESULT_DECL
- A GCC internal representation node for a function result (return value) declaration.
- MEM_EXPR
- A GCC internal representation for memory references, typically involving a base address and an offset.
- load/store pair-fusion pass
- An optimization pass that fuses adjacent load and store operations that access memory at similar locations for improved performance.
- aarch64
- The 64-bit ARM architecture, for which GCC generates code.
- SSA
- Static Single Assignment form, an intermediate representation where every variable is assigned a value exactly once.