This is an archive of the discontinued LLVM Phabricator instance.

Add support for preserve_most/preserve_all calling conventions to the AArch64 backend.
Needs ReviewPublic

Authored by swiftix on Mar 9 2016, 9:02 AM.

Details

Summary

This change add a support for preserve_most/preserve_all calling conventions to the AArch64 backend, similar to how it was done for X86-64.

There is also a subsequent patch on top of this one to add a tail-calls support for these calling conventions.

Diff Detail

Event Timeline

swiftix updated this revision to Diff 50147.Mar 9 2016, 9:02 AM
swiftix retitled this revision from to Add support for preserve_most/preserve_all calling conventions to the AArch64 backend..
swiftix updated this object.
swiftix added reviewers: t.p.northover, ributzka.
swiftix added a subscriber: llvm-commits.
t.p.northover added inline comments.Mar 9 2016, 9:46 AM
lib/Target/AArch64/AArch64CallingConvention.td
314–315

I think some more comments on the choices here would be useful. Obviously you can't preserve x16 or x17 because the linker may use them to resolve a PLT call, and x18 is the platform register on Darwin.

But you're excluding x15 too, which makes "RT_AllRegs" increasingly misnamed (it also excludes the high half of vector registers and the argument registers).

swiftix added inline comments.Mar 9 2016, 11:12 AM
lib/Target/AArch64/AArch64CallingConvention.td
314–315

x15 was excluded, because AArch64 backend seems to need pairs of registers, when it store/restores them in the epilogue. With x15 included, we get an odd number of registers to store/restore, which triggers an assertion in the backend.

The argument registers were not included (yet), because LLVM seems to have problems in situations, where a set of callee-saved registers overlaps with the sets of argument/return registers. In particular, it led the incorrect code being produced, when functions using these new calling conventions call each other or are using tail calls. I've filed a couple of radars about it, but they are not resolved yet.

314–315

As for RT_AllRegs, you are probably right. Currently we do not really use this convention on AArch64, it was implemented more for a sake of completeness.

But may be indeed, we should add x15 and the high half of vector registers and the argument registers there.

swiftix added inline comments.Mar 9 2016, 11:15 AM
lib/Target/AArch64/AArch64CallingConvention.td
314–315

x15 was excluded, because AArch64 backend seems to need pairs of registers, when it store/restores them in the epilogue. With x15 included, we get an odd number of registers to store/restore, which triggers an assertion in the backend.

The argument registers were not included (yet), because LLVM seems to have problems in situations, where a set of callee-saved registers overlaps with the sets of argument/return registers. In particular, it led the incorrect code being produced, when functions using these new calling conventions call each other or are using tail calls. I've filed a couple of radars about it, but they are not resolved yet.

I addressed the comments in http://reviews.llvm.org/D18016.

  • PreserveMost callee-saves X15 now, because the backend can support it in the meantime.
  • After a discussion with Tim, I decided to remove preserve_all support for the time being, as it is not really used yet and the set of registers it should callee-save is not quite settled yet.