When removing frame indices on PowerPC, we need to scavenge a GPR to materialize a large constant if the stack offset for the spill/reload cannot be reached by a D-Form instruction. However, in a perfect storm of conditions, we may not have GPR's available to scavenge, thereby requiring an emergency spill. If such an emergency spill also needs to be spilled to a location with a large offset, it would itself require register scavenging thereby creating an infinite loop.
This patch detects when the scavenger cannot scavenge a register and the spill/reload is to a location with a large offset. It then stashes a GPR into a VSR so that it can use the GPR to materialize the constant (rather than scavenging a GPR).
FYI you can arrange for RS to always be non-nullptr here, by overriding PPCRegisterInfo::requiresFrameIndexReplacementScavenging to return true. But that changes the code generated for the tests you added here, to the point that I'm not even sure if they're still testing the right thing.