[libc-commits] [PATCH] D124958: [libc] Align functions to 64B to lower benchmarking variance
Guillaume Chatelet via Phabricator via libc-commits
libc-commits at lists.llvm.org
Wed May 4 13:30:45 PDT 2022
gchatelet created this revision.
gchatelet added a reviewer: sivachandra.
Herald added subscribers: libc-commits, ecnelises, tschuett.
Herald added projects: libc-project, All.
gchatelet requested review of this revision.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D124958
Files:
libc/src/__support/common.h
Index: libc/src/__support/common.h
===================================================================
--- libc/src/__support/common.h
+++ libc/src/__support/common.h
@@ -15,6 +15,18 @@
#define unlikely(x) __builtin_expect(x, 0)
#define UNUSED __attribute__((unused))
+#ifdef __has_attribute
+#define LIBC_HAVE_ATTRIBUTE(x) __has_attribute(x)
+#else
+#define LIBC_HAVE_ATTRIBUTE(x) 0
+#endif
+
+#if LIBC_HAVE_ATTRIBUTE(aligned) || (defined(__GNUC__) && !defined(__clang__))
+#define LIBC_ATTRIBUTE_FUNC_ALIGN(bytes) __attribute__((aligned(bytes)))
+#else
+#define LIBC_ATTRIBUTE_FUNC_ALIGN(bytes)
+#endif
+
#ifndef LLVM_LIBC_FUNCTION_ATTR
#define LLVM_LIBC_FUNCTION_ATTR
#endif
@@ -25,9 +37,10 @@
LLVM_LIBC_FUNCTION_ATTR decltype(__llvm_libc::name) \
__##name##_impl__ __asm__(#name); \
decltype(__llvm_libc::name) name [[gnu::alias(#name)]]; \
- type __##name##_impl__ arglist
+ type LIBC_ATTRIBUTE_FUNC_ALIGN(64) __##name##_impl__ arglist
#else
-#define LLVM_LIBC_FUNCTION(type, name, arglist) type name arglist
+#define LLVM_LIBC_FUNCTION(type, name, arglist) \
+ type LIBC_ATTRIBUTE_FUNC_ALIGN(64) name arglist
#endif
namespace __llvm_libc {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124958.427118.patch
Type: text/x-patch
Size: 1290 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20220504/5a525155/attachment.bin>
More information about the libc-commits
mailing list