[PATCH] D46315: [RegUsageInfoCollector] Fix handling of callee saved registers with CSR optimization.

Jonas Paulsson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 4 01:24:13 PDT 2018


jonpa added a comment.

In https://reviews.llvm.org/D46315#1087145, @qcolombet wrote:

> Hi Jonas,
>
> > 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")
>
> Usually those are marked reserved and don't need to show up in the mask. Though having them here is probably a good thing :).
>
> Anyhow, shouldn't getCallPreservedMask be a super set of determineCalleeSaves? (A quick look at the header of TFI confirms that.)
>  Therefore, the current implementation should be conservatively correct.
>
> What am I missing here?


When isSafeForNoCSROpt() returns true, the unpatched implementation does not add any callee saved registers as preserved. This seems to assume the default implementation of determineCalleeSaves() which then returns an empty set. However, SystemZ overrides this and saves the return register because it has to always do that in order to use it when returning from a function.

So my understanding is that since determineCalleeSaves() can be overridden (and depends on isSafeForNoCSROpt) , that is the function should be consulted for the actual dynamic set of saved registers.


https://reviews.llvm.org/D46315





More information about the llvm-commits mailing list