This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Stop marking interface symbols always_inline + hidden when building for unstable ABI
Needs ReviewPublic

Authored by eugenis on Oct 13 2015, 6:20 PM.

Details

Summary

ABI stability is not an issue when building for unstable ABI.
Other than that, always_inline is mostly harmful:

  • it does not completely solve the ABI stability problem, because there is no guarantee that an always_inline function will be inlined.
  • it really harms -O0 where indiscriminate inlining results in huge stack frames.
  • check-libcxx becomes faster by 18% when always_inline is removed

Diff Detail

Repository
rL LLVM

Event Timeline

eugenis updated this revision to Diff 37309.Oct 13 2015, 6:20 PM
eugenis retitled this revision from to [libc++] Stop marking interface symbols always_inline + hidden when building for unstable ABI.
eugenis updated this object.
eugenis added reviewers: mclow.lists, EricWF.
eugenis set the repository for this revision to rL LLVM.
eugenis added a subscriber: cfe-commits.
EricWF edited edge metadata.Oct 13 2015, 6:37 PM

I'm not sure about this patch quite yet.

However I am sure windows still needs these even in an unstable build.

  • I would love to have some documentation in libc++ about always-inline, the ABI problem it is trying to solve, and how it falls short. Because you tried to fix these semantics in clang would you be willing to write up a short summary of when always-inline does and doesn't work.
  • If this is about always-inline semantics why are we turning off the hidden-visibility part of the macro?
  • Can you offer other approaches for hiding internal symbols such as helper functions.? For example
inline _LIBCPP_INLINE_VISIBILITY __foo_impl(); // current way.
static inline _LIBCPP_HIDDEN __foo_impl(); // better way?
namespace { inline __foo_impl(); } // a (probably bad) possibility
  • The test suite speedup is amazing. Is it possible to safely remove the __always_inline__ attribute from functions in the stable ABI configuration?

It seems like always-inline semantics can hurt our users in debug builds and we would benefit from drastically reducing its usage. However I need to understand exactly what __always_inline__ buys us in ABI stability before I can make an informed decision on changing its usage.

EricWF requested changes to this revision.Oct 14 2015, 12:39 PM
EricWF edited edge metadata.

Setting "Request Changes" so that phabricator bins this correctly.

This revision now requires changes to proceed.Oct 14 2015, 12:39 PM
eugenis updated this revision to Diff 37427.Oct 14 2015, 4:48 PM
eugenis edited edge metadata.
eugenis added a reviewer: howard.hinnant.

I've wrote down my understanding of the problem in ABIVersioning.rst.
AFAIK, Howard added the attribute so he might know more about it.

Why does windows need this attributes in the unstable abi build?

Hidden visibility and always_inline work together for the same goal, so I'm removing them both. Keeping hidden visibility but removing always inline would break things because user code will expect external definitions for class members that would not be there.

Other approaches don't work for class members. AFAIK, there is no way in C++ to declare a class member function to have an internal linkage. In C this is done with the "static" keywords, but C++ went ahead an redefined it to mean something completely different.

One idea that we had for this was to introduce a attribute((internal_linkage)) and use it in place of always_inline with the supporting compiler.

I remeasured the test suite speed up on a different, faster machine and it is just 10%. Still quite a lot.