This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Optimize std::string's external instantiations in an ABI compatible way

Authored by ldionne on Jan 31 2020, 2:27 PM.



This patch introduces the mechanism through which libc++ can add, remove, or modify externally instantiated methods of std::string.
Under an unstable ABI, adding and removing external definitions is trivial. Under the stable ABI we are much more limited.

If we want to allow inlining of a external method in ABI v1 we can remove the extern template declaration while
retaining the extern template definition New code will no longer generate out-of-line calls to that method, but
old code will continue to work since the definition is still present.

At the same time, we can define but not declare new out-of-line methods in the stable ABI. Staging these definitions
for use in the future, after all supported dylibs contain them.

This allows code to perform and inline std::string roughly the same across both ABI's. Meaning std::string
should retain the same performance characteristics regardless of ABI.


Diff Detail

Event Timeline

EricWF created this revision.Jan 31 2020, 2:27 PM
mvels requested changes to this revision.Jan 31 2020, 2:40 PM
mvels added inline comments.

We should probably not outline this ctor before we do the 'init_long_external'


nit : empty line added


Should we add a comment that these entries should never be removed, ever? This for reviewers less familiar with ABI subtleties.

This revision now requires changes to proceed.Jan 31 2020, 2:40 PM
phosek added a subscriber: phosek.Mar 11 2020, 4:37 PM

I think this can be abandoned since the work has been done in another patch. Is that correct? If so, please close to clean up the queue.

ldionne commandeered this revision.Jul 23 2021, 8:43 AM
ldionne edited reviewers, added: EricWF; removed: ldionne.

Commandeering to abandon since the work has been done differently.

ldionne abandoned this revision.Jul 23 2021, 8:43 AM