summaryrefslogtreecommitdiffstats
path: root/libcxx/include
diff options
context:
space:
mode:
authorLouis Dionne <ldionne@apple.com>2018-07-27 12:46:03 +0000
committerLouis Dionne <ldionne@apple.com>2018-07-27 12:46:03 +0000
commitcb3eb30636c8d9136c8a01126963eded45617531 (patch)
tree543d289ebbd8c0e403009c9565f18e63a3284760 /libcxx/include
parent88e154ff90c128f1382c54d345087ed79ae7a4d4 (diff)
downloadbcm5719-llvm-cb3eb30636c8d9136c8a01126963eded45617531.tar.gz
bcm5719-llvm-cb3eb30636c8d9136c8a01126963eded45617531.zip
[libc++] Introduce _LIBCPP_HIDE_FROM_ABI to replace _LIBCPP_INLINE_VISIBILITY
Summary: This commit introduces a new macro, _LIBCPP_HIDE_FROM_ABI, whose goal is to mark functions that shouldn't be part of libc++'s ABI. It marks the functions as being hidden for dylib visibility purposes, and as having internal linkage using Clang's __attribute__((internal_linkage)) when available, and __always_inline__ otherwise. It replaces _LIBCPP_INLINE_VISIBILITY, which was always using __always_inline__ to achieve similar goals, but suffered from debuggability and code size problems. The full proposal, along with more background information, can be found here: http://lists.llvm.org/pipermail/cfe-dev/2018-July/058419.html This commit does not rename uses of _LIBCPP_INLINE_VISIBILITY to _LIBCPP_HIDE_FROM_ABI: this wide reaching but mechanical change can be done later when we've confirmed we're happy with the new macro. In the future, it would be nice if we could optionally allow dropping any internal_linkage or __always_inline__ attribute, which could result in code size improvements. However, this is currently impossible for reasons explained here: http://lists.llvm.org/pipermail/cfe-dev/2018-July/058450.html Reviewers: EricWF, dexonsmith, mclow.lists Subscribers: christof, dexonsmith, llvm-commits, mclow.lists Differential Revision: https://reviews.llvm.org/D49240 llvm-svn: 338122
Diffstat (limited to 'libcxx/include')
-rw-r--r--libcxx/include/__config27
1 files changed, 19 insertions, 8 deletions
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 139c199710a..c01ac12be4b 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -491,6 +491,8 @@ namespace std {
#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
#endif
+#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
+
#elif defined(_LIBCPP_COMPILER_GCC)
#define _ALIGNAS(x) __attribute__((__aligned__(x)))
@@ -582,6 +584,8 @@ namespace std {
#define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS
#endif
+#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
+
#elif defined(_LIBCPP_COMPILER_MSVC)
#define _LIBCPP_TOSTRING2(x) #x
@@ -614,6 +618,8 @@ namespace std {
#define _LIBCPP_HAS_NO_ASAN
+#define _LIBCPP_ALWAYS_INLINE __forceinline
+
#elif defined(_LIBCPP_COMPILER_IBM)
#define _ALIGNAS(x) __attribute__((__aligned__(x)))
@@ -644,6 +650,8 @@ namespace std {
#define _LIBCPP_HAS_NO_ASAN
+#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__))
+
#endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM]
#if _LIBCPP_STD_VER >= 17
@@ -695,10 +703,8 @@ namespace std {
#define _LIBCPP_ENUM_VIS
#if defined(_LIBCPP_COMPILER_MSVC)
-# define _LIBCPP_INLINE_VISIBILITY __forceinline
# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __forceinline
#else
-# define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__ ((__always_inline__))
#endif
@@ -785,14 +791,19 @@ namespace std {
#define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
#endif
-#ifndef _LIBCPP_INLINE_VISIBILITY
-# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
-# define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
-# else
-# define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__always_inline__))
-# endif
+#if __has_attribute(internal_linkage)
+# define _LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage))
+#else
+# define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE
#endif
+#ifndef _LIBCPP_HIDE_FROM_ABI
+# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
+#endif
+
+// Just so we can migrate to _LIBCPP_HIDE_FROM_ABI gradually.
+#define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
+
#ifndef _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
# define _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY __attribute__((__visibility__("default"), __always_inline__))
OpenPOWER on IntegriCloud