This patch adds the architecture-neutral components of a fix for issue #57482 ( https://github.com/llvm/llvm-project/issues/57482 ), and the artitecture-specific parts of the fix for MIPS processors.
IPRA allows the save/restore sequences to be omitted from callees whose clobber sets have been fully accounted for by the calling function due to IPRA. However, since the return address to return from the callee is used in the *return* instruction of the calling instruction rather than in the caller, having the caller preserve a value is inadequate for return addresses.
No existing register property available in the framework encapsulates this "needed for return instruction" property, so this changed adds this as a TargerRegisterInfo query method.
It would be better to handle the list of special case registers rather than iterating through every CSR