Prevent pseudo register creation after pseudos are disallowed on RISC-V
Fixes a bug on RISC-V where pseudo registers were incorrectly created after they were disallowed.
This commit corrects a bug in the RISC-V backend where pseudo registers were being created even after the compiler had determined that no new pseudo registers should be allowed. This occurred due to a new path calling synthesize_add without adequately checking the pseudo-creation constraint. The fix ensures that synthesize_add returns false when pseudo creation is forbidden, preventing incorrect register allocation and potential regressions.
In Details
The synthesize_add function in the RISC-V backend was being called through a new path after the can_create_pseudos_p check had already returned false. This commit modifies synthesize_add to return false if it would require creating a new pseudo register when !can_create_pseudos_p. This prevents the scheduler from erroneously creating pseudos in contexts where they are disallowed, thus avoiding potential register allocation issues and regressions.
- pseudo register
- A temporary, compiler-managed register used during intermediate stages of compilation. Pseudo registers are not actual hardware registers and are later mapped to physical registers or spilled to memory.
- RISC-V
- An open-standard instruction set architecture (ISA) based on Reduced Instruction Set Computer principles. GCC supports various RISC-V configurations.
- synthesize_add
- A function within GCC's backend that likely generates RTL (Register Transfer Language) for an 'add' operation, possibly involving optimizations like peephole transforms or pseudo-register creation.
- can_create_pseudos_p
- A predicate function in GCC's compiler internals that checks whether the compiler is currently allowed to create new pseudo registers. This is often tied to specific optimization passes or compiler states.