This is an archive of the discontinued LLVM Phabricator instance.

Add calling convention for C++ TLS on Darwin
ClosedPublic

Authored by manmanren on Nov 18 2015, 9:52 AM.

Details

Summary

This patch adds a new target-independent calling convention for C++ TLS access functions.

The target-specific implementation for X86-64 is defined as following:

  • Arguments are passed as for the default C calling convention
  • The same applies for the return value(s)
  • the callee preserves all GPRs - except RAX and RDI

It attempts to make the code in the caller as little intrusive as possible. The access function makes C-style TLS function calls in the entry and exit block, C-style TLS functions save a lot more registers than normal calls. The added calling convention ties into the existing implementation of the C-style TLS functions, so we can't simply use existing calling conventions such as preserve_mostcc.

Cheers,
Manman

Diff Detail

Repository
rL LLVM

Event Timeline

manmanren updated this revision to Diff 40529.Nov 18 2015, 9:52 AM
manmanren retitled this revision from to Add calling convention for C++ TLS on Darwin.
manmanren updated this object.
manmanren added reviewers: qcolombet, ributzka.
manmanren set the repository for this revision to rL LLVM.
qcolombet edited edge metadata.Nov 18 2015, 10:03 AM
qcolombet added a subscriber: qcolombet.

Hi Manman,

I think you want to add the LLVM list as a subscriber.

Cheers,
-Quentin

manmanren edited edge metadata.Nov 18 2015, 10:14 AM
manmanren added a subscriber: llvm-commits.

ping

Cheers,
Manman

silvas added a subscriber: silvas.Nov 30 2015, 7:28 PM

Small question: how Darwin-specific is this? Should it be darwin_cxx_tlscc or do you expect other platforms to use it?

Small question: how Darwin-specific is this? Should it be darwin_cxx_tlscc or do you expect other platforms to use it?

This is currently specific to Darwin. I don't see another example of putting the platform in the name of a calling convention. But I can be convinced :]

lhames edited edge metadata.Dec 3 2015, 10:56 AM

Perhaps a less generic name would be good, since not all platforms will use cxx_tlscc for C++ TLS. Maybe 'darwin_cxx_tlscc' as Sean suggested, or 'cxx_fast_tlscc'?

Otherwise this looks good to me. :)

docs/LangRef.rst
410–411

I think this should be "...attempts to make the code as non-intrusive as possible." or "This calling convention aims to minimize overhead in the caller by preserving as many registers as possible".

Perhaps a less generic name would be good, since not all platforms will use cxx_tlscc for C++ TLS. Maybe 'darwin_cxx_tlscc' as Sean suggested, or 'cxx_fast_tlscc'?

Thanks for reviewing! I changed the name to cxx_fast_tlscc as suggested and committed r254737.

Cheer,
Manman

Otherwise this looks good to me. :)

qcolombet accepted this revision.Feb 10 2016, 2:54 PM
qcolombet edited edge metadata.

This landed in r254737.
Closing.

This revision is now accepted and ready to land.Feb 10 2016, 2:54 PM
qcolombet closed this revision.Feb 10 2016, 2:54 PM