[RISCV] Dynamically find unused register for stack protection code (#210992)
Previously stack protection used hardcoded registers which could
conflict with registers being used by user code. This fixes a bug where
clang -fstack-clash-protection would cause local variables to be trashed
by the stack probing loop.
The implementation is following the pattern of the AArch64 and X86
backends. Utility function getLiveRegsForEntryMBB has been copied from
AArch64FrameLowering.cpp and findScratchNonCalleeSaveRegister is loosely
based on the AArch64 version.
This fixes Github issue #198699