I saw a test case on SystemZ, where Target needed to save and restore the return register (and therefore also the SP), but those registers were missing from the regmask on the call to that function (in other words they were "not preserved"). This is wrong.
Currently, the set of clobbered physregs are first built, and then the callee saved regs are added back as preserved if the CSROpt did not take effect. This misses the registers that the target still had to save.
This patch instead first checks which registers the target actually decided to save, and then checks against this set during iteration over the target registers.